Index: DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_RandomClusterPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_RandomClusterPlugin.java	(revision 574)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_RandomClusterPlugin.java	(revision 1207)
@@ -61,5 +61,5 @@
 		List<ComputingNode> nodes = resourceManager.getComputingNodes();
 		int nodeIdx = rand.nextInt(nodes.size());
-		return nodes.get(nodeIdx).getName();
+		return nodes.get(nodeIdx).getFullName();
 	}
 
Index: DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_FanManagementClusterPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_FanManagementClusterPlugin.java	(revision 778)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_FanManagementClusterPlugin.java	(revision 1207)
@@ -8,7 +8,9 @@
 
 import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingNode;
 import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName;
 import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.devices.Device;
 import schedframe.scheduling.manager.resources.ClusterResourceManager;
 import schedframe.scheduling.manager.resources.ResourceManager;
@@ -54,10 +56,22 @@
 					if (node != null) {
 						//if there are two or more tasks ( running on the given node then
-						if(new JobRegistryImpl(node.getName()).getRunningTasks().size() > 0)
-							node.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO"));
-						else 
-							node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON);
+						if(new JobRegistryImpl(node.getFullName()).getRunningTasks().size() > 0){
+							List<Device> devices = node.getResourceCharacteristic().getDevices();
+							for(Device dev : devices){
+								if(dev.getType().equals(StandardResourceType.Fan)){
+									dev.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO"));
+								}
+							}
+						}
+						else {
+							List<Device> devices = node.getResourceCharacteristic().getDevices();
+							for(Device dev : devices){
+								if(dev.getType().equals(StandardResourceType.Fan)){
+									dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.ON);	
+								}
+							}
+						}
 						notSelectedNodes.remove(node);
-						addToSchedulingPlan(plan, task, node.getName());
+						addToSchedulingPlan(plan, task, node.getFullName());
 					}
 				}
@@ -98,10 +112,25 @@
 	private void adjustOtherFans(List<ComputingNode> nodes){
 		for(ComputingNode node : nodes){
+			List<Device> devices = node.getResourceCharacteristic().getDevices();
 			if(node.getFreeProcessorsNumber() == node.getProcessorsNumber()){
-				node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_OFF);
-			} else if(new JobRegistryImpl(node.getName()).getRunningTasks().size() > 1)
-				node.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO"));
-			else 
-				node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON);
+				for(Device dev : devices){
+					if(dev.getType().equals(StandardResourceType.Fan)){
+						dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.OFF);
+					}
+				}
+			} else if(new JobRegistryImpl(node.getFullName()).getRunningTasks().size() > 1){
+				for(Device dev : devices){
+					if(dev.getType().equals(StandardResourceType.Fan)){
+						dev.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO"));
+					}
+				}
+			}
+			else {
+				for(Device dev : devices){
+					if(dev.getType().equals(StandardResourceType.Fan)){
+						dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.ON);
+					}
+				}
+			}
 		}
 	}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ConsolidationClusterPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ConsolidationClusterPlugin.java	(revision 574)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ConsolidationClusterPlugin.java	(revision 1207)
@@ -98,5 +98,5 @@
 				}
 			}
-			ProcessingElements result = new ProcessingElements(node.getName());
+			ProcessingElements result = new ProcessingElements(node.getFullName());
 			result.addAll(choosenResources);
 			map.put(StandardResourceUnitName.PE, result);
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_SP.java	(revision 1207)
@@ -0,0 +1,218 @@
+package example.localplugin.coolemall.computebox1;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.coolemall.Node;
+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 testbed_hpc.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB1_FCFS_Consolidation_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB1_FCFS_Consolidation_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		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(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = null;
+		try {
+			nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		List<Node> avNodes = filterNodes(nodes, task);
+		Collections.sort(avNodes, new FavourableNodeComparator());
+		if(avNodes.size() == 0)
+			return null;
+		Node node = findTheMostLoadedNode(avNodes);
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			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;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 1;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 1;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_NodePowMan_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_NodePowMan_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Consolidation_NodePowMan_SP.java	(revision 1207)
@@ -0,0 +1,341 @@
+package example.localplugin.coolemall.computebox1;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.Device;
+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 testbed_hpc.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB1_FCFS_Consolidation_NodePowMan_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB1_FCFS_Consolidation_NodePowMan_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		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);
+			
+			List<Node> notSelectedNodes = null;
+			try {
+				notSelectedNodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+			} catch (ResourceException e) {
+			}
+			
+			// 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);
+						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
+						Node node = (Node) pe.get(0).getParent().getParent();
+						notSelectedNodes.remove(node);
+					}
+				}
+			}
+			manageResources(notSelectedNodes);
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = null;
+		try {
+			nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		List<Node> avNodes = filterNodes(nodes, task);
+		Node node;
+		if(avNodes.size() == 0){
+			try {
+				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			Collections.sort(nodes, new FavourableNodeComparator());
+			node = turnOnFirstNode(nodes, task);
+			if(node == null)
+				return null;
+		} else {
+			Collections.sort(avNodes, new FavourableNodeComparator());
+			node = findTheMostLoadedNode(avNodes);			
+		}
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			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;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
+		Node startedNode = null;
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		
+		for(Node node: nodes){
+			
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+				
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE || core.getStatus() == ResourceStatus.UNAVAILABLE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				else {
+					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+						if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+							device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+							break;
+						}
+					}
+					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
+					startedNode = node;
+					break;
+				}				
+			}
+		}
+		return startedNode;
+	}
+	
+	protected void manageResources(List<Node> notSelectedNodes) {
+		turnOffIdleNodes(notSelectedNodes);
+		//adjustFans(notSelectedNodes);
+	
+	}
+
+	private void turnOffIdleNodes(List<Node> nodes){
+		for(Node 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()) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
+			}
+
+		}
+	}
+
+	/*private void adjustFans(List<Node> nodes) {
+		for (Node node : nodes) {
+
+			if (node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+			} else {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+						break;
+					}
+				}
+			}
+		}
+	}
+	*/
+	
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 1;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 1;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationAtom_NodePowMan_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationAtom_NodePowMan_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_ConsolidationAtom_NodePowMan_SP.java	(revision 1207)
@@ -0,0 +1,341 @@
+package example.localplugin.coolemall.computebox1;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.Device;
+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 testbed_hpc.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB1_FCFS_ConsolidationAtom_NodePowMan_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB1_FCFS_ConsolidationAtom_NodePowMan_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		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);
+			
+			List<Node> notSelectedNodes = null;
+			try {
+				notSelectedNodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+			} catch (ResourceException e) {
+			}
+			
+			// 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);
+						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
+						Node node = (Node) pe.get(0).getParent().getParent();
+						notSelectedNodes.remove(node);
+					}
+				}
+			}
+			manageResources(notSelectedNodes);
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = null;
+		try {
+			nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		List<Node> avNodes = filterNodes(nodes, task);
+		Node node;
+		if(avNodes.size() == 0){
+			try {
+				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			Collections.sort(nodes, new FavourableNodeComparator());
+			node = turnOnFirstNode(nodes, task);
+			if(node == null)
+				return null;
+		} else {
+			Collections.sort(avNodes, new FavourableNodeComparator());
+			node = findTheMostLoadedNode(avNodes);			
+		}
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			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;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
+		Node startedNode = null;
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		
+		for(Node node: nodes){
+			
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+				
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE || core.getStatus() == ResourceStatus.UNAVAILABLE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				else {
+					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+						if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+							device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+							break;
+						}
+					}
+					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
+					startedNode = node;
+					break;
+				}				
+			}
+		}
+		return startedNode;
+	}
+	
+	protected void manageResources(List<Node> notSelectedNodes) {
+		turnOffIdleNodes(notSelectedNodes);
+		//adjustFans(notSelectedNodes);
+	
+	}
+
+	private void turnOffIdleNodes(List<Node> nodes){
+		for(Node 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()) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
+			}
+
+		}
+	}
+
+	/*private void adjustFans(List<Node> nodes) {
+		for (Node node : nodes) {
+
+			if (node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+			} else {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+						break;
+					}
+				}
+			}
+		}
+	}
+	*/
+	
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 2;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 1;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 4;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 5;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 2;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 1;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 4;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 5;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_LoadBalancing_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_LoadBalancing_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_LoadBalancing_SP.java	(revision 1207)
@@ -0,0 +1,89 @@
+package example.localplugin.coolemall.computebox1;
+
+import java.util.List;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.coolemall.Node;
+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 example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB1_FCFS_LoadBalancing_SP extends BaseLocalSchedulingPlugin {
+
+	public CB1_FCFS_LoadBalancing_SP () {
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		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:
+			// 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) {
+
+					String nodeName = chooseProvider(resourceManager);
+					if (nodeName != null) {
+						addToSchedulingPlan(plan, task, nodeName);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private String chooseProvider(ClusterResourceManager resourceManager) {
+		List<ComputingResource> nodes = null;
+		try {
+			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		int nodeIdx = findLeastLoadedResourceIdx(nodes);
+		return nodes.get(nodeIdx).getFullName();
+	}
+	
+	private int findLeastLoadedResourceIdx(List<ComputingResource> nodes ){
+		int resourceIdx = -1;
+		int minLoad = Integer.MAX_VALUE;
+		
+		for(int i = 0; i < nodes.size(); i++){
+			Node node = (Node) nodes.get(i);
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			int totalLoad = jr.getRunningTasks().size(); 
+			if(totalLoad < minLoad){
+				resourceIdx = i;
+				minLoad = totalLoad;
+			}
+		}
+		return resourceIdx;
+	}
+
+}
+
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Random_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Random_SP.java	(revision 1099)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Random_SP.java	(revision 1207)
@@ -1,11 +1,21 @@
 package example.localplugin.coolemall.computebox1;
 
+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.exceptions.ResourceException;
-import schedframe.resources.CoolEmAllResourceType;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.coolemall.Node;
+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;
@@ -17,4 +27,5 @@
 import schedframe.scheduling.queue.TaskQueueList;
 import schedframe.scheduling.tasks.TaskInterface;
+import testbed_hpc.Node_Fan_Mapping;
 import example.localplugin.BaseLocalSchedulingPlugin;
 import gridsim.dcworms.DCWormsTags;
@@ -26,4 +37,5 @@
 	public CB1_FCFS_Random_SP () {
 		rand = new Random(47);
+		Node_Fan_Mapping.init();
 	}
 
@@ -49,7 +61,7 @@
 				if (task.getStatus() == DCWormsTags.READY) {
 
-					String nodeName = chooseRandomProvider(resourceManager);
-					if (nodeName != null) {
-						addToSchedulingPlan(plan, task, nodeName);
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
 					}
 				}
@@ -61,14 +73,88 @@
 
 	@SuppressWarnings("unchecked")
-	private String chooseRandomProvider(ClusterResourceManager resourceManager) {
-		List<ComputingResource> nodes = null;
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = null;
 		try {
-			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node);
+			nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
 		} catch (ResourceException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
-		int nodeIdx = rand.nextInt(nodes.size());
-		return nodes.get(nodeIdx).getName();
+		List<Node> avNodes = filterNodes(nodes, task);
+		if(avNodes.size() == 0)
+			return null;
+		Node node = randomNode(avNodes);
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			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;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node randomNode(List<Node> nodes){
+		return nodes.get(rand.nextInt(nodes.size()));
 	}
 
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/FCFSBF_RECS_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/FCFSBF_RECS_SP.java	(revision 1100)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/FCFSBF_RECS_SP.java	(revision 1207)
@@ -6,5 +6,5 @@
 import schedframe.events.scheduling.SchedulingEvent;
 import schedframe.exceptions.ResourceException;
-import schedframe.resources.CoolEmAllResourceType;
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
 import schedframe.scheduling.manager.resources.ClusterResourceManager;
@@ -64,5 +64,5 @@
 		List<ComputingResource> nodes = null;
 		try {
-			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node);
+			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(StandardResourceType.Node);
 		} catch (ResourceException e) {
 			// TODO Auto-generated catch block
@@ -70,5 +70,5 @@
 		}
 		int nodeIdx = rand.nextInt(nodes.size());
-		return nodes.get(nodeIdx).getName();
+		return nodes.get(nodeIdx).getFullName();
 	}
 
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_SP.java	(revision 1207)
@@ -0,0 +1,219 @@
+package example.localplugin.coolemall.computebox2;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.coolemall.Node;
+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 testbed_hpc.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB2_FCFS_Consolidation_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB2_FCFS_Consolidation_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		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(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = null;
+		try {
+			nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		List<Node> avNodes = filterNodes(nodes, task);
+		Collections.sort(avNodes, new FavourableNodeComparator());
+		if(avNodes.size() == 0)
+			return null;
+		Node node = findTheMostLoadedNode(avNodes);
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			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;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 1;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 1;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_NodePowMan_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_NodePowMan_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Consolidation_NodePowMan_SP.java	(revision 1207)
@@ -0,0 +1,341 @@
+package example.localplugin.coolemall.computebox2;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.Node;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
+import schedframe.resources.devices.Device;
+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 testbed_hpc.Node_Fan_Mapping;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB2_FCFS_Consolidation_NodePowMan_SP extends BaseLocalSchedulingPlugin {
+
+	
+	public CB2_FCFS_Consolidation_NodePowMan_SP () {
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		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);
+			
+			List<Node> notSelectedNodes = null;
+			try {
+				notSelectedNodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+			} catch (ResourceException e) {
+			}
+			
+			// 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);
+						ProcessingElements pe = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
+						Node node = (Node) pe.get(0).getParent().getParent();
+						notSelectedNodes.remove(node);
+					}
+				}
+			}
+			manageResources(notSelectedNodes);
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = null;
+		try {
+			nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		List<Node> avNodes = filterNodes(nodes, task);
+		Node node;
+		if(avNodes.size() == 0){
+			try {
+				nodes = (List<Node>) resourceManager.getResourcesByTypeWithStatus(StandardResourceType.Node, ResourceStatus.UNAVAILABLE);
+			} catch (ResourceException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			Collections.sort(nodes, new FavourableNodeComparator());
+			node = turnOnFirstNode(nodes, task);
+			if(node == null)
+				return null;
+		} else {
+			Collections.sort(avNodes, new FavourableNodeComparator());
+			node = findTheMostLoadedNode(avNodes);			
+		}
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			List<Core> cores = node.getCores();			
+			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;
+			}
+			//choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node findTheMostLoadedNode(List<Node> nodes){
+		Node mostLoadedNode = null;
+			
+		int maxRunningTask = -1;
+		int nrRunningTasks;
+		for(Node node: nodes){
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			nrRunningTasks = jr.getRunningTasks().size(); 
+			if(nrRunningTasks > maxRunningTask){
+				mostLoadedNode = node;
+				maxRunningTask = nrRunningTasks;
+			}
+		}
+		return mostLoadedNode;
+	}
+	
+	private Node turnOnFirstNode(List<Node> nodes, TaskInterface<?> task){
+		Node startedNode = null;
+
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		
+		for(Node node: nodes){
+			
+			if (cpuRequest != 0) {
+
+				List<Core> cores = node.getCores();
+				if (cores.size() < cpuRequest) {
+					if(cores.size() == 0){
+						if(node.getProcessors().size() < cpuRequest)
+							continue;
+					}
+				}
+				
+				int freeCores = 0;
+				for(Core core: cores){
+					if(core.getStatus() == ResourceStatus.FREE || core.getStatus() == ResourceStatus.UNAVAILABLE)
+						freeCores++;
+				}
+				
+				if(freeCores < cpuRequest)
+					continue;
+				else {
+					for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+						if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+							device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+							break;
+						}
+					}
+					node.getPowerInterface().setPowerState(StandardPowerStateName.ON);
+					startedNode = node;
+					break;
+				}				
+			}
+		}
+		return startedNode;
+	}
+	
+	protected void manageResources(List<Node> notSelectedNodes) {
+		turnOffIdleNodes(notSelectedNodes);
+		//adjustFans(notSelectedNodes);
+	
+	}
+
+	private void turnOffIdleNodes(List<Node> nodes){
+		for(Node 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()) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
+			}
+
+		}
+	}
+
+	/*private void adjustFans(List<Node> nodes) {
+		for (Node node : nodes) {
+
+			if (node.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("1"));
+						break;
+					}
+				}
+			} else {
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("2"));
+						break;
+					}
+				}
+			}
+		}
+	}
+	*/
+	
+	class FavourableNodeComparator implements Comparator<Node>{
+		
+	    public int compare(Node node1, Node node2){    
+	    	double node1Rank = Double.MAX_VALUE;
+	    	double node2Rank = Double.MAX_VALUE;
+	    	
+	    	try {
+				String productName = node1.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node1Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node1Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node1Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node1Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node1Rank = 1;
+			} catch (Exception e){
+				
+			}
+	    	try {
+				String productName = node2.getProcessors().get(0).getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+				if(productName.equals("Fusion G - T40N"))
+					node2Rank = 3;
+				else if(productName.equals("Atom - D510"))
+					node2Rank = 4;
+				else if(productName.equals("Atom - N2600"))
+					node2Rank = 5;
+				else if(productName.equals("Core i7 - 2715QE"))
+					node2Rank = 2;
+				else if(productName.equals("Core i7 - 3615QE"))
+					node2Rank = 1;
+			} catch (Exception e){
+				
+			}
+	        if(node1Rank > node2Rank)
+	        	return 1;
+	        else if (node1Rank < node2Rank)
+	        	return -1;
+	        else return 0;	   
+	    }
+	}
+	
+}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_LoadBalancing_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_LoadBalancing_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_LoadBalancing_SP.java	(revision 1207)
@@ -0,0 +1,89 @@
+package example.localplugin.coolemall.computebox2;
+
+import java.util.List;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.coolemall.Node;
+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 example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB2_FCFS_LoadBalancing_SP extends BaseLocalSchedulingPlugin {
+
+	public CB2_FCFS_LoadBalancing_SP () {
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		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:
+			// 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) {
+
+					String nodeName = chooseProvider(resourceManager);
+					if (nodeName != null) {
+						addToSchedulingPlan(plan, task, nodeName);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private String chooseProvider(ClusterResourceManager resourceManager) {
+		List<ComputingResource> nodes = null;
+		try {
+			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		int nodeIdx = findLeastLoadedResourceIdx(nodes);
+		return nodes.get(nodeIdx).getFullName();
+	}
+	
+	private int findLeastLoadedResourceIdx(List<ComputingResource> nodes ){
+		int resourceIdx = -1;
+		int minLoad = Integer.MAX_VALUE;
+		
+		for(int i = 0; i < nodes.size(); i++){
+			Node node = (Node) nodes.get(i);
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
+			int totalLoad = jr.getRunningTasks().size(); 
+			if(totalLoad < minLoad){
+				resourceIdx = i;
+				minLoad = totalLoad;
+			}
+		}
+		return resourceIdx;
+	}
+
+}
+
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Random_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Random_SP.java	(revision 1207)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Random_SP.java	(revision 1207)
@@ -0,0 +1,180 @@
+package example.localplugin.coolemall.computebox2;
+
+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.exceptions.ResourceException;
+import schedframe.resources.StandardResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.Node;
+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 schedframe.scheduling.tasks.phases.PhaseBehaviour;
+import testbed_hpc.Node_Fan_Mapping;
+import dcworms.schedframe.scheduling.ExecTask;
+import example.energy.coolemall.CoolEmAllTestbedMeasurements;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class CB2_FCFS_Random_SP extends BaseLocalSchedulingPlugin {
+
+	private Random rand;
+	
+	public CB2_FCFS_Random_SP () {
+		rand = new Random(47);
+		Node_Fan_Mapping.init();
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		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(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<Node> nodes = null;
+		try {
+			nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		List<Node> avNodes = filterNodes(nodes, task);
+		if(avNodes.size() == 0)
+			return null;
+		Node node = randomNode(avNodes);
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+
+		if (cpuRequest != 0) {
+
+			List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();	
+			
+			choosenResources.add(node.getProcessors().get(0));
+			ProcessingElements pe = new ProcessingElements();
+			pe.addAll(choosenResources);
+			map.put(StandardResourceUnitName.PE, pe);
+			return map;
+		}
+		return null;
+	}
+	
+	private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){
+		List<Node> filteredNodes = new ArrayList<Node>();
+		int cpuRequest;
+		try {
+			cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();
+		} catch (NoSuchFieldException e) {
+			cpuRequest = 0;
+		}
+		for (Node node : nodes) {
+
+			if (cpuRequest != 0) {
+
+				double sumLoad = 0;
+				Processor proc = node.getProcessors().get(0);
+				JobRegistry jr = new JobRegistryImpl(proc.getFullName());
+				for(ExecTask execTask: jr.getRunningTasks()){
+					double cpuUsage = 100;
+					double nrOfThreadsOfApplciation = 1;
+					for(PhaseBehaviour pb: execTask.getCurrentResourceConsumption().getBehaviourList()){
+						if(pb.getResouceName().equals("PM_CPU_Usage")){
+							cpuUsage = pb.getUtilization();
+						}
+						if(pb.getResouceName().equals("PM_Threads")){
+							nrOfThreadsOfApplciation = pb.getUtilization();
+							break;
+						}
+					}
+					sumLoad = sumLoad + nrOfThreadsOfApplciation;
+				}
+
+				int nrOfThreadsOnCpu = 1;
+				
+				if(proc.getResourceCharacteristic().getParameters().get("product") != null){
+					String productName = proc.getResourceCharacteristic().getParameters().get("product").get(0).getContent();
+					if(productName.equals("Fusion G - T40N"))
+						nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Fusion_G_T40N_NR_OF_THREADS;
+					else if(productName.equals("Atom - D510"))
+						nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Atom_D510_NR_OF_THREADS/2;
+					else if(productName.equals("Atom - N2600"))
+						nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Atom_N2600_NR_OF_THREADS/2;
+					else if(productName.equals("Core i7 - 2715QE"))
+						nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Core_i7_2715QE_NR_OF_THREADS/2;
+					else if(productName.equals("Core i7 - 3615QE"))
+						nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Core_i7_3615QE_NR_OF_THREADS/2;
+				}
+
+				System.out.println(sumLoad + ":" + nrOfThreadsOnCpu + ";" + cpuRequest);
+				int freeThreads = (int) (nrOfThreadsOnCpu - sumLoad) ;
+
+				
+				if(freeThreads < cpuRequest)
+					continue;
+				
+				filteredNodes.add(node);
+			}
+		}
+		
+		return filteredNodes;
+	}
+	
+	private Node randomNode(List<Node> nodes){
+		return nodes.get(rand.nextInt(nodes.size()));
+	}
+
+	
+}
+
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Consolidation_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Consolidation_SP.java	(revision 1102)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Consolidation_SP.java	(revision 1207)
@@ -10,10 +10,10 @@
 import schedframe.events.scheduling.SchedulingEvent;
 import schedframe.exceptions.ResourceException;
-import schedframe.resources.CoolEmAllResourceType;
 import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
 import schedframe.resources.computing.Processor;
+import schedframe.resources.computing.coolemall.Node;
 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName;
-import schedframe.resources.computing.recs.Node;
 import schedframe.resources.units.Memory;
 import schedframe.resources.units.ProcessingElements;
@@ -55,5 +55,5 @@
 			List<Node> nodes;
 			try {
-				nodes = (List<Node>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node);
+				nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node);
 			} catch (ResourceException e) {
 				break;
@@ -140,5 +140,5 @@
 				}
 			}
-			ProcessingElements result = new ProcessingElements(node.getName());
+			ProcessingElements result = new ProcessingElements(node.getFullName());
 			result.addAll(choosenResources);
 			map.put(StandardResourceUnitName.PE, result);
@@ -183,5 +183,5 @@
 	private void turnOffIdleNodes(List<Node> nodes){
 		for(Node node : nodes){
-			JobRegistry jr = new JobRegistryImpl(node.getName());
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
 			if(jr.getRunningTasks().size() == 0)
 				node.getPowerInterface().setPowerState(StandardPowerStateName.OFF);
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_LB_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_LB_SP.java	(revision 1102)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_LB_SP.java	(revision 1207)
@@ -5,7 +5,7 @@
 import schedframe.events.scheduling.SchedulingEvent;
 import schedframe.exceptions.ResourceException;
-import schedframe.resources.CoolEmAllResourceType;
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingResource;
-import schedframe.resources.computing.recs.Node;
+import schedframe.resources.computing.coolemall.Node;
 import schedframe.scheduling.manager.resources.ClusterResourceManager;
 import schedframe.scheduling.manager.resources.ResourceManager;
@@ -62,5 +62,5 @@
 		List<ComputingResource> nodes = null;
 		try {
-			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node);
+			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(StandardResourceType.Node);
 		} catch (ResourceException e) {
 			// TODO Auto-generated catch block
@@ -68,5 +68,5 @@
 		}
 		int nodeIdx = findLeastLoadedResourceIdx(nodes);
-		return nodes.get(nodeIdx).getName();
+		return nodes.get(nodeIdx).getFullName();
 	}
 	
@@ -77,5 +77,5 @@
 		for(int i = 0; i < nodes.size(); i++){
 			Node node = (Node) nodes.get(i);
-			JobRegistry jr = new JobRegistryImpl(node.getName());
+			JobRegistry jr = new JobRegistryImpl(node.getFullName());
 			int totalLoad = jr.getRunningTasks().size(); 
 			if(totalLoad < minLoad){
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Random_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Random_SP.java	(revision 1103)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Random_SP.java	(revision 1207)
@@ -2,12 +2,22 @@
 
 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.exceptions.ResourceException;
-import schedframe.resources.CoolEmAllResourceType;
+import schedframe.resources.ResourceStatus;
+import schedframe.resources.StandardResourceType;
 import schedframe.resources.computing.ComputingNode;
-import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.Core;
+import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName;
+import schedframe.resources.devices.Device;
+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;
@@ -19,4 +29,5 @@
 import schedframe.scheduling.queue.TaskQueueList;
 import schedframe.scheduling.tasks.TaskInterface;
+import testbed_hpc.Node_Fan_Mapping;
 import example.localplugin.BaseLocalSchedulingPlugin;
 import gridsim.dcworms.DCWormsTags;
@@ -28,4 +39,5 @@
 	public RECS_FCFS_Random_SP () {
 		rand = new Random(47);
+		Node_Fan_Mapping.init();
 	}
 
@@ -47,5 +59,5 @@
 			List<ComputingNode> notSelectedNodes = null;
 			try {
-				notSelectedNodes = (List<ComputingNode>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node);
+				notSelectedNodes = (List<ComputingNode>) resourceManager.getResourcesOfType(StandardResourceType.Node);
 			} catch (ResourceException e) {
 				// TODO Auto-generated catch block
@@ -57,10 +69,14 @@
 				// if status of the tasks in READY
 				if (task.getStatus() == DCWormsTags.READY) {
-					ComputingNode node = chooseRandomProvider(resourceManager);
+					Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task);
+					if (choosenResources != null) {
+						addToSchedulingPlan(plan, task, choosenResources);
+					}
+					/*ComputingNode node = chooseRandomProvider(resourceManager);
 					if (node != null) {
-						node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON);
+						//node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON);
 						notSelectedNodes.remove(node);
 						addToSchedulingPlan(plan, task, node.getName());
-					}
+					}*/
 				}
 			}
@@ -75,5 +91,5 @@
 		List<ComputingNode> nodes = null;
 		try {
-			nodes = (List<ComputingNode>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node);
+			nodes = (List<ComputingNode>) resourceManager.getResourcesOfType(StandardResourceType.Node);
 		} catch (ResourceException e) {
 			// TODO Auto-generated catch block
@@ -94,10 +110,110 @@
 		return filteredNodes;
 	}
+	
+	private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(
+			ClusterResourceManager resourceManager, TaskInterface<?> task) {
+
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
+		
+		List<ComputingNode> nodes = null;
+		try {
+			nodes = (List<ComputingNode>) resourceManager.getResourcesOfType(StandardResourceType.Node);
+		} catch (ResourceException e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		}
+		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(); i++) {
+				if (cores.get(i).getStatus() == ResourceStatus.FREE) {
+					//choosenResources.add(cores.get(i));
+					cpuRequest--;
+				}
+			}
+			if (cpuRequest > 0) {
+				return null;
+			}
+			choosenResources.add(node.getProcessors().get(0));
+			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) {
+					if(cores.size() == 0){
+						if(node.getProcessors().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 adjustOtherFans(List<ComputingNode> nodes) {
 		for (ComputingNode node : nodes) {
+			
 			if (node.getProcessors().size() == node.getFreeProcessorsNumber()) {
-				node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_OFF);
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("Off"));
+						break;
+					}
+				}
+
 			} else {
-				node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON);
+				for(Device device: node.getParent().getResourceCharacteristic().getDevices()){
+					if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){
+						device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("On"));
+						break;
+					}
+				}
 			}
 		}
Index: DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ClusterPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ClusterPlugin.java	(revision 575)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ClusterPlugin.java	(revision 1207)
@@ -145,10 +145,10 @@
 		List<ComputingResource> nodes;
 		Properties properties = new Properties();
-		properties.setProperty("type", StandardResourceType.ComputingNode.getName());
+		properties.setProperty("type", StandardResourceType.Node.getName());
 		// properties.setProperty("status", ResourceStatus.FREE.toString());
 		nodes = (List<ComputingResource>) unitsManager.filterResources(properties);
 		
 		//always return the same node from the list
-		return nodes.get(0).getName();
+		return nodes.get(0).getFullName();
 	}
 
Index: DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_NodePowerManagementClusterPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_NodePowerManagementClusterPlugin.java	(revision 531)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_NodePowerManagementClusterPlugin.java	(revision 1207)
@@ -90,5 +90,5 @@
 				}
 			}
-			ProcessingElements result = new ProcessingElements(nodes.get(0).getName());
+			ProcessingElements result = new ProcessingElements(nodes.get(0).getFullName());
 			result.addAll(choosenResources);
 			map.put(StandardResourceUnitName.PE, result);
