Index: DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessNodePowManSP.java
===================================================================
--- DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessNodePowManSP.java	(revision 663)
+++ DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessNodePowManSP.java	(revision 663)
@@ -0,0 +1,176 @@
+package test.article.recs.plugins.scheduling;
+
+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.ComputingNode;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+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.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class RecsExclusivenessNodePowManSP extends BaseLocalSchedulingPlugin {
+
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+
+			TaskQueue q = queues.get(0);
+
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources  != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					} else {
+						if(harnessIdleNodesToWork(task, resourceManager.getComputingNodes()))
+							i--;
+					}
+				}
+			}
+			turnOffIdleNodes(resourceManager.getComputingNodes());
+			break;
+		}
+		return plan;
+	}
+	
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<ComputingNode> nodes = resourceManager.getComputingNodes();
+		List<ComputingNode> avNodes = filterNodes(nodes, task);
+		if(avNodes.size() == 0)
+			return null;
+
+		for(ComputingNode node: avNodes){
+			int cpuRequest;
+			try {
+				cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+			} catch (NoSuchFieldException e) {
+				cpuRequest = 0;
+			}
+	
+			if (cpuRequest != 0) {
+	
+				List<Core> cores = node.getProcessors().get(0).getCores();
+				List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();				
+				for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+					if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+						choosenResources.add(cores.get(i));
+						cpuRequest--;
+					}
+				}
+				if (cpuRequest > 0) {
+					continue;
+				}
+				ProcessingElements pe = new ProcessingElements();
+				pe.addAll(choosenResources);
+				map.put(StandardResourceUnitName.PE, pe);
+				return map;
+			}
+		}
+		return null;
+	}
+
+	private void turnOffIdleNodes(List<ComputingNode> nodes){
+		for(ComputingNode node : nodes){
+			Processor proc = node.getProcessors().get(0);
+			int freeCores = 0;
+			for(Core core: proc.getCores()){
+				if(core.getStatus() == ResourceStatus.FREE)
+					freeCores++;
+			}
+			
+			if(freeCores == proc.getCores().size())
+				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
+	
+		}
+	}
+	
+	private boolean harnessIdleNodesToWork(TaskInterface<?> task, List<ComputingNode> nodes){
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (int i = 0; i < nodes.size(); i++) {
+			ComputingNode node = nodes.get(i);
+			if(node.getPowerInterface().getPowerState() == StandardPowerStateName.OFF){
+
+				List<Core> cores = node.getProcessors().get(0).getCores();
+				if (cores.size() < cpuRequest) {
+					continue;
+				}
+				node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
+				return true;
+			}
+		}
+		return false;
+	}
+
+	
+	private List<ComputingNode> filterNodes(List<ComputingNode> nodes, TaskInterface<?> task){
+		List<ComputingNode> filteredNodes = new ArrayList<ComputingNode>();
+		for (ComputingNode node : nodes) {
+			int cpuRequest;
+			try {
+				cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+			} catch (NoSuchFieldException e) {
+				cpuRequest = 0;
+			}
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getProcessors().get(0).getCores();
+				if (cores.size() < cpuRequest) {
+					continue;
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores != cores.size())
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+}
Index: DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessDFSSP.java
===================================================================
--- DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessDFSSP.java	(revision 663)
+++ DCWoRMS/trunk/src/test/article/recs/plugins/scheduling/RecsExclusivenessDFSSP.java	(revision 663)
@@ -0,0 +1,163 @@
+package test.article.recs.plugins.scheduling;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.computing.ComputingNode;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+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.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 test.article.recs.utils.RecsProcessorPowerInterface;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class RecsExclusivenessDFSSP extends BaseLocalSchedulingPlugin {
+
+	private Random rand = new Random(5);
+	
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// our tasks are placed only in first queue (see
+		// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+		TaskQueue q = queues.get(0);
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+			// 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(resourceManager, task);
+					if (choosenResources  != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					} 
+				}
+			}
+			adjustFrequency(resourceManager.getProcessors());
+		}
+		return plan;
+	}
+	
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<ComputingNode> nodes = resourceManager.getComputingNodes();
+		List<ComputingNode> avNodes = filterNodes(nodes, task);
+		if(avNodes.size() == 0)
+			return null;
+		ComputingNode node = randomNode(avNodes);
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<Core> cores = node.getProcessors().get(0).getCores();
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();				
+			for (int i = 0; i < cores.size() && cpuRequest > 0; i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					choosenResources.add(cores.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 List<ComputingNode> filterNodes(List<ComputingNode> nodes, TaskInterface<?> task){
+		List<ComputingNode> filteredNodes = new ArrayList<ComputingNode>();
+		for (ComputingNode node : nodes) {
+			int cpuRequest;
+			try {
+				cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+			} catch (NoSuchFieldException e) {
+				cpuRequest = 0;
+			}
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getProcessors().get(0).getCores();
+				if (cores.size() < cpuRequest) {
+					continue;
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores != cores.size())
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private ComputingNode randomNode(List<ComputingNode> nodes){
+		return nodes.get(rand.nextInt(nodes.size()));
+	}
+	
+	
+	private void adjustFrequency(List<Processor> processors){
+
+		for(Processor cpu: processors){
+			RecsProcessorPowerInterface rppi = (RecsProcessorPowerInterface) cpu.getPowerInterface();
+			int freeCores = 0;
+
+			for(Core core: cpu.getCores()){
+				if(core.getStatus() == ResourceStatus.FREE)
+					freeCores++;
+			}
+			if(freeCores == cpu.getCores().size())
+				rppi.setPState(rppi.getHighestPState().getName());
+			else
+				rppi.setPState(rppi.getLowestPState().getName());
+
+		}
+	}
+
+}
