-
Notifications
You must be signed in to change notification settings - Fork 0
WorkflowSim Framework and How to Add Your Algorithm
First of all, we should be aware that WorkflowSim (and other real workflow management systems) has a hierarchical framework. From top to bottom, we have:
- Workflow Planner. It calls Workflow Parser to parse a xml file and create a list of tasks (or cloudlets in CloudSim) and then submits this list to Clustering Engine.
- Clustering Engine. It merges tasks into jobs (a group of task) based on the algorithm a user specifies (horizontal, vertical, random, or more). If not specified, Clustering Engine would not merge at all and just submits the list of jobs to Workflow Engine. From now on, we have jobs even though they may have just one task actually.
- Workflow Engine. It releases jobs based on the dependency and assures every job can only be submitted to Workflow Scheduler when all of its parent jobs have completely successfully.
- Workflow Scheduler. It matches VMs with jobs based on the algorithm a user specified (scheduler.method). Currently we may MINMIN_SCH, MAXMIN_SCH, MCT_SCH and etc. The HEFT_SCH is there but not implemented.
Now we come back to the original question: how to add your own algorithm?
There are two types of algorithms. The first one is for scheduling free jobs. I usually call it dynamic or runtime scheduling algorithm since it happens right before the execution of the jobs. Free means they are working at the Workflow Scheduler level and all of their parent jobs have completely successfully and thus you don't need to worry about the dependency issues at this level.
For the first one, it is easy to add a new algorithm. Follow the steps below:
Step 1. Create your own algorithm implementation under org.workflowsim.scheduler. similar to MinMinScheduler.java. Assuming you call it PSOScheduler.java.
If you take a look at MinMinScheduler.java, the key steps of implementing a scheduling is
92 for (int j = 0; j < vmSize; j++) {
93 CondorVM vm = (CondorVM) getVmList().get(j);
94 if ((vm.getState() == WorkflowSimTags.VM_STATUS_IDLE)
95 && vm.getCurrentRequestedTotalMips() >firstIdleVm.getCurrentRequestedTotalMips())
96{
97 firstIdleVm = vm;
98
99 }
100 }
101 firstIdleVm.setState(WorkflowSimTags.VM_STATUS_BUSY);
102 minCloudlet.setVmId(firstIdleVm.getId());
103 getScheduledList().add(minCloudlet);
You have at least three steps. First determine whether a VM is free (line 94) and set it to be busy (line 101). Second, set the VM id for a cloudlet (it is actually a job) (line 102). Third, add the cloudlet (line 103) to the getScheduledList() such that it will be submitted for execution.
Step 2. In org.workflowsim.utils.Parameters.SCHMethod , add a new value to it, i.e. PSO_SCH
Step 3. In org.workflosim.WorkflowScheduler.getScheduler(), add a new case, for example
case PSO_SCH:
scheduler = new PSOScheduler()
break;
And then you when you run WorkflowSim, just set the scheduler.method = PSO_SCH in your config file. Then you are done.
The second type is for scheduling all tasks/jobs. I usually call it static scheduling algorithm or planning algorithm because you set the mapping relation between VMs and jobs in the Workflow Planner and should not change in Workflow Scheduler. It usually happens when you have a evolutionary algorithm such as PSO. In this planning algorithm, you do not consider whether a VM is busy or not. During the runtime, if a VM allocated to the job is busy, the job will be queued until the VM gets free.
Similarly, we have three steps: Step 1. Create your own algorithm implementation under org.workflowsim.planner. similar to RandomPlanner.java. Assuming you call it PSOPlanner.java.
If you take a look at RandomPlanner.java, the key steps of implementing a planning is
63 task.setVmId(vm.getId());
Step 2. In org.workflowsim.utils.Parameters.PLNMethod , add a new value to it, i.e. PSO
Step 3. In org.workflosim.WorkflowPlanner.getPlanner(), add a new case, for example
case PSO:
planner = new PSOPlanner()
break;
Step 4. in your config file, set planner.method = PSO (If you set the planner.method, your scheduler.method will be automatically set to STATIC_SCH such that it won't change your planning results during the runtime) That's all.