├── .classpath ├── .gitignore ├── .project ├── LICENSE ├── README.md ├── out └── production │ └── .gitignore └── src ├── executeTuple.png ├── executeTuple.useq ├── images ├── 1.gif ├── actuator.png ├── actuatorModule.png ├── dc.png ├── disk.png ├── edge.png ├── exit.png ├── hline.png ├── hline2.png ├── host.png ├── logo.png ├── module.png ├── openPhyTop.png ├── openVirTop.png ├── play.png ├── savePhyTop.png ├── saveVirTop.png ├── sensor.png ├── sensorModule.png ├── switch.png ├── upload1.png ├── upload2.png ├── upload3.png ├── upload4.png ├── vline.png ├── vline2.png ├── vline3.png ├── vline4.png ├── vm1.png └── vm2.png ├── org ├── cloudbus │ └── cloudsim │ │ ├── Cloudlet.java │ │ ├── CloudletScheduler.java │ │ ├── CloudletSchedulerDynamicWorkload.java │ │ ├── CloudletSchedulerSpaceShared.java │ │ ├── CloudletSchedulerTimeShared.java │ │ ├── Consts.java │ │ ├── DataCloudTags.java │ │ ├── Datacenter.java │ │ ├── DatacenterBroker.java │ │ ├── DatacenterCharacteristics.java │ │ ├── File.java │ │ ├── FileAttribute.java │ │ ├── HarddriveStorage.java │ │ ├── Host.java │ │ ├── HostDynamicWorkload.java │ │ ├── HostStateHistoryEntry.java │ │ ├── InfoPacket.java │ │ ├── Log.java │ │ ├── NetworkTopology.java │ │ ├── Packet.java │ │ ├── ParameterException.java │ │ ├── Pe.java │ │ ├── ResCloudlet.java │ │ ├── SanStorage.java │ │ ├── Storage.java │ │ ├── UtilizationModel.java │ │ ├── UtilizationModelFull.java │ │ ├── UtilizationModelNull.java │ │ ├── UtilizationModelPlanetLabInMemory.java │ │ ├── UtilizationModelStochastic.java │ │ ├── Vm.java │ │ ├── VmAllocationPolicy.java │ │ ├── VmAllocationPolicySimple.java │ │ ├── VmScheduler.java │ │ ├── VmSchedulerSpaceShared.java │ │ ├── VmSchedulerTimeShared.java │ │ ├── VmSchedulerTimeSharedOverSubscription.java │ │ ├── VmStateHistoryEntry.java │ │ ├── core │ │ ├── CloudInformationService.java │ │ ├── CloudSim.java │ │ ├── CloudSimShutdown.java │ │ ├── CloudSimTags.java │ │ ├── DeferredQueue.java │ │ ├── FutureQueue.java │ │ ├── SimEntity.java │ │ ├── SimEvent.java │ │ └── predicates │ │ │ ├── Predicate.java │ │ │ ├── PredicateAny.java │ │ │ ├── PredicateFrom.java │ │ │ ├── PredicateNone.java │ │ │ ├── PredicateNotFrom.java │ │ │ ├── PredicateNotType.java │ │ │ └── PredicateType.java │ │ ├── distributions │ │ ├── ContinuousDistribution.java │ │ ├── ExponentialDistr.java │ │ ├── GammaDistr.java │ │ ├── LognormalDistr.java │ │ ├── LomaxDistribution.java │ │ ├── ParetoDistr.java │ │ ├── UniformDistr.java │ │ ├── WeibullDistr.java │ │ └── ZipfDistr.java │ │ ├── lists │ │ ├── CloudletList.java │ │ ├── HostList.java │ │ ├── PeList.java │ │ ├── ResCloudletList.java │ │ └── VmList.java │ │ ├── network │ │ ├── DelayMatrix_Float.java │ │ ├── FloydWarshall_Float.java │ │ ├── GraphReaderBrite.java │ │ ├── GraphReaderIF.java │ │ ├── TopologicalGraph.java │ │ ├── TopologicalLink.java │ │ ├── TopologicalNode.java │ │ └── datacenter │ │ │ ├── AggregateSwitch.java │ │ │ ├── AppCloudlet.java │ │ │ ├── EdgeSwitch.java │ │ │ ├── HostPacket.java │ │ │ ├── NetDatacenterBroker.java │ │ │ ├── NetworkCloudlet.java │ │ │ ├── NetworkCloudletSpaceSharedScheduler.java │ │ │ ├── NetworkConstants.java │ │ │ ├── NetworkDatacenter.java │ │ │ ├── NetworkHost.java │ │ │ ├── NetworkPacket.java │ │ │ ├── NetworkVm.java │ │ │ ├── NetworkVmAllocationPolicy.java │ │ │ ├── RootSwitch.java │ │ │ ├── Switch.java │ │ │ ├── TaskStage.java │ │ │ └── WorkflowApp.java │ │ ├── power │ │ ├── PowerDatacenter.java │ │ ├── PowerDatacenterBroker.java │ │ ├── PowerDatacenterNonPowerAware.java │ │ ├── PowerHost.java │ │ ├── PowerHostUtilizationHistory.java │ │ ├── PowerVm.java │ │ ├── PowerVmAllocationPolicyAbstract.java │ │ ├── PowerVmAllocationPolicyMigrationAbstract.java │ │ ├── PowerVmAllocationPolicyMigrationInterQuartileRange.java │ │ ├── PowerVmAllocationPolicyMigrationLocalRegression.java │ │ ├── PowerVmAllocationPolicyMigrationLocalRegressionRobust.java │ │ ├── PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation.java │ │ ├── PowerVmAllocationPolicyMigrationStaticThreshold.java │ │ ├── PowerVmAllocationPolicySimple.java │ │ ├── PowerVmSelectionPolicy.java │ │ ├── PowerVmSelectionPolicyMaximumCorrelation.java │ │ ├── PowerVmSelectionPolicyMinimumMigrationTime.java │ │ ├── PowerVmSelectionPolicyMinimumUtilization.java │ │ ├── PowerVmSelectionPolicyRandomSelection.java │ │ ├── lists │ │ │ └── PowerVmList.java │ │ └── models │ │ │ ├── PowerModel.java │ │ │ ├── PowerModelCubic.java │ │ │ ├── PowerModelLinear.java │ │ │ ├── PowerModelSpecPower.java │ │ │ ├── PowerModelSpecPowerHpProLiantMl110G3PentiumD930.java │ │ │ ├── PowerModelSpecPowerHpProLiantMl110G4Xeon3040.java │ │ │ ├── PowerModelSpecPowerHpProLiantMl110G5Xeon3075.java │ │ │ ├── PowerModelSpecPowerIbmX3250XeonX3470.java │ │ │ ├── PowerModelSpecPowerIbmX3250XeonX3480.java │ │ │ ├── PowerModelSpecPowerIbmX3550XeonX5670.java │ │ │ ├── PowerModelSpecPowerIbmX3550XeonX5675.java │ │ │ ├── PowerModelSqrt.java │ │ │ └── PowerModelSquare.java │ │ ├── provisioners │ │ ├── BwProvisioner.java │ │ ├── BwProvisionerSimple.java │ │ ├── PeProvisioner.java │ │ ├── PeProvisionerSimple.java │ │ ├── RamProvisioner.java │ │ └── RamProvisionerSimple.java │ │ ├── sdn │ │ ├── Activity.java │ │ ├── AggregationSwitch.java │ │ ├── Arc.java │ │ ├── Channel.java │ │ ├── Constants.java │ │ ├── CoreSwitch.java │ │ ├── EdgeSwitch.java │ │ ├── ForwardingRule.java │ │ ├── Link.java │ │ ├── Middlebox.java │ │ ├── NetworkOperatingSystem.java │ │ ├── Node.java │ │ ├── Package.java │ │ ├── PhysicalTopology.java │ │ ├── Processing.java │ │ ├── Request.java │ │ ├── RoutingTable.java │ │ ├── SDNDatacenter.java │ │ ├── SDNHost.java │ │ ├── Switch.java │ │ ├── TimedVm.java │ │ ├── Transmission.java │ │ ├── example │ │ │ ├── LogPrinter.java │ │ │ ├── SDNBroker.java │ │ │ ├── SDNExample.java │ │ │ ├── SimpleNetworkOperatingSystem.java │ │ │ ├── VmAllocationPolicyCombinedLeastFullFirst.java │ │ │ ├── VmAllocationPolicyCombinedMostFullFirst.java │ │ │ ├── VmAllocationPolicyMipsLeastFullFirst.java │ │ │ ├── VmAllocationPolicyMipsMostFullFirst.java │ │ │ ├── VmSchedulerSpaceSharedEnergy.java │ │ │ ├── Workload.java │ │ │ ├── WorkloadParser.java │ │ │ ├── policies │ │ │ │ ├── VmAllocationPolicyCombinedLeastFullFirst.java │ │ │ │ ├── VmAllocationPolicyCombinedMostFullFirst.java │ │ │ │ ├── VmAllocationPolicyMipsLeastFullFirst.java │ │ │ │ ├── VmAllocationPolicyMipsMostFullFirst.java │ │ │ │ └── VmSchedulerTimeSharedEnergy.java │ │ │ └── topogenerators │ │ │ │ ├── PhysicalTopologyGenerator.java │ │ │ │ ├── VMRequestRandomGenerator.java │ │ │ │ ├── VirtualTopologyGenerator.java │ │ │ │ └── VirtualTopologyGeneratorVmTypes.java │ │ ├── graph │ │ │ ├── core │ │ │ │ ├── Bridge.java │ │ │ │ ├── Coordinates.java │ │ │ │ ├── Edge.java │ │ │ │ ├── Graph.java │ │ │ │ ├── GraphView.java │ │ │ │ ├── HostNode.java │ │ │ │ ├── Node.java │ │ │ │ ├── NodeCellRenderer.java │ │ │ │ ├── SpringUtilities.java │ │ │ │ ├── SwitchNode.java │ │ │ │ └── VmNode.java │ │ │ ├── dialog │ │ │ │ ├── About.java │ │ │ │ ├── AddPhysicalEdge.java │ │ │ │ ├── AddPhysicalNode.java │ │ │ │ ├── AddVirtualEdge.java │ │ │ │ ├── AddVirtualNode.java │ │ │ │ └── SDNRun.java │ │ │ └── example │ │ │ │ ├── GraphicSDN.java │ │ │ │ └── GraphicSDNExample.java │ │ ├── overbooking │ │ │ ├── BwProvisionerOverbooking.java │ │ │ ├── OverbookingNetworkOperatingSystem.java │ │ │ ├── PeProvisionerOverbooking.java │ │ │ ├── VmAllocationPolicyOverbooking.java │ │ │ └── VmSchedulerTimeSharedOverbookingEnergy.java │ │ ├── power │ │ │ ├── PowerUtilizationHistoryEntry.java │ │ │ ├── PowerUtilizationInterface.java │ │ │ └── PowerUtilizationMaxHostInterface.java │ │ └── request │ │ │ └── VMRequestGenerator.java │ │ └── util │ │ ├── Check.java │ │ ├── ExecutionTimeMeasurer.java │ │ ├── MathUtil.java │ │ ├── Test.java │ │ ├── Test2.java │ │ ├── WorkloadFileReader.java │ │ └── WorkloadModel.java └── fog │ ├── application │ ├── AppEdge.java │ ├── AppLoop.java │ ├── AppModule.java │ ├── Application.java │ ├── DAG.java │ └── selectivity │ │ ├── BurstySelectivity.java │ │ ├── FractionalSelectivity.java │ │ └── SelectivityModel.java │ ├── entities │ ├── Actuator.java │ ├── ControllerComponent.java │ ├── FogBroker.java │ ├── FogDevice.java │ ├── FogDeviceCharacteristics.java │ ├── LoadBalancer.java │ ├── ManagementTuple.java │ ├── MicroserviceFogDevice.java │ ├── PhysicalTopology.java │ ├── PlacementRequest.java │ ├── RRLoadBalancer.java │ ├── Sensor.java │ └── Tuple.java │ ├── gui │ ├── core │ │ ├── ActuatorGui.java │ │ ├── ActuatorModule.java │ │ ├── AppModule.java │ │ ├── Bridge.java │ │ ├── Coordinates.java │ │ ├── Edge.java │ │ ├── FogDeviceGui.java │ │ ├── Graph.java │ │ ├── GraphView.java │ │ ├── HostNode.java │ │ ├── Link.java │ │ ├── Node.java │ │ ├── NodeCellRenderer.java │ │ ├── PlaceHolder.java │ │ ├── SensorGui.java │ │ ├── SensorModule.java │ │ ├── SpringUtilities.java │ │ ├── SwitchNode.java │ │ └── VmNode.java │ ├── dialog │ │ ├── About.java │ │ ├── AddActuator.java │ │ ├── AddActuatorModule.java │ │ ├── AddAppEdge.java │ │ ├── AddApplicationModule.java │ │ ├── AddFogDevice.java │ │ ├── AddLink.java │ │ ├── AddPhysicalEdge.java │ │ ├── AddPhysicalNode.java │ │ ├── AddSensor.java │ │ ├── AddSensorModule.java │ │ ├── AddVirtualEdge.java │ │ ├── AddVirtualNode.java │ │ └── SDNRun.java │ └── example │ │ └── FogGui.java │ ├── mobilitydata │ ├── Clustering.java │ ├── DataParser.java │ ├── Location.java │ ├── Polygon2D.java │ ├── RandomMobilityGenerator.java │ └── References.java │ ├── placement │ ├── ClusteredMicroservicePlacementLogic.java │ ├── ClusteringController.java │ ├── Controller.java │ ├── DistributedMicroservicePlacementLogic.java │ ├── LocationHandler.java │ ├── MicroservicePlacementLogic.java │ ├── MicroservicesController.java │ ├── MicroservicesMobilityClusteringController.java │ ├── MobilityController.java │ ├── ModuleMapping.java │ ├── ModulePlacement.java │ ├── ModulePlacementEdgewards.java │ ├── ModulePlacementMapping.java │ ├── ModulePlacementMobileEdgewards.java │ ├── ModulePlacementMobileEdgewardsCluster.java │ ├── ModulePlacementOnlyCloud.java │ ├── PlacementLogicFactory.java │ └── PlacementLogicOutput.java │ ├── policy │ └── AppModuleAllocationPolicy.java │ ├── scheduler │ ├── StreamOperatorScheduler.java │ └── TupleScheduler.java │ ├── serverless │ ├── application │ │ ├── FogFaaSAppEdge.java │ │ ├── FogFaaSAppLoop.java │ │ ├── FogFaaSAppModule.java │ │ └── FogFaaSApplication.java │ ├── entities │ │ ├── FogFaaSActuator.java │ │ ├── FogFaaSBroker.java │ │ ├── FogFaaSDevice.java │ │ ├── FogFaaSSensor.java │ │ └── FogFaaSTuple.java │ ├── examples │ │ ├── DCNS_FogFaaS.java │ │ ├── Real_trace_test2_small.csv │ │ └── VRGame_FogFaaS.java │ ├── faas │ │ ├── FogFaaSContainer.java │ │ ├── FogFaaSFunction.java │ │ ├── FogFaaSInvoker.java │ │ ├── FogFaaSRequest.java │ │ └── FogFaaSUtilizationModelPartial.java │ ├── placement │ │ ├── FogFaaSContainerRamProvisioner.java │ │ ├── FogFaaSController.java │ │ ├── FogFaaSModuleMapping.java │ │ ├── FogFaaSModulePlacement.java │ │ ├── FogFaaSModulePlacementEdgewards.java │ │ ├── FogFaaSModulePlacementMapping.java │ │ └── FogFaaSModulePlacementMobileEdgewards.java │ ├── scheduler │ │ ├── FogFaaSContainerScheduler.java │ │ ├── FogFaaSFunctionScheduler.java │ │ └── FogFaaSRequestScheduler.java │ └── utils │ │ ├── Constants.java │ │ ├── FogFaaSTags.java │ │ └── FogFaaSTimeKeeper.java │ ├── test │ ├── CleanFromJson.java │ └── perfeval │ │ ├── ApplicationConfig.json │ │ ├── CardiovascularHealthMonitoringApplication.java │ │ ├── CardiovascularHealthMonitoringApplicationEdgeward.java │ │ ├── CrowdSensing_Microservices_RandomMobility_Clustering.java │ │ ├── DCNSFog.java │ │ ├── MicroserviceAppSample2.java │ │ ├── MicroserviceApp_RandomMobility_Clustering.java │ │ ├── MicroservicesAppSample1.java │ │ ├── TranslationServiceFog.java │ │ ├── TranslationServiceFog_Clustering.java │ │ ├── TranslationServiceFog_RandomMobility.java │ │ ├── TranslationServiceFog_RandomMobility_Clustering.java │ │ ├── TwoApps.java │ │ └── VRGameFog.java │ └── utils │ ├── CanBeSentResult.java │ ├── Config.java │ ├── FogEntityFactory.java │ ├── FogEvents.java │ ├── FogLinearPowerModel.java │ ├── FogUtils.java │ ├── GeoCoverage.java │ ├── GeoLocation.java │ ├── JsonToTopology.java │ ├── Logger.java │ ├── MicroservicePlacementConfig.java │ ├── MigrationDelayMonitor.java │ ├── ModuleLaunchConfig.java │ ├── NetworkUsageMonitor.java │ ├── OperatorEdge.java │ ├── OperatorSetComparator.java │ ├── ResourceUsageDetails.java │ ├── ShortestPathRoutingGenerator.java │ ├── TimeKeeper.java │ ├── TupleFinishDetails.java │ └── distribution │ ├── DeterministicDistribution.java │ ├── Distribution.java │ ├── NormalDistribution.java │ └── UniformDistribution.java └── topologies └── routerTopology /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | replay_pid* 25 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | FoGFaaS 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /out/production/.gitignore: -------------------------------------------------------------------------------- 1 | /iFogSim2/ 2 | -------------------------------------------------------------------------------- /src/executeTuple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/executeTuple.png -------------------------------------------------------------------------------- /src/executeTuple.useq: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/images/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/1.gif -------------------------------------------------------------------------------- /src/images/actuator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/actuator.png -------------------------------------------------------------------------------- /src/images/actuatorModule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/actuatorModule.png -------------------------------------------------------------------------------- /src/images/dc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/dc.png -------------------------------------------------------------------------------- /src/images/disk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/disk.png -------------------------------------------------------------------------------- /src/images/edge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/edge.png -------------------------------------------------------------------------------- /src/images/exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/exit.png -------------------------------------------------------------------------------- /src/images/hline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/hline.png -------------------------------------------------------------------------------- /src/images/hline2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/hline2.png -------------------------------------------------------------------------------- /src/images/host.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/host.png -------------------------------------------------------------------------------- /src/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/logo.png -------------------------------------------------------------------------------- /src/images/module.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/module.png -------------------------------------------------------------------------------- /src/images/openPhyTop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/openPhyTop.png -------------------------------------------------------------------------------- /src/images/openVirTop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/openVirTop.png -------------------------------------------------------------------------------- /src/images/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/play.png -------------------------------------------------------------------------------- /src/images/savePhyTop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/savePhyTop.png -------------------------------------------------------------------------------- /src/images/saveVirTop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/saveVirTop.png -------------------------------------------------------------------------------- /src/images/sensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/sensor.png -------------------------------------------------------------------------------- /src/images/sensorModule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/sensorModule.png -------------------------------------------------------------------------------- /src/images/switch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/switch.png -------------------------------------------------------------------------------- /src/images/upload1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/upload1.png -------------------------------------------------------------------------------- /src/images/upload2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/upload2.png -------------------------------------------------------------------------------- /src/images/upload3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/upload3.png -------------------------------------------------------------------------------- /src/images/upload4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/upload4.png -------------------------------------------------------------------------------- /src/images/vline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/vline.png -------------------------------------------------------------------------------- /src/images/vline2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/vline2.png -------------------------------------------------------------------------------- /src/images/vline3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/vline3.png -------------------------------------------------------------------------------- /src/images/vline4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/vline4.png -------------------------------------------------------------------------------- /src/images/vm1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/vm1.png -------------------------------------------------------------------------------- /src/images/vm2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/images/vm2.png -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/Consts.java: -------------------------------------------------------------------------------- 1 | package org.cloudbus.cloudsim; 2 | 3 | /** 4 | * 5 | * Defines common constants, used throughout cloudsim. 6 | * 7 | * @author nikolay.grozev 8 | * 9 | */ 10 | public final class Consts { 11 | 12 | /** 13 | * Suppreses intantiation. 14 | */ 15 | private Consts(){} 16 | 17 | public static int MILLION = 1000000; 18 | } 19 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/ParameterException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * ** Network and Service Differentiation Extensions to CloudSim 3.0 ** 3 | * 4 | * Gokul Poduval & Chen-Khong Tham 5 | * Computer Communication Networks (CCN) Lab 6 | * Dept of Electrical & Computer Engineering 7 | * National University of Singapore 8 | * October 2004 9 | * 10 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 11 | * Copyright (c) 2004, The University of Melbourne, Australia and 12 | * National University of Singapore 13 | * ParameterException.java - Thrown for illegal parameters 14 | * 15 | */ 16 | 17 | package org.cloudbus.cloudsim; 18 | 19 | /** 20 | * This exception is to report bad or invalid parameters given during constructor. 21 | * 22 | * @author Gokul Poduval 23 | * @author Chen-Khong Tham, National University of Singapore 24 | * @since CloudSim Toolkit 1.0 25 | */ 26 | public class ParameterException extends Exception { 27 | 28 | /** The Constant serialVersionUID. */ 29 | private static final long serialVersionUID = 1L; 30 | 31 | /** The message. */ 32 | private final String message; 33 | 34 | /** 35 | * Constructs a new exception with null as its detail message. 36 | * 37 | * @pre $none 38 | * @post $none 39 | */ 40 | public ParameterException() { 41 | super(); 42 | message = null; 43 | } 44 | 45 | /** 46 | * Creates a new ParameterException object. 47 | * 48 | * @param message an error message 49 | * @pre $none 50 | * @post $none 51 | */ 52 | public ParameterException(String message) { 53 | super(); 54 | this.message = message; 55 | } 56 | 57 | /** 58 | * Returns an error message of this object. 59 | * 60 | * @return an error message 61 | * @pre $none 62 | * @post $none 63 | */ 64 | @Override 65 | public String toString() { 66 | return message; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/UtilizationModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim; 10 | 11 | /** 12 | * The UtilizationModel interface needs to be implemented in order to provide a fine-grained control 13 | * over resource usage by a Cloudlet. 14 | * 15 | * @author Anton Beloglazov 16 | * @since CloudSim Toolkit 2.0 17 | */ 18 | public interface UtilizationModel { 19 | 20 | /** 21 | * Returns utilization in percents according to the time. 22 | * 23 | * @param time the time 24 | * @return utilization percentage 25 | */ 26 | double getUtilization(double time); 27 | 28 | } -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/UtilizationModelFull.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim; 10 | 11 | /** 12 | * The UtilizationModelFull class is a simple model, according to which a Cloudlet always utilize 13 | * all the available CPU capacity. 14 | * 15 | * @author Anton Beloglazov 16 | * @since CloudSim Toolkit 2.0 17 | */ 18 | public class UtilizationModelFull implements UtilizationModel { 19 | 20 | /* 21 | * (non-Javadoc) 22 | * @see cloudsim.power.UtilizationModel#getUtilization(double) 23 | */ 24 | @Override 25 | public double getUtilization(double time) { 26 | return 1; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/UtilizationModelNull.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim; 10 | 11 | /** 12 | * The UtilizationModelNull class is a simple model, according to which a Cloudlet always require 13 | * zero capacity. 14 | * 15 | * @author Anton Beloglazov 16 | * @since CloudSim Toolkit 2.0 17 | */ 18 | public class UtilizationModelNull implements UtilizationModel { 19 | 20 | /* 21 | * (non-Javadoc) 22 | * @see cloudsim.power.UtilizationModel#getUtilization(double) 23 | */ 24 | @Override 25 | public double getUtilization(double time) { 26 | return 0; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/core/DeferredQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.core; 10 | 11 | import java.util.Iterator; 12 | import java.util.LinkedList; 13 | import java.util.List; 14 | import java.util.ListIterator; 15 | 16 | /** 17 | * This class implements the deferred event queue used by {@link Simulation}. The event queue uses a 18 | * linked list to store the events. 19 | * 20 | * @author Marcos Dias de Assuncao 21 | * @since CloudSim Toolkit 1.0 22 | * @see Simulation 23 | * @see SimEvent 24 | */ 25 | public class DeferredQueue { 26 | 27 | /** The list. */ 28 | private final List list = new LinkedList(); 29 | 30 | /** The max time. */ 31 | private double maxTime = -1; 32 | 33 | /** 34 | * Adds a new event to the queue. Adding a new event to the queue preserves the temporal order 35 | * of the events. 36 | * 37 | * @param newEvent The event to be added to the queue. 38 | */ 39 | public void addEvent(SimEvent newEvent) { 40 | // The event has to be inserted as the last of all events 41 | // with the same event_time(). Yes, this matters. 42 | double eventTime = newEvent.eventTime(); 43 | if (eventTime >= maxTime) { 44 | list.add(newEvent); 45 | maxTime = eventTime; 46 | return; 47 | } 48 | 49 | ListIterator iterator = list.listIterator(); 50 | SimEvent event; 51 | while (iterator.hasNext()) { 52 | event = iterator.next(); 53 | if (event.eventTime() > eventTime) { 54 | iterator.previous(); 55 | iterator.add(newEvent); 56 | return; 57 | } 58 | } 59 | 60 | list.add(newEvent); 61 | } 62 | 63 | /** 64 | * Returns an iterator to the events in the queue. 65 | * 66 | * @return the iterator 67 | */ 68 | public Iterator iterator() { 69 | return list.iterator(); 70 | } 71 | 72 | /** 73 | * Returns the size of this event queue. 74 | * 75 | * @return the number of events in the queue. 76 | */ 77 | public int size() { 78 | return list.size(); 79 | } 80 | 81 | /** 82 | * Clears the queue. 83 | */ 84 | public void clear() { 85 | list.clear(); 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/core/FutureQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.core; 10 | 11 | import java.util.Collection; 12 | import java.util.Iterator; 13 | import java.util.SortedSet; 14 | import java.util.TreeSet; 15 | 16 | /** 17 | * This class implements the future event queue used by {@link Simulation}. The event queue uses a 18 | * {@link TreeSet} in order to store the events. 19 | * 20 | * @author Marcos Dias de Assuncao 21 | * @since CloudSim Toolkit 1.0 22 | * @see Simulation 23 | * @see java.util.TreeSet 24 | */ 25 | public class FutureQueue { 26 | 27 | /** The sorted set. */ 28 | private final SortedSet sortedSet = new TreeSet(); 29 | 30 | /** The serial. */ 31 | private long serial = 0; 32 | 33 | /** 34 | * Add a new event to the queue. Adding a new event to the queue preserves the temporal order of 35 | * the events in the queue. 36 | * 37 | * @param newEvent The event to be put in the queue. 38 | */ 39 | public void addEvent(SimEvent newEvent) { 40 | newEvent.setSerial(serial++); 41 | sortedSet.add(newEvent); 42 | } 43 | 44 | /** 45 | * Add a new event to the head of the queue. 46 | * 47 | * @param newEvent The event to be put in the queue. 48 | */ 49 | public void addEventFirst(SimEvent newEvent) { 50 | newEvent.setSerial(0); 51 | sortedSet.add(newEvent); 52 | } 53 | 54 | /** 55 | * Returns an iterator to the queue. 56 | * 57 | * @return the iterator 58 | */ 59 | public Iterator iterator() { 60 | return sortedSet.iterator(); 61 | } 62 | 63 | /** 64 | * Returns the size of this event queue. 65 | * 66 | * @return the size 67 | */ 68 | public int size() { 69 | return sortedSet.size(); 70 | } 71 | 72 | /** 73 | * Removes the event from the queue. 74 | * 75 | * @param event the event 76 | * @return true, if successful 77 | */ 78 | public boolean remove(SimEvent event) { 79 | return sortedSet.remove(event); 80 | } 81 | 82 | /** 83 | * Removes all the events from the queue. 84 | * 85 | * @param events the events 86 | * @return true, if successful 87 | */ 88 | public boolean removeAll(Collection events) { 89 | return sortedSet.removeAll(events); 90 | } 91 | 92 | /** 93 | * Clears the queue. 94 | */ 95 | public void clear() { 96 | sortedSet.clear(); 97 | } 98 | 99 | } -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/core/predicates/Predicate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.core.predicates; 10 | 11 | import org.cloudbus.cloudsim.core.SimEvent; 12 | 13 | /** 14 | * Predicates are used to select events from the deferred queue. This class is abstract and must be 15 | * extended when writing a new predicate. Some standard predicates are provided.
16 | * The idea of simulation predicates was copied from SimJava 2. 17 | * 18 | * @author Marcos Dias de Assuncao 19 | * @since CloudSim Toolkit 1.0 20 | * @see PredicateType 21 | * @see PredicateFrom 22 | * @see PredicateAny 23 | * @see PredicateNone 24 | * @see Simulation 25 | */ 26 | public abstract class Predicate { 27 | 28 | /** 29 | * The match function which must be overridden when writing a new predicate. The function is 30 | * called with each event in the deferred queue as its parameter when a 31 | * Simulation.select() call is made by the user. 32 | * 33 | * @param event The event to test for a match. 34 | * @return The function should return true if the event matches and should be 35 | * selected, or false if it does not match the predicate. 36 | */ 37 | public abstract boolean match(SimEvent event); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/core/predicates/PredicateAny.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.core.predicates; 10 | 11 | import org.cloudbus.cloudsim.core.SimEvent; 12 | 13 | /** 14 | * A predicate which will match any event on the deferred event queue. There is a publicly 15 | * accessible instance of this predicate in Simulation, called 16 | * Simulation.SIM_ANY, so no new instances need to be created.
17 | * The idea of simulation predicates was copied from SimJava 2. 18 | * 19 | * @author Marcos Dias de Assuncao 20 | * @since CloudSim Toolkit 1.0 21 | * @see Predicate 22 | * @see Simulation 23 | */ 24 | public class PredicateAny extends Predicate { 25 | 26 | /** 27 | * The match function called by Simulation, not used directly by the user. 28 | * 29 | * @param ev the ev 30 | * @return true, if match 31 | */ 32 | @Override 33 | public boolean match(SimEvent ev) { 34 | return true; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/core/predicates/PredicateFrom.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.core.predicates; 10 | 11 | import org.cloudbus.cloudsim.core.SimEvent; 12 | 13 | /** 14 | * A predicate which selects events from specific entities.
15 | * The idea of simulation predicates was copied from SimJava 2. 16 | * 17 | * @author Marcos Dias de Assuncao 18 | * @since CloudSim Toolkit 1.0 19 | * @see PredicateNotFrom 20 | * @see Predicate 21 | */ 22 | public class PredicateFrom extends Predicate { 23 | 24 | /** The ids. */ 25 | private final int[] ids; 26 | 27 | /** 28 | * Constructor used to select events that were sent by a specific entity. 29 | * 30 | * @param sourceId the id number of the source entity 31 | */ 32 | public PredicateFrom(int sourceId) { 33 | ids = new int[] { sourceId }; 34 | } 35 | 36 | /** 37 | * Constructor used to select events that were sent by any entity from a given set. 38 | * 39 | * @param sourceIds the set of id numbers of the source entities 40 | */ 41 | public PredicateFrom(int[] sourceIds) { 42 | ids = sourceIds.clone(); 43 | } 44 | 45 | /** 46 | * The match function called by Simulation, not used directly by the user. 47 | * 48 | * @param ev the event to check 49 | * @return true if the event matches the predicate, false otherwise 50 | */ 51 | @Override 52 | public boolean match(SimEvent ev) { 53 | int src = ev.getSource(); 54 | for (int id : ids) { 55 | if (src == id) { 56 | return true; 57 | } 58 | } 59 | return false; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/core/predicates/PredicateNone.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.core.predicates; 10 | 11 | import org.cloudbus.cloudsim.core.SimEvent; 12 | 13 | /** 14 | * A predicate which will not match any event on the deferred event queue. There is a 15 | * publicly accessible instance of this predicate in the {@link Simulation} class, called 16 | * {@link Simulation#SIM_NONE}, so the user does not need to create any new instances. The idea of 17 | * simulation predicates was copied from SimJava 2. 18 | * 19 | * @author Marcos Dias de Assuncao 20 | * @since CloudSim Toolkit 1.0 21 | * @see Predicate 22 | * @see Simulation 23 | */ 24 | public class PredicateNone extends Predicate { 25 | 26 | /** 27 | * The match function called by {@link Simulation}, not used directly by the user. 28 | * 29 | * @param ev the event to check 30 | * @return true if the event matches the predicate, false otherwise 31 | */ 32 | @Override 33 | public boolean match(SimEvent ev) { 34 | return false; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/core/predicates/PredicateNotFrom.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.core.predicates; 10 | 11 | import org.cloudbus.cloudsim.core.SimEvent; 12 | 13 | /** 14 | * A predicate which selects events that have not been sent by specific entities. 15 | * 16 | * @author Marcos Dias de Assuncao 17 | * @since CloudSim Toolkit 1.0 18 | * @see PredicateFrom 19 | * @see Predicate 20 | */ 21 | public class PredicateNotFrom extends Predicate { 22 | 23 | /** The ids. */ 24 | private final int[] ids; 25 | 26 | /** 27 | * Constructor used to select events that were not sent by a specific entity. 28 | * 29 | * @param sourceId the id number of the source entity 30 | */ 31 | public PredicateNotFrom(int sourceId) { 32 | ids = new int[] { sourceId }; 33 | } 34 | 35 | /** 36 | * Constructor used to select events that were not sent by any entity from a given set. 37 | * 38 | * @param sourceIds the set of id numbers of the source entities 39 | */ 40 | public PredicateNotFrom(int[] sourceIds) { 41 | ids = sourceIds.clone(); 42 | } 43 | 44 | /** 45 | * The match function called by {@link Simulation}, not used directly by the user. 46 | * 47 | * @param ev the event to check 48 | * @return true if the event matches the predicate, false otherwise 49 | */ 50 | @Override 51 | public boolean match(SimEvent ev) { 52 | int src = ev.getSource(); 53 | for (int id : ids) { 54 | if (src == id) { 55 | return false; 56 | } 57 | } 58 | return true; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/core/predicates/PredicateNotType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.core.predicates; 10 | 11 | import org.cloudbus.cloudsim.core.SimEvent; 12 | 13 | /** 14 | * A predicate to select events that don't match specific tags. 15 | * 16 | * @author Marcos Dias de Assuncao 17 | * @since CloudSim Toolkit 1.0 18 | * @see PredicateType 19 | * @see Predicate 20 | */ 21 | public class PredicateNotType extends Predicate { 22 | 23 | /** The tags. */ 24 | private final int[] tags; 25 | 26 | /** 27 | * Constructor used to select events whose tags do not match a given tag. 28 | * 29 | * @param tag An event tag value 30 | */ 31 | public PredicateNotType(int tag) { 32 | tags = new int[] { tag }; 33 | } 34 | 35 | /** 36 | * Constructor used to select events whose tag values do not match any of the given tags. 37 | * 38 | * @param tags the list of tags 39 | */ 40 | public PredicateNotType(int[] tags) { 41 | this.tags = tags.clone(); 42 | } 43 | 44 | /** 45 | * The match function called by {@link Simulation}, not used directly by the user. 46 | * 47 | * @param ev the ev 48 | * @return true, if match 49 | */ 50 | @Override 51 | public boolean match(SimEvent ev) { 52 | int tag = ev.getTag(); 53 | for (int tag2 : tags) { 54 | if (tag == tag2) { 55 | return false; 56 | } 57 | } 58 | return true; 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/core/predicates/PredicateType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.core.predicates; 10 | 11 | import org.cloudbus.cloudsim.core.SimEvent; 12 | 13 | /** 14 | * A predicate to select events with specific tags. 15 | * 16 | * @author Marcos Dias de Assuncao 17 | * @since CloudSim Toolkit 1.0 18 | * @see PredicateNotType 19 | * @see Predicate 20 | */ 21 | public class PredicateType extends Predicate { 22 | 23 | /** The tags. */ 24 | private final int[] tags; 25 | 26 | /** 27 | * Constructor used to select events with the tag value t1. 28 | * 29 | * @param t1 an event tag value 30 | */ 31 | public PredicateType(int t1) { 32 | tags = new int[] { t1 }; 33 | } 34 | 35 | /** 36 | * Constructor used to select events with a tag value equal to any of the specified tags. 37 | * 38 | * @param tags the list of tags 39 | */ 40 | public PredicateType(int[] tags) { 41 | this.tags = tags.clone(); 42 | } 43 | 44 | /** 45 | * The match function called by Sim_system, not used directly by the user. 46 | * 47 | * @param ev the ev 48 | * @return true, if match 49 | */ 50 | @Override 51 | public boolean match(SimEvent ev) { 52 | int tag = ev.getTag(); 53 | for (int tag2 : tags) { 54 | if (tag == tag2) { 55 | return true; 56 | } 57 | } 58 | return false; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/distributions/ContinuousDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.distributions; 10 | 11 | /** 12 | * Interface to be implemented by a random number generator. 13 | * 14 | * @author Marcos Dias de Assuncao 15 | * @since CloudSim Toolkit 1.0 16 | */ 17 | public interface ContinuousDistribution { 18 | 19 | /** 20 | * Sample the random number generator. 21 | * 22 | * @return The sample 23 | */ 24 | double sample(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/distributions/ExponentialDistr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.distributions; 10 | 11 | import java.util.Random; 12 | 13 | /** 14 | * An exponential number generator. 15 | * 16 | * @author Marcos Dias de Assuncao 17 | * @since CloudSim Toolkit 1.0 18 | */ 19 | public class ExponentialDistr implements ContinuousDistribution { 20 | 21 | /** The num gen. */ 22 | private final Random numGen; 23 | 24 | /** The mean. */ 25 | private final double mean; 26 | 27 | /** 28 | * Creates a new exponential number generator. 29 | * 30 | * @param seed the seed to be used. 31 | * @param mean the mean for the distribution. 32 | */ 33 | public ExponentialDistr(long seed, double mean) { 34 | if (mean <= 0.0) { 35 | throw new IllegalArgumentException("Mean must be greater than 0.0"); 36 | } 37 | numGen = new Random(seed); 38 | this.mean = mean; 39 | } 40 | 41 | /** 42 | * Creates a new exponential number generator. 43 | * 44 | * @param mean the mean for the distribution. 45 | */ 46 | public ExponentialDistr(double mean) { 47 | if (mean <= 0.0) { 48 | throw new IllegalArgumentException("Mean must be greated than 0.0"); 49 | } 50 | numGen = new Random(System.currentTimeMillis()); 51 | this.mean = mean; 52 | } 53 | 54 | /** 55 | * Generate a new random number. 56 | * 57 | * @return the next random number in the sequence 58 | */ 59 | @Override 60 | public double sample() { 61 | return -mean * Math.log(numGen.nextDouble()); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/distributions/GammaDistr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Descripimport java.util.Random; 4 | mulation) Toolkit for Modeling and Simulation of Clouds 5 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 6 | * 7 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 8 | */ 9 | 10 | package org.cloudbus.cloudsim.distributions; 11 | 12 | import java.util.Random; 13 | 14 | /** 15 | * The Class GammaDistr. 16 | * 17 | * @author Marcos Dias de Assuncao 18 | * @since CloudSim Toolkit 1.0 19 | */ 20 | public class GammaDistr implements ContinuousDistribution { 21 | 22 | /** The num gen. */ 23 | private final Random numGen; 24 | 25 | /** The alpha. */ 26 | private final int alpha; 27 | 28 | /** The beta. */ 29 | private final double beta; 30 | 31 | /** 32 | * Instantiates a new gamma distr. 33 | * 34 | * @param seed the seed 35 | * @param alpha the alpha 36 | * @param beta the beta 37 | */ 38 | public GammaDistr(Random seed, int alpha, double beta) { 39 | if (alpha <= 0 || beta <= 0.0) { 40 | throw new IllegalArgumentException("Alpha and beta must be greater than 0.0"); 41 | } 42 | 43 | numGen = seed; 44 | this.alpha = alpha; 45 | this.beta = beta; 46 | } 47 | 48 | /** 49 | * Instantiates a new gamma distr. 50 | * 51 | * @param alpha the alpha 52 | * @param beta the beta 53 | */ 54 | public GammaDistr(int alpha, double beta) { 55 | if (alpha <= 0 || beta <= 0.0) { 56 | throw new IllegalArgumentException("Alpha and beta must be greater than 0.0"); 57 | } 58 | 59 | numGen = new Random(System.currentTimeMillis()); 60 | this.alpha = alpha; 61 | this.beta = beta; 62 | } 63 | 64 | /* 65 | * (non-Javadoc) 66 | * @see cloudsim.distributions.ContinuousDistribution#sample() 67 | */ 68 | @Override 69 | public double sample() { 70 | double sum = 0.0; 71 | for (int i = 0; i < alpha; i++) { 72 | sum += Math.log(numGen.nextDouble()); 73 | } 74 | 75 | return -beta * sum; 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/distributions/LognormalDistr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.distributions; 10 | 11 | import java.util.Random; 12 | 13 | /** 14 | * The Class LognormalDistr. 15 | * 16 | * @author Marcos Dias de Assuncao 17 | * @since CloudSim Toolkit 1.0 18 | */ 19 | public class LognormalDistr implements ContinuousDistribution { 20 | 21 | /** The num gen. */ 22 | private final Random numGen; 23 | 24 | /** The mean. */ 25 | private final double mean; 26 | 27 | /** The dev. */ 28 | private final double dev; 29 | 30 | /** 31 | * Instantiates a new lognormal distr. 32 | * 33 | * @param seed the seed 34 | * @param mean the mean 35 | * @param dev the dev 36 | */ 37 | public LognormalDistr(Random seed, double mean, double dev) { 38 | if (mean <= 0.0 || dev <= 0.0) { 39 | throw new IllegalArgumentException("Mean and deviation must be greater than 0.0"); 40 | } 41 | 42 | numGen = seed; 43 | this.mean = mean; 44 | this.dev = dev; 45 | } 46 | 47 | /** 48 | * Instantiates a new lognormal distr. 49 | * 50 | * @param mean the mean 51 | * @param dev the dev 52 | */ 53 | public LognormalDistr(double mean, double dev) { 54 | if (mean <= 0.0 || dev <= 0.0) { 55 | throw new IllegalArgumentException("Mean and deviation must be greater than 0.0"); 56 | } 57 | 58 | numGen = new Random(System.currentTimeMillis()); 59 | this.mean = mean; 60 | this.dev = dev; 61 | } 62 | 63 | /* 64 | * (non-Javadoc) 65 | * @see cloudsim.distributions.ContinuousDistribution#sample() 66 | */ 67 | @Override 68 | public double sample() { 69 | // generate a normal variate from a uniform variate 70 | double n = Math.sqrt(-2 * Math.log(numGen.nextDouble())) 71 | * Math.sin(2 * Math.PI * numGen.nextDouble()); 72 | 73 | // use it to generate the lognormal variate 74 | return Math.pow(Math.E, mean + dev * n); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/distributions/LomaxDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.distributions; 10 | 11 | import java.util.Random; 12 | 13 | /** 14 | * The Class LomaxDistribution. 15 | * 16 | * @author Marcos Dias de Assuncao 17 | * @since CloudSim Toolkit 1.0 18 | */ 19 | public class LomaxDistribution extends ParetoDistr implements ContinuousDistribution { 20 | 21 | /** The shift. */ 22 | private final double shift; 23 | 24 | /** 25 | * Instantiates a new lomax distribution. 26 | * 27 | * @param shape the shape 28 | * @param location the location 29 | * @param shift the shift 30 | */ 31 | public LomaxDistribution(double shape, double location, double shift) { 32 | super(shape, location); 33 | 34 | if (shift > location) { 35 | throw new IllegalArgumentException("Shift must be smaller or equal than location"); 36 | } 37 | 38 | this.shift = shift; 39 | } 40 | 41 | /** 42 | * Instantiates a new lomax distribution. 43 | * 44 | * @param seed the seed 45 | * @param shape the shape 46 | * @param location the location 47 | * @param shift the shift 48 | */ 49 | public LomaxDistribution(Random seed, double shape, double location, double shift) { 50 | super(seed, shape, location); 51 | 52 | if (shift > location) { 53 | throw new IllegalArgumentException("Shift must be smaller or equal than location"); 54 | } 55 | 56 | this.shift = shift; 57 | } 58 | 59 | /* 60 | * (non-Javadoc) 61 | * @see cloudsim.distributions.ParetoDistr#sample() 62 | */ 63 | @Override 64 | public double sample() { 65 | return super.sample() - shift; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/distributions/ParetoDistr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Descripimport java.util.Random; 4 | mulation) Toolkit for Modeling and Simulation of Clouds 5 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 6 | * 7 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 8 | */ 9 | 10 | package org.cloudbus.cloudsim.distributions; 11 | 12 | import java.util.Random; 13 | 14 | /** 15 | * The Class ParetoDistr. 16 | * 17 | * @author Marcos Dias de Assuncao 18 | * @since CloudSim Toolkit 1.0 19 | */ 20 | public class ParetoDistr implements ContinuousDistribution { 21 | 22 | /** The num gen. */ 23 | private final Random numGen; 24 | 25 | /** The shape. */ 26 | private final double shape; 27 | 28 | /** The location. */ 29 | private final double location; 30 | 31 | /** 32 | * Instantiates a new pareto distr. 33 | * 34 | * @param seed the seed 35 | * @param shape the shape 36 | * @param location the location 37 | */ 38 | public ParetoDistr(Random seed, double shape, double location) { 39 | if (shape <= 0.0 || location <= 0.0) { 40 | throw new IllegalArgumentException("Mean and deviation must be greater than 0.0"); 41 | } 42 | 43 | numGen = seed; 44 | this.shape = shape; 45 | this.location = location; 46 | } 47 | 48 | /** 49 | * Instantiates a new pareto distr. 50 | * 51 | * @param shape the shape 52 | * @param location the location 53 | */ 54 | public ParetoDistr(double shape, double location) { 55 | if (shape <= 0.0 || location <= 0.0) { 56 | throw new IllegalArgumentException("Mean and deviation must be greater than 0.0"); 57 | } 58 | 59 | numGen = new Random(System.currentTimeMillis()); 60 | this.shape = shape; 61 | this.location = location; 62 | } 63 | 64 | /* 65 | * (non-Javadoc) 66 | * @see cloudsim.distributions.ContinuousDistribution#sample() 67 | */ 68 | @Override 69 | public double sample() { 70 | return location / Math.pow(numGen.nextDouble(), 1 / shape); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/distributions/UniformDistr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.distributions; 10 | 11 | import java.util.Random; 12 | 13 | /** 14 | * A random number generator based on the Uniform distribution. 15 | * 16 | * @author Marcos Dias de Assuncao 17 | * @since CloudSim Toolkit 1.0 18 | */ 19 | public class UniformDistr implements ContinuousDistribution { 20 | 21 | /** The num gen. */ 22 | private final Random numGen; 23 | 24 | /** The min. */ 25 | private final double mag, min; 26 | 27 | /** 28 | * Creates new uniform distribution. 29 | * 30 | * @param min minimum value 31 | * @param max maximum value 32 | */ 33 | public UniformDistr(double min, double max) { 34 | if (min >= max) { 35 | throw new IllegalArgumentException("Maximum must be greater than the minimum."); 36 | } 37 | numGen = new Random(); 38 | mag = max - min; 39 | this.min = min; 40 | } 41 | 42 | /** 43 | * Creates new uniform distribution. 44 | * 45 | * @param min minimum value 46 | * @param max maximum value 47 | * @param seed simulation seed to be used 48 | */ 49 | public UniformDistr(double min, double max, long seed) { 50 | if (min >= max) { 51 | throw new IllegalArgumentException("Maximum must be greater than the minimum."); 52 | } 53 | 54 | numGen = new Random(seed); 55 | mag = max - min; 56 | this.min = min; 57 | } 58 | 59 | /** 60 | * Generate a new random number. 61 | * 62 | * @return the next random number in the sequence 63 | */ 64 | @Override 65 | public double sample() { 66 | return (numGen.nextDouble() * (mag)) + min; 67 | } 68 | 69 | /** 70 | * Generates a new random number based on the number generator and values provided as 71 | * parameters. 72 | * 73 | * @param rd the random number generator 74 | * @param min the minimum value 75 | * @param max the maximum value 76 | * @return the next random number in the sequence 77 | */ 78 | public static double sample(Random rd, double min, double max) { 79 | if (min >= max) { 80 | throw new IllegalArgumentException("Maximum must be greater than the minimum."); 81 | } 82 | 83 | return (rd.nextDouble() * (max - min)) + min; 84 | } 85 | 86 | /** 87 | * Set the random number generator's seed. 88 | * 89 | * @param seed the new seed for the generator 90 | */ 91 | public void setSeed(long seed) { 92 | numGen.setSeed(seed); 93 | } 94 | 95 | } -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/distributions/WeibullDistr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Descripimport java.util.Random; 4 | mulation) Toolkit for Modeling and Simulation of Clouds 5 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 6 | * 7 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 8 | */ 9 | 10 | package org.cloudbus.cloudsim.distributions; 11 | 12 | import java.util.Random; 13 | 14 | /** 15 | * The Class WeibullDistr. 16 | * 17 | * @author Marcos Dias de Assuncao 18 | * @since CloudSim Toolkit 1.0 19 | */ 20 | public class WeibullDistr implements ContinuousDistribution { 21 | 22 | /** The num gen. */ 23 | private final Random numGen; 24 | 25 | /** The alpha. */ 26 | private final double alpha; 27 | 28 | /** The beta. */ 29 | private final double beta; 30 | 31 | /** 32 | * Instantiates a new weibull distr. 33 | * 34 | * @param seed the seed 35 | * @param alpha the alpha 36 | * @param beta the beta 37 | */ 38 | public WeibullDistr(Random seed, double alpha, double beta) { 39 | if (alpha <= 0.0 || beta <= 0.0) { 40 | throw new IllegalArgumentException("Alpha and beta must be greater than 0.0"); 41 | } 42 | 43 | numGen = seed; 44 | this.alpha = alpha; 45 | this.beta = beta; 46 | } 47 | 48 | /** 49 | * Instantiates a new weibull distr. 50 | * 51 | * @param alpha the alpha 52 | * @param beta the beta 53 | */ 54 | public WeibullDistr(double alpha, double beta) { 55 | if (alpha <= 0.0 || beta <= 0.0) { 56 | throw new IllegalArgumentException("Alpha and beta must be greater than 0.0"); 57 | } 58 | 59 | numGen = new Random(System.currentTimeMillis()); 60 | this.alpha = alpha; 61 | this.beta = beta; 62 | } 63 | 64 | /* 65 | * (non-Javadoc) 66 | * @see cloudsim.distributions.ContinuousDistribution#sample() 67 | */ 68 | @Override 69 | public double sample() { 70 | return beta * Math.pow(-Math.log(numGen.nextDouble()), 1 / alpha); 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/distributions/ZipfDistr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Descripimport java.util.Random; 4 | mulation) Toolkit for Modeling and Simulation of Clouds 5 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 6 | * 7 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 8 | */ 9 | 10 | package org.cloudbus.cloudsim.distributions; 11 | 12 | import java.util.Random; 13 | 14 | /** 15 | * The Class ZipfDistr. 16 | * 17 | * @author Marcos Dias de Assuncao 18 | * @since CloudSim Toolkit 1.0 19 | */ 20 | public class ZipfDistr implements ContinuousDistribution { 21 | 22 | /** The num gen. */ 23 | private final Random numGen; 24 | 25 | /** The shape. */ 26 | private final double shape; 27 | 28 | /** The den. */ 29 | private double den; 30 | 31 | /** 32 | * Instantiates a new zipf distr. 33 | * 34 | * @param seed the seed 35 | * @param shape the shape 36 | * @param population the population 37 | */ 38 | public ZipfDistr(long seed, double shape, int population) { 39 | if (shape <= 0.0 || population < 1) { 40 | throw new IllegalArgumentException("Mean must be greater than 0.0 and population greater than 0"); 41 | } 42 | numGen = new Random(seed); 43 | this.shape = shape; 44 | 45 | computeDen(shape, population); 46 | } 47 | 48 | /** 49 | * Instantiates a new zipf distr. 50 | * 51 | * @param shape the shape 52 | * @param population the population 53 | */ 54 | public ZipfDistr(double shape, int population) { 55 | if (shape <= 0.0) { 56 | throw new IllegalArgumentException("Mean must be greated than 0.0 and population greater than 0"); 57 | } 58 | numGen = new Random(System.currentTimeMillis()); 59 | this.shape = shape; 60 | computeDen(shape, population); 61 | } 62 | 63 | /** 64 | * Generate a new random number. 65 | * 66 | * @return the next random number in the sequence 67 | */ 68 | @Override 69 | public double sample() { 70 | double variate = numGen.nextDouble(); 71 | double num = 1; 72 | double nextNum = 1 + 1 / Math.pow(2, shape); 73 | double j = 3; 74 | 75 | while (variate > nextNum / den) { 76 | num = nextNum; 77 | nextNum += 1 / Math.pow(j, shape); 78 | j++; 79 | } 80 | 81 | return num / den; 82 | } 83 | 84 | /** 85 | * Compute den. 86 | * 87 | * @param shape the shape 88 | * @param population the population 89 | */ 90 | private void computeDen(double shape, int population) { 91 | den = 0.0; 92 | for (int j = 1; j <= population; j++) { 93 | den += 1 / Math.pow(j, shape); 94 | } 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/lists/VmList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.lists; 10 | 11 | import java.util.List; 12 | 13 | import org.cloudbus.cloudsim.Vm; 14 | 15 | /** 16 | * VmList is a collection of operations on lists of VMs. 17 | * 18 | * @author Anton Beloglazov 19 | * @since CloudSim Toolkit 2.0 20 | */ 21 | public class VmList { 22 | 23 | /** 24 | * Return a reference to a Vm object from its ID. 25 | * 26 | * @param id ID of required VM 27 | * @param vmList the vm list 28 | * @return Vm with the given ID, $null if not found 29 | * @pre $none 30 | * @post $none 31 | */ 32 | public static T getById(List vmList, int id) { 33 | for (T vm : vmList) { 34 | if (vm.getId() == id) { 35 | return vm; 36 | } 37 | } 38 | return null; 39 | } 40 | 41 | /** 42 | * Return a reference to a Vm object from its ID and user ID. 43 | * 44 | * @param id ID of required VM 45 | * @param userId the user ID 46 | * @param vmList the vm list 47 | * @return Vm with the given ID, $null if not found 48 | * @pre $none 49 | * @post $none 50 | */ 51 | public static T getByIdAndUserId(List vmList, int id, int userId) { 52 | for (T vm : vmList) { 53 | if (vm.getId() == id && vm.getUserId() == userId) { 54 | return vm; 55 | } 56 | } 57 | return null; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/network/GraphReaderIF.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.network; 10 | 11 | import java.io.IOException; 12 | 13 | /** 14 | * This interface abstracts an reader for different graph-file-formats 15 | * 16 | * @author Thomas Hohnstein 17 | * @since CloudSim Toolkit 1.0 18 | */ 19 | public interface GraphReaderIF { 20 | 21 | /** 22 | * this method just reads the file and creates an TopologicalGraph object 23 | * 24 | * @param filename name of the file to read 25 | * @return created TopologicalGraph 26 | * @throws IOException 27 | */ 28 | TopologicalGraph readGraphFile(String filename) throws IOException; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/network/TopologicalLink.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.network; 10 | 11 | /** 12 | * This class represents an link (edge) from an graph 13 | * 14 | * @author Thomas Hohnstein 15 | * @since CloudSim Toolkit 1.0 16 | */ 17 | public class TopologicalLink { 18 | 19 | /** 20 | * id of the link src node-id 21 | */ 22 | private int srcNodeID = 0; 23 | 24 | /** 25 | * id of the link dest node-id 26 | */ 27 | private int destNodeID = 0; 28 | 29 | /** 30 | * representing the link-delay of the connection 31 | */ 32 | private float linkDelay = 0; 33 | 34 | private float linkBw = 0; 35 | 36 | /** 37 | * creates an new link-object 38 | */ 39 | public TopologicalLink(int srcNode, int destNode, float delay, float bw) { 40 | // lets initialize all internal attributes 41 | linkDelay = delay; 42 | srcNodeID = srcNode; 43 | destNodeID = destNode; 44 | linkBw = bw; 45 | } 46 | 47 | /** 48 | * returns the node-ID from the SrcNode 49 | * 50 | * @return nodeID 51 | */ 52 | public int getSrcNodeID() { 53 | return srcNodeID; 54 | } 55 | 56 | /** 57 | * return the node-ID from the DestNode 58 | * 59 | * @return nodeID 60 | */ 61 | public int getDestNodeID() { 62 | return destNodeID; 63 | } 64 | 65 | /** 66 | * return the link-delay of the defined linke 67 | * 68 | * @return the delay-amount 69 | */ 70 | public float getLinkDelay() { 71 | return linkDelay; 72 | } 73 | 74 | /** 75 | * return the link-bw of the defined linke 76 | * 77 | * @return the bw 78 | */ 79 | public float getLinkBw() { 80 | return linkBw; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/network/TopologicalNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.network; 10 | 11 | /** 12 | * Just represents an topological network node retrieves its information from an 13 | * topological-generated file (eg. topology-generator) 14 | * 15 | * @author Thomas Hohnstein 16 | * @since CloudSim Toolkit 1.0 17 | */ 18 | public class TopologicalNode { 19 | 20 | /** 21 | * its the nodes-ID inside this network 22 | */ 23 | private int nodeID = 0; 24 | 25 | /** 26 | * describes the nodes-name inside the network 27 | */ 28 | private String nodeName = null; 29 | 30 | /** 31 | * representing the x an y world-coordinates 32 | */ 33 | private int worldX = 0; 34 | 35 | private int worldY = 0; 36 | 37 | /** 38 | * constructs an new node 39 | */ 40 | public TopologicalNode(int nodeID) { 41 | // lets initialize all private class attributes 42 | this.nodeID = nodeID; 43 | nodeName = String.valueOf(nodeID); 44 | } 45 | 46 | /** 47 | * constructs an new node including world-coordinates 48 | */ 49 | public TopologicalNode(int nodeID, int x, int y) { 50 | // lets initialize all private class attributes 51 | this.nodeID = nodeID; 52 | nodeName = String.valueOf(nodeID); 53 | worldX = x; 54 | worldY = y; 55 | } 56 | 57 | /** 58 | * constructs an new node including world-coordinates and the nodeName 59 | */ 60 | public TopologicalNode(int nodeID, String nodeName, int x, int y) { 61 | // lets initialize all private class attributes 62 | this.nodeID = nodeID; 63 | this.nodeName = nodeName; 64 | worldX = x; 65 | worldY = y; 66 | } 67 | 68 | /** 69 | * delivers the nodes id 70 | * 71 | * @return just the nodeID 72 | */ 73 | public int getNodeID() { 74 | return nodeID; 75 | } 76 | 77 | /** 78 | * delivers the name of the node 79 | * 80 | * @return name of the node 81 | */ 82 | public String getNodeLabel() { 83 | return nodeName; 84 | } 85 | 86 | /** 87 | * returns the x coordinate of this network-node 88 | * 89 | * @return the x coordinate 90 | */ 91 | public int getCoordinateX() { 92 | return worldX; 93 | } 94 | 95 | /** 96 | * returns the y coordinate of this network-node 97 | * 98 | * @return the y coordinate 99 | */ 100 | public int getCoordinateY() { 101 | return worldY; 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/network/datacenter/HostPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.network.datacenter; 10 | 11 | /** 12 | * HostPacket represents the packet that travels through the virtual network with a Host. It 13 | * contains information about cloudlets which are communicating 14 | * 15 | * Please refer to following publication for more details: 16 | * 17 | * Saurabh Kumar Garg and Rajkumar Buyya, NetworkCloudSim: Modelling Parallel Applications in Cloud 18 | * Simulations, Proceedings of the 4th IEEE/ACM International Conference on Utility and Cloud 19 | * Computing (UCC 2011, IEEE CS Press, USA), Melbourne, Australia, December 5-7, 2011. 20 | * 21 | * @author Saurabh Kumar Garg 22 | * @since CloudSim Toolkit 1.0 23 | */ 24 | public class HostPacket { 25 | 26 | public HostPacket( 27 | int sender, 28 | int reciever, 29 | double data, 30 | double sendtime, 31 | double recievetime, 32 | int vsnd, 33 | int vrvd) { 34 | super(); 35 | this.sender = sender; 36 | this.reciever = reciever; 37 | this.data = data; 38 | this.sendtime = sendtime; 39 | this.recievetime = recievetime; 40 | virtualrecvid = vrvd; 41 | virtualsendid = vsnd; 42 | } 43 | 44 | int sender; 45 | 46 | int virtualrecvid; 47 | 48 | int virtualsendid; 49 | 50 | int reciever; 51 | 52 | double data; 53 | 54 | double sendtime; 55 | 56 | double recievetime; 57 | } 58 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/network/datacenter/NetworkConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.network.datacenter; 10 | 11 | public class NetworkConstants { 12 | 13 | public static int maxhostVM = 2; 14 | public static int HOST_PEs = 8; 15 | 16 | public static double maxMemperVM = 1024 * 1024;// kb 17 | 18 | public static int currentCloudletId = 0; 19 | public static int currentAppId = 0; 20 | 21 | // stage type 22 | public static final int EXECUTION = 0; 23 | public static final int WAIT_SEND = 1; 24 | public static final int WAIT_RECV = 2; 25 | public static final int FINISH = -2; 26 | 27 | // number of switches at each level 28 | public static final int ROOT_LEVEL = 0; 29 | public static final int Agg_LEVEL = 1; 30 | public static final int EDGE_LEVEL = 2; 31 | 32 | public static final int PES_NUMBER = 4; 33 | public static final int FILE_SIZE = 300; 34 | public static final int OUTPUT_SIZE = 300; 35 | 36 | public static final int COMMUNICATION_LENGTH = 1; 37 | 38 | public static boolean BASE = true; 39 | 40 | public static long BandWidthEdgeAgg = 100 * 1024 * 1024;// 100 Megabits 41 | public static long BandWidthEdgeHost = 100 * 1024 * 1024;// 42 | public static long BandWidthAggRoot = 20 * 1024 * 1024 * 2;// 40gb 43 | 44 | public static double SwitchingDelayRoot = .00285; 45 | public static double SwitchingDelayAgg = .00245;// .00245 46 | public static double SwitchingDelayEdge = .00157;// ms 47 | 48 | public static double EdgeSwitchPort = 4;// number of host 49 | 50 | public static double AggSwitchPort = 1;// number of Edge 51 | 52 | public static double RootSwitchPort = 1;// number of Agg 53 | 54 | public static double seed = 199; 55 | 56 | public static boolean logflag = false; 57 | 58 | public static int iteration = 10; 59 | public static int nexttime = 1000; 60 | 61 | public static int totaldatatransfer = 0; 62 | } 63 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/network/datacenter/NetworkPacket.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.network.datacenter; 10 | 11 | /** 12 | * NewtorkPacket represents the packet which travel from one server to another. Each packet contains 13 | * ids of the sender VM and receiver VM, time at which it is send and received, type and virtual ids 14 | * of tasks, which are communicating. 15 | * 16 | * Please refer to following publication for more details: 17 | * 18 | * Saurabh Kumar Garg and Rajkumar Buyya, NetworkCloudSim: Modelling Parallel Applications in Cloud 19 | * Simulations, Proceedings of the 4th IEEE/ACM International Conference on Utility and Cloud 20 | * Computing (UCC 2011, IEEE CS Press, USA), Melbourne, Australia, December 5-7, 2011. 21 | * 22 | * @author Saurabh Kumar Garg 23 | * @since CloudSim Toolkit 1.0 24 | */ 25 | public class NetworkPacket { 26 | 27 | public NetworkPacket(int id, HostPacket pkt2, int vmid, int cloudletid) { 28 | pkt = pkt2; 29 | sendervmid = vmid; 30 | this.cloudletid = cloudletid; 31 | senderhostid = id; 32 | stime = pkt.sendtime; 33 | recievervmid = pkt2.reciever; 34 | 35 | } 36 | 37 | HostPacket pkt; 38 | 39 | int senderhostid; 40 | 41 | int recieverhostid; 42 | 43 | int sendervmid; 44 | 45 | int recievervmid; 46 | 47 | int cloudletid; 48 | 49 | double stime;// time when sent 50 | 51 | double rtime;// time when received 52 | } 53 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/network/datacenter/NetworkVm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.network.datacenter; 10 | 11 | import java.util.ArrayList; 12 | 13 | import org.cloudbus.cloudsim.CloudletScheduler; 14 | import org.cloudbus.cloudsim.Vm; 15 | 16 | /** 17 | * NetworkVm class extends Vm to support simulation of networked datacenters. It executes actions 18 | * related to management of packets (send and receive). 19 | * 20 | * Please refer to following publication for more details: 21 | * 22 | * Saurabh Kumar Garg and Rajkumar Buyya, NetworkCloudSim: Modelling Parallel Applications in Cloud 23 | * Simulations, Proceedings of the 4th IEEE/ACM International Conference on Utility and Cloud 24 | * Computing (UCC 2011, IEEE CS Press, USA), Melbourne, Australia, December 5-7, 2011. 25 | * 26 | * @author Saurabh Kumar Garg 27 | * @since CloudSim Toolkit 3.0 28 | */ 29 | public class NetworkVm extends Vm implements Comparable { 30 | 31 | public NetworkVm( 32 | int id, 33 | int userId, 34 | double mips, 35 | int pesNumber, 36 | int ram, 37 | long bw, 38 | long size, 39 | String vmm, 40 | CloudletScheduler cloudletScheduler) { 41 | super(id, userId, mips, pesNumber, ram, bw, size, vmm, cloudletScheduler); 42 | 43 | cloudletlist = new ArrayList(); 44 | } 45 | 46 | public ArrayList cloudletlist; 47 | 48 | int type; 49 | 50 | public ArrayList recvPktlist; 51 | 52 | public double memory; 53 | 54 | public boolean flagfree;// if true it is free 55 | 56 | public double finishtime; 57 | 58 | public boolean isFree() { 59 | return flagfree; 60 | } 61 | 62 | @Override 63 | public int compareTo(Object arg0) { 64 | NetworkVm hs = (NetworkVm) arg0; 65 | if (hs.finishtime > finishtime) { 66 | return -1; 67 | } 68 | if (hs.finishtime < finishtime) { 69 | return 1; 70 | } 71 | return 0; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/network/datacenter/TaskStage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.network.datacenter; 10 | 11 | /** 12 | * Taskstage represents various stages a networkCloudlet can have during execution. Four stage types 13 | * which are possible-> EXECUTION=0; WAIT_SEND=1; WAIT_RECV=2; FINISH=-2; Check NeworkConstants.java 14 | * file for that. 15 | * 16 | * Please refer to following publication for more details: 17 | * 18 | * Saurabh Kumar Garg and Rajkumar Buyya, NetworkCloudSim: Modelling Parallel Applications in Cloud 19 | * Simulations, Proceedings of the 4th IEEE/ACM International Conference on Utility and Cloud 20 | * Computing (UCC 2011, IEEE CS Press, USA), Melbourne, Australia, December 5-7, 2011. 21 | * 22 | * @author Saurabh Kumar Garg 23 | * @since CloudSim Toolkit 1.0 24 | */ 25 | public class TaskStage { 26 | 27 | public TaskStage(int type, double data, double time, double stageid, long memory, int peer, int vpeer) { 28 | super(); 29 | this.type = type; 30 | this.data = data; 31 | this.time = time; 32 | this.stageid = stageid; 33 | this.memory = memory; 34 | this.peer = peer; 35 | this.vpeer = vpeer; 36 | } 37 | 38 | int vpeer; 39 | 40 | int type;// execution, recv, send, 41 | 42 | double data;// data generated or send or recv 43 | 44 | double time;// execution time for this stage 45 | 46 | double stageid; 47 | 48 | long memory; 49 | 50 | int peer;// from whom data needed to be recieved or send 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/PowerDatacenterBroker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power; 10 | 11 | import org.cloudbus.cloudsim.DatacenterBroker; 12 | import org.cloudbus.cloudsim.core.CloudSim; 13 | import org.cloudbus.cloudsim.core.CloudSimTags; 14 | import org.cloudbus.cloudsim.core.SimEvent; 15 | 16 | /** 17 | * A broker for the power package. 18 | * 19 | * If you are using any algorithms, policies or workload included in the power package please cite 20 | * the following paper: 21 | * 22 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 23 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 24 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 25 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 26 | * 27 | * @author Anton Beloglazov 28 | * @since CloudSim Toolkit 2.0 29 | */ 30 | public class PowerDatacenterBroker extends DatacenterBroker { 31 | 32 | /** 33 | * Instantiates a new power datacenter broker. 34 | * 35 | * @param name the name 36 | * @throws Exception the exception 37 | */ 38 | public PowerDatacenterBroker(String name) throws Exception { 39 | super(name); 40 | } 41 | 42 | /* 43 | * (non-Javadoc) 44 | * @see 45 | * org.cloudbus.cloudsim.DatacenterBroker#processVmCreate(org.cloudbus.cloudsim.core.SimEvent) 46 | */ 47 | @Override 48 | protected void processVmCreate(SimEvent ev) { 49 | int[] data = (int[]) ev.getData(); 50 | int result = data[2]; 51 | 52 | if (result != CloudSimTags.TRUE) { 53 | int datacenterId = data[0]; 54 | int vmId = data[1]; 55 | System.out.println(CloudSim.clock() + ": " + getName() + ": Creation of VM #" + vmId 56 | + " failed in Datacenter #" + datacenterId); 57 | System.exit(0); 58 | } 59 | super.processVmCreate(ev); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/PowerVmAllocationPolicySimple.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power; 10 | 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | import org.cloudbus.cloudsim.Host; 15 | import org.cloudbus.cloudsim.Vm; 16 | 17 | /** 18 | * This a simple class representing a simple VM allocation policy that does not perform any 19 | * optimization of the VM allocation. 20 | * 21 | * If you are using any algorithms, policies or workload included in the power package, please cite 22 | * the following paper: 23 | * 24 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 25 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 26 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 27 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 28 | * 29 | * @author Anton Beloglazov 30 | * @since CloudSim Toolkit 3.0 31 | */ 32 | public class PowerVmAllocationPolicySimple extends PowerVmAllocationPolicyAbstract { 33 | 34 | /** 35 | * Instantiates a new power vm allocation policy simple. 36 | * 37 | * @param list the list 38 | */ 39 | public PowerVmAllocationPolicySimple(List list) { 40 | super(list); 41 | } 42 | 43 | /* 44 | * (non-Javadoc) 45 | * @see org.cloudbus.cloudsim.VmAllocationPolicy#optimizeAllocation(java.util.List) 46 | */ 47 | @Override 48 | public List> optimizeAllocation(List vmList) { 49 | // This policy does not optimize the VM allocation 50 | return null; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/PowerVmSelectionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power; 10 | 11 | import java.util.ArrayList; 12 | import java.util.List; 13 | 14 | import org.cloudbus.cloudsim.Vm; 15 | 16 | /** 17 | * The class of an abstract VM selection policy. 18 | * 19 | * If you are using any algorithms, policies or workload included in the power package, please cite 20 | * the following paper: 21 | * 22 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 23 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 24 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 25 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 26 | * 27 | * @author Anton Beloglazov 28 | * @since CloudSim Toolkit 3.0 29 | */ 30 | public abstract class PowerVmSelectionPolicy { 31 | 32 | /** 33 | * Gets the vms to migrate. 34 | * 35 | * @param host the host 36 | * @return the vms to migrate 37 | */ 38 | public abstract Vm getVmToMigrate(PowerHost host); 39 | 40 | /** 41 | * Gets the migratable vms. 42 | * 43 | * @param host the host 44 | * @return the migratable vms 45 | */ 46 | protected List getMigratableVms(PowerHost host) { 47 | List migratableVms = new ArrayList(); 48 | for (PowerVm vm : host. getVmList()) { 49 | if (!vm.isInMigration()) { 50 | migratableVms.add(vm); 51 | } 52 | } 53 | return migratableVms; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/PowerVmSelectionPolicyMinimumMigrationTime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power; 10 | 11 | import java.util.List; 12 | 13 | import org.cloudbus.cloudsim.Vm; 14 | 15 | /** 16 | * The Minimum Migration Time (MMT) VM selection policy. 17 | * 18 | * If you are using any algorithms, policies or workload included in the power package, please cite 19 | * the following paper: 20 | * 21 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 22 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 23 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 24 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 25 | * 26 | * @author Anton Beloglazov 27 | * @since CloudSim Toolkit 3.0 28 | */ 29 | public class PowerVmSelectionPolicyMinimumMigrationTime extends PowerVmSelectionPolicy { 30 | 31 | /* 32 | * (non-Javadoc) 33 | * @see 34 | * org.cloudbus.cloudsim.experiments.power.PowerVmSelectionPolicy#getVmsToMigrate(org.cloudbus 35 | * .cloudsim.power.PowerHost) 36 | */ 37 | @Override 38 | public Vm getVmToMigrate(PowerHost host) { 39 | List migratableVms = getMigratableVms(host); 40 | if (migratableVms.isEmpty()) { 41 | return null; 42 | } 43 | Vm vmToMigrate = null; 44 | double minMetric = Double.MAX_VALUE; 45 | for (Vm vm : migratableVms) { 46 | if (vm.isInMigration()) { 47 | continue; 48 | } 49 | double metric = vm.getRam(); 50 | if (metric < minMetric) { 51 | minMetric = metric; 52 | vmToMigrate = vm; 53 | } 54 | } 55 | return vmToMigrate; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/PowerVmSelectionPolicyMinimumUtilization.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power; 10 | 11 | import java.util.List; 12 | 13 | import org.cloudbus.cloudsim.Vm; 14 | import org.cloudbus.cloudsim.core.CloudSim; 15 | 16 | /** 17 | * The Minimum Utilization (MU) VM selection policy. 18 | * 19 | * If you are using any algorithms, policies or workload included in the power package, please cite 20 | * the following paper: 21 | * 22 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 23 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 24 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 25 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 26 | * 27 | * @author Anton Beloglazov 28 | * @since CloudSim Toolkit 3.0 29 | */ 30 | public class PowerVmSelectionPolicyMinimumUtilization extends PowerVmSelectionPolicy { 31 | 32 | /* 33 | * (non-Javadoc) 34 | * @see 35 | * org.cloudbus.cloudsim.experiments.power.PowerVmSelectionPolicy#getVmsToMigrate(org.cloudbus 36 | * .cloudsim.power.PowerHost) 37 | */ 38 | @Override 39 | public Vm getVmToMigrate(PowerHost host) { 40 | List migratableVms = getMigratableVms(host); 41 | if (migratableVms.isEmpty()) { 42 | return null; 43 | } 44 | Vm vmToMigrate = null; 45 | double minMetric = Double.MAX_VALUE; 46 | for (Vm vm : migratableVms) { 47 | if (vm.isInMigration()) { 48 | continue; 49 | } 50 | double metric = vm.getTotalUtilizationOfCpuMips(CloudSim.clock()) / vm.getMips(); 51 | if (metric < minMetric) { 52 | minMetric = metric; 53 | vmToMigrate = vm; 54 | } 55 | } 56 | return vmToMigrate; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/PowerVmSelectionPolicyRandomSelection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power; 10 | 11 | import java.util.List; 12 | import java.util.Random; 13 | 14 | import org.cloudbus.cloudsim.Vm; 15 | 16 | /** 17 | * The Random Selection (RS) VM selection policy. 18 | * 19 | * If you are using any algorithms, policies or workload included in the power package, please cite 20 | * the following paper: 21 | * 22 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 23 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 24 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 25 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 26 | * 27 | * @author Anton Beloglazov 28 | * @since CloudSim Toolkit 3.0 29 | */ 30 | public class PowerVmSelectionPolicyRandomSelection extends PowerVmSelectionPolicy { 31 | 32 | /* 33 | * (non-Javadoc) 34 | * @see 35 | * org.cloudbus.cloudsim.experiments.power.PowerVmSelectionPolicy#getVmsToMigrate(org.cloudbus 36 | * .cloudsim.power.PowerHost) 37 | */ 38 | @Override 39 | public Vm getVmToMigrate(PowerHost host) { 40 | List migratableVms = getMigratableVms(host); 41 | if (migratableVms.isEmpty()) { 42 | return null; 43 | } 44 | int index = (new Random()).nextInt(migratableVms.size()); 45 | return migratableVms.get(index); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/lists/PowerVmList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power.lists; 10 | 11 | import java.util.Collections; 12 | import java.util.Comparator; 13 | import java.util.List; 14 | 15 | import org.cloudbus.cloudsim.Vm; 16 | import org.cloudbus.cloudsim.core.CloudSim; 17 | import org.cloudbus.cloudsim.lists.VmList; 18 | 19 | /** 20 | * PowerVmList is a collection of operations on lists of power-enabled VMs. 21 | * 22 | * If you are using any algorithms, policies or workload included in the power package, please cite 23 | * the following paper: 24 | * 25 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 26 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 27 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 28 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 29 | * 30 | * @author Anton Beloglazov 31 | * 32 | * @author Anton Beloglazov 33 | * @since CloudSim Toolkit 2.0 34 | */ 35 | public class PowerVmList extends VmList { 36 | 37 | /** 38 | * Sort by cpu utilization. 39 | * 40 | * @param vmList the vm list 41 | */ 42 | public static void sortByCpuUtilization(List vmList) { 43 | Collections.sort(vmList, new Comparator() { 44 | 45 | @Override 46 | public int compare(T a, T b) throws ClassCastException { 47 | Double aUtilization = a.getTotalUtilizationOfCpuMips(CloudSim.clock()); 48 | Double bUtilization = b.getTotalUtilizationOfCpuMips(CloudSim.clock()); 49 | return bUtilization.compareTo(aUtilization); 50 | } 51 | }); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/models/PowerModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power.models; 10 | 11 | /** 12 | * The PowerModel interface needs to be implemented in order to provide a model of power consumption 13 | * depending on utilization for system components. 14 | * 15 | * If you are using any algorithms, policies or workload included in the power package, please cite 16 | * the following paper: 17 | * 18 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 19 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 20 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 21 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 22 | * 23 | * @author Anton Beloglazov 24 | * 25 | * @author Anton Beloglazov 26 | * @since CloudSim Toolkit 2.0 27 | */ 28 | public interface PowerModel { 29 | 30 | /** 31 | * Get power consumption by the utilization percentage according to the power model. 32 | * 33 | * @param utilization the utilization 34 | * @return power consumption 35 | * @throws IllegalArgumentException the illegal argument exception 36 | */ 37 | double getPower(double utilization) throws IllegalArgumentException; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/models/PowerModelSpecPower.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power.models; 10 | 11 | /** 12 | * The abstract class of power models created based on data from SPECpower benchmark: 13 | * http://www.spec.org/power_ssj2008/ 14 | * 15 | * If you are using any algorithms, policies or workload included in the power package, please cite 16 | * the following paper: 17 | * 18 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 19 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 20 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 21 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 22 | * 23 | * @author Anton Beloglazov 24 | * @since CloudSim Toolkit 3.0 25 | */ 26 | public abstract class PowerModelSpecPower implements PowerModel { 27 | 28 | /* 29 | * (non-Javadoc) 30 | * @see org.cloudbus.cloudsim.power.models.PowerModel#getPower(double) 31 | */ 32 | @Override 33 | public double getPower(double utilization) throws IllegalArgumentException { 34 | if (utilization < 0 || utilization > 1) { 35 | throw new IllegalArgumentException("Utilization value must be between 0 and 1"); 36 | } 37 | if (utilization % 0.1 == 0) { 38 | return getPowerData((int) (utilization * 10)); 39 | } 40 | int utilization1 = (int) Math.floor(utilization * 10); 41 | int utilization2 = (int) Math.ceil(utilization * 10); 42 | double power1 = getPowerData(utilization1); 43 | double power2 = getPowerData(utilization2); 44 | double delta = (power2 - power1) / 10; 45 | double power = power1 + delta * (utilization - (double) utilization1 / 10) * 100; 46 | return power; 47 | } 48 | 49 | /** 50 | * Gets the power data. 51 | * 52 | * @param index the index 53 | * @return the power data 54 | */ 55 | protected abstract double getPowerData(int index); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/models/PowerModelSpecPowerHpProLiantMl110G3PentiumD930.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power.models; 10 | 11 | /** 12 | * The power model of an HP ProLiant ML110 G3 (1 x [Pentium D930 3000 MHz, 2 cores], 4GB). 13 | * http://www.spec.org/power_ssj2008/results/res2011q1/power_ssj2008-20110127-00342.html 14 | * 15 | * If you are using any algorithms, policies or workload included in the power package, please cite 16 | * the following paper: 17 | * 18 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 19 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 20 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 21 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 22 | * 23 | * @author Anton Beloglazov 24 | * @since CloudSim Toolkit 3.0 25 | */ 26 | public class PowerModelSpecPowerHpProLiantMl110G3PentiumD930 extends PowerModelSpecPower { 27 | 28 | /** The power. */ 29 | private final double[] power = { 105, 112, 118, 125, 131, 137, 147, 153, 157, 164, 169 }; 30 | 31 | /* 32 | * (non-Javadoc) 33 | * @see org.cloudbus.cloudsim.power.models.PowerModelSpecPower#getPowerData(int) 34 | */ 35 | @Override 36 | protected double getPowerData(int index) { 37 | return power[index]; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/models/PowerModelSpecPowerHpProLiantMl110G4Xeon3040.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power.models; 10 | 11 | /** 12 | * The power model of an HP ProLiant ML110 G4 (1 x [Xeon 3040 1860 MHz, 2 cores], 4GB). 13 | * http://www.spec.org/power_ssj2008/results/res2011q1/power_ssj2008-20110127-00342.html 14 | * 15 | * If you are using any algorithms, policies or workload included in the power package, please cite 16 | * the following paper: 17 | * 18 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 19 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 20 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 21 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 22 | * 23 | * @author Anton Beloglazov 24 | * @since CloudSim Toolkit 3.0 25 | */ 26 | public class PowerModelSpecPowerHpProLiantMl110G4Xeon3040 extends PowerModelSpecPower { 27 | 28 | /** The power. */ 29 | private final double[] power = { 86, 89.4, 92.6, 96, 99.5, 102, 106, 108, 112, 114, 117 }; 30 | 31 | /* 32 | * (non-Javadoc) 33 | * @see org.cloudbus.cloudsim.power.models.PowerModelSpecPower#getPowerData(int) 34 | */ 35 | @Override 36 | protected double getPowerData(int index) { 37 | return power[index]; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/models/PowerModelSpecPowerHpProLiantMl110G5Xeon3075.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power.models; 10 | 11 | /** 12 | * The power model of an HP ProLiant ML110 G5 (1 x [Xeon 3075 2660 MHz, 2 cores], 4GB). 13 | * http://www.spec.org/power_ssj2008/results/res2011q1/power_ssj2008-20110124-00339.html 14 | * 15 | * If you are using any algorithms, policies or workload included in the power package, please cite 16 | * the following paper: 17 | * 18 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 19 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 20 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 21 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 22 | * 23 | * @author Anton Beloglazov 24 | * @since CloudSim Toolkit 3.0 25 | */ 26 | public class PowerModelSpecPowerHpProLiantMl110G5Xeon3075 extends PowerModelSpecPower { 27 | 28 | /** The power. */ 29 | private final double[] power = { 93.7, 97, 101, 105, 110, 116, 121, 125, 129, 133, 135 }; 30 | 31 | /* 32 | * (non-Javadoc) 33 | * @see org.cloudbus.cloudsim.power.models.PowerModelSpecPower#getPowerData(int) 34 | */ 35 | @Override 36 | protected double getPowerData(int index) { 37 | return power[index]; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/models/PowerModelSpecPowerIbmX3250XeonX3470.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power.models; 10 | 11 | /** 12 | * The power model of an IBM server x3250 (1 x [Xeon X3470 2933 MHz, 4 cores], 8GB). 13 | * http://www.spec.org/power_ssj2008/results/res2009q4/power_ssj2008-20091104-00213.html 14 | * 15 | * If you are using any algorithms, policies or workload included in the power package, please cite 16 | * the following paper: 17 | * 18 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 19 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 20 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 21 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 22 | * 23 | * @author Anton Beloglazov 24 | * @since CloudSim Toolkit 3.0 25 | */ 26 | public class PowerModelSpecPowerIbmX3250XeonX3470 extends PowerModelSpecPower { 27 | 28 | /** The power. */ 29 | private final double[] power = { 41.6, 46.7, 52.3, 57.9, 65.4, 73, 80.7, 89.5, 99.6, 105, 113 }; 30 | 31 | /* 32 | * (non-Javadoc) 33 | * @see org.cloudbus.cloudsim.power.models.PowerModelSpecPower#getPowerData(int) 34 | */ 35 | @Override 36 | protected double getPowerData(int index) { 37 | return power[index]; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/models/PowerModelSpecPowerIbmX3250XeonX3480.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power.models; 10 | 11 | /** 12 | * The power model of an IBM server x3250 (1 x [Xeon X3480 3067 MHz, 4 cores], 8GB). 13 | * http://www.spec.org/power_ssj2008/results/res2010q4/power_ssj2008-20101001-00297.html 14 | * 15 | * If you are using any algorithms, policies or workload included in the power package, please cite 16 | * the following paper: 17 | * 18 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 19 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 20 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 21 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 22 | * 23 | * @author Anton Beloglazov 24 | * @since CloudSim Toolkit 3.0 25 | */ 26 | public class PowerModelSpecPowerIbmX3250XeonX3480 extends PowerModelSpecPower { 27 | 28 | /** The power. */ 29 | private final double[] power = { 42.3, 46.7, 49.7, 55.4, 61.8, 69.3, 76.1, 87, 96.1, 106, 113 }; 30 | 31 | /* 32 | * (non-Javadoc) 33 | * @see org.cloudbus.cloudsim.power.models.PowerModelSpecPower#getPowerData(int) 34 | */ 35 | @Override 36 | protected double getPowerData(int index) { 37 | return power[index]; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/models/PowerModelSpecPowerIbmX3550XeonX5670.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power.models; 10 | 11 | /** 12 | * The power model of an IBM server x3550 (2 x [Xeon X5670 2933 MHz, 6 cores], 12GB). 13 | * http://www.spec.org/power_ssj2008/results/res2010q2/power_ssj2008-20100315-00239.html 14 | * 15 | * If you are using any algorithms, policies or workload included in the power package, please cite 16 | * the following paper: 17 | * 18 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 19 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 20 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 21 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 22 | * 23 | * @author Anton Beloglazov 24 | * @since CloudSim Toolkit 3.0 25 | */ 26 | public class PowerModelSpecPowerIbmX3550XeonX5670 extends PowerModelSpecPower { 27 | 28 | /** The power. */ 29 | private final double[] power = { 66, 107, 120, 131, 143, 156, 173, 191, 211, 229, 247 }; 30 | 31 | /* 32 | * (non-Javadoc) 33 | * @see org.cloudbus.cloudsim.power.models.PowerModelSpecPower#getPowerData(int) 34 | */ 35 | @Override 36 | protected double getPowerData(int index) { 37 | return power[index]; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/power/models/PowerModelSpecPowerIbmX3550XeonX5675.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.power.models; 10 | 11 | /** 12 | * The power model of an IBM server x3550 (2 x [Xeon X5675 3067 MHz, 6 cores], 16GB). 13 | * http://www.spec.org/power_ssj2008/results/res2011q2/power_ssj2008-20110406-00368.html 14 | * 15 | * If you are using any algorithms, policies or workload included in the power package, please cite 16 | * the following paper: 17 | * 18 | * Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive 19 | * Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in 20 | * Cloud Data Centers", Concurrency and Computation: Practice and Experience (CCPE), Volume 24, 21 | * Issue 13, Pages: 1397-1420, John Wiley & Sons, Ltd, New York, USA, 2012 22 | * 23 | * @author Anton Beloglazov 24 | * @since CloudSim Toolkit 3.0 25 | */ 26 | public class PowerModelSpecPowerIbmX3550XeonX5675 extends PowerModelSpecPower { 27 | 28 | /** The power. */ 29 | private final double[] power = { 58.4, 98, 109, 118, 128, 140, 153, 170, 189, 205, 222 }; 30 | 31 | /* 32 | * (non-Javadoc) 33 | * @see org.cloudbus.cloudsim.power.models.PowerModelSpecPower#getPowerData(int) 34 | */ 35 | @Override 36 | protected double getPowerData(int index) { 37 | return power[index]; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/Activity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.sdn; 10 | 11 | /** 12 | * Activities that can be performed by VM. (Transmission or Compute) 13 | * 14 | * @author Jungmin Son 15 | * @author Rodrigo N. Calheiros 16 | * @since CloudSimSDN 1.0 17 | */ 18 | public interface Activity { 19 | } 20 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/AggregationSwitch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.sdn; 10 | 11 | /** 12 | * Represent aggregation switch 13 | * 14 | * @author Jungmin Son 15 | * @author Rodrigo N. Calheiros 16 | * @since CloudSimSDN 1.0 17 | */ 18 | public class AggregationSwitch extends Switch { 19 | 20 | public AggregationSwitch(String name,int bw, long iops, int upports, int downports, NetworkOperatingSystem nos) { 21 | super(name, bw, iops, upports, downports, nos); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/Arc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.sdn; 10 | 11 | /** 12 | * Traffic requirements between two VMs 13 | * 14 | * @author Jungmin Son 15 | * @author Rodrigo N. Calheiros 16 | * @since CloudSimSDN 1.0 17 | */ 18 | public class Arc { 19 | 20 | int srcId; 21 | int dstId; 22 | int flowId; 23 | long requiredBandwidth; 24 | double requiredLatency; 25 | 26 | public Arc(int srcId, int dstId, int flowId, long reqBW, double reqLatency) { 27 | super(); 28 | this.srcId = srcId; 29 | this.dstId = dstId; 30 | this.flowId = flowId; 31 | this.requiredBandwidth = reqBW; 32 | this.requiredLatency = reqLatency; 33 | } 34 | 35 | public int getSrcId() { 36 | return srcId; 37 | } 38 | 39 | public int getDstId() { 40 | return dstId; 41 | } 42 | public int getFlowId() { 43 | return flowId; 44 | } 45 | 46 | public long getBw() { 47 | return requiredBandwidth; 48 | } 49 | 50 | public double getLatency() { 51 | return requiredLatency; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.sdn; 10 | 11 | /** 12 | * Constant variables to use 13 | * 14 | * @author Jungmin Son 15 | * @author Rodrigo N. Calheiros 16 | * @since CloudSimSDN 1.0 17 | */ 18 | public class Constants { 19 | 20 | private static final int SDN_BASE = 89000000; 21 | 22 | public static final int SDN_PACKAGE = SDN_BASE + 1; 23 | public static final int SDN_INTERNAL_PACKAGE_PROCESS = SDN_BASE + 2; 24 | public static final int REQUEST_SUBMIT = SDN_BASE + 10; 25 | public static final int REQUEST_COMPLETED = SDN_BASE + 11; 26 | public static final int APPLICATION_SUBMIT = SDN_BASE + 20; // Broker -> Datacenter. 27 | public static final int APPLICATION_SUBMIT_ACK = SDN_BASE + 21; 28 | } 29 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/CoreSwitch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.sdn; 10 | 11 | /** 12 | * Represent core switch 13 | * 14 | * @author Jungmin Son 15 | * @author Rodrigo N. Calheiros 16 | * @since CloudSimSDN 1.0 17 | */ 18 | public class CoreSwitch extends Switch { 19 | 20 | public CoreSwitch(String name,int bw, long iops, int upports, int downports, NetworkOperatingSystem nos) { 21 | super(name, bw, iops, upports, downports, nos); 22 | //if (upports>0) throw new IllegalArgumentException("Core switches cannot have uplinks."); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/EdgeSwitch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.sdn; 10 | 11 | /** 12 | * Represent edge switch 13 | * 14 | * @author Jungmin Son 15 | * @author Rodrigo N. Calheiros 16 | * @since CloudSimSDN 1.0 17 | */ 18 | public class EdgeSwitch extends Switch { 19 | 20 | public EdgeSwitch(String name,int bw, long iops, int upports, int downports, NetworkOperatingSystem nos) { 21 | super(name, bw, iops, upports, downports, nos); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/Middlebox.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.sdn; 10 | 11 | import org.cloudbus.cloudsim.Cloudlet; 12 | import org.cloudbus.cloudsim.UtilizationModelFull; 13 | import org.cloudbus.cloudsim.Vm; 14 | import org.cloudbus.cloudsim.core.CloudSimTags; 15 | 16 | /** 17 | * Middlebox represent specific VM that acts as a middle box 18 | * 19 | * @author Jungmin Son 20 | * @author Rodrigo N. Calheiros 21 | * @since CloudSimSDN 1.0 22 | */ 23 | public abstract class Middlebox { 24 | 25 | Vm vm; 26 | int mipsPerOp; 27 | SDNHost host; 28 | static int id=0; 29 | 30 | public Middlebox(Vm vm, int misPerOperation){ 31 | this.vm=vm; 32 | this.mipsPerOp=misPerOperation; 33 | } 34 | 35 | public abstract void editRequest(Request req); 36 | 37 | public int getId(){ 38 | return vm.getId(); 39 | } 40 | 41 | public Vm getVm(){ 42 | return vm; 43 | } 44 | 45 | public void setHost(SDNHost host){ 46 | this.host=host; 47 | } 48 | 49 | public void submitRequest(Request req){ 50 | Cloudlet cl = new Cloudlet(id++,mipsPerOp,1,0,0,new UtilizationModelFull(),new UtilizationModelFull(),new UtilizationModelFull()); 51 | cl.setVmId(vm.getId()); 52 | 53 | host.schedule(host.getHost().getDatacenter().getId(), 0.0, CloudSimTags.CLOUDLET_SUBMIT, cl); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/Node.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.sdn; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * Node represents network node (host or switch) 15 | * 16 | * @author Jungmin Son 17 | * @author Rodrigo N. Calheiros 18 | * @since CloudSimSDN 1.0 19 | */ 20 | public interface Node { 21 | 22 | int getAddress(); 23 | public long getBandwidth(); 24 | public void setRank(int rank); 25 | public int getRank(); 26 | 27 | public void clearVMRoutingTable(); 28 | public void addVMRoute(int srcVM, int destVM, int flowId, Node to); 29 | public Node getVMRoute(int srcVM, int destVM, int flowId); 30 | public void removeVMRoute(int srcVM, int destVM, int flowId); 31 | public void printVMRoute(); 32 | 33 | public void addRoute(Node destHost, Link to); 34 | public List getRoute(Node destHost); 35 | 36 | public RoutingTable getRoutingTable(); 37 | 38 | public void addLink(Link l); 39 | public void updateNetworkUtilization(); 40 | } 41 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/Package.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.sdn; 10 | 11 | 12 | /** 13 | * Network data packet to transfer from source to destination. 14 | * Payload of Package will have a list of activities. 15 | * 16 | * @author Jungmin Son 17 | * @author Rodrigo N. Calheiros 18 | * @since CloudSimSDN 1.0 19 | */ 20 | public class Package { 21 | 22 | int origin; 23 | int destination; 24 | long size; 25 | int flowId; 26 | Request payload; 27 | 28 | private double startTime=-1; 29 | private double finishTime=-1; 30 | 31 | public Package(int origin, int destination, long size, int flowId, Request payload) { 32 | this.origin = origin; 33 | this.destination = destination; 34 | this.size = size; 35 | this.flowId = flowId; 36 | this.payload = payload; 37 | 38 | } 39 | 40 | public int getOrigin() { 41 | return origin; 42 | } 43 | 44 | public int getDestination() { 45 | return destination; 46 | } 47 | 48 | public long getSize() { 49 | return size; 50 | } 51 | 52 | public Request getPayload() { 53 | return payload; 54 | } 55 | 56 | public int getFlowId() { 57 | return flowId; 58 | } 59 | 60 | public String toString() { 61 | return "PKG:"+origin + "->" + destination + " - " + payload.toString(); 62 | } 63 | 64 | public void setStartTime(double time) { 65 | this.startTime = time; 66 | } 67 | public void setFinishTime(double time) { 68 | this.finishTime = time; 69 | } 70 | public double getStartTime() { 71 | return this.startTime; 72 | } 73 | public double getFinishTime() { 74 | return this.finishTime; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/Processing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | package org.cloudbus.cloudsim.sdn; 9 | 10 | import org.cloudbus.cloudsim.Cloudlet; 11 | 12 | /** 13 | * Processing activity to compute in VM. Basically a wrapper of Cloudlet. 14 | * 15 | * @author Jungmin Son 16 | * @author Rodrigo N. Calheiros 17 | * @since CloudSimSDN 1.0 18 | */ 19 | public class Processing implements Activity { 20 | 21 | long requestId; 22 | Cloudlet cl; 23 | 24 | public Processing(Cloudlet cl){ 25 | this.cl=cl; 26 | } 27 | 28 | public Cloudlet getCloudlet(){ 29 | return cl; 30 | } 31 | } -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/Request.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.sdn; 10 | 11 | import java.util.LinkedList; 12 | import java.util.List; 13 | 14 | 15 | /** 16 | * Request class represents a message submitted to VM. Each request has a list of activities 17 | * that should be performed at the VM. (Processing and Transmission) 18 | * 19 | * @author Jungmin Son 20 | * @author Rodrigo N. Calheiros 21 | * @since CloudSimSDN 1.0 22 | */ 23 | public class Request { 24 | 25 | long requestId; 26 | int userId; 27 | LinkedList activities; 28 | 29 | private LinkedList removedActivites; //Logging purpose only 30 | 31 | public Request(long requestId, int userId){ 32 | this.requestId=requestId; 33 | this.userId=userId; 34 | this.activities = new LinkedList(); 35 | 36 | this.removedActivites = new LinkedList(); 37 | 38 | } 39 | 40 | public long getRequestId(){ 41 | return requestId; 42 | } 43 | 44 | public int getUserId(){ 45 | return userId; 46 | } 47 | 48 | public boolean isFinished(){ 49 | return activities.size()==0; 50 | } 51 | 52 | public void addActivity(Activity act){ 53 | activities.add(act); 54 | } 55 | 56 | public Activity getNextActivity(){ 57 | Activity act = activities.get(0); 58 | return act; 59 | } 60 | 61 | public Transmission getNextTransmission() { 62 | for(Activity act:activities) { 63 | if(act instanceof Transmission) 64 | return (Transmission) act; 65 | } 66 | return null; 67 | } 68 | 69 | public Activity removeNextActivity(){ 70 | Activity act = activities.remove(0); 71 | 72 | this.removedActivites.add(act); 73 | 74 | return act; 75 | } 76 | public String toString() { 77 | return "Request. UserID:"+ this.userId + ",Req ID:"+this.requestId; 78 | } 79 | 80 | public List getRemovedActivities() { 81 | return this.removedActivites; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/RoutingTable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | package org.cloudbus.cloudsim.sdn; 9 | 10 | import java.util.ArrayList; 11 | import java.util.HashMap; 12 | import java.util.List; 13 | import java.util.Map; 14 | import java.util.Set; 15 | 16 | /** 17 | * Routing table for hosts and switches. This has information about the next hop. 18 | * When physical topology is set up, RoutingTable is created with the information 19 | * about next hop 20 | * 21 | * @author Jungmin Son 22 | * @author Rodrigo N. Calheiros 23 | * @since CloudSimSDN 1.0 24 | */ 25 | public class RoutingTable { 26 | 27 | Map> table; 28 | 29 | public RoutingTable(){ 30 | this.table = new HashMap>(); 31 | } 32 | 33 | public void clear(){ 34 | table.clear(); 35 | } 36 | 37 | public void addRoute(Node destHost, Link to){ 38 | List links = table.get(destHost); 39 | if(links == null) 40 | { 41 | links = new ArrayList(); 42 | } 43 | links.add(to); 44 | table.put(destHost, links); 45 | } 46 | 47 | public void removeRoute(Node destHost){ 48 | table.remove(destHost); 49 | } 50 | 51 | public List getRoute(Node destHost) { 52 | List links = table.get(destHost); 53 | if(links == null) 54 | links = table.get(null); 55 | return links; 56 | } 57 | 58 | public Set getKnownDestination() { 59 | return table.keySet(); 60 | } 61 | 62 | public void printRoutingTable() { 63 | for(Node key:table.keySet()) { 64 | for(Link l: table.get(key)) { 65 | System.out.println("dst:"+key+" : "+l); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/TimedVm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | package org.cloudbus.cloudsim.sdn; 9 | 10 | import org.cloudbus.cloudsim.CloudletScheduler; 11 | import org.cloudbus.cloudsim.Vm; 12 | 13 | /** 14 | * Extension of VM that supports to set start and terminate time of VM in VM creation request. 15 | * If start time and finish time is set up, specific CloudSim Event is triggered 16 | * in datacenter to create and terminate the VM. 17 | * 18 | * @author Jungmin Son 19 | * @author Rodrigo N. Calheiros 20 | * @since CloudSimSDN 1.0 21 | */ 22 | public class TimedVm extends Vm { 23 | 24 | private double startTime; 25 | private double finishTime; 26 | 27 | public TimedVm(int id, int userId, double mips, int numberOfPes, int ram, 28 | long bw, long size, String vmm, CloudletScheduler cloudletScheduler) { 29 | super(id, userId, mips, numberOfPes, ram, bw, size, vmm, cloudletScheduler); 30 | } 31 | 32 | public TimedVm(int id, int userId, double mips, int numberOfPes, int ram, 33 | long bw, long size, String vmm, CloudletScheduler cloudletScheduler, double startTime, double finishTime) { 34 | super(id, userId, mips, numberOfPes, ram, bw, size, vmm, cloudletScheduler); 35 | 36 | this.startTime = startTime; 37 | this.finishTime = finishTime; 38 | } 39 | 40 | public double getStartTime() { 41 | return startTime; 42 | } 43 | 44 | public double getFinishTime() { 45 | return finishTime; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/Transmission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.sdn; 10 | 11 | /** 12 | * This class represents transmission of a package. It controls 13 | * amount of data transmitted in a shared data medium. Relation between 14 | * Transmission and Channel is the same as Cloudlet and CloudletScheduler, 15 | * but here we consider only the time shared case, representing a shared 16 | * channel among different simultaneous package transmissions. 17 | * Note that estimated transmission time is calculated in NOS. 18 | * 19 | * @author Jungmin Son 20 | * @author Rodrigo N. Calheiros 21 | * @since CloudSimSDN 1.0 22 | */ 23 | public class Transmission implements Activity { 24 | Package pkg; 25 | long amountToBeProcessed; 26 | 27 | public Transmission(int origin, int destination, long size, int flowId, Request payload) { 28 | this.pkg = new Package(origin, destination, size, flowId, payload); 29 | this.amountToBeProcessed=pkg.getSize(); 30 | } 31 | 32 | public Transmission(Package pkg){ 33 | this.pkg = pkg; 34 | this.amountToBeProcessed=pkg.getSize(); 35 | } 36 | 37 | public long getSize(){ 38 | return amountToBeProcessed; 39 | } 40 | 41 | public Package getPackage(){ 42 | return pkg; 43 | } 44 | 45 | /** 46 | * Sums some amount of data to the already transmitted data 47 | * @param completed amount of data completed since last update 48 | */ 49 | public void addCompletedLength(long completed){ 50 | amountToBeProcessed-=completed; 51 | if (amountToBeProcessed<=0) amountToBeProcessed = 0; 52 | } 53 | 54 | /** 55 | * Say if the Package transmission finished or not. 56 | * @return true if transmission finished; false otherwise 57 | */ 58 | public boolean isCompleted(){ 59 | return amountToBeProcessed==0; 60 | } 61 | 62 | public String toString() { 63 | return "Transmission:"+this.pkg.toString(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/example/Workload.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | package org.cloudbus.cloudsim.sdn.example; 9 | 10 | import org.cloudbus.cloudsim.sdn.Request; 11 | 12 | /** 13 | * Class to keep workload information parsed from files. 14 | * This class is used in WorkloadParser 15 | * 16 | * @author Jungmin Son 17 | * @since CloudSimSDN 1.0 18 | */ 19 | public class Workload { 20 | public int appId; 21 | public double time; 22 | public int submitVmId; 23 | public int submitPktSize; 24 | public Request request; 25 | } 26 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/graph/core/Coordinates.java: -------------------------------------------------------------------------------- 1 | package org.cloudbus.cloudsim.sdn.graph.core; 2 | 3 | public class Coordinates { 4 | 5 | private int x; 6 | private int y; 7 | 8 | public Coordinates() { 9 | this.x = 0; 10 | this.y = 0; 11 | } 12 | public Coordinates(int x, int y) { 13 | this.x = x; 14 | this.y = y; 15 | } 16 | 17 | public int getX() { 18 | return x; 19 | } 20 | public void setX(int x) { 21 | this.x = x; 22 | } 23 | 24 | public int getY() { 25 | return y; 26 | } 27 | public void setY(int y) { 28 | this.y = y; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "Coordinates [abscissa=" + x + ", ordinate=" + y + "]"; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/graph/core/Edge.java: -------------------------------------------------------------------------------- 1 | package org.cloudbus.cloudsim.sdn.graph.core; 2 | 3 | import java.io.Serializable; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | /** 8 | * The model that represents an edge with two vertexes, for physical link and virtual edge. 9 | * 10 | */ 11 | public class Edge implements Serializable { 12 | private static final long serialVersionUID = -356975278987708987L; 13 | 14 | private Node dest = null; 15 | 16 | private double latency = 0.0; 17 | private String name = ""; 18 | private long bandwidth = 0; 19 | 20 | /** 21 | * Constructor. 22 | * 23 | * @param node the node that belongs to the edge. 24 | */ 25 | public Edge(Node to) { 26 | this.dest = to; 27 | } 28 | 29 | /** physical topology link */ 30 | public Edge(Node to, double latency) { 31 | this.dest = to; 32 | this.latency = latency; 33 | } 34 | 35 | /** virtual virtual edge */ 36 | public Edge(Node to, String name, long bw) { 37 | this.dest = to; 38 | this.name = name; 39 | this.bandwidth = bw; 40 | } 41 | 42 | /** copy edge */ 43 | public Edge(Node to, Map info){ 44 | this.dest = to; 45 | if(info.get("name")!=null){ 46 | this.name = (String) info.get("name"); 47 | } 48 | if(info.get("bandwidth")!=null){ 49 | this.bandwidth = (long) info.get("bandwidth"); 50 | } 51 | if(info.get("latency")!=null){ 52 | this.latency = (double) info.get("latency"); 53 | } 54 | } 55 | 56 | public Node getNode() { 57 | return dest; 58 | } 59 | 60 | public long getBandwidth() { 61 | return bandwidth; 62 | } 63 | 64 | public double getLatency() { 65 | return latency; 66 | } 67 | 68 | public Map getInfo() { 69 | Map info = new HashMap(); 70 | info.put("name", this.name); 71 | info.put("bandwidth",this.bandwidth); 72 | info.put("latency", this.latency); 73 | return info; 74 | } 75 | 76 | public void setInfo(Map info){ 77 | if(info.get("name")!=null){ 78 | this.name = (String) info.get("name"); 79 | } 80 | if(info.get("bandwidth")!=null){ 81 | this.bandwidth = (long) info.get("bandwidth"); 82 | } 83 | if(info.get("latency")!=null){ 84 | this.latency = (double) info.get("latency"); 85 | } 86 | } 87 | 88 | @Override 89 | public String toString() { 90 | return "Edge [dest=" + dest + "]"; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/graph/core/HostNode.java: -------------------------------------------------------------------------------- 1 | package org.cloudbus.cloudsim.sdn.graph.core; 2 | 3 | /** 4 | * The model that represents virtual machine node for the graph. 5 | * 6 | */ 7 | public class HostNode extends Node { 8 | private static final long serialVersionUID = -8635044061126993668L; 9 | 10 | private long pes; 11 | private long mips; 12 | private int ram; 13 | private long storage; 14 | private long bw; 15 | 16 | 17 | public HostNode() { 18 | } 19 | 20 | public HostNode(String name, String type, long pes, long mips, int ram, long storage, long bw) { 21 | super(name, type); 22 | this.pes = pes; 23 | this.mips = mips; 24 | this.ram = ram; 25 | this.storage = storage; 26 | this.bw = bw; 27 | } 28 | 29 | public void setPes(long pes) { 30 | this.pes = pes; 31 | } 32 | 33 | public long getPes() { 34 | return pes; 35 | } 36 | 37 | public void setMips(long mips) { 38 | this.mips = mips; 39 | } 40 | 41 | public long getMips() { 42 | return mips; 43 | } 44 | 45 | public void setRam(int ram) { 46 | this.ram = ram; 47 | } 48 | 49 | public int getRam() { 50 | return ram; 51 | } 52 | 53 | public void setStorage(long storage) { 54 | this.storage = storage; 55 | } 56 | 57 | public long getStorage() { 58 | return storage; 59 | } 60 | 61 | public void setBw(long bw) { 62 | this.bw = bw; 63 | } 64 | 65 | public long getBw() { 66 | return bw; 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return "Node [pes=" + pes + " mips=" + mips + " ram=" + ram + " storage=" + storage + " bw=" + bw + "]"; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/graph/core/Node.java: -------------------------------------------------------------------------------- 1 | package org.cloudbus.cloudsim.sdn.graph.core; 2 | 3 | import java.io.Serializable; 4 | 5 | import org.cloudbus.cloudsim.sdn.graph.core.Coordinates; 6 | 7 | /** 8 | * The model that represents node (host or vm) for the graph. 9 | * 10 | */ 11 | public class Node implements Serializable { 12 | private static final long serialVersionUID = 823544330517091616L; 13 | 14 | private Coordinates coord; 15 | private String name; 16 | private String type; 17 | 18 | public Node() { 19 | } 20 | 21 | public Node(String name, String type) { 22 | this.name = name; 23 | this.type = type; 24 | coord = new Coordinates(); 25 | } 26 | 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setType(String type) { 36 | this.type = type; 37 | } 38 | 39 | public String getType() { 40 | return type; 41 | } 42 | 43 | public void setCoordinate(Coordinates coord) { 44 | this.coord.setX(coord.getX()); 45 | this.coord.setY(coord.getY()); 46 | } 47 | 48 | public Coordinates getCoordinate() { 49 | return coord; 50 | } 51 | 52 | @Override 53 | public int hashCode() { 54 | final int prime = 31; 55 | int result = 1; 56 | result = prime * result + ((name == null) ? 0 : name.hashCode()); 57 | return result; 58 | } 59 | 60 | @Override 61 | public boolean equals(Object obj) { 62 | if (this == obj) 63 | return true; 64 | if (obj == null) 65 | return false; 66 | if (getClass() != obj.getClass()) 67 | return false; 68 | Node other = (Node) obj; 69 | if (name == null) { 70 | if (other.name != null) 71 | return false; 72 | } else if (!name.equals(other.name)) 73 | return false; 74 | return true; 75 | } 76 | 77 | @Override 78 | public String toString() { 79 | return "Node [name=" + name + " type=" + type + "]"; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/graph/core/NodeCellRenderer.java: -------------------------------------------------------------------------------- 1 | package org.cloudbus.cloudsim.sdn.graph.core; 2 | 3 | import java.awt.Component; 4 | 5 | import javax.swing.JLabel; 6 | import javax.swing.JList; 7 | import javax.swing.ListCellRenderer; 8 | 9 | /** A cell renderer for the JComboBox when displaying a node object */ 10 | @SuppressWarnings("rawtypes") 11 | public class NodeCellRenderer extends JLabel implements ListCellRenderer { 12 | private static final long serialVersionUID = 6021697923766790099L; 13 | 14 | @Override 15 | public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 16 | 17 | Node node = (Node) value; 18 | JLabel label = new JLabel(); 19 | 20 | if (node != null && node.getName() != null) { 21 | label.setText(node.getName()); 22 | } 23 | 24 | return label; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/graph/core/SwitchNode.java: -------------------------------------------------------------------------------- 1 | package org.cloudbus.cloudsim.sdn.graph.core; 2 | 3 | /** 4 | * The model that represents virtual machine node for the graph. 5 | * 6 | */ 7 | public class SwitchNode extends Node { 8 | private static final long serialVersionUID = 804858850147477656L; 9 | 10 | private long iops; 11 | private int upports; 12 | private int downports; 13 | private long bw; 14 | 15 | 16 | public SwitchNode() { 17 | } 18 | 19 | public SwitchNode(String name, String type, long iops, int upports, int downports, long bw) { 20 | super(name, type); 21 | this.iops = iops; 22 | this.upports = upports; 23 | this.downports = downports; 24 | this.bw = bw; 25 | } 26 | 27 | public void setIops(long iops) { 28 | this.iops = iops; 29 | } 30 | 31 | public long getIops() { 32 | return iops; 33 | } 34 | 35 | public void setUpports(int upports) { 36 | this.upports = upports; 37 | } 38 | 39 | public int getUpports() { 40 | return upports; 41 | } 42 | public void setDownports(int downports) { 43 | this.downports = downports; 44 | } 45 | 46 | public int getDownports() { 47 | return downports; 48 | } 49 | public void setBw(long bw) { 50 | this.bw = bw; 51 | } 52 | 53 | public long getBw() { 54 | return bw; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "Node [iops=" + iops + " upports=" + upports + " downports=" + downports + " bw=" + bw + "]"; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/graph/core/VmNode.java: -------------------------------------------------------------------------------- 1 | package org.cloudbus.cloudsim.sdn.graph.core; 2 | 3 | /** 4 | * The model that represents virtual machine node for the graph. 5 | * 6 | */ 7 | public class VmNode extends Node { 8 | private static final long serialVersionUID = 804858850147477656L; 9 | 10 | private long size; 11 | private int pes; 12 | private long mips; 13 | private int ram; 14 | 15 | 16 | public VmNode() { 17 | } 18 | 19 | public VmNode(String name, String type, long size, int pes, long mips, int ram) { 20 | super(name, type); 21 | this.size = size; 22 | this.pes = pes; 23 | this.mips = mips; 24 | this.ram = ram; 25 | } 26 | 27 | public void setSize(int size) { 28 | this.size = size; 29 | } 30 | 31 | public long getSize() { 32 | return size; 33 | } 34 | 35 | public void setPes(int pes) { 36 | this.pes = pes; 37 | } 38 | 39 | public int getPes() { 40 | return pes; 41 | } 42 | public void setMips(long mips) { 43 | this.mips = mips; 44 | } 45 | 46 | public long getMips() { 47 | return mips; 48 | } 49 | public void setRam(int ram) { 50 | this.ram = ram; 51 | } 52 | 53 | public int getRam() { 54 | return ram; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "Node [size=" + size + " pes=" + pes + " mips=" + mips + " ram=" + ram + "]"; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/graph/dialog/About.java: -------------------------------------------------------------------------------- 1 | package org.cloudbus.cloudsim.sdn.graph.dialog; 2 | 3 | import java.awt.Dimension; 4 | import java.awt.Font; 5 | import java.awt.event.ActionEvent; 6 | import java.awt.event.ActionListener; 7 | 8 | import javax.swing.Box; 9 | import javax.swing.BoxLayout; 10 | import javax.swing.ImageIcon; 11 | import javax.swing.JButton; 12 | import javax.swing.JDialog; 13 | import javax.swing.JLabel; 14 | 15 | @SuppressWarnings("serial") 16 | class About extends JDialog { 17 | 18 | public About() { 19 | initUI(); 20 | } 21 | 22 | public final void initUI() { 23 | 24 | setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); 25 | 26 | add(Box.createRigidArea(new Dimension(0, 10))); 27 | 28 | ImageIcon icon = new ImageIcon("src/logo.png"); 29 | JLabel label = new JLabel(icon); 30 | label.setAlignmentX(0.5f); 31 | add(label); 32 | 33 | add(Box.createRigidArea(new Dimension(0, 10))); 34 | 35 | JLabel name = new JLabel("CloudSim SDN, 1.00"); 36 | name.setFont(new Font("Serif", Font.BOLD, 15)); 37 | name.setAlignmentX(0.5f); 38 | add(name); 39 | 40 | add(Box.createRigidArea(new Dimension(0, 50))); 41 | 42 | JButton close = new JButton("Close"); 43 | close.addActionListener(new ActionListener() { 44 | public void actionPerformed(ActionEvent event) { 45 | dispose(); 46 | } 47 | }); 48 | 49 | close.setAlignmentX(0.5f); 50 | add(close); 51 | 52 | setModalityType(ModalityType.APPLICATION_MODAL); 53 | 54 | setTitle("About CloudSim"); 55 | setDefaultCloseOperation(DISPOSE_ON_CLOSE); 56 | setLocationRelativeTo(null); 57 | setSize(350, 300); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/graph/dialog/AddPhysicalEdge.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/org/cloudbus/cloudsim/sdn/graph/dialog/AddPhysicalEdge.java -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/graph/dialog/AddVirtualEdge.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ParallelProcessingLab/fogfaas/bb8be9074de619093f0b5e5788e50ec6ef2a8c85/src/org/cloudbus/cloudsim/sdn/graph/dialog/AddVirtualEdge.java -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/power/PowerUtilizationHistoryEntry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.sdn.power; 10 | 11 | /** 12 | * To log utilization history, this class holds power utilization information 13 | * 14 | * @author Jungmin Son 15 | * @since CloudSimSDN 1.0 16 | */ 17 | public class PowerUtilizationHistoryEntry { 18 | public double startTime; 19 | public double usedMips; 20 | public PowerUtilizationHistoryEntry(double t, double m) { startTime=t; usedMips=m;} 21 | } 22 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/power/PowerUtilizationInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.sdn.power; 10 | 11 | import java.util.List; 12 | 13 | 14 | /** 15 | * Interface to manage utilization history. 16 | * 17 | * @author Jungmin Son 18 | * @since CloudSimSDN 1.0 19 | */ 20 | public interface PowerUtilizationInterface { 21 | public void addUtilizationEntryTermination(double terminatedTime); 22 | public List getUtilizationHisotry(); 23 | public double getUtilizationEnergyConsumption(); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/sdn/power/PowerUtilizationMaxHostInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSimSDN 3 | * Description: SDN extension for CloudSim 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2015, The University of Melbourne, Australia 7 | */ 8 | package org.cloudbus.cloudsim.sdn.power; 9 | 10 | 11 | /** 12 | * Interface to manage host history. 13 | * 14 | * @author Jungmin Son 15 | * @since CloudSimSDN 1.0 16 | */ 17 | public interface PowerUtilizationMaxHostInterface { 18 | void logMaxNumHostsUsed(); 19 | int getMaxNumHostsUsed(); 20 | } 21 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/util/Check.java: -------------------------------------------------------------------------------- 1 | package org.cloudbus.cloudsim.util; 2 | 3 | public class Check { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | // Test2 t2 = new Test2(10); 8 | // Test2 t1 = new Test2(10); 9 | // Test2 t3 = new Test2(40); 10 | // 11 | // if(t1.equals(t2)){ 12 | // System.out.println("Success1"); 13 | // }if(t3==t2){ 14 | // System.out.println("Success2"); 15 | // }if(t1==t3){ 16 | // System.out.println("Success3"); 17 | // } 18 | // System.out.println("DONE"); 19 | Test t2 = new Test(10); 20 | Test t1 = new Test(10); 21 | Test t3 = new Test(40); 22 | 23 | if(t1.equals(t2)){ 24 | System.out.println("Success1"); 25 | }if(t3==t2){ 26 | System.out.println("Success2"); 27 | }if(t1==t3){ 28 | System.out.println("Success3"); 29 | } 30 | System.out.println("DONE"); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/util/ExecutionTimeMeasurer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.util; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | /** 15 | * The class for measuring the execution time. 16 | * 17 | * @author Anton Beloglazov 18 | * @since CloudSim Toolkit 3.0 19 | */ 20 | public class ExecutionTimeMeasurer { 21 | 22 | /** The execution times. */ 23 | private final static Map executionTimes = new HashMap(); 24 | 25 | /** 26 | * Start. 27 | * 28 | * @param name the name 29 | */ 30 | public static void start(String name) { 31 | getExecutionTimes().put(name, System.currentTimeMillis()); 32 | } 33 | 34 | /** 35 | * End. 36 | * 37 | * @param name the name 38 | * @return the double 39 | */ 40 | public static double end(String name) { 41 | double time = (System.currentTimeMillis() - getExecutionTimes().get(name)) / 1000.0; 42 | getExecutionTimes().remove(name); 43 | return time; 44 | } 45 | 46 | /** 47 | * Gets the execution times. 48 | * 49 | * @return the execution times 50 | */ 51 | public static Map getExecutionTimes() { 52 | return executionTimes; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/util/Test.java: -------------------------------------------------------------------------------- 1 | package org.cloudbus.cloudsim.util; 2 | 3 | public class Test { 4 | public String s1; 5 | public int i1; 6 | 7 | public Test(int i){ 8 | s1 = new String("chas"); 9 | i1=i; 10 | } 11 | 12 | public boolean equals(Test t){ 13 | if(t.s1.equals(s1) && t.i1==(i1) ) 14 | return true; 15 | return false; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/util/Test2.java: -------------------------------------------------------------------------------- 1 | package org.cloudbus.cloudsim.util; 2 | 3 | public class Test2 { 4 | public Test t; 5 | public String st; 6 | 7 | public Test2(int i){ 8 | t = new Test(i); 9 | st = new String("PP"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/org/cloudbus/cloudsim/util/WorkloadModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Title: CloudSim Toolkit 3 | * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds 4 | * Licence: GPL - http://www.gnu.org/copyleft/gpl.html 5 | * 6 | * Copyright (c) 2009-2012, The University of Melbourne, Australia 7 | */ 8 | 9 | package org.cloudbus.cloudsim.util; 10 | 11 | import java.util.List; 12 | 13 | import org.cloudbus.cloudsim.Cloudlet; 14 | 15 | /** 16 | * This interface defines what a workload model should provide. A workload model generates a list of 17 | * jobs that can be dispatched to a resource by {@link Workload}. 18 | * 19 | * @author Marcos Dias de Assuncao 20 | * @since 5.0 21 | * 22 | * @see Workload 23 | * @see WorkloadFileReader 24 | */ 25 | public interface WorkloadModel { 26 | 27 | /** 28 | * Returns a list with the jobs generated by the workload. 29 | * 30 | * @return a list with the jobs generated by the workload. 31 | */ 32 | List generateWorkload(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/org/fog/application/AppLoop.java: -------------------------------------------------------------------------------- 1 | package org.fog.application; 2 | 3 | import java.util.List; 4 | 5 | import org.fog.utils.TimeKeeper; 6 | 7 | public class AppLoop { 8 | private int loopId; 9 | private List modules; 10 | public AppLoop(List modules){ 11 | setLoopId(TimeKeeper.getInstance().getUniqueId()); 12 | setModules(modules); 13 | } 14 | 15 | public boolean hasEdge(String src, String dest){ 16 | for(int i=0;i getModules() { 56 | return modules; 57 | } 58 | public void setModules(List modules) { 59 | this.modules = modules; 60 | } 61 | 62 | public int getLoopId() { 63 | return loopId; 64 | } 65 | 66 | public void setLoopId(int loopId) { 67 | this.loopId = loopId; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/org/fog/application/selectivity/BurstySelectivity.java: -------------------------------------------------------------------------------- 1 | package org.fog.application.selectivity; 2 | 3 | import org.cloudbus.cloudsim.core.CloudSim; 4 | 5 | /** 6 | * Generates an output tuple for every input tuple according to a bursty model. 7 | * During high burst period, all input tuples result in an output tuple. 8 | * During low burst period, no input tuples result in an output tuple. 9 | * @author Harshit Gupta 10 | * 11 | */ 12 | public class BurstySelectivity implements SelectivityModel{ 13 | 14 | /** 15 | * Duration of the low burst period 16 | */ 17 | double burstLowPeriod; 18 | 19 | /** 20 | * Duration of the high burst period 21 | */ 22 | double burstHighPeriod; 23 | 24 | /** 25 | * First instance of the start of high burst period, using which subsequent burst periods will be calculated. 26 | */ 27 | double firstHighTime; 28 | 29 | public BurstySelectivity(double burstLowPeriod, double burstHighPeriod, double firstHighTime){ 30 | setBurstLowPeriod(burstLowPeriod); 31 | setBurstHighPeriod(burstHighPeriod); 32 | setFirstHighTime(firstHighTime); 33 | } 34 | 35 | /** 36 | * If the current time falls in the high burst period of the specified burst model, an output tuple is generated for the incoming tuple. 37 | */ 38 | @Override 39 | public boolean canSelect() { 40 | double time = CloudSim.clock() + getFirstHighTime(); 41 | double burstPeriod = getBurstHighPeriod()+getBurstLowPeriod(); 42 | double burstStartTime = burstPeriod*((int)(time/burstPeriod)); 43 | if(time <= burstStartTime + getBurstHighPeriod()) 44 | return true; 45 | else 46 | return false; 47 | } 48 | 49 | /** 50 | * The mean tuple generation rate is the fraction of high burst period in the total burst period. 51 | */ 52 | @Override 53 | public double getMeanRate() { 54 | return getBurstHighPeriod()/(getBurstHighPeriod()+getBurstLowPeriod()); 55 | } 56 | 57 | /** 58 | * Maximum tuple generation rate equals 1 (when the burst is high) 59 | */ 60 | @Override 61 | public double getMaxRate() { 62 | return 1; 63 | } 64 | 65 | public double getBurstLowPeriod() { 66 | return burstLowPeriod; 67 | } 68 | 69 | public void setBurstLowPeriod(double burstLowPeriod) { 70 | this.burstLowPeriod = burstLowPeriod; 71 | } 72 | 73 | public double getBurstHighPeriod() { 74 | return burstHighPeriod; 75 | } 76 | 77 | public void setBurstHighPeriod(double burstHighPeriod) { 78 | this.burstHighPeriod = burstHighPeriod; 79 | } 80 | 81 | public double getFirstHighTime() { 82 | return firstHighTime; 83 | } 84 | 85 | public void setFirstHighTime(double firstHighTime) { 86 | this.firstHighTime = firstHighTime; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /src/org/fog/application/selectivity/FractionalSelectivity.java: -------------------------------------------------------------------------------- 1 | package org.fog.application.selectivity; 2 | 3 | /** 4 | * Generates an output tuple for an incoming input tuple with a fixed probability 5 | * @author Harshit Gupta 6 | * 7 | */ 8 | public class FractionalSelectivity implements SelectivityModel{ 9 | 10 | /** 11 | * The fixed probability of output tuple creation per incoming input tuple 12 | */ 13 | double selectivity; 14 | 15 | public FractionalSelectivity(double selectivity){ 16 | setSelectivity(selectivity); 17 | } 18 | public double getSelectivity() { 19 | return selectivity; 20 | } 21 | public void setSelectivity(double selectivity) { 22 | this.selectivity = selectivity; 23 | } 24 | 25 | @Override 26 | public boolean canSelect() { 27 | if(Math.random() < getSelectivity()) // if the probability condition is satisfied 28 | return true; 29 | return false; 30 | } 31 | 32 | @Override 33 | public double getMeanRate() { 34 | return getSelectivity(); // the average rate of tuple generation is the fixed probability value 35 | } 36 | 37 | @Override 38 | public double getMaxRate() { 39 | return getSelectivity(); // the maximum rate of tuple generation is the fixed probability value 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/org/fog/application/selectivity/SelectivityModel.java: -------------------------------------------------------------------------------- 1 | package org.fog.application.selectivity; 2 | 3 | /** 4 | * Class representing the input-output relationships of application modules. 5 | * @author Harshit Gupta 6 | * 7 | */ 8 | public interface SelectivityModel { 9 | 10 | /** 11 | * Function called to check whether incoming tuple can generate an output tuple. 12 | * @return true if a tuple can be emitted (selection possible) 13 | */ 14 | public boolean canSelect(); 15 | 16 | /** 17 | * Average number of tuples generated per incoming input tuple. 18 | * @return avg tuple generation rate 19 | */ 20 | public double getMeanRate(); 21 | 22 | /** 23 | * Maximum number of tuples generated per incoming input tuple. 24 | * @return max tuple generation rate 25 | */ 26 | public double getMaxRate(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/org/fog/entities/FogBroker.java: -------------------------------------------------------------------------------- 1 | package org.fog.entities; 2 | 3 | import org.cloudbus.cloudsim.core.SimEvent; 4 | import org.cloudbus.cloudsim.power.PowerDatacenterBroker; 5 | 6 | public class FogBroker extends PowerDatacenterBroker{ 7 | 8 | public FogBroker(String name) throws Exception { 9 | super(name); 10 | // TODO Auto-generated constructor stub 11 | } 12 | 13 | @Override 14 | public void startEntity() { 15 | // TODO Auto-generated method stub 16 | 17 | } 18 | 19 | @Override 20 | public void processEvent(SimEvent ev) { 21 | // TODO Auto-generated method stub 22 | 23 | } 24 | 25 | @Override 26 | public void shutdownEntity() { 27 | // TODO Auto-generated method stub 28 | 29 | } 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/org/fog/entities/LoadBalancer.java: -------------------------------------------------------------------------------- 1 | package org.fog.entities; 2 | 3 | /** 4 | * Created by Samodha Pallewatta 5 | */ 6 | public interface LoadBalancer { 7 | int getDeviceId(String microservice, ServiceDiscovery serviceDiscoveryInfo); 8 | } 9 | -------------------------------------------------------------------------------- /src/org/fog/entities/PhysicalTopology.java: -------------------------------------------------------------------------------- 1 | package org.fog.entities; 2 | 3 | import java.util.List; 4 | 5 | public class PhysicalTopology { 6 | 7 | private List fogDevices; 8 | private List sensors; 9 | private List actuators; 10 | public List getFogDevices() { 11 | return fogDevices; 12 | } 13 | public void setFogDevices(List fogDevices) { 14 | this.fogDevices = fogDevices; 15 | } 16 | public List getSensors() { 17 | return sensors; 18 | } 19 | public void setSensors(List sensors) { 20 | this.sensors = sensors; 21 | } 22 | public List getActuators() { 23 | return actuators; 24 | } 25 | public void setActuators(List actuators) { 26 | this.actuators = actuators; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/org/fog/entities/PlacementRequest.java: -------------------------------------------------------------------------------- 1 | package org.fog.entities; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class PlacementRequest { 7 | private String applicationId; 8 | private Map placedMicroservices; // microservice name to placed device id 9 | private int placementRequestId; //sensor Id 10 | private int gatewayDeviceId; //device generating the request 11 | 12 | public PlacementRequest(String applicationId,int placementRequestId,int gatewayDeviceId,Map placedMicroservicesMap){ 13 | this.applicationId = applicationId; 14 | this.placementRequestId = placementRequestId; 15 | this.gatewayDeviceId = gatewayDeviceId; 16 | this.placedMicroservices = placedMicroservicesMap; 17 | } 18 | 19 | public PlacementRequest(String applicationId,int placementRequestId,int gatewayDeviceId){ 20 | this.applicationId = applicationId; 21 | this.placementRequestId = placementRequestId; 22 | this.gatewayDeviceId = gatewayDeviceId; 23 | this.placedMicroservices = new HashMap<>(); 24 | } 25 | 26 | public String getApplicationId(){ 27 | return applicationId; 28 | } 29 | 30 | public int getPlacementRequestId() { 31 | return placementRequestId; 32 | } 33 | 34 | public int getGatewayDeviceId() { 35 | return gatewayDeviceId; 36 | } 37 | 38 | public Map getPlacedMicroservices() { 39 | return placedMicroservices; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/org/fog/entities/RRLoadBalancer.java: -------------------------------------------------------------------------------- 1 | package org.fog.entities; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | * Created by Samodha Pallewatta 8 | * Round Robin LoadBalancer 9 | */ 10 | public class RRLoadBalancer implements LoadBalancer { 11 | protected Map loadBalancerPosition = new HashMap(); 12 | 13 | public int getDeviceId(String microservice, ServiceDiscovery serviceDiscoveryInfo) { 14 | if (loadBalancerPosition.containsKey(microservice) && serviceDiscoveryInfo.getServiceDiscoveryInfo().containsKey(microservice)) { 15 | int pos = loadBalancerPosition.get(microservice); 16 | if (pos + 1 > serviceDiscoveryInfo.getServiceDiscoveryInfo().get(microservice).size() - 1) 17 | pos = 0; 18 | else 19 | pos = pos + 1; 20 | loadBalancerPosition.put(microservice, pos); 21 | return serviceDiscoveryInfo.getServiceDiscoveryInfo().get(microservice).get(pos); 22 | } else { 23 | if(serviceDiscoveryInfo.getServiceDiscoveryInfo().containsKey(microservice)) { 24 | loadBalancerPosition.put(microservice, 0); 25 | if (serviceDiscoveryInfo.getServiceDiscoveryInfo().get(microservice) == null) 26 | System.out.println("null"); 27 | int deviceId = serviceDiscoveryInfo.getServiceDiscoveryInfo().get(microservice).get(0); 28 | return deviceId; 29 | } 30 | System.out.println("Service Discovery Information Missing"); 31 | return -1; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/ActuatorGui.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | import java.io.Serializable; 4 | 5 | public class ActuatorGui extends Node implements Serializable{ 6 | 7 | private static final long serialVersionUID = 4087896123649020073L; 8 | 9 | private String name; 10 | private String actuatorType; 11 | 12 | public ActuatorGui(String name, String actuatorType){ 13 | super(name, "ACTUATOR"); 14 | setName(name); 15 | setActuatorType(actuatorType); 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public void setName(String name) { 23 | this.name = name; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "Actuator []"; 29 | } 30 | 31 | public String getActuatorType() { 32 | return actuatorType; 33 | } 34 | 35 | public void setActuatorType(String actuatorType) { 36 | this.actuatorType = actuatorType; 37 | } 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/ActuatorModule.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | /** 4 | * The model that represents virtual machine node for the graph. 5 | * 6 | */ 7 | public class ActuatorModule extends Node { 8 | private static final long serialVersionUID = 804858850147477656L; 9 | 10 | String actuatorType; 11 | 12 | public ActuatorModule() { 13 | } 14 | 15 | public ActuatorModule(String actuatorType) { 16 | super(actuatorType, "ACTUATOR_MODULE"); 17 | setActuatorType(actuatorType); 18 | } 19 | 20 | 21 | public String getActuatorType() { 22 | return actuatorType; 23 | } 24 | 25 | public void setActuatorType(String actuatorType) { 26 | this.actuatorType = actuatorType; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "Node []"; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/AppModule.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | /** 4 | * The model that represents virtual machine node for the graph. 5 | * 6 | */ 7 | public class AppModule extends Node { 8 | private static final long serialVersionUID = 804858850147477656L; 9 | 10 | 11 | 12 | public AppModule() { 13 | } 14 | 15 | public AppModule(String name) { 16 | super(name, "APP_MODULE"); 17 | } 18 | 19 | 20 | @Override 21 | public String toString() { 22 | return "Node []"; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/Coordinates.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | public class Coordinates { 4 | 5 | private int x; 6 | private int y; 7 | 8 | public Coordinates() { 9 | this.x = 0; 10 | this.y = 0; 11 | } 12 | public Coordinates(int x, int y) { 13 | this.x = x; 14 | this.y = y; 15 | } 16 | 17 | public int getX() { 18 | return x; 19 | } 20 | public void setX(int x) { 21 | this.x = x; 22 | } 23 | 24 | public int getY() { 25 | return y; 26 | } 27 | public void setY(int y) { 28 | this.y = y; 29 | } 30 | 31 | @Override 32 | public String toString() { 33 | return "Coordinates [abscissa=" + x + ", ordinate=" + y + "]"; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/Edge.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | import java.io.Serializable; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | /** 8 | * The model that represents an edge with two vertexes, for physical link and virtual edge. 9 | * 10 | */ 11 | public class Edge implements Serializable { 12 | private static final long serialVersionUID = -356975278987708987L; 13 | 14 | private Node dest = null; 15 | 16 | private double latency = 0.0; 17 | private String name = ""; 18 | private long bandwidth = 0; 19 | 20 | /** 21 | * Constructor. 22 | * 23 | * @param node the node that belongs to the edge. 24 | */ 25 | public Edge(Node to) { 26 | this.dest = to; 27 | } 28 | 29 | /** physical topology link */ 30 | public Edge(Node to, double latency) { 31 | this.dest = to; 32 | this.latency = latency; 33 | } 34 | 35 | /** virtual virtual edge */ 36 | public Edge(Node to, String name, long bw) { 37 | this.dest = to; 38 | this.name = name; 39 | this.bandwidth = bw; 40 | } 41 | 42 | /** copy edge */ 43 | public Edge(Node to, Map info){ 44 | this.dest = to; 45 | if(info.get("name")!=null){ 46 | this.name = (String) info.get("name"); 47 | } 48 | if(info.get("bandwidth")!=null){ 49 | this.bandwidth = (long) info.get("bandwidth"); 50 | } 51 | if(info.get("latency")!=null){ 52 | this.latency = (double) info.get("latency"); 53 | } 54 | } 55 | 56 | public Node getNode() { 57 | return dest; 58 | } 59 | 60 | public long getBandwidth() { 61 | return bandwidth; 62 | } 63 | 64 | public double getLatency() { 65 | return latency; 66 | } 67 | 68 | public Map getInfo() { 69 | Map info = new HashMap(); 70 | info.put("name", this.name); 71 | info.put("bandwidth",this.bandwidth); 72 | info.put("latency", this.latency); 73 | return info; 74 | } 75 | 76 | public void setInfo(Map info){ 77 | if(info.get("name")!=null){ 78 | this.name = (String) info.get("name"); 79 | } 80 | if(info.get("bandwidth")!=null){ 81 | this.bandwidth = (long) info.get("bandwidth"); 82 | } 83 | if(info.get("latency")!=null){ 84 | this.latency = (double) info.get("latency"); 85 | } 86 | } 87 | 88 | @Override 89 | public String toString() { 90 | return "Edge [dest=" + dest + "]"; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/FogDeviceGui.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | /** 4 | * The model that represents virtual machine node for the graph. 5 | * 6 | */ 7 | public class FogDeviceGui extends Node { 8 | private static final long serialVersionUID = -8635044061126993668L; 9 | 10 | private int level; 11 | private String name; 12 | private long mips; 13 | private int ram; 14 | private long upBw; 15 | private long downBw; 16 | private double ratePerMips; 17 | 18 | public FogDeviceGui() { 19 | } 20 | 21 | public FogDeviceGui(String name, long mips, int ram, long upBw, long downBw, int level, double rate) { 22 | super(name, "FOG_DEVICE"); 23 | this.name = name; 24 | this.mips = mips; 25 | this.ram = ram; 26 | this.upBw = upBw; 27 | this.downBw = downBw; 28 | this.level = level; 29 | this.ratePerMips = rate; 30 | } 31 | 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | 41 | public long getMips() { 42 | return mips; 43 | } 44 | 45 | public void setMips(long mips) { 46 | this.mips = mips; 47 | } 48 | 49 | public int getRam() { 50 | return ram; 51 | } 52 | 53 | public void setRam(int ram) { 54 | this.ram = ram; 55 | } 56 | 57 | public long getUpBw() { 58 | return upBw; 59 | } 60 | 61 | public void setUpBw(long upBw) { 62 | this.upBw = upBw; 63 | } 64 | 65 | public long getDownBw() { 66 | return downBw; 67 | } 68 | 69 | public void setDownBw(long downBw) { 70 | this.downBw = downBw; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | return "FogDevice [mips=" + mips + " ram=" + ram + " upBw=" + upBw + " downBw=" + downBw + "]"; 76 | } 77 | 78 | public int getLevel() { 79 | return level; 80 | } 81 | 82 | public void setLevel(int level) { 83 | this.level = level; 84 | } 85 | 86 | public double getRatePerMips() { 87 | return ratePerMips; 88 | } 89 | 90 | public void setRatePerMips(double ratePerMips) { 91 | this.ratePerMips = ratePerMips; 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/HostNode.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | /** 4 | * The model that represents virtual machine node for the graph. 5 | * 6 | */ 7 | public class HostNode extends Node { 8 | private static final long serialVersionUID = -8635044061126993668L; 9 | 10 | private long pes; 11 | private long mips; 12 | private int ram; 13 | private long storage; 14 | private long bw; 15 | 16 | 17 | public HostNode() { 18 | } 19 | 20 | public HostNode(String name, String type, long pes, long mips, int ram, long storage, long bw) { 21 | super(name, type); 22 | this.pes = pes; 23 | this.mips = mips; 24 | this.ram = ram; 25 | this.storage = storage; 26 | this.bw = bw; 27 | } 28 | 29 | public void setPes(long pes) { 30 | this.pes = pes; 31 | } 32 | 33 | public long getPes() { 34 | return pes; 35 | } 36 | 37 | public void setMips(long mips) { 38 | this.mips = mips; 39 | } 40 | 41 | public long getMips() { 42 | return mips; 43 | } 44 | 45 | public void setRam(int ram) { 46 | this.ram = ram; 47 | } 48 | 49 | public int getRam() { 50 | return ram; 51 | } 52 | 53 | public void setStorage(long storage) { 54 | this.storage = storage; 55 | } 56 | 57 | public long getStorage() { 58 | return storage; 59 | } 60 | 61 | public void setBw(long bw) { 62 | this.bw = bw; 63 | } 64 | 65 | public long getBw() { 66 | return bw; 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return "Node [pes=" + pes + " mips=" + mips + " ram=" + ram + " storage=" + storage + " bw=" + bw + "]"; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/Link.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | import java.io.Serializable; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | /** 8 | * The model that represents an edge with two vertexes, for physical link and virtual edge. 9 | * 10 | */ 11 | public class Link extends Edge implements Serializable { 12 | private static final long serialVersionUID = -356975278987708987L; 13 | 14 | private Node dest = null; 15 | 16 | private double latency = 0.0; 17 | private String name = ""; 18 | private long bandwidth = 0; 19 | 20 | /** 21 | * Constructor. 22 | * 23 | * @param node the node that belongs to the edge. 24 | */ 25 | public Link(Node to) { 26 | super(to); 27 | this.dest = to; 28 | } 29 | 30 | /** physical topology link */ 31 | public Link(Node to, double latency) { 32 | super(to, latency); 33 | this.dest = to; 34 | this.latency = latency; 35 | } 36 | 37 | /** virtual virtual edge */ 38 | public Link(Node to, String name, long bw) { 39 | super(to, name, bw); 40 | this.dest = to; 41 | this.name = name; 42 | this.bandwidth = bw; 43 | } 44 | 45 | /** copy edge */ 46 | public Link(Node to, Map info){ 47 | super(to, info); 48 | this.dest = to; 49 | if(info.get("name")!=null){ 50 | this.name = (String) info.get("name"); 51 | } 52 | if(info.get("bandwidth")!=null){ 53 | this.bandwidth = (long) info.get("bandwidth"); 54 | } 55 | if(info.get("latency")!=null){ 56 | this.latency = (double) info.get("latency"); 57 | } 58 | } 59 | 60 | public Node getNode() { 61 | return dest; 62 | } 63 | 64 | public long getBandwidth() { 65 | return bandwidth; 66 | } 67 | 68 | public double getLatency() { 69 | return latency; 70 | } 71 | 72 | public Map getInfo() { 73 | Map info = new HashMap(); 74 | info.put("name", this.name); 75 | info.put("bandwidth",this.bandwidth); 76 | info.put("latency", this.latency); 77 | return info; 78 | } 79 | 80 | public void setInfo(Map info){ 81 | if(info.get("name")!=null){ 82 | this.name = (String) info.get("name"); 83 | } 84 | if(info.get("bandwidth")!=null){ 85 | this.bandwidth = (long) info.get("bandwidth"); 86 | } 87 | if(info.get("latency")!=null){ 88 | this.latency = (double) info.get("latency"); 89 | } 90 | } 91 | 92 | @Override 93 | public String toString() { 94 | return "Edge [dest=" + dest + "]"; 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/Node.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | import java.io.Serializable; 4 | 5 | 6 | /** 7 | * The model that represents node (host or vm) for the graph. 8 | * 9 | */ 10 | public class Node implements Serializable { 11 | private static final long serialVersionUID = 823544330517091616L; 12 | 13 | private Coordinates coord; 14 | private String name; 15 | private String type; 16 | private boolean isPlaced; 17 | 18 | public Node() { 19 | setPlaced(false); 20 | } 21 | 22 | public Node(String name, String type) { 23 | this.name = name; 24 | this.type = type; 25 | setPlaced(false); 26 | coord = new Coordinates(); 27 | } 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setType(String type) { 38 | this.type = type; 39 | } 40 | 41 | public String getType() { 42 | return type; 43 | } 44 | 45 | public void setCoordinate(Coordinates coord) { 46 | this.coord.setX(coord.getX()); 47 | this.coord.setY(coord.getY()); 48 | } 49 | 50 | public Coordinates getCoordinate() { 51 | return coord; 52 | } 53 | 54 | @Override 55 | public int hashCode() { 56 | final int prime = 31; 57 | int result = 1; 58 | result = prime * result + ((name == null) ? 0 : name.hashCode()); 59 | return result; 60 | } 61 | 62 | @Override 63 | public boolean equals(Object obj) { 64 | if (this == obj) 65 | return true; 66 | if (obj == null) 67 | return false; 68 | if (getClass() != obj.getClass()) 69 | return false; 70 | Node other = (Node) obj; 71 | if (name == null) { 72 | if (other.name != null) 73 | return false; 74 | } else if (!name.equals(other.name)) 75 | return false; 76 | return true; 77 | } 78 | 79 | @Override 80 | public String toString() { 81 | return "Node [name=" + name + " type=" + type + "]"; 82 | } 83 | 84 | public boolean isPlaced() { 85 | return isPlaced; 86 | } 87 | 88 | public void setPlaced(boolean isPlaced) { 89 | this.isPlaced = isPlaced; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/NodeCellRenderer.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | import java.awt.Component; 4 | 5 | import javax.swing.JLabel; 6 | import javax.swing.JList; 7 | import javax.swing.ListCellRenderer; 8 | 9 | /** A cell renderer for the JComboBox when displaying a node object */ 10 | @SuppressWarnings("rawtypes") 11 | public class NodeCellRenderer extends JLabel implements ListCellRenderer { 12 | private static final long serialVersionUID = 6021697923766790099L; 13 | 14 | @Override 15 | public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 16 | 17 | Node node = (Node) value; 18 | JLabel label = new JLabel(); 19 | 20 | if (node != null && node.getName() != null) { 21 | label.setText(node.getName()); 22 | } 23 | 24 | return label; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/PlaceHolder.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | public class PlaceHolder { 4 | 5 | protected Coordinates coordinates; 6 | protected boolean isOccupied; 7 | protected Node node; 8 | 9 | public Node getNode() { 10 | return node; 11 | } 12 | 13 | public void setNode(Node node) { 14 | this.node = node; 15 | } 16 | 17 | public boolean isOccupied() { 18 | return isOccupied; 19 | } 20 | 21 | public void setOccupied(boolean isOccupied) { 22 | this.isOccupied = isOccupied; 23 | } 24 | 25 | public PlaceHolder(Coordinates coordinates){ 26 | setCoordinates(coordinates); 27 | setOccupied(false); 28 | } 29 | 30 | public PlaceHolder(){ 31 | setCoordinates(new Coordinates()); 32 | setOccupied(false); 33 | } 34 | 35 | public PlaceHolder(int x, int y){ 36 | setCoordinates(new Coordinates(x, y)); 37 | setOccupied(false); 38 | } 39 | 40 | public Coordinates getCoordinates() { 41 | return coordinates; 42 | } 43 | 44 | public void setCoordinates(Coordinates coordinates) { 45 | this.coordinates = coordinates; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/SensorGui.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | import java.io.Serializable; 4 | 5 | import org.fog.utils.distribution.DeterministicDistribution; 6 | import org.fog.utils.distribution.Distribution; 7 | import org.fog.utils.distribution.NormalDistribution; 8 | import org.fog.utils.distribution.UniformDistribution; 9 | 10 | public class SensorGui extends Node implements Serializable{ 11 | 12 | private static final long serialVersionUID = 4087896123649020073L; 13 | 14 | private String name; 15 | private String sensorType; 16 | 17 | private Distribution distribution; 18 | 19 | public SensorGui(String name, String type, Distribution distribution){ 20 | super(name, "SENSOR"); 21 | setName(name); 22 | setSensorType(type); 23 | setDistribution(distribution); 24 | } 25 | 26 | public SensorGui(String name, String sensorType, String selectedItem, double normalMean_, 27 | double normalStdDev_, double uniformLow_, double uniformUp_, 28 | double deterministicVal_) { 29 | super(name, "SENSOR"); 30 | setName(name); 31 | setSensorType(sensorType); 32 | if(normalMean_ != -1){ 33 | setDistribution(new NormalDistribution(normalMean_, normalStdDev_)); 34 | }else if(uniformLow_ != -1){ 35 | setDistribution(new UniformDistribution(uniformLow_, uniformUp_)); 36 | }else if(deterministicVal_ != -1){ 37 | setDistribution(new DeterministicDistribution(deterministicVal_)); 38 | } 39 | } 40 | 41 | public int getDistributionType(){ 42 | return distribution.getDistributionType(); 43 | } 44 | 45 | public String getName() { 46 | return name; 47 | } 48 | 49 | public void setName(String name) { 50 | this.name = name; 51 | } 52 | 53 | public Distribution getDistribution() { 54 | return distribution; 55 | } 56 | 57 | public void setDistribution(Distribution distribution) { 58 | this.distribution = distribution; 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | 64 | if(distribution instanceof NormalDistribution) 65 | return "Sensor [dist=1 mean=" + ((NormalDistribution)distribution).getMean() + " stdDev=" + ((NormalDistribution)distribution).getStdDev() + "]"; 66 | else if(distribution instanceof UniformDistribution) 67 | return "Sensor [dist=2 min=" + ((UniformDistribution)distribution).getMin() + " max=" + ((UniformDistribution)distribution).getMax() + "]"; 68 | else if(distribution instanceof DeterministicDistribution) 69 | return "Sensor [dist=3 value=" + ((DeterministicDistribution)distribution).getValue() + "]"; 70 | else 71 | return ""; 72 | } 73 | 74 | public String getSensorType() { 75 | return sensorType; 76 | } 77 | 78 | public void setSensorType(String sensorType) { 79 | this.sensorType = sensorType; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/SensorModule.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | /** 4 | * The model that represents virtual machine node for the graph. 5 | * 6 | */ 7 | public class SensorModule extends Node { 8 | private static final long serialVersionUID = 804858850147477656L; 9 | 10 | String sensorType; 11 | 12 | public SensorModule() { 13 | } 14 | 15 | public SensorModule(String sensorType) { 16 | super(sensorType, "SENSOR_MODULE"); 17 | setSensorType(sensorType); 18 | } 19 | 20 | 21 | public String getSensorType() { 22 | return sensorType; 23 | } 24 | 25 | public void setSensorType(String sensorType) { 26 | this.sensorType = sensorType; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return "Node []"; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/SwitchNode.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | /** 4 | * The model that represents virtual machine node for the graph. 5 | * 6 | */ 7 | public class SwitchNode extends Node { 8 | private static final long serialVersionUID = 804858850147477656L; 9 | 10 | private long iops; 11 | private int upports; 12 | private int downports; 13 | private long bw; 14 | 15 | 16 | public SwitchNode() { 17 | } 18 | 19 | public SwitchNode(String name, String type, long iops, int upports, int downports, long bw) { 20 | super(name, type); 21 | this.iops = iops; 22 | this.upports = upports; 23 | this.downports = downports; 24 | this.bw = bw; 25 | } 26 | 27 | public void setIops(long iops) { 28 | this.iops = iops; 29 | } 30 | 31 | public long getIops() { 32 | return iops; 33 | } 34 | 35 | public void setUpports(int upports) { 36 | this.upports = upports; 37 | } 38 | 39 | public int getUpports() { 40 | return upports; 41 | } 42 | public void setDownports(int downports) { 43 | this.downports = downports; 44 | } 45 | 46 | public int getDownports() { 47 | return downports; 48 | } 49 | public void setBw(long bw) { 50 | this.bw = bw; 51 | } 52 | 53 | public long getBw() { 54 | return bw; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "Node [iops=" + iops + " upports=" + upports + " downports=" + downports + " bw=" + bw + "]"; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/org/fog/gui/core/VmNode.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.core; 2 | 3 | /** 4 | * The model that represents virtual machine node for the graph. 5 | * 6 | */ 7 | public class VmNode extends Node { 8 | private static final long serialVersionUID = 804858850147477656L; 9 | 10 | private long size; 11 | private int pes; 12 | private long mips; 13 | private int ram; 14 | 15 | 16 | public VmNode() { 17 | } 18 | 19 | public VmNode(String name, String type, long size, int pes, long mips, int ram) { 20 | super(name, type); 21 | this.size = size; 22 | this.pes = pes; 23 | this.mips = mips; 24 | this.ram = ram; 25 | } 26 | 27 | public void setSize(int size) { 28 | this.size = size; 29 | } 30 | 31 | public long getSize() { 32 | return size; 33 | } 34 | 35 | public void setPes(int pes) { 36 | this.pes = pes; 37 | } 38 | 39 | public int getPes() { 40 | return pes; 41 | } 42 | public void setMips(long mips) { 43 | this.mips = mips; 44 | } 45 | 46 | public long getMips() { 47 | return mips; 48 | } 49 | public void setRam(int ram) { 50 | this.ram = ram; 51 | } 52 | 53 | public int getRam() { 54 | return ram; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "Node [size=" + size + " pes=" + pes + " mips=" + mips + " ram=" + ram + "]"; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/org/fog/gui/dialog/About.java: -------------------------------------------------------------------------------- 1 | package org.fog.gui.dialog; 2 | 3 | import java.awt.Dimension; 4 | import java.awt.Font; 5 | import java.awt.event.ActionEvent; 6 | import java.awt.event.ActionListener; 7 | 8 | import javax.swing.Box; 9 | import javax.swing.BoxLayout; 10 | import javax.swing.ImageIcon; 11 | import javax.swing.JButton; 12 | import javax.swing.JDialog; 13 | import javax.swing.JLabel; 14 | 15 | @SuppressWarnings("serial") 16 | class About extends JDialog { 17 | 18 | public About() { 19 | initUI(); 20 | } 21 | 22 | public final void initUI() { 23 | 24 | setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); 25 | 26 | add(Box.createRigidArea(new Dimension(0, 10))); 27 | 28 | ImageIcon icon = new ImageIcon("src/logo.png"); 29 | JLabel label = new JLabel(icon); 30 | label.setAlignmentX(0.5f); 31 | add(label); 32 | 33 | add(Box.createRigidArea(new Dimension(0, 10))); 34 | 35 | JLabel name = new JLabel("CloudSim SDN, 1.00"); 36 | name.setFont(new Font("Serif", Font.BOLD, 15)); 37 | name.setAlignmentX(0.5f); 38 | add(name); 39 | 40 | add(Box.createRigidArea(new Dimension(0, 50))); 41 | 42 | JButton close = new JButton("Close"); 43 | close.addActionListener(new ActionListener() { 44 | public void actionPerformed(ActionEvent event) { 45 | dispose(); 46 | } 47 | }); 48 | 49 | close.setAlignmentX(0.5f); 50 | add(close); 51 | 52 | setModalityType(ModalityType.APPLICATION_MODAL); 53 | 54 | setTitle("About CloudSim"); 55 | setDefaultCloseOperation(DISPOSE_ON_CLOSE); 56 | setLocationRelativeTo(null); 57 | setSize(350, 300); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/org/fog/mobilitydata/Location.java: -------------------------------------------------------------------------------- 1 | package org.fog.mobilitydata; 2 | 3 | 4 | public class Location { 5 | 6 | public double latitude; 7 | public double longitude; 8 | public int block; 9 | 10 | public Location(double latitude, double longitude, int block) { 11 | // TODO Auto-generated constructor stub 12 | this.latitude = latitude; 13 | this.longitude = longitude; 14 | this.block = block; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/org/fog/mobilitydata/References.java: -------------------------------------------------------------------------------- 1 | package org.fog.mobilitydata; 2 | 3 | public class References { 4 | 5 | public static final int NOT_SET = -1; 6 | public static final double SETUP_TIME = -1.00; 7 | public static final double INIT_TIME = 0.00; 8 | 9 | public static final int DIRECTIONAL_MOBILITY = 1; 10 | public static final int RANDOM_MOBILITY = 2; 11 | 12 | // Reference geographical information to create random mobility pattern for mobile users 13 | public static final double lat_reference = -37.81349283433532; 14 | public static final double long_reference = 144.952370512958; 15 | 16 | // Reference dataset filename to store and retrieve users positions 17 | // ".\\dataset\\usersLocation-melbCBD_" 18 | // ".\\dataset\\usersLocation-melbCBD-random_ 19 | public static final String dataset_reference = ".\\dataset\\usersLocation-melbCBD_"; 20 | public static final String dataset_random = ".\\dataset\\random_usersLocation-melbCBD_"; 21 | public static final int random_walk_mobility_model = 1; 22 | public static final int random_waypoint_mobility_model = 2; 23 | public static double MinMobilitySpeed = 1; // 24 | public static double MaxMobilitySpeed = 2; // 25 | public static double environmentLimit = 6371; // shows the maximum latitude and longitude of the environment. Currently it is set based on radius of the Earth (6371 KM) 26 | } 27 | -------------------------------------------------------------------------------- /src/org/fog/placement/MicroservicePlacementLogic.java: -------------------------------------------------------------------------------- 1 | package org.fog.placement; 2 | 3 | import org.fog.application.Application; 4 | import org.fog.entities.FogDevice; 5 | import org.fog.entities.PlacementRequest; 6 | 7 | import java.util.List; 8 | import java.util.Map; 9 | 10 | /** 11 | * Created by Samodha Pallewatta 12 | */ 13 | public interface MicroservicePlacementLogic { 14 | PlacementLogicOutput run(List fogDevices, Map applicationInfo, Map> resourceAvailability, List pr); 15 | void updateResources(Map> resourceAvailability); 16 | void postProcessing(); 17 | } 18 | -------------------------------------------------------------------------------- /src/org/fog/placement/ModuleMapping.java: -------------------------------------------------------------------------------- 1 | package org.fog.placement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | public class ModuleMapping { 9 | /** 10 | * Mapping from node name to list of of instances to be launched on node 11 | */ 12 | protected Map> moduleMapping; 13 | 14 | public static ModuleMapping createModuleMapping(){ 15 | return new ModuleMapping(); 16 | } 17 | 18 | public Map> getModuleMapping() { 19 | return moduleMapping; 20 | } 21 | 22 | public void setModuleMapping(Map> moduleMapping) { 23 | this.moduleMapping = moduleMapping; 24 | } 25 | 26 | protected ModuleMapping(){ 27 | setModuleMapping(new HashMap>()); 28 | } 29 | 30 | /** 31 | * Add instanceCount number of instances of module moduleName to device deviceName 32 | * @param moduleName 33 | * @param deviceName 34 | * @param instanceCount 35 | */ 36 | public void addModuleToDevice(String moduleName, String deviceName){ 37 | if(!getModuleMapping().containsKey(deviceName)) 38 | getModuleMapping().put(deviceName, new ArrayList()); 39 | if(!getModuleMapping().get(deviceName).contains(moduleName)) 40 | getModuleMapping().get(deviceName).add(moduleName); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/org/fog/placement/ModulePlacementMapping.java: -------------------------------------------------------------------------------- 1 | package org.fog.placement; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import org.fog.application.AppModule; 8 | import org.fog.application.Application; 9 | import org.fog.entities.FogDevice; 10 | 11 | public class ModulePlacementMapping extends ModulePlacement{ 12 | 13 | private ModuleMapping moduleMapping; 14 | 15 | @Override 16 | protected void mapModules() { 17 | Map> mapping = moduleMapping.getModuleMapping(); 18 | for(String deviceName : mapping.keySet()){ 19 | FogDevice device = getDeviceByName(deviceName); 20 | for(String moduleName : mapping.get(deviceName)){ 21 | 22 | AppModule module = getApplication().getModuleByName(moduleName); 23 | if(module == null) 24 | continue; 25 | createModuleInstanceOnDevice(module, device); 26 | //getModuleInstanceCountMap().get(device.getId()).put(moduleName, mapping.get(deviceName).get(moduleName)); 27 | } 28 | } 29 | } 30 | 31 | public ModulePlacementMapping(List fogDevices, Application application, 32 | ModuleMapping moduleMapping){ 33 | this.setFogDevices(fogDevices); 34 | this.setApplication(application); 35 | this.setModuleMapping(moduleMapping); 36 | this.setModuleToDeviceMap(new HashMap>()); 37 | this.setDeviceToModuleMap(new HashMap>()); 38 | this.setModuleInstanceCountMap(new HashMap>()); 39 | for(FogDevice device : getFogDevices()) 40 | getModuleInstanceCountMap().put(device.getId(), new HashMap()); 41 | mapModules(); 42 | } 43 | 44 | 45 | public ModuleMapping getModuleMapping() { 46 | return moduleMapping; 47 | } 48 | public void setModuleMapping(ModuleMapping moduleMapping) { 49 | this.moduleMapping = moduleMapping; 50 | } 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/org/fog/placement/PlacementLogicFactory.java: -------------------------------------------------------------------------------- 1 | package org.fog.placement; 2 | 3 | import org.fog.utils.Logger; 4 | 5 | /** 6 | * Created by Samodha Pallewatta. 7 | */ 8 | public class PlacementLogicFactory { 9 | 10 | public static final int EDGEWART_MICROSERCVICES_PLACEMENT = 1; 11 | public static final int CLUSTERED_MICROSERVICES_PLACEMENT = 2; 12 | public static final int DISTRIBUTED_MICROSERVICES_PLACEMENT =3; 13 | 14 | public MicroservicePlacementLogic getPlacementLogic(int logic, int fonId) { 15 | switch (logic) { 16 | // case EDGEWART_MICROSERCVICES_PLACEMENT: 17 | // return new EdgewardMicroservicePlacementLogic(fonId); 18 | case CLUSTERED_MICROSERVICES_PLACEMENT: 19 | return new ClusteredMicroservicePlacementLogic(fonId); 20 | case DISTRIBUTED_MICROSERVICES_PLACEMENT: 21 | return new DistributedMicroservicePlacementLogic(fonId); 22 | } 23 | 24 | Logger.error("Placement Logic Error", "Error initializing placement logic"); 25 | return null; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/org/fog/placement/PlacementLogicOutput.java: -------------------------------------------------------------------------------- 1 | package org.fog.placement; 2 | 3 | import org.apache.commons.math3.util.Pair; 4 | import org.fog.application.Application; 5 | import org.fog.entities.PlacementRequest; 6 | import org.fog.utils.ModuleLaunchConfig; 7 | 8 | import java.util.HashMap; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | /** 13 | * Created by Samodha Pallewatta on 9/12/2020. 14 | */ 15 | public class PlacementLogicOutput { 16 | 17 | // module placement info 18 | //todo it assumed that modules are not shared among applications. 19 | // this is to remove deploying same module more than once on a certain device. 20 | Map>> perDevice = new HashMap<>(); 21 | 22 | Map>> serviceDiscoveryInfo = new HashMap<>(); 23 | 24 | //Integer indicates next device to send the placement request (-1 for finished, or device id for others ) 25 | Map prStatus = new HashMap<>(); 26 | 27 | public PlacementLogicOutput(Map>> perDevice, Map>> serviceDiscoveryInfo, Map prStatus) { 28 | this.perDevice = perDevice; 29 | this.serviceDiscoveryInfo = serviceDiscoveryInfo; 30 | this.prStatus = prStatus; 31 | } 32 | 33 | public Map>> getServiceDiscoveryInfo() { 34 | return serviceDiscoveryInfo; 35 | } 36 | 37 | public Map>> getPerDevice() { 38 | return perDevice; 39 | } 40 | 41 | public Map getPrStatus() { 42 | return prStatus; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/org/fog/policy/AppModuleAllocationPolicy.java: -------------------------------------------------------------------------------- 1 | package org.fog.policy; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import org.cloudbus.cloudsim.Host; 8 | import org.cloudbus.cloudsim.Vm; 9 | import org.cloudbus.cloudsim.VmAllocationPolicy; 10 | import org.fog.application.AppModule; 11 | 12 | public class AppModuleAllocationPolicy extends VmAllocationPolicy{ 13 | 14 | private Host fogHost; 15 | 16 | private List appModuleIds; 17 | 18 | public AppModuleAllocationPolicy(List list) { 19 | super(list); 20 | if(list.size()==1) 21 | fogHost = list.get(0); 22 | appModuleIds = new ArrayList(); 23 | } 24 | 25 | @Override 26 | public boolean allocateHostForVm(Vm vm) { 27 | Host host = fogHost; 28 | boolean result = host.vmCreate(vm); 29 | if (result) { // if vm were succesfully created in the host 30 | getAppModuleIdsIds().add(vm.getId()); 31 | } 32 | 33 | return result; 34 | } 35 | 36 | @Override 37 | public boolean allocateHostForVm(Vm vm, Host host) { 38 | boolean result = host.vmCreate(vm); 39 | if (result) { // if vm were succesfully created in the host 40 | getAppModuleIdsIds().add(vm.getId()); 41 | } 42 | 43 | return result; 44 | } 45 | 46 | @Override 47 | public List> optimizeAllocation( 48 | List vmList) { 49 | // TODO Auto-generated method stub 50 | return null; 51 | } 52 | 53 | @Override 54 | public void deallocateHostForVm(Vm vm) { 55 | if (fogHost != null) { 56 | fogHost.vmDestroy(vm); 57 | } 58 | } 59 | 60 | @Override 61 | public Host getHost(Vm vm) { 62 | return fogHost; 63 | } 64 | 65 | @Override 66 | public Host getHost(int vmId, int userId) { 67 | return fogHost; 68 | } 69 | 70 | public Host getFogHost() { 71 | return fogHost; 72 | } 73 | 74 | public void setFogHost(Host fogHost) { 75 | this.fogHost = fogHost; 76 | } 77 | 78 | public List getAppModuleIdsIds() { 79 | return appModuleIds; 80 | } 81 | 82 | public void setAppModuleIds(List appModuleIds) { 83 | this.appModuleIds = appModuleIds; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/org/fog/scheduler/StreamOperatorScheduler.java: -------------------------------------------------------------------------------- 1 | package org.fog.scheduler; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import org.cloudbus.cloudsim.Pe; 7 | import org.cloudbus.cloudsim.VmSchedulerTimeShared; 8 | import org.cloudbus.cloudsim.VmSchedulerTimeSharedOverSubscription; 9 | import org.cloudbus.cloudsim.sdn.overbooking.VmSchedulerTimeSharedOverbookingEnergy; 10 | 11 | public class StreamOperatorScheduler extends VmSchedulerTimeSharedOverbookingEnergy{ 12 | 13 | public StreamOperatorScheduler(List pelist) { 14 | super(pelist); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/org/fog/scheduler/TupleScheduler.java: -------------------------------------------------------------------------------- 1 | package org.fog.scheduler; 2 | 3 | import org.cloudbus.cloudsim.CloudletSchedulerTimeShared; 4 | import org.cloudbus.cloudsim.ResCloudlet; 5 | 6 | public class TupleScheduler extends CloudletSchedulerTimeShared{ 7 | 8 | public TupleScheduler(double mips, int numberOfPes) { 9 | //super(mips, numberOfPes); 10 | super(); 11 | } 12 | 13 | /** 14 | * Get estimated cloudlet completion time. 15 | * 16 | * @param rcl the rcl 17 | * @param time the time 18 | * @return the estimated finish time 19 | */ 20 | public double getEstimatedFinishTime(ResCloudlet rcl, double time) { 21 | //System.out.println("REMAINING CLOUDLET LENGTH : "+rcl.getRemainingCloudletLength()+"\tCLOUDLET LENGTH"+rcl.getCloudletLength()); 22 | //System.out.println("CURRENT ALLOC MIPS FOR CLOUDLET : "+getTotalCurrentAllocatedMipsForCloudlet(rcl, time)); 23 | 24 | /*>>>>>>>>>>>>>>>>>>>>*/ 25 | /* edit made by HARSHIT GUPTA */ 26 | 27 | System.out.println("ALLOCATED MIPS FOR CLOUDLET = "+getTotalCurrentAllocatedMipsForCloudlet(rcl, time)); 28 | return time 29 | + ((rcl.getRemainingCloudletLength()) / getTotalCurrentAllocatedMipsForCloudlet(rcl, time)); 30 | 31 | 32 | 33 | //return ((rcl.getRemainingCloudletLength()) / getTotalCurrentAllocatedMipsForCloudlet(rcl, time)); 34 | /*end of edit*/ 35 | /*<<<<<<<<<<<<<<<<<<<<<*/ 36 | } 37 | 38 | // public void cloudletFinish(ResCloudlet rcl) { 39 | // rcl.setCloudletStatus(Cloudlet.SUCCESS); 40 | // rcl.finalizeCloudlet(); 41 | // getCloudletFinishedList().add(rcl); 42 | // } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/org/fog/serverless/application/FogFaaSAppLoop.java: -------------------------------------------------------------------------------- 1 | package org.fog.serverless.application; 2 | 3 | import java.util.List; 4 | 5 | import org.fog.serverless.utils.FogFaaSTimeKeeper; 6 | 7 | public class FogFaaSAppLoop { 8 | private int loopId; 9 | private List modules; 10 | public FogFaaSAppLoop(List modules){ 11 | setLoopId(FogFaaSTimeKeeper.getInstance().getUniqueId()); 12 | setModules(modules); 13 | } 14 | 15 | public boolean hasEdge(String src, String dest){ 16 | for(int i=0;i getModules() { 56 | return modules; 57 | } 58 | public void setModules(List modules) { 59 | this.modules = modules; 60 | } 61 | 62 | public int getLoopId() { 63 | return loopId; 64 | } 65 | 66 | public void setLoopId(int loopId) { 67 | this.loopId = loopId; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/org/fog/serverless/entities/FogFaaSBroker.java: -------------------------------------------------------------------------------- 1 | package org.fog.serverless.entities; 2 | 3 | import org.fog.entities.FogBroker; 4 | 5 | public class FogFaaSBroker extends FogBroker{ 6 | 7 | public FogFaaSBroker(String name) throws Exception { 8 | super(name); 9 | // TODO Auto-generated constructor stub 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/org/fog/serverless/faas/FogFaaSFunction.java: -------------------------------------------------------------------------------- 1 | package org.fog.serverless.faas; 2 | /** 3 | * Function Class for FoGFaaS extension. 4 | * 5 | * @author Ghaseminya 6 | * Created on 12/16/2024 7 | */ 8 | public class FogFaaSFunction { 9 | private String functionId; 10 | private double cpuRequired; 11 | private double memoryRequired; 12 | private double executionTime; 13 | 14 | public FogFaaSFunction(String functionId, double cpuRequired, double memoryRequired, double executionTime) { 15 | this.functionId = functionId; 16 | this.cpuRequired = cpuRequired; 17 | this.memoryRequired = memoryRequired; 18 | this.executionTime = executionTime; 19 | System.out.println("Created function: " + functionId); 20 | System.out.println(" CPU Required: " + cpuRequired); 21 | System.out.println(" RAM Required: " + memoryRequired); 22 | } 23 | 24 | public String getFunctionId() { 25 | return functionId; 26 | } 27 | 28 | public double getCpuRequired() { 29 | return cpuRequired; 30 | } 31 | 32 | public double getMemoryRequired() { 33 | return memoryRequired; 34 | } 35 | 36 | public double getExecutionTime() { 37 | return executionTime; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/org/fog/serverless/faas/FogFaaSUtilizationModelPartial.java: -------------------------------------------------------------------------------- 1 | package org.fog.serverless.faas; 2 | 3 | import org.cloudbus.cloudsim.UtilizationModel; 4 | /** 5 | * Utilization Model Partial Class for FoGFaaS extension. 6 | * 7 | * @author Ghaseminya 8 | * Created on 12/16/2024 9 | */ 10 | public class FogFaaSUtilizationModelPartial implements UtilizationModel { 11 | @Override 12 | public double getUtilization(double time) { 13 | return 0; 14 | } 15 | 16 | public double getCpuUtilization(FogFaaSRequest request) { 17 | return request.getCpuShareRequest(); 18 | } 19 | public double getMemUtilization(FogFaaSRequest request) { 20 | return request.getMemShareRequest(); 21 | } 22 | 23 | 24 | } -------------------------------------------------------------------------------- /src/org/fog/serverless/placement/FogFaaSContainerRamProvisioner.java: -------------------------------------------------------------------------------- 1 | package org.fog.serverless.placement; 2 | 3 | import org.cloudbus.cloudsim.container.containerProvisioners.ContainerRamProvisionerSimple; 4 | import org.cloudbus.cloudsim.container.core.Container; 5 | 6 | public class FogFaaSContainerRamProvisioner extends ContainerRamProvisionerSimple { 7 | public FogFaaSContainerRamProvisioner(float availableRam) { 8 | super(availableRam); 9 | 10 | } 11 | 12 | @Override 13 | public boolean allocateRamForContainer(Container container, 14 | float ram) { 15 | float oldRam = container.getCurrentAllocatedRam(); 16 | deallocateRamForContainer(container); 17 | 18 | if (getAvailableVmRam() >= ram) { 19 | System.out.println("New available ram: "+(getAvailableVmRam() - ram)); 20 | setAvailableVmRam(getAvailableVmRam() - ram); 21 | getContainerRamTable().put(container.getUid(), ram); 22 | container.setCurrentAllocatedRam(ram); 23 | return true; 24 | } 25 | 26 | 27 | 28 | container.setCurrentAllocatedRam(oldRam); 29 | 30 | return false; 31 | } 32 | 33 | 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/org/fog/serverless/placement/FogFaaSModuleMapping.java: -------------------------------------------------------------------------------- 1 | package org.fog.serverless.placement; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | public class FogFaaSModuleMapping { 9 | /** 10 | * Mapping from node name to list of of instances to be launched on node 11 | */ 12 | protected Map> moduleMapping; 13 | 14 | public static FogFaaSModuleMapping createModuleMapping(){ 15 | return new FogFaaSModuleMapping(); 16 | } 17 | 18 | public Map> getModuleMapping() { 19 | return moduleMapping; 20 | } 21 | 22 | public void setModuleMapping(Map> moduleMapping) { 23 | this.moduleMapping = moduleMapping; 24 | } 25 | 26 | protected FogFaaSModuleMapping(){ 27 | setModuleMapping(new HashMap>()); 28 | } 29 | 30 | /** 31 | * Add instanceCount number of instances of module moduleName to device deviceName 32 | * @param moduleName 33 | * @param deviceName 34 | * @param instanceCount 35 | */ 36 | public void addModuleToDevice(String moduleName, String deviceName){ 37 | if(!getModuleMapping().containsKey(deviceName)) 38 | getModuleMapping().put(deviceName, new ArrayList()); 39 | if(!getModuleMapping().get(deviceName).contains(moduleName)) 40 | getModuleMapping().get(deviceName).add(moduleName); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/org/fog/serverless/placement/FogFaaSModulePlacementMapping.java: -------------------------------------------------------------------------------- 1 | package org.fog.serverless.placement; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import org.fog.serverless.application.FogFaaSAppModule; 8 | import org.fog.serverless.application.FogFaaSApplication; 9 | import org.fog.serverless.entities.FogFaaSDevice; 10 | 11 | public class FogFaaSModulePlacementMapping extends FogFaaSModulePlacement{ 12 | 13 | private FogFaaSModuleMapping moduleMapping; 14 | 15 | @Override 16 | protected void mapModules() { 17 | Map> mapping = moduleMapping.getModuleMapping(); 18 | for(String deviceName : mapping.keySet()){ 19 | FogFaaSDevice device = getDeviceByName(deviceName); 20 | for(String moduleName : mapping.get(deviceName)){ 21 | 22 | FogFaaSAppModule module = getApplication().getModuleByName(moduleName); 23 | if(module == null) 24 | continue; 25 | createModuleInstanceOnDevice(module, device); 26 | //getModuleInstanceCountMap().get(device.getId()).put(moduleName, mapping.get(deviceName).get(moduleName)); 27 | } 28 | } 29 | } 30 | 31 | public FogFaaSModulePlacementMapping(List fogDevices, FogFaaSApplication application, 32 | FogFaaSModuleMapping moduleMapping){ 33 | this.setFogDevices(fogDevices); 34 | this.setApplication(application); 35 | this.setModuleMapping(moduleMapping); 36 | this.setModuleToDeviceMap(new HashMap>()); 37 | this.setDeviceToModuleMap(new HashMap>()); 38 | this.setModuleInstanceCountMap(new HashMap>()); 39 | for(FogFaaSDevice device : getFogDevices()) 40 | getModuleInstanceCountMap().put(device.getId(), new HashMap()); 41 | mapModules(); 42 | } 43 | 44 | 45 | public FogFaaSModuleMapping getModuleMapping() { 46 | return moduleMapping; 47 | } 48 | public void setModuleMapping(FogFaaSModuleMapping moduleMapping) { 49 | this.moduleMapping = moduleMapping; 50 | } 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/org/fog/serverless/scheduler/FogFaaSFunctionScheduler.java: -------------------------------------------------------------------------------- 1 | package org.fog.serverless.scheduler; 2 | 3 | 4 | import org.fog.scheduler.TupleScheduler; 5 | /** 6 | * Function Scheduler Class for FoGFaaS extension. 7 | * 8 | * @author Ghaseminya 9 | * Created on 12/16/2024 10 | */ 11 | public class FogFaaSFunctionScheduler extends TupleScheduler { 12 | 13 | public FogFaaSFunctionScheduler(double mips, int numberOfPes) { 14 | super(mips, numberOfPes); 15 | // TODO Auto-generated constructor stub 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/org/fog/serverless/utils/FogFaaSTags.java: -------------------------------------------------------------------------------- 1 | package org.fog.serverless.utils; 2 | import org.cloudbus.cloudsim.core.CloudSimTags; 3 | public class FogFaaSTags extends CloudSimTags { 4 | 5 | /** Starting constant value for function-related tags. **/ 6 | private static final int BASE = 0; 7 | 8 | /** 9 | * Denotes a request for a deadline checkpoint for a cloudlet 10 | */ 11 | public static final int DEADLINE_CHECKPOINT = BASE + 51; 12 | 13 | /** 14 | * Denotes a request to reschedule given cloudlet 15 | */ 16 | public static final int CLOUDLET_RESCHEDULE = 52; 17 | 18 | /** 19 | * Denotes a request to record CPU usage of vm 20 | */ 21 | public static final int RECORD_CPU_USAGE = 53; 22 | 23 | public static final int CREATE_CLOUDLETS = 54; 24 | 25 | public static final int PREEMPT_REQUEST = 55 ; 26 | public static final int SCALED_CONTAINER = 56 ; 27 | 28 | public static final int AUTO_SCALE = 57 ; 29 | public static final int VERTICAL_SCALE = 58 ; 30 | 31 | 32 | 33 | private FogFaaSTags() { 34 | super(); 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /src/org/fog/utils/CanBeSentResult.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | public class CanBeSentResult { 4 | 5 | private double cpuLoad; 6 | private double nwLoad; 7 | 8 | private boolean canBeSent; 9 | 10 | public CanBeSentResult(double cpuLoad, double nwLoad, boolean canBeSent){ 11 | this.cpuLoad = cpuLoad; 12 | this.nwLoad = nwLoad; 13 | this.canBeSent = canBeSent; 14 | } 15 | 16 | public CanBeSentResult() { 17 | // TODO Auto-generated constructor stub 18 | } 19 | 20 | public double getCpuLoad() { 21 | return cpuLoad; 22 | } 23 | 24 | public void setCpuLoad(double cpuLoad) { 25 | this.cpuLoad = cpuLoad; 26 | } 27 | 28 | public double getNwLoad() { 29 | return nwLoad; 30 | } 31 | 32 | public void setNwLoad(double nwLoad) { 33 | this.nwLoad = nwLoad; 34 | } 35 | 36 | public boolean isCanBeSent() { 37 | return canBeSent; 38 | } 39 | 40 | public void setCanBeSent(boolean canBeSent) { 41 | this.canBeSent = canBeSent; 42 | } 43 | 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/org/fog/utils/Config.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | public class Config { 4 | 5 | public static final double RESOURCE_MGMT_INTERVAL = 100; 6 | public static int MAX_SIMULATION_TIME = 2000; 7 | public static int RESOURCE_MANAGE_INTERVAL = 100; 8 | public static String FOG_DEVICE_ARCH = "x86"; 9 | public static String FOG_DEVICE_OS = "Linux"; 10 | public static String FOG_DEVICE_VMM = "Xen"; 11 | public static double FOG_DEVICE_TIMEZONE = 10.0; 12 | public static double FOG_DEVICE_COST = 3.0; 13 | public static double FOG_DEVICE_COST_PER_MEMORY = 0.05; 14 | public static double FOG_DEVICE_COST_PER_STORAGE = 0.001; 15 | public static double FOG_DEVICE_COST_PER_BW = 0.0; 16 | public static double MAX_VALUE = 1000000.0; 17 | 18 | // Create cluster among devices of same level with common parent irrespective of location. Only one of the two clustering modes should be used for clustering 19 | public static boolean ENABLE_STATIC_CLUSTERING = false; 20 | //Dynamic Clustering 21 | public static boolean ENABLE_DYNAMIC_CLUSTERING = true; 22 | public static double Node_Communication_RANGE = 300.0; // In terms of meter 23 | public static double clusteringLatency = 2.0; //milisecond 24 | 25 | public static final int TRANSMISSION_START_DELAY = 50; 26 | } 27 | -------------------------------------------------------------------------------- /src/org/fog/utils/FogEvents.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | public class FogEvents { 4 | private static final int BASE = 50; 5 | public static final int TUPLE_ARRIVAL = BASE + 1; 6 | public static final int LAUNCH_MODULE = BASE + 2; 7 | public static final int RELEASE_OPERATOR = BASE + 3; 8 | public static final int SENSOR_JOINED = BASE + 4; 9 | public static final int TUPLE_ACK = BASE + 5; 10 | public static final int APP_SUBMIT = BASE + 6; 11 | public static final int CALCULATE_INPUT_RATE = BASE + 7; 12 | public static final int CALCULATE_UTIL = BASE + 8; 13 | public static final int UPDATE_RESOURCE_USAGE = BASE + 9; 14 | //public static final int UPDATE_TUPLE_QUEUE = BASE + 10; 15 | public static final int TUPLE_FINISHED = BASE + 11; 16 | public static final int ACTIVE_APP_UPDATE = BASE + 12; 17 | public static final int CONTROLLER_RESOURCE_MANAGE = BASE + 13; 18 | public static final int ADAPTIVE_OPERATOR_REPLACEMENT = BASE + 14; 19 | public static final int GET_RESOURCE_USAGE = BASE + 15; 20 | public static final int RESOURCE_USAGE = BASE + 16; 21 | public static final int CONTROL_MSG_ARRIVAL = BASE + 17; 22 | public static final int UPDATE_NORTH_TUPLE_QUEUE = BASE + 18; 23 | public static final int UPDATE_SOUTH_TUPLE_QUEUE = BASE + 19; 24 | public static final int ACTUATOR_JOINED = BASE + 20; 25 | public static final int STOP_SIMULATION = BASE + 21; 26 | public static final int SEND_PERIODIC_TUPLE = BASE + 22; 27 | public static final int LAUNCH_MODULE_INSTANCE = BASE + 23; 28 | public static final int RESOURCE_MGMT = BASE + 24; 29 | public static final int INITIALIZE_SENSOR = BASE + 24; 30 | public static final int EMIT_TUPLE = BASE + 25; 31 | //----------------------------------------- 32 | public static final int MOBILITY_SUBMIT = BASE + 26; 33 | public static final int MOBILITY_MANAGEMENT = BASE + 27; 34 | public static final int MODULE_SEND = BASE + 28; 35 | public static final int MODULE_RECEIVE = BASE + 29; 36 | public static final int RELEASE_MODULE = BASE + 30; 37 | //------------------------------------------- 38 | public static final int UPDATE_CLUSTER_TUPLE_QUEUE = BASE + 31; 39 | public static final int PROCESS_PRS = BASE + 32; 40 | public static final int RECEIVE_PR = BASE + 33; 41 | public static final int UPDATE_SERVICE_DISCOVERY = BASE + 34; 42 | //--------------------------------------------- 43 | public static final int TRANSMIT_PR = BASE + 35; 44 | public static final int MANAGEMENT_TUPLE_ARRIVAL = BASE + 36; 45 | public static final int UPDATE_RESOURCE_INFO = BASE + 37; 46 | //--------------------------------------------- 47 | public static final int START_DYNAMIC_CLUSTERING = BASE + 38; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/org/fog/utils/FogUtils.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class FogUtils { 7 | private static int TUPLE_ID = 1; 8 | private static int ENTITY_ID = 1; 9 | private static int ACTUAL_TUPLE_ID = 1; 10 | 11 | public static int generateTupleId(){ 12 | return TUPLE_ID++; 13 | } 14 | 15 | public static String getSensorTypeFromSensorName(String sensorName){ 16 | return sensorName.substring(sensorName.indexOf('-')+1, sensorName.lastIndexOf('-')); 17 | } 18 | 19 | public static int generateEntityId(){ 20 | return ENTITY_ID++; 21 | } 22 | 23 | public static int generateActualTupleId(){ 24 | return ACTUAL_TUPLE_ID++; 25 | } 26 | 27 | public static int USER_ID = 1; 28 | 29 | //public static int MAX = 10000000; 30 | public static int MAX = 10000000; 31 | 32 | public static Map appIdToGeoCoverageMap = new HashMap(); 33 | } 34 | -------------------------------------------------------------------------------- /src/org/fog/utils/GeoCoverage.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | public class GeoCoverage { 4 | 5 | private double lat_l; 6 | private double lat_u; 7 | private double long_l; 8 | private double long_u; 9 | 10 | public GeoCoverage(double lat_l, double lat_u, double long_l, double long_u){ 11 | this.lat_l = lat_l; 12 | this.lat_u = lat_u; 13 | this.long_l = long_l; 14 | this.long_u = long_u; 15 | } 16 | 17 | public boolean covers(GeoCoverage geo){ 18 | if(this.lat_l <= geo.lat_l && this.lat_u >= geo.lat_u && this.long_l <= geo.long_l && this.long_u >= geo.long_u) 19 | return true; 20 | return false; 21 | } 22 | 23 | public double getLat_l() { 24 | return lat_l; 25 | } 26 | 27 | public void setLat_l(double lat_l) { 28 | this.lat_l = lat_l; 29 | } 30 | 31 | public double getLat_u() { 32 | return lat_u; 33 | } 34 | 35 | public void setLat_u(double lat_u) { 36 | this.lat_u = lat_u; 37 | } 38 | 39 | public double getLong_l() { 40 | return long_l; 41 | } 42 | 43 | public void setLong_l(double long_l) { 44 | this.long_l = long_l; 45 | } 46 | 47 | public double getLong_u() { 48 | return long_u; 49 | } 50 | 51 | public void setLong_u(double long_u) { 52 | this.long_u = long_u; 53 | } 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/org/fog/utils/GeoLocation.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | public class GeoLocation { 4 | 5 | private double latitude; 6 | private double longitude; 7 | 8 | public GeoLocation(double latitude, double longitude){ 9 | this.latitude = latitude; 10 | this.longitude = longitude; 11 | } 12 | 13 | public double getLatitude() { 14 | return latitude; 15 | } 16 | public void setLatitude(double latitude) { 17 | this.latitude = latitude; 18 | } 19 | public double getLongitude() { 20 | return longitude; 21 | } 22 | public void setLongitude(double longitude) { 23 | this.longitude = longitude; 24 | } 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/org/fog/utils/Logger.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | import java.text.DecimalFormat; 4 | 5 | import org.cloudbus.cloudsim.core.CloudSim; 6 | 7 | public class Logger { 8 | 9 | public static final int ERROR = 1; 10 | public static final int DEBUG = 0; 11 | 12 | public static int LOG_LEVEL = Logger.DEBUG; 13 | private static DecimalFormat df = new DecimalFormat("#.00"); 14 | 15 | public static boolean ENABLED = false;; 16 | 17 | public static void setLogLevel(int level){ 18 | Logger.LOG_LEVEL = level; 19 | } 20 | 21 | public static void debug(String name, String message){ 22 | if(!ENABLED) 23 | return; 24 | if(Logger.LOG_LEVEL <= Logger.DEBUG) 25 | System.out.println(df.format(CloudSim.clock())+" : "+name+" : "+message); 26 | } 27 | public static void error(String name, String message){ 28 | if(!ENABLED) 29 | return; 30 | if(Logger.LOG_LEVEL <= Logger.ERROR) 31 | System.out.println(df.format(CloudSim.clock())+" : "+name+" : "+message); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/org/fog/utils/MicroservicePlacementConfig.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | public class MicroservicePlacementConfig { 4 | 5 | // simulation modes - STATIC - 1(initial placement happens before simulation start and placement related delays are not simulated) 6 | // DYNAMIC - 2(placement happens after simulation starts and placement related delays are simulated) 7 | public static String SIMULATION_MODE = "STATIC"; 8 | 9 | //Placement Request Processing Mode 10 | public static String PERIODIC = "Periodic"; 11 | public static String SEQUENTIAL = "Sequential"; 12 | public static String PR_PROCESSING_MODE = PERIODIC; 13 | 14 | // For periodic placement 15 | public static final double PLACEMENT_INTERVAL = 1; 16 | 17 | //Resource info sharing among cluster nodes 18 | public static Boolean ENABLE_RESOURCE_DATA_SHARING = false; 19 | public static double MODULE_DEPLOYMENT_TIME = 0.0; 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/org/fog/utils/MigrationDelayMonitor.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | public class MigrationDelayMonitor { 4 | 5 | private static double migrationDelay = 0.0; 6 | 7 | public static double getMigrationDelay() { 8 | return migrationDelay; 9 | } 10 | 11 | public static void setMigrationDelay(double migrationDelayReceived) { 12 | migrationDelay += migrationDelayReceived; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/org/fog/utils/ModuleLaunchConfig.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | import org.fog.application.AppModule; 4 | 5 | public class ModuleLaunchConfig { 6 | 7 | private AppModule module; 8 | private int instanceCount; 9 | 10 | public ModuleLaunchConfig(AppModule module, int instanceCount){ 11 | setModule(module); 12 | setInstanceCount(instanceCount); 13 | } 14 | 15 | public AppModule getModule() { 16 | return module; 17 | } 18 | public void setModule(AppModule module) { 19 | this.module = module; 20 | } 21 | public int getInstanceCount() { 22 | return instanceCount; 23 | } 24 | public void setInstanceCount(int instanceCount) { 25 | this.instanceCount = instanceCount; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/org/fog/utils/NetworkUsageMonitor.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | public class NetworkUsageMonitor { 4 | 5 | private static double networkUsage = 0.0; 6 | 7 | public static void sendingTuple(double latency, double tupleNwSize){ 8 | networkUsage += latency*tupleNwSize; 9 | } 10 | 11 | public static void sendingModule(double latency, long moduleSize){ 12 | networkUsage += latency*moduleSize; 13 | } 14 | 15 | public static double getNetworkUsage(){ 16 | return networkUsage; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/org/fog/utils/OperatorEdge.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | public class OperatorEdge { 4 | 5 | private String src; 6 | private String dst; 7 | private double selectivity; 8 | 9 | public OperatorEdge(String src, String dst, double selectivity){ 10 | this.src = src; 11 | this.dst = dst; 12 | this.selectivity = selectivity; 13 | } 14 | 15 | public String getSrc() { 16 | return src; 17 | } 18 | public void setSrc(String src) { 19 | this.src = src; 20 | } 21 | public String getDst() { 22 | return dst; 23 | } 24 | public void setDst(String dst) { 25 | this.dst = dst; 26 | } 27 | public double getSelectivity() { 28 | return selectivity; 29 | } 30 | public void setSelectivity(double selectivity) { 31 | this.selectivity = selectivity; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/org/fog/utils/OperatorSetComparator.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | import java.util.Comparator; 4 | import java.util.List; 5 | 6 | public class OperatorSetComparator implements Comparator>{ 7 | 8 | @Override 9 | public int compare(List arg0, List arg1) { 10 | return (arg1.size() - arg0.size()); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/org/fog/utils/ResourceUsageDetails.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | public class ResourceUsageDetails { 4 | 5 | private double mips; 6 | private double uplinkBandwidth; 7 | private double cpuTrafficIntensity; 8 | private double nwTrafficIntensity; 9 | 10 | public ResourceUsageDetails(double mips, double uplinkBandwidth, 11 | double cpuTrafficIntensity, double nwTrafficIntensity) { 12 | super(); 13 | this.mips = mips; 14 | this.uplinkBandwidth = uplinkBandwidth; 15 | this.cpuTrafficIntensity = cpuTrafficIntensity; 16 | this.nwTrafficIntensity = nwTrafficIntensity; 17 | } 18 | public double getMips() { 19 | return mips; 20 | } 21 | public void setMips(double mips) { 22 | this.mips = mips; 23 | } 24 | public double getUplinkBandwidth() { 25 | return uplinkBandwidth; 26 | } 27 | public void setUplinkBandwidth(double uplinkBandwidth) { 28 | this.uplinkBandwidth = uplinkBandwidth; 29 | } 30 | public double getCpuTrafficIntensity() { 31 | return cpuTrafficIntensity; 32 | } 33 | public void setCpuTrafficIntensity(double cpuTrafficIntensity) { 34 | this.cpuTrafficIntensity = cpuTrafficIntensity; 35 | } 36 | public double getNwTrafficIntensity() { 37 | return nwTrafficIntensity; 38 | } 39 | public void setNwTrafficIntensity(double nwTrafficIntensity) { 40 | this.nwTrafficIntensity = nwTrafficIntensity; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/org/fog/utils/TupleFinishDetails.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils; 2 | 3 | public class TupleFinishDetails { 4 | 5 | private String queryId; 6 | private int actualTupleId; 7 | private double emitTime; 8 | private double finishTime; 9 | private String sensorType; 10 | public TupleFinishDetails(String queryId, int actualTupleId, double emitTime, double finishTime, String sensorType){ 11 | this.queryId = queryId; 12 | this.actualTupleId = actualTupleId; 13 | this.emitTime = emitTime; 14 | this.finishTime = finishTime; 15 | this.sensorType = sensorType; 16 | } 17 | 18 | public String getQueryId() { 19 | return queryId; 20 | } 21 | public void setQueryId(String queryId) { 22 | this.queryId = queryId; 23 | } 24 | public int getActualTupleId() { 25 | return actualTupleId; 26 | } 27 | public void setActualTupleId(int actualTupleId) { 28 | this.actualTupleId = actualTupleId; 29 | } 30 | public double getEmitTime() { 31 | return emitTime; 32 | } 33 | public void setEmitTime(double emitTime) { 34 | this.emitTime = emitTime; 35 | } 36 | public double getFinishTime() { 37 | return finishTime; 38 | } 39 | public void setFinishTime(double finishTime) { 40 | this.finishTime = finishTime; 41 | } 42 | 43 | public String getSensorType() { 44 | return sensorType; 45 | } 46 | 47 | public void setSensorType(String sensorType) { 48 | this.sensorType = sensorType; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/org/fog/utils/distribution/DeterministicDistribution.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils.distribution; 2 | 3 | public class DeterministicDistribution extends Distribution{ 4 | 5 | private double value; 6 | 7 | public DeterministicDistribution(double value) { 8 | super(); 9 | setValue(value); 10 | } 11 | 12 | @Override 13 | public double getNextValue() { 14 | return value; 15 | } 16 | 17 | public double getValue() { 18 | return value; 19 | } 20 | 21 | public void setValue(double value) { 22 | this.value = value; 23 | } 24 | 25 | @Override 26 | public int getDistributionType() { 27 | return Distribution.DETERMINISTIC; 28 | } 29 | 30 | @Override 31 | public double getMeanInterTransmitTime() { 32 | return value; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/org/fog/utils/distribution/Distribution.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils.distribution; 2 | 3 | import java.util.Random; 4 | 5 | public abstract class Distribution { 6 | 7 | public static int NORMAL = 1; 8 | public static int DETERMINISTIC = 2; 9 | public static int UNIFORM = 3; 10 | 11 | protected Random random; 12 | public abstract double getNextValue(); 13 | 14 | public Random getRandom() { 15 | return random; 16 | } 17 | 18 | public void setRandom(Random random) { 19 | this.random = random; 20 | } 21 | 22 | public abstract int getDistributionType(); 23 | public abstract double getMeanInterTransmitTime(); 24 | } 25 | -------------------------------------------------------------------------------- /src/org/fog/utils/distribution/NormalDistribution.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils.distribution; 2 | 3 | import java.util.Random; 4 | 5 | public class NormalDistribution extends Distribution{ 6 | 7 | private double mean; 8 | private double stdDev; 9 | 10 | public NormalDistribution(double mean, double stdDev) { 11 | setMean(mean); 12 | setStdDev(stdDev); 13 | setRandom(new Random()); 14 | } 15 | 16 | @Override 17 | public double getNextValue() { 18 | return random.nextGaussian()*stdDev + mean; 19 | } 20 | 21 | public double getMean() { 22 | return mean; 23 | } 24 | 25 | public void setMean(double mean) { 26 | this.mean = mean; 27 | } 28 | 29 | public double getStdDev() { 30 | return stdDev; 31 | } 32 | 33 | public void setStdDev(double stdDev) { 34 | this.stdDev = stdDev; 35 | } 36 | 37 | @Override 38 | public int getDistributionType() { 39 | return Distribution.NORMAL; 40 | } 41 | 42 | @Override 43 | public double getMeanInterTransmitTime() { 44 | return mean; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/org/fog/utils/distribution/UniformDistribution.java: -------------------------------------------------------------------------------- 1 | package org.fog.utils.distribution; 2 | 3 | public class UniformDistribution extends Distribution{ 4 | 5 | private double min; 6 | private double max; 7 | 8 | public UniformDistribution(double min, double max){ 9 | super(); 10 | setMin(min); 11 | setMax(max); 12 | } 13 | 14 | @Override 15 | public double getNextValue() { 16 | return getRandom().nextDouble()*(getMax()-getMin())+getMin(); 17 | } 18 | 19 | public double getMin() { 20 | return min; 21 | } 22 | 23 | public void setMin(double min) { 24 | this.min = min; 25 | } 26 | 27 | public double getMax() { 28 | return max; 29 | } 30 | 31 | public void setMax(double max) { 32 | this.max = max; 33 | } 34 | 35 | @Override 36 | public int getDistributionType() { 37 | return Distribution.UNIFORM; 38 | } 39 | 40 | @Override 41 | public double getMeanInterTransmitTime() { 42 | return (min+max)/2; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/topologies/routerTopology: -------------------------------------------------------------------------------- 1 | {"nodes":[{"name":"motor-1","actuatorType":"MOTOR","type":"ACTUATOR"},{"ratePerMips":0.0,"downBw":1000,"level":1,"upBw":1000,"ram":1024,"name":"router","mips":1000,"type":"FOG_DEVICE"},{"sensorType":"TEMP","name":"temp-1","mean":10.0,"type":"SENSOR","distribution":1,"stdDev":2.0},{"sensorType":"TEMP","name":"temp-0","mean":10.0,"type":"SENSOR","distribution":1,"stdDev":2.0},{"ratePerMips":0.0,"downBw":1000,"level":2,"upBw":1000,"ram":1024,"name":"mobile-0","mips":1000,"type":"FOG_DEVICE"},{"ratePerMips":0.0,"downBw":1000,"level":2,"upBw":1000,"ram":1024,"name":"mobile-1","mips":1000,"type":"FOG_DEVICE"},{"name":"motor-0","actuatorType":"MOTOR","type":"ACTUATOR"},{"ratePerMips":10.0,"downBw":1000,"level":0,"upBw":100,"ram":10240,"name":"cloud","mips":100000,"type":"FOG_DEVICE"}],"links":[{"latency":2.0,"source":"motor-1","destination":"mobile-1"},{"latency":50.0,"source":"router","destination":"cloud"},{"latency":2.0,"source":"temp-1","destination":"mobile-1"},{"latency":2.0,"source":"temp-0","destination":"mobile-0"},{"latency":10.0,"source":"mobile-0","destination":"router"},{"latency":10.0,"source":"mobile-1","destination":"router"},{"latency":2.0,"source":"motor-0","destination":"mobile-0"}]} --------------------------------------------------------------------------------