writing-workload-generators.md
April 3, 2023 ยท View on GitHub
layout: page title: "Writing Workload Generators with CloudSim Express" permalink: /examples/writing-workload-generators
Writing Workload Generators with CloudSim Express
CloudSim Express introduces a new approach to connect workloads. In research, the workloads are available as traces, and they can be submitted all-at-once, or dynamically. To cater these requirements, CloudSim Express introduces two new interfaces,
By default, an implementation of CloudSimWorkloadGenerator is available with the class,
DummyWorkloadGenerator.
In this example, we are extending this DummyWorkloadGenerator to write a custom workload generator
and deploy it with the system model that we built with Say "Hello World!" with CloudSim Express example.
Creating a java project for the workload generator
We implement the workload generator in a separate java project first. We use Maven-based java project.
- Create a simple Maven project.
- Go to a new folder.
- Execute
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-simple -DarchetypeVersion=1.4- Pre-requisite: Maven
- Enter followings when prompted.
- groupId =
org.cloudbus.cloudsim.express.examples - artifactId =
custom-workload-generator - version =
1.0-SNAPSHOT - package =
org.cloudbus.cloudsim.express.examples - Press Enter to confirm.
- groupId =
- Configure dependencies.
- Go to the
custom-workload-generatorproject folder. - Open
pom.xml - Within the
<dependencies>tag, copy the following to declare CloudSim Express as a dependency- Pre-requisite: You must build
cloudsim-expressproject at least once. - Copy and paste the following.
<dependency> <artifactId>cloudsim-express-extensions</artifactId> <groupId>org.cloudbus.cloudsim.cloudsim-express</groupId> <version>0.1-SNAPSHOT</version> </dependency>
- Pre-requisite: You must build
- Create the custom workload generator class in the
/src/main/java/org/cloudbus/cloudsim/express/examples/folder by creating a new fileCustomWorkloadGenerator.java.- Delete the generated
App.javafile.
- Delete the generated
- Implement the workload generator to return a single cloudlet.
- The sample code is available in the custom-workload-generator project.
- Build the project by executing
mvn clean installfrom the project root directory (i.e., where thepom.xmlfile resides).
- Go to the
Deploying the custom workload generator
- Copy the workload generator jar file from
<custom-workload-generator>/target/custom-workload-generator-1.0-SNAPSHOT.jar, tocloudsim-express-tool-location/extensions. - Modify the
system-model.yamlto use the custom workload generator.- From:
... Zone: &Zone name: "default zone" datacenter: *Datacenter broker: variant: className: "org.cloudbus.cloudsim.DatacenterBroker" name: "RegionalBroker" workloadGenerator: variant: className: "org.crunchycookie.research.distributed.computing.cloudsim.workload.impl.DummyWorkloadGenerator" ... - To:
... Zone: &Zone name: "default zone" datacenter: *Datacenter broker: variant: className: "org.cloudbus.cloudsim.DatacenterBroker" name: "RegionalBroker" workloadGenerator: variant: className: "org.cloudbus.cloudsim.express.examples.CustomWorkloadGenerator" ...
- From:
- Executes the simulation via
sh ./cloudsim-express.sh - Check the latest CloudSim log file from
logs. You can observe that only one Cloudlet has been created during the simulation.... 0.01: RegionalBroker: VM #1 has been created in Datacenter #3, Host #1 0.01: RegionalBroker: Sending cloudlet 1 to VM #1 10000.01: RegionalBroker: Cloudlet 1 received 10000.01: RegionalBroker: All Cloudlets executed. Finishing... 10000.01: RegionalBroker: Destroying VM #1 RegionalBroker is shutting down... ...
Materials
The related materials are included in the resources folder.