Index: DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_Metrics.txt
===================================================================
--- DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_Metrics.txt	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_Metrics.txt	(revision 1375)
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
Index: DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_ResourceUtilization.txt
===================================================================
--- DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_ResourceUtilization.txt	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_ResourceUtilization.txt	(revision 1375)
@@ -0,0 +1,6 @@
+utlization;compRes;1225666800000;1;
+utlization;compRes;1225681200000;0;
+mean: 1.0
+utlization;compRes/Processor_1;1225666800000;1;
+utlization;compRes/Processor_1;1225681200000;0;
+mean: 1.0
Index: DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_Simulation.txt
===================================================================
--- DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_Simulation.txt	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_Simulation.txt	(revision 1375)
@@ -0,0 +1,14 @@
+Resource name;mean;stdev;variance;minimum;maximum;sum;count;
+Delayed tasks;0;0;0;0;0;0;1;
+Failed requests (tasks);0;0;0;0;0;0;1;
+Makespan;14,400;0;0;14,400;14,400;14,400;1;
+Resources queue length;0.25;0;0;0.25;0.25;0.25;1;
+Resources total load;1;0;0;1;1;1;1;
+Energy usage;?;?;?;?;?;?;0;
+Task completion time;12,600;1,800;3,240,000;10,800;14,400;25,200;2;
+Task execution time;7,200;0;0;7,200;7,200;14,400;2;
+Task start time;0;0;0;0;0;0;2;
+Task flow time;10,800;3,600;12,960,000;7,200;14,400;21,600;2;
+Task waiting time;0;0;0;0;0;0;2;
+Task lateness;0;0;0;0;0;0;2;
+Task tardiness;0;0;0;0;0;0;2;
Index: DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_Tasks.txt
===================================================================
--- DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_Tasks.txt	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_Tasks.txt	(revision 1375)
@@ -0,0 +1,3 @@
+JobID;TaskID;UserDN;SchedName;CpuCnt;ExecStartDate;ExecFinishDate;ExecEndDate;GB_SubDate;LB_SubDate;CompletionTime;ExecStartTime;ExecutionTime;ReadyTime;StartTime;FlowTime;WaitingTime;GQ_WaitingTime;Lateness;Tardiness;ReservStartDate;ReservFinishDate;HostNames;ProcessorName;Energy;AppName;
+1;1;-1;cluster;1;1225666800;1225681200;1225681200;1225666800;1225666800;14400;0;7200;0;0;14400;0;0;0;0;0;0;[];[compRes/Processor_1];0;null;
+2;2;-1;cluster;1;1225670400;1225677600;1225677600;1225670400;1225670400;10800;3600;7200;3600;0;7200;0;0;0;0;0;0;[];[compRes/Processor_1];0;null;
Index: DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/experiment.properties
===================================================================
--- DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/experiment.properties	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/experiment.properties	(revision 1375)
@@ -0,0 +1,26 @@
+# Use single *.swf file as workload description.
+
+# Path to xml file which describes resource characteristics.
+resdesc=src/test/pausing_resuming/resources1.xml
+
+# and swf file, which name is declared by readscenario.workloadfilename parameter.
+# Swf file must be placed in readscenario.inputfolder directory.  
+readscenario.workloadfilename=src/test/pausing_resuming/workload.swf
+
+# Choose directory where all result files should be placed.
+stats.outputfolder=src/test/pausing_resuming_result
+
+# Define the type and content of charts to generate
+
+# Gantt chart
+creatediagrams.gantt=true
+
+# Shows the execution times of tasks
+creatediagrams.tasks=true
+
+# Shows the waiting times of tasks
+creatediagrams.taskswaitingtime=true
+
+# Resource utilization chart - only for processors
+creatediagrams.resutilization=Processor
+
Index: DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_ResourceOccupancy.txt
===================================================================
--- DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_ResourceOccupancy.txt	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_ResourceOccupancy.txt	(revision 1375)
@@ -0,0 +1,10 @@
+utlization;compRes;1225666800000;1;
+utlization;compRes;1225670400000;1;
+utlization;compRes;1225677600000;1;
+utlization;compRes;1225681200000;0;
+mean: 1.0
+utlization;compRes/Processor_1;1225666800000;1;
+utlization;compRes/Processor_1;1225670400000;1;
+utlization;compRes/Processor_1;1225677600000;1;
+utlization;compRes/Processor_1;1225681200000;0;
+mean: 1.0
Index: DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_Jobs.txt
===================================================================
--- DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_Jobs.txt	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/pausing_resuming_result/Stats_Simulation_1_Jobs.txt	(revision 1375)
@@ -0,0 +1,3 @@
+jobID;meanTaskCompletionTime;meanTaskExecutionTime;meanTaskStartTime;meanTaskFlowTime;meanTaskWaitingTime;meanTaskGQ_WaitingTime;lateness;tardiness;makespan;
+1;14,400;7,200;0;14,400;0;0;0;0;14,400;
+2;10,800;7,200;0;7,200;0;0;0;0;10,800;
Index: DCWoRMS/branches/coolemall/src/test/pausing_resuming/experiment1.properties
===================================================================
--- DCWoRMS/branches/coolemall/src/test/pausing_resuming/experiment1.properties	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/pausing_resuming/experiment1.properties	(revision 1375)
@@ -0,0 +1,26 @@
+# Use single *.swf file as workload description.
+
+# Path to xml file which describes resource characteristics.
+resdesc=src/test/pausing_resuming/resources1.xml
+
+# and swf file, which name is declared by readscenario.workloadfilename parameter.
+# Swf file must be placed in readscenario.inputfolder directory.  
+readscenario.workloadfilename=src/test/pausing_resuming/workload.swf
+
+# Choose directory where all result files should be placed.
+stats.outputfolder=src/test/pausing_resuming_result
+
+# Define the type and content of charts to generate
+
+# Gantt chart
+creatediagrams.gantt=true
+
+# Shows the execution times of tasks
+creatediagrams.tasks=true
+
+# Shows the waiting times of tasks
+creatediagrams.taskswaitingtime=true
+
+# Resource utilization chart - only for processors
+creatediagrams.resutilization=Processor
+
Index: DCWoRMS/branches/coolemall/src/test/pausing_resuming/workload.swf
===================================================================
--- DCWoRMS/branches/coolemall/src/test/pausing_resuming/workload.swf	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/pausing_resuming/workload.swf	(revision 1375)
@@ -0,0 +1,18 @@
+;Automatically generated workload description by the Grid Scheduling Simulator
+;		j|		s|		w|		r|		c|		c|		m|		p|		t|		m|		s|		u|		g|		e|		q|		p|		p|		t|
+;		o|		u|		a|		u|		p|		p|		e|		r|		i|		e|		t|		i|		i|		x|		u|		a|		r|		h|
+;		b|		b|		i|		n|		u|		u|		m|		o|		m|		m|		a|		d|		d|		e|		e|		r|		e|		i|
+;		 |		m|		t|		t|		 |		 |		 |		c|		e|		 |		t|		 |		 |		c|		u|		t|		c|		n|
+;		 |		i|		 |		i|		a|		t|		u|		 |		 |		r|		u|		 |		 |		u|		e|		i|		 |		k|
+;		 |		t|		 |		m|		l|		i|		s|		r|		r|		e|		s|		 |		 |		t|		 |		t|		j|		 |
+;		 |		 |		 |		e|		l|		m|		e|		e|		e|		q|		 |		 |		 |		a|		n|		i|		o|		t|
+;		 |		 |		 |		 |		o|		e|		d|		q|		q|		 |		 |		 |		 |		b|		r|		o|		b|		i|
+;		 |		 |		 |		 |		c|		 |		 |		 |		 |		 |		 |		 |		 |		l|		 |		n|		 |		m|
+;		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		e|		 |		 |		 |		e|
+;StartTime: Mon Nov 03 00:00:00 CET 2008
+;PUSpeed: 1
+;
+
+
+		1			0			-1		7200	1		-1		-1		1		-1		-1		-1		-1		-1		1		1		1		-1		-1
+		2			3600			-1		7200	1		-1		-1		1		-1		-1		-1		-1		-1		1		1		1		-1		-1
Index: DCWoRMS/branches/coolemall/src/test/pausing_resuming/RunExperiment.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/pausing_resuming/RunExperiment.java	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/pausing_resuming/RunExperiment.java	(revision 1375)
@@ -0,0 +1,19 @@
+package test.pausing_resuming;
+import simulator.DataCenterWorkloadSimulator;
+
+
+public class RunExperiment {
+	
+	public static void main(String args[]){
+		RunExperiment runner = new RunExperiment();
+		runner.run();
+	}
+	
+	public void run(){
+		String args[] = {
+				"src/test/pausing_resuming/experiment1.properties"
+				};
+		DataCenterWorkloadSimulator.main(args);
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/pausing_resuming/FCFSBF_RandomPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/pausing_resuming/FCFSBF_RandomPlugin.java	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/pausing_resuming/FCFSBF_RandomPlugin.java	(revision 1375)
@@ -0,0 +1,159 @@
+package test.pausing_resuming;
+
+import dcworms.schedframe.scheduling.ExecTask;
+import dcworms.schedframe.scheduling.Executable;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.Gridlet;
+import gridsim.dcworms.DCWormsTags;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.joda.time.DateTime;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.EnergyEventType;
+import schedframe.resources.units.Memory;
+import schedframe.resources.units.PEUnit;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.plugin.local.ResourceAllocation;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import simulator.DataCenterWorkloadSimulator;
+
+public class FCFSBF_RandomPlugin extends BaseLocalSchedulingPlugin {
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		List<Processor> processors = resourceManager.getProcessors();
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		//case TIMER:
+			// our tasks are placed only in first queue (see BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			// check all tasks in queue
+
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(processors, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					} else {
+						if(jobRegistry.getRunningTasks().size() > 0) {
+							for(ExecTask exec: jobRegistry.getRunningTasks()){
+								jobRegistry.pauseTask(exec.getJobId(), exec.getId());
+							}
+						} 
+					}
+				}
+			}
+
+			break;
+		case TASK_FINISHED:
+			for(ExecTask exec: jobRegistry.getTasks(DCWormsTags.PAUSED)){
+				jobRegistry.resumeTask(exec.getJobId(), exec.getId());
+			}
+			q = queues.get(0);
+			// check all tasks in queue
+
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(processors, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+				}
+			}
+
+			break;
+		case TASK_PAUSED: 
+			 q = queues.get(0);
+			// check all tasks in queue
+
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(processors, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+				}
+			}
+
+		}
+		
+		return plan;
+	}
+
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			List<Processor> processors, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(1);
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			if (processors.size() < cpuRequest) {
+				return null;
+			}
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+			for (int i = 0; i < processors.size() && cpuRequest > 0; i++) {
+				if (processors.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(processors.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+
+		return null;
+	}
+
+
+
+}
Index: DCWoRMS/branches/coolemall/src/test/pausing_resuming/resources1.xml
===================================================================
--- DCWoRMS/branches/coolemall/src/test/pausing_resuming/resources1.xml	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/pausing_resuming/resources1.xml	(revision 1375)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<environment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+	xsi:noNamespaceSchemaLocation="../../simulator/schemas/resources/DCwormsResSchema.xsd">
+	
+	<!-- Simple data center description -->
+	<resources>
+		<computingResource class="DataCenter" name="compRes">
+			<!-- Defined data center contains only 6 processors -->
+			<computingResource class="Processor" count="1"/>
+		</computingResource>
+		<scheduler class="Cluster" name="cluster">
+			<!-- Definition of scheduling plugin at cluster level -->
+			<schedulingPlugin>
+				<name>test.pausing_resuming.FCFSBF_RandomPlugin</name>
+			</schedulingPlugin>	
+			<!-- Reference to managed resources - cluster manages resources belonging to the defined data center -->
+			<managedComputingResources include="false">
+				<resourceName>compRes</resourceName>
+			</managedComputingResources>
+		</scheduler>	
+	</resources>
+
+</environment>
Index: DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_ResourceOccupancy.txt
===================================================================
--- DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_ResourceOccupancy.txt	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_ResourceOccupancy.txt	(revision 1375)
@@ -0,0 +1,87 @@
+utlization;compRes;1225666800000;0;
+utlization;compRes;1225666801000;0.083;
+utlization;compRes;1225666802000;0.167;
+utlization;compRes;1225666803000;0.25;
+utlization;compRes;1225666804000;0.333;
+utlization;compRes;1225666805000;0.417;
+utlization;compRes;1225667315000;0.333;
+utlization;compRes;1225667316000;0.25;
+utlization;compRes;1225667317000;0.167;
+utlization;compRes;1225667318000;0.083;
+utlization;compRes;1225667319000;0;
+mean: 0.4126525369299936
+utlization;compRes/Rack_1;1225666800000;0;
+utlization;compRes/Rack_1;1225666801000;0.083;
+utlization;compRes/Rack_1;1225666802000;0.167;
+utlization;compRes/Rack_1;1225666803000;0.25;
+utlization;compRes/Rack_1;1225666804000;0.333;
+utlization;compRes/Rack_1;1225666805000;0.417;
+utlization;compRes/Rack_1;1225667315000;0.333;
+utlization;compRes/Rack_1;1225667316000;0.25;
+utlization;compRes/Rack_1;1225667317000;0.167;
+utlization;compRes/Rack_1;1225667318000;0.083;
+utlization;compRes/Rack_1;1225667319000;0;
+mean: 0.4126525369299936
+utlization;compRes/Rack_1/Node_1;1225666800000;0;
+utlization;compRes/Rack_1/Node_1;1225666801000;0.25;
+utlization;compRes/Rack_1/Node_1;1225666802000;0.5;
+utlization;compRes/Rack_1/Node_1;1225667315000;0.25;
+utlization;compRes/Rack_1/Node_1;1225667316000;0;
+utlization;compRes/Rack_1/Node_1;1225667319000;0;
+mean: 0.4951830443159923
+utlization;compRes/Rack_1/Node_2;1225666800000;0;
+utlization;compRes/Rack_1/Node_2;1225666803000;0.25;
+utlization;compRes/Rack_1/Node_2;1225666805000;0.5;
+utlization;compRes/Rack_1/Node_2;1225667317000;0.25;
+utlization;compRes/Rack_1/Node_2;1225667319000;0;
+mean: 0.4951830443159923
+utlization;compRes/Rack_1/Node_3;1225666800000;0;
+utlization;compRes/Rack_1/Node_3;1225666804000;0.25;
+utlization;compRes/Rack_1/Node_3;1225667318000;0;
+utlization;compRes/Rack_1/Node_3;1225667319000;0;
+mean: 0.24759152215799615
+utlization;compRes/Rack_1/Node_1/Processor_1;1225666800000;0;
+utlization;compRes/Rack_1/Node_1/Processor_1;1225666801000;1;
+utlization;compRes/Rack_1/Node_1/Processor_1;1225667315000;0;
+utlization;compRes/Rack_1/Node_1/Processor_1;1225667319000;0;
+mean: 0.9903660886319846
+utlization;compRes/Rack_1/Node_1/Processor_2;1225666800000;0;
+utlization;compRes/Rack_1/Node_1/Processor_2;1225666802000;1;
+utlization;compRes/Rack_1/Node_1/Processor_2;1225667316000;0;
+utlization;compRes/Rack_1/Node_1/Processor_2;1225667319000;0;
+mean: 0.9903660886319846
+utlization;compRes/Rack_1/Node_1/Processor_3;1225666800000;0;
+utlization;compRes/Rack_1/Node_1/Processor_3;1225667319000;0;
+mean: 0.0
+utlization;compRes/Rack_1/Node_1/Processor_4;1225666800000;0;
+utlization;compRes/Rack_1/Node_1/Processor_4;1225667319000;0;
+mean: 0.0
+utlization;compRes/Rack_1/Node_2/Processor_5;1225666800000;0;
+utlization;compRes/Rack_1/Node_2/Processor_5;1225666803000;1;
+utlization;compRes/Rack_1/Node_2/Processor_5;1225667317000;0;
+utlization;compRes/Rack_1/Node_2/Processor_5;1225667319000;0;
+mean: 0.9903660886319846
+utlization;compRes/Rack_1/Node_2/Processor_6;1225666800000;0;
+utlization;compRes/Rack_1/Node_2/Processor_6;1225666805000;1;
+utlization;compRes/Rack_1/Node_2/Processor_6;1225667319000;0;
+mean: 0.9903660886319846
+utlization;compRes/Rack_1/Node_2/Processor_7;1225666800000;0;
+utlization;compRes/Rack_1/Node_2/Processor_7;1225667319000;0;
+mean: 0.0
+utlization;compRes/Rack_1/Node_2/Processor_8;1225666800000;0;
+utlization;compRes/Rack_1/Node_2/Processor_8;1225667319000;0;
+mean: 0.0
+utlization;compRes/Rack_1/Node_3/Processor_9;1225666800000;0;
+utlization;compRes/Rack_1/Node_3/Processor_9;1225666804000;1;
+utlization;compRes/Rack_1/Node_3/Processor_9;1225667318000;0;
+utlization;compRes/Rack_1/Node_3/Processor_9;1225667319000;0;
+mean: 0.9903660886319846
+utlization;compRes/Rack_1/Node_3/Processor_10;1225666800000;0;
+utlization;compRes/Rack_1/Node_3/Processor_10;1225667319000;0;
+mean: 0.0
+utlization;compRes/Rack_1/Node_3/Processor_11;1225666800000;0;
+utlization;compRes/Rack_1/Node_3/Processor_11;1225667319000;0;
+mean: 0.0
+utlization;compRes/Rack_1/Node_3/Processor_12;1225666800000;0;
+utlization;compRes/Rack_1/Node_3/Processor_12;1225667319000;0;
+mean: 0.0
Index: DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_Jobs.txt
===================================================================
--- DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_Jobs.txt	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_Jobs.txt	(revision 1375)
@@ -0,0 +1,6 @@
+jobID;meanTaskCompletionTime;meanTaskExecutionTime;meanTaskStartTime;meanTaskFlowTime;meanTaskWaitingTime;meanTaskGQ_WaitingTime;lateness;tardiness;makespan;
+0;515;514;0;514;0;0;0;0;515;
+1;516;514;0;514;0;0;0;0;516;
+2;517;514;0;514;0;0;0;0;517;
+3;518;514;0;514;0;0;0;0;518;
+4;519;514;0;514;0;0;0;0;519;
Index: DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_Metrics.txt
===================================================================
--- DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_Metrics.txt	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_Metrics.txt	(revision 1375)
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
Index: DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_EnergyUsage.txt
===================================================================
--- DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_EnergyUsage.txt	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_EnergyUsage.txt	(revision 1375)
@@ -0,0 +1,18 @@
+powerConsumption;compRes/Rack_1/Node_1;1225666800000;0;
+powerConsumption;compRes/Rack_1/Node_1;1225666801000;80;
+powerConsumption;compRes/Rack_1/Node_1;1225666802000;120;
+powerConsumption;compRes/Rack_1/Node_1;1225667315000;80;
+powerConsumption;compRes/Rack_1/Node_1;1225667316000;0;
+powerConsumption;compRes/Rack_1/Node_1;1225667319000;0;
+mean: 118.92100192678228 sum: 17.144444444444446
+powerConsumption;compRes/Rack_1/Node_2;1225666800000;0;
+powerConsumption;compRes/Rack_1/Node_2;1225666803000;80;
+powerConsumption;compRes/Rack_1/Node_2;1225666805000;120;
+powerConsumption;compRes/Rack_1/Node_2;1225667317000;80;
+powerConsumption;compRes/Rack_1/Node_2;1225667319000;0;
+mean: 118.99807321772639 sum: 17.155555555555555
+powerConsumption;compRes/Rack_1/Node_3;1225666800000;0;
+powerConsumption;compRes/Rack_1/Node_3;1225666804000;80;
+powerConsumption;compRes/Rack_1/Node_3;1225667318000;0;
+powerConsumption;compRes/Rack_1/Node_3;1225667319000;0;
+mean: 79.22928709055877 sum: 11.422222222222222
Index: DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_ResourceUtilization.txt
===================================================================
--- DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_ResourceUtilization.txt	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_ResourceUtilization.txt	(revision 1375)
@@ -0,0 +1,87 @@
+utlization;compRes;1225666800000;0;
+utlization;compRes;1225666801000;0.083;
+utlization;compRes;1225666802000;0.167;
+utlization;compRes;1225666803000;0.25;
+utlization;compRes;1225666804000;0.333;
+utlization;compRes;1225666805000;0.417;
+utlization;compRes;1225667315000;0.333;
+utlization;compRes;1225667316000;0.25;
+utlization;compRes;1225667317000;0.167;
+utlization;compRes;1225667318000;0.083;
+utlization;compRes;1225667319000;0;
+mean: 0.41265253692999354
+utlization;compRes/Rack_1;1225666800000;0;
+utlization;compRes/Rack_1;1225666801000;0.083;
+utlization;compRes/Rack_1;1225666802000;0.167;
+utlization;compRes/Rack_1;1225666803000;0.25;
+utlization;compRes/Rack_1;1225666804000;0.333;
+utlization;compRes/Rack_1;1225666805000;0.417;
+utlization;compRes/Rack_1;1225667315000;0.333;
+utlization;compRes/Rack_1;1225667316000;0.25;
+utlization;compRes/Rack_1;1225667317000;0.167;
+utlization;compRes/Rack_1;1225667318000;0.083;
+utlization;compRes/Rack_1;1225667319000;0;
+mean: 0.41265253692999354
+utlization;compRes/Rack_1/Node_1;1225666800000;0;
+utlization;compRes/Rack_1/Node_1;1225666801000;0.25;
+utlization;compRes/Rack_1/Node_1;1225666802000;0.5;
+utlization;compRes/Rack_1/Node_1;1225667315000;0.25;
+utlization;compRes/Rack_1/Node_1;1225667316000;0;
+utlization;compRes/Rack_1/Node_1;1225667319000;0;
+mean: 0.4951830443159923
+utlization;compRes/Rack_1/Node_2;1225666800000;0;
+utlization;compRes/Rack_1/Node_2;1225666803000;0.25;
+utlization;compRes/Rack_1/Node_2;1225666805000;0.5;
+utlization;compRes/Rack_1/Node_2;1225667317000;0.25;
+utlization;compRes/Rack_1/Node_2;1225667319000;0;
+mean: 0.4951830443159923
+utlization;compRes/Rack_1/Node_3;1225666800000;0;
+utlization;compRes/Rack_1/Node_3;1225666804000;0.25;
+utlization;compRes/Rack_1/Node_3;1225667318000;0;
+utlization;compRes/Rack_1/Node_3;1225667319000;0;
+mean: 0.24759152215799615
+utlization;compRes/Rack_1/Node_1/Processor_1;1225666800000;0;
+utlization;compRes/Rack_1/Node_1/Processor_1;1225666801000;1;
+utlization;compRes/Rack_1/Node_1/Processor_1;1225667315000;0;
+utlization;compRes/Rack_1/Node_1/Processor_1;1225667319000;0;
+mean: 0.9903660886319846
+utlization;compRes/Rack_1/Node_1/Processor_2;1225666800000;0;
+utlization;compRes/Rack_1/Node_1/Processor_2;1225666802000;1;
+utlization;compRes/Rack_1/Node_1/Processor_2;1225667316000;0;
+utlization;compRes/Rack_1/Node_1/Processor_2;1225667319000;0;
+mean: 0.9903660886319846
+utlization;compRes/Rack_1/Node_1/Processor_3;1225666800000;0;
+utlization;compRes/Rack_1/Node_1/Processor_3;1225667319000;0;
+mean: 0.0
+utlization;compRes/Rack_1/Node_1/Processor_4;1225666800000;0;
+utlization;compRes/Rack_1/Node_1/Processor_4;1225667319000;0;
+mean: 0.0
+utlization;compRes/Rack_1/Node_2/Processor_5;1225666800000;0;
+utlization;compRes/Rack_1/Node_2/Processor_5;1225666803000;1;
+utlization;compRes/Rack_1/Node_2/Processor_5;1225667317000;0;
+utlization;compRes/Rack_1/Node_2/Processor_5;1225667319000;0;
+mean: 0.9903660886319846
+utlization;compRes/Rack_1/Node_2/Processor_6;1225666800000;0;
+utlization;compRes/Rack_1/Node_2/Processor_6;1225666805000;1;
+utlization;compRes/Rack_1/Node_2/Processor_6;1225667319000;0;
+mean: 0.9903660886319846
+utlization;compRes/Rack_1/Node_2/Processor_7;1225666800000;0;
+utlization;compRes/Rack_1/Node_2/Processor_7;1225667319000;0;
+mean: 0.0
+utlization;compRes/Rack_1/Node_2/Processor_8;1225666800000;0;
+utlization;compRes/Rack_1/Node_2/Processor_8;1225667319000;0;
+mean: 0.0
+utlization;compRes/Rack_1/Node_3/Processor_9;1225666800000;0;
+utlization;compRes/Rack_1/Node_3/Processor_9;1225666804000;1;
+utlization;compRes/Rack_1/Node_3/Processor_9;1225667318000;0;
+utlization;compRes/Rack_1/Node_3/Processor_9;1225667319000;0;
+mean: 0.9903660886319846
+utlization;compRes/Rack_1/Node_3/Processor_10;1225666800000;0;
+utlization;compRes/Rack_1/Node_3/Processor_10;1225667319000;0;
+mean: 0.0
+utlization;compRes/Rack_1/Node_3/Processor_11;1225666800000;0;
+utlization;compRes/Rack_1/Node_3/Processor_11;1225667319000;0;
+mean: 0.0
+utlization;compRes/Rack_1/Node_3/Processor_12;1225666800000;0;
+utlization;compRes/Rack_1/Node_3/Processor_12;1225667319000;0;
+mean: 0.0
Index: DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_Simulation.txt
===================================================================
--- DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_Simulation.txt	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_Simulation.txt	(revision 1375)
@@ -0,0 +1,14 @@
+Resource name;mean;stdev;variance;minimum;maximum;sum;count;
+Delayed tasks;0;0;0;0;0;0;1;
+Failed requests (tasks);0;0;0;0;0;0;1;
+Makespan;519;0;0;519;519;519;1;
+Resources queue length;0.01;0;0;0.01;0.01;0.01;1;
+Resources total load;0.413;0;0;0.413;0.413;0.413;1;
+Energy usage;15.241;2.7;7.291;11.422;17.156;45.722;3;
+Task completion time;517;1.414;2;515;519;2,585;5;
+Task execution time;514;0;0;514;514;2,570;5;
+Task start time;0;0;0;0;0;0;5;
+Task flow time;514;0;0;514;514;2,570;5;
+Task waiting time;0;0;0;0;0;0;5;
+Task lateness;0;0;0;0;0;0;5;
+Task tardiness;0;0;0;0;0;0;5;
Index: DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_Tasks.txt
===================================================================
--- DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_Tasks.txt	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/migrate_result/Stats_Simulation_1_Tasks.txt	(revision 1375)
@@ -0,0 +1,6 @@
+JobID;TaskID;UserDN;SchedName;CpuCnt;ExecStartDate;ExecFinishDate;ExecEndDate;GB_SubDate;LB_SubDate;CompletionTime;ExecStartTime;ExecutionTime;ReadyTime;StartTime;FlowTime;WaitingTime;GQ_WaitingTime;Lateness;Tardiness;ReservStartDate;ReservFinishDate;HostNames;ProcessorName;Energy;AppName;
+0;0;-1;cluster;1;1225666801;1225667315;1225667315;1225666801;1225666801;515;1;514;1;0;514;0;0;0;0;0;0;[compRes/Rack_1/Node_1];[compRes/Rack_1/Node_1/Processor_1];0;null;
+1;1;-1;cluster;1;1225666802;1225667316;1225667316;1225666802;1225666802;516;2;514;2;0;514;0;0;0;0;0;0;[compRes/Rack_1/Node_1];[compRes/Rack_1/Node_1/Processor_2];0;null;
+2;2;-1;cluster;1;1225666803;1225667317;1225667317;1225666803;1225666803;517;3;514;3;0;514;0;0;0;0;0;0;[compRes/Rack_1/Node_1, compRes/Rack_1/Node_2];[compRes/Rack_1/Node_1/Processor_3, compRes/Rack_1/Node_2/Processor_5];0;null;
+3;3;-1;cluster;1;1225666804;1225667318;1225667318;1225666804;1225666804;518;4;514;4;0;514;0;0;0;0;0;0;[compRes/Rack_1/Node_1, compRes/Rack_1/Node_3];[compRes/Rack_1/Node_1/Processor_3, compRes/Rack_1/Node_3/Processor_9];0;null;
+4;4;-1;cluster;1;1225666805;1225667319;1225667319;1225666805;1225666805;519;5;514;5;0;514;0;0;0;0;0;0;[compRes/Rack_1/Node_1, compRes/Rack_1/Node_2];[compRes/Rack_1/Node_1/Processor_3, compRes/Rack_1/Node_2/Processor_6];0;null;
Index: DCWoRMS/branches/coolemall/src/test/migrate_result/experiment.properties
===================================================================
--- DCWoRMS/branches/coolemall/src/test/migrate_result/experiment.properties	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/migrate_result/experiment.properties	(revision 1375)
@@ -0,0 +1,26 @@
+# Use single *.swf file as workload description.
+
+# Path to xml file which describes resource characteristics.
+resdesc=src/test/migrate/resources1.xml
+
+# and swf file, which name is declared by readscenario.workloadfilename parameter.
+# Swf file must be placed in readscenario.inputfolder directory.  
+readscenario.workloadfilename=src/test/migrate/workload.swf
+
+# Choose directory where all result files should be placed.
+stats.outputfolder=src/test/migrate_result
+
+# Define the type and content of charts to generate
+
+# Gantt chart
+creatediagrams.gantt=true
+
+# Shows the execution times of tasks
+creatediagrams.tasks=true
+
+# Shows the waiting times of tasks
+creatediagrams.taskswaitingtime=true
+
+# Resource utilization chart - only for processors
+creatediagrams.resutilization=Processor
+
Index: DCWoRMS/branches/coolemall/src/test/migrate/resources1.xml
===================================================================
--- DCWoRMS/branches/coolemall/src/test/migrate/resources1.xml	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/migrate/resources1.xml	(revision 1375)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<environment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+	xsi:noNamespaceSchemaLocation="../../simulator/schemas/resources/DCwormsResSchema.xsd">
+
+	<resources>
+		<computingResource class="DataCenter" name="compRes">
+			<computingResource class="Rack" count="1">
+				<computingResource class="Node" count="3">
+					<profile>
+						<powerProfile>
+							<energyEstimationPlugin>
+								<name>test.migrate.NodeEnergyEstimationPlugin</name>
+							</energyEstimationPlugin>
+							<powerStates>
+								<powerState>
+									<name>ON_100</name>
+									<powerUsage>200</powerUsage>
+								</powerState>
+								<powerState>
+									<name>ON_75</name>
+									<powerUsage>160</powerUsage>
+								</powerState>
+								<powerState>
+									<name>ON_50</name>
+									<powerUsage>120</powerUsage>
+								</powerState>
+								<powerState>
+									<name>ON_25</name>
+									<powerUsage>80</powerUsage>
+								</powerState>
+								<powerState>
+									<name>ON</name>
+									<powerUsage>40</powerUsage>
+								</powerState>
+								<powerState>
+									<name>OFF</name>
+									<powerUsage>0</powerUsage>
+								</powerState>
+							</powerStates>				
+						</powerProfile>
+					</profile>
+					<computingResource class="Processor" count="4"/>
+				</computingResource>
+			</computingResource>
+		</computingResource>
+		<scheduler class="Cluster" name="cluster">
+			<schedulingPlugin>
+				<name>test.migrate.FCFSBF_RandomPluginMigrate</name>
+			</schedulingPlugin>	
+			<managedComputingResources include="false">
+				<resourceName>compRes</resourceName>
+			</managedComputingResources>
+		</scheduler>	
+	</resources>
+
+</environment>
Index: DCWoRMS/branches/coolemall/src/test/migrate/NodeEnergyEstimationPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/migrate/NodeEnergyEstimationPlugin.java	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/migrate/NodeEnergyEstimationPlugin.java	(revision 1375)
@@ -0,0 +1,99 @@
+package test.migrate;
+
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.profiles.energy.EnergyEvent;
+import schedframe.resources.computing.profiles.energy.power.PowerState;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.computing.profiles.energy.power.UserPowerStateName;
+import schedframe.resources.devices.PhysicalResource;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import simulator.DataCenterWorkloadSimulator;
+import example.energy.BaseEnergyEstimationPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin {
+
+	private static int POWER_CAP_LEVEL = 150;
+
+	
+	public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry,
+			PhysicalResource resource) {
+		double powerConsumption = 0;
+		Node node = (Node) resource;
+
+		if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON)){
+			powerConsumption = getPowerConsumption(node);
+		} 
+		if(powerConsumption > POWER_CAP_LEVEL ){
+			DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.POWER_LIMIT_EXCEEDED, node.getFullName());
+		}
+System.out.println("power: " + node.getFullName()  + "; " + powerConsumption);
+		return powerConsumption;
+	}
+	
+	public double getPowerConsumption(Node node){
+		double powerConsumption = 0;
+		double loadLevel = node.getLoadInterface().getRecentUtilization().getValue();
+		double lowestLoadLevel = 100;
+		double highestLoadLevel = 0;
+		try{
+			if(node.getPowerInterface().getSupportedPowerStates().contains(new UserPowerStateName("ON_" + new Double(loadLevel).intValue()))){
+				powerConsumption = node.getPowerInterface().getPowerConsumption(new UserPowerStateName("ON_" + new Double(loadLevel).intValue()));
+			} else {
+				for(PowerState powerState: node.getPowerInterface().getSupportedPowerStates()){
+					Double load;
+					try{
+						load = Double.valueOf(powerState.getName().getName().substring(3));
+					}catch (Exception e){
+						continue;
+					}
+					if(lowestLoadLevel > load){
+						lowestLoadLevel = load;
+					}
+					if(highestLoadLevel < load){
+						highestLoadLevel = load;
+					}
+				}
+				if(loadLevel == 0){
+					powerConsumption = node.getPowerInterface().getPowerConsumption(new UserPowerStateName("ON_0"));
+				} else {
+					
+					double lowerLoadLevel = lowestLoadLevel;
+					double higherLoadLevel = highestLoadLevel;
+
+					for(PowerState powerState: node.getPowerInterface().getSupportedPowerStates()){
+						Double load = Double.valueOf(powerState.getName().getName().substring(3));
+						if(loadLevel > load){
+							lowerLoadLevel = load;
+						}
+						else if(loadLevel < load){
+							higherLoadLevel = load;
+							break;
+						}
+					}
+					double powerBelow;
+					double powerAbove;
+					double a;
+					double b;
+					if(lowerLoadLevel != higherLoadLevel) {
+						powerBelow = node.getPowerInterface().getPowerConsumption(new UserPowerStateName("ON_" + new Double(lowerLoadLevel).intValue()));
+						powerAbove = node.getPowerInterface().getPowerConsumption(new UserPowerStateName("ON_" + new Double(higherLoadLevel).intValue()));
+						a = (powerAbove - powerBelow)/(higherLoadLevel - lowerLoadLevel);
+						b = powerAbove - a * higherLoadLevel;
+					} else {
+						powerBelow = node.getPowerInterface().getPowerConsumption(new UserPowerStateName("ON_" + new Double(lowestLoadLevel).intValue()));
+						powerAbove = node.getPowerInterface().getPowerConsumption(new UserPowerStateName("ON_" + new Double(highestLoadLevel).intValue()));
+						a = (powerAbove - powerBelow)/(highestLoadLevel - lowestLoadLevel);
+						b = powerAbove - a * highestLoadLevel;
+					}
+					powerConsumption = a * loadLevel + b;
+				}
+			}
+		} catch (Exception e){
+			
+		}
+	
+		return powerConsumption;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/migrate/experiment1.properties
===================================================================
--- DCWoRMS/branches/coolemall/src/test/migrate/experiment1.properties	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/migrate/experiment1.properties	(revision 1375)
@@ -0,0 +1,26 @@
+# Use single *.swf file as workload description.
+
+# Path to xml file which describes resource characteristics.
+resdesc=src/test/migrate/resources1.xml
+
+# and swf file, which name is declared by readscenario.workloadfilename parameter.
+# Swf file must be placed in readscenario.inputfolder directory.  
+readscenario.workloadfilename=src/test/migrate/workload.swf
+
+# Choose directory where all result files should be placed.
+stats.outputfolder=src/test/migrate_result
+
+# Define the type and content of charts to generate
+
+# Gantt chart
+creatediagrams.gantt=true
+
+# Shows the execution times of tasks
+creatediagrams.tasks=true
+
+# Shows the waiting times of tasks
+creatediagrams.taskswaitingtime=true
+
+# Resource utilization chart - only for processors
+creatediagrams.resutilization=Processor
+
Index: DCWoRMS/branches/coolemall/src/test/migrate/workload.swf
===================================================================
--- DCWoRMS/branches/coolemall/src/test/migrate/workload.swf	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/migrate/workload.swf	(revision 1375)
@@ -0,0 +1,18 @@
+;Automatically generated workload description by the Grid Scheduling Simulator																																				
+;		j|		s|		w|		r|		c|		c|		m|		p|		t|		m|		s|		u|		g|		e|		q|		p|		p|		t|
+;		o|		u|		a|		u|		p|		p|		e|		r|		i|		e|		t|		i|		i|		x|		u|		a|		r|		h|
+;		b|		b|		i|		n|		u|		u|		m|		o|		m|		m|		a|		d|		d|		e|		e|		r|		e|		i|
+;		 |		m|		t|		t|		 |		 |		 |		c|		e|		 |		t|		 |		 |		c|		u|		t|		c|		n|
+;		 |		i|		 |		i|		a|		t|		u|		 |		 |		r|		u|		 |		 |		u|		e|		i|		 |		k|
+;		 |		t|		 |		m|		l|		i|		s|		r|		r|		e|		s|		 |		 |		t|		 |		t|		j|		 |
+;		 |		 |		 |		e|		l|		m|		e|		e|		e|		q|		 |		 |		 |		a|		n|		i|		o|		t|
+;		 |		 |		 |		 |		o|		e|		d|		q|		q|		 |		 |		 |		 |		b|		r|		o|		b|		i|
+;		 |		 |		 |		 |		c|		 |		 |		 |		 |		 |		 |		 |		 |		l|		 |		n|		 |		m|
+;		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		 |		e|		 |		 |		 |		e|
+;StartTime: Mon Nov 03 00:00:00 CET 2008																																				
+;PUSpeed: 1																																				
+		0		1		-1		514		1		-1		-1		1		514		-1		-1		-1		-1		-1		-1		-1		-1		-1
+		1		2		-1		514		1		-1		-1		1		514		-1		-1		-1		-1		-1		-1		-1		-1		-1
+		2		3		-1		514		1		-1		-1		1		514		-1		-1		-1		-1		-1		-1		-1		-1		-1
+		3		4		-1		514		1		-1		-1		1		514		-1		-1		-1		-1		-1		-1		-1		-1		-1
+		4		5		-1		514		1		-1		-1		1		514		-1		-1		-1		-1		-1		-1		-1		-1		-1
Index: DCWoRMS/branches/coolemall/src/test/migrate/FCFSBF_RandomPluginMigrate.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/migrate/FCFSBF_RandomPluginMigrate.java	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/migrate/FCFSBF_RandomPluginMigrate.java	(revision 1375)
@@ -0,0 +1,141 @@
+package test.migrate;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Node;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.units.ProcessingElements;
+import schedframe.resources.units.ResourceUnit;
+import schedframe.resources.units.ResourceUnitName;
+import schedframe.resources.units.StandardResourceUnitName;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import dcworms.schedframe.scheduling.ExecTask;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class FCFSBF_RandomPluginMigrate extends BaseLocalSchedulingPlugin {
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		List<Processor> processors = resourceManager.getProcessors();
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			// check all tasks in queue
+
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(processors, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					} 
+				}
+			}
+			break;
+		case POWER_LIMIT_EXCEEDED:
+			String src = event.getSource();
+			optimizeEnergyUsage(jobRegistry, resourceManager , src);
+			break;
+
+		}
+		
+		return plan;
+	}
+
+	private void optimizeEnergyUsage(JobRegistry jobRegistry, ClusterResourceManager resourceManager, String resName) {
+		Node overLoadedNode = (Node)resourceManager .getResourceByName(resName);
+		Node leastLoadedNode = findLeastLoadedResource(resourceManager.getNodes());
+		
+		if(leastLoadedNode.getLoadInterface().getRecentUtilization().getValue() >= overLoadedNode.getLoadInterface().getRecentUtilization().getValue()){
+			return;
+		}
+
+		JobRegistry srcHostJr = new JobRegistryImpl(overLoadedNode.getFullName());
+		int runningTasksNumber = srcHostJr.getRunningTasks().size();
+		for(int i = srcHostJr.getRunningTasks().size() - 1; i >= 0 && runningTasksNumber > 2; i--) {
+			ExecTask execTask = srcHostJr.getRunningTasks().get(i);
+			Map<ResourceUnitName, ResourceUnit> destinationResources = chooseResourcesForExecution(findLeastLoadedResource(resourceManager.getNodes()).getProcessors(), execTask);
+			jobRegistry.migrateTask(execTask.getJobId(), execTask.getId(), destinationResources);
+			runningTasksNumber--;
+		}
+	}
+
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			List<Processor> processors, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(1);
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			if (processors.size() < cpuRequest) {
+				return null;
+			}
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(cpuRequest);				
+			for (int i = 0; i < processors.size() && cpuRequest > 0; i++) {
+				if (processors.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(processors.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+
+		return null;
+	}
+
+	private Node findLeastLoadedResource(List<Node> nodes ){
+		Node leastLoadedNoded = null;
+		double minLoad = Double.MAX_VALUE;
+		
+		for(int i = 0; i < nodes.size(); i++){
+			Node node = nodes.get(i);
+			double totalLoad = node.getLoadInterface().getRecentUtilization().getValue();
+			if(totalLoad < minLoad){
+				leastLoadedNoded= node;
+				minLoad = totalLoad;
+			}
+		}
+		return leastLoadedNoded;
+	}
+
+}
Index: DCWoRMS/branches/coolemall/src/test/migrate/RunExperiment.java
===================================================================
--- DCWoRMS/branches/coolemall/src/test/migrate/RunExperiment.java	(revision 1375)
+++ DCWoRMS/branches/coolemall/src/test/migrate/RunExperiment.java	(revision 1375)
@@ -0,0 +1,19 @@
+package test.migrate;
+import simulator.DataCenterWorkloadSimulator;
+
+
+public class RunExperiment {
+	
+	public static void main(String args[]){
+		RunExperiment runner = new RunExperiment();
+		runner.run();
+	}
+	
+	public void run(){
+		String args[] = {
+				"src/test/migrate/experiment1.properties"
+				};
+		DataCenterWorkloadSimulator.main(args);
+	}
+
+}
