Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Random_PowerCapping_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Random_PowerCapping_SP.java	(revision 1440)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_Random_PowerCapping_SP.java	(revision 1449)
@@ -8,5 +8,4 @@
 
 import schedframe.events.scheduling.SchedulingEvent;
-import schedframe.exceptions.ResourceException;
 import schedframe.resources.CoolEmAllResourceType;
 import schedframe.resources.ResourceStatus;
@@ -177,205 +176,200 @@
 	
 	private void powerCap(ResourceManager resManager){
-		try {
-			
-			for(ComputingResource compRes: resManager.getResourcesOfType(StandardResourceType.Rack)){
-				if(!powerCapsLevels.containsKey(compRes.getFullName()) || !powerUpgradesLevels.containsKey(compRes.getFullName())){
-					loadThresholds(compRes);
-				}
-				double powerConsumption = compRes.getPowerInterface().getRecentPowerUsage().getValue();
-				//System.out.println(compRes.getFullName() + " current: " + powerConsumption);
-				if(powerConsumption > powerCapsLevels.get(compRes.getFullName())){
-					ComputeBox1 cb1 = (ComputeBox1) compRes;
-					List<Processor> processors = cb1.getProcessors();
-					
-					double currentFrequencyLevel = 0;
-					if(currentFrequencyLevels.get(compRes.getFullName()) != null){
-						currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-					} else {
-						currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
-					}
-					boolean overThreshold = true;
-					boolean canDoBetter = true;
-
-					while(overThreshold && canDoBetter){
-						//System.out.println(compRes.getFullName() + " - downgrading");
-						int procNumberWithoutChange = 0;
-						boolean improvement = false;
-						//System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel);
+
+		for(ComputingResource compRes: resManager.getResourcesOfType(StandardResourceType.Rack)){
+			if(!powerCapsLevels.containsKey(compRes.getFullName()) || !powerUpgradesLevels.containsKey(compRes.getFullName())){
+				loadThresholds(compRes);
+			}
+			double powerConsumption = compRes.getPowerInterface().getRecentPowerUsage().getValue();
+			//System.out.println(compRes.getFullName() + " current: " + powerConsumption);
+			if(powerConsumption > powerCapsLevels.get(compRes.getFullName())){
+				ComputeBox1 cb1 = (ComputeBox1) compRes;
+				List<Processor> processors = cb1.getProcessors();
+				
+				double currentFrequencyLevel = 0;
+				if(currentFrequencyLevels.get(compRes.getFullName()) != null){
+					currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+				} else {
+					currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
+				}
+				boolean overThreshold = true;
+				boolean canDoBetter = true;
+
+				while(overThreshold && canDoBetter){
+					//System.out.println(compRes.getFullName() + " - downgrading");
+					int procNumberWithoutChange = 0;
+					boolean improvement = false;
+					//System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel);
+					for (Processor proc: processors){
+						PState currPState = proc.getPowerInterface().getPState();
+						//System.out.println(proc.getFullName() + " - checking");
+						if(currPState.getFrequency() <= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){
+							//System.out.println("operating same level");
+							procNumberWithoutChange++;
+							continue;
+						} 
+						if (proc.getFreeCores().size() == proc.getCores().size()){	
+							//System.out.println("free");
+							procNumberWithoutChange++;
+							continue;
+						} 
+		
+						double lowerFrequency = proc.getPowerInterface().getHighestPState().getFrequency();
+						for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
+							PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
+							if(pState.getFrequency() > lowerFrequency && pState.getFrequency() < currPState.getFrequency()){
+								lowerFrequency = pState.getFrequency();
+							}
+						}
+						//System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency);
+						if(lowerFrequency < currentFrequencyLevel){
+							//System.out.println(compRes.getFullName() + " - changing current frequency level");
+							currentFrequencyLevels.put(compRes.getFullName(), lowerFrequency);
+							currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+						}
+						
+						if(lowerFrequency != currPState.getFrequency()) {
+							//System.out.println(proc.getFullName() + " - lowering frequency");
+							proc.getPowerInterface().setFrequency(lowerFrequency);
+							Node n = proc.getNode();
+							for(Device device: n.getParent().getResourceCharacteristic().getDevices()){
+								
+								if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+									Fan fan = (Fan) device;
+
+									if(fan.getChilledResources().contains(n.getFullName())){
+										fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2"));
+									}
+								}
+							}
+							improvement = true;
+						}
+						if(lowerFrequency == proc.getPowerInterface().getHighestPState().getFrequency()){
+							canDoBetter = false;
+						} else {
+							canDoBetter = true;
+						}
+						if(compRes.getPowerInterface().getRecentPowerUsage().getValue() <= powerCapsLevels.get(compRes.getFullName())){
+							overThreshold = false;
+							break;
+						}
+					}	
+					if(procNumberWithoutChange == processors.size() || improvement == false){
+						//System.out.println(compRes.getFullName() + " - failed to improve");
+						double nextFrequencyLevel = processors.get(0).getPowerInterface().getHighestPState().getFrequency();
 						for (Processor proc: processors){
-							PState currPState = proc.getPowerInterface().getPState();
-							//System.out.println(proc.getFullName() + " - checking");
-							if(currPState.getFrequency() <= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){
-								//System.out.println("operating same level");
-								procNumberWithoutChange++;
-								continue;
-							} 
-							if (proc.getFreeCores().size() == proc.getCores().size()){	
-								//System.out.println("free");
-								procNumberWithoutChange++;
-								continue;
-							} 
-			
-							double lowerFrequency = proc.getPowerInterface().getHighestPState().getFrequency();
 							for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
 								PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
-								if(pState.getFrequency() > lowerFrequency && pState.getFrequency() < currPState.getFrequency()){
-									lowerFrequency = pState.getFrequency();
-								}
-							}
-							//System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency);
-							if(lowerFrequency < currentFrequencyLevel){
-								//System.out.println(compRes.getFullName() + " - changing current frequency level");
-								currentFrequencyLevels.put(compRes.getFullName(), lowerFrequency);
-								currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-							}
-							
-							if(lowerFrequency != currPState.getFrequency()) {
-								//System.out.println(proc.getFullName() + " - lowering frequency");
-								proc.getPowerInterface().setFrequency(lowerFrequency);
-								Node n = proc.getNode();
-								for(Device device: n.getParent().getResourceCharacteristic().getDevices()){
-									
-									if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
-										Fan fan = (Fan) device;
-
-										if(fan.getChilledResources().contains(n.getFullName())){
-											fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2"));
-										}
+								if(pState.getFrequency() > nextFrequencyLevel && pState.getFrequency() < currentFrequencyLevel){
+									nextFrequencyLevel = pState.getFrequency();
+								} 
+							}
+						}
+						//System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel);
+						currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel);
+						currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+						if(currentFrequencyLevel == processors.get(0).getPowerInterface().getHighestPState().getFrequency()){
+							canDoBetter = false;
+						}
+						procNumberWithoutChange = 0;
+					}
+				}
+
+			} else if (powerConsumption < powerUpgradesLevels.get(compRes.getFullName())) {
+				ComputeBox1 cb1 = (ComputeBox1) compRes;
+				List<Processor> processors = cb1.getProcessors();
+				
+				double currentFrequencyLevel = 0;
+				if(currentFrequencyLevels.get(compRes.getFullName()) != null){
+					currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+				} else {
+					currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
+				}
+				boolean overThreshold = true;
+				boolean canDoBetter = true;
+
+				while(overThreshold && canDoBetter){
+					//System.out.println(compRes.getFullName() + " - downgrading");
+					int procNumberWithoutChange = 0;
+					boolean improvement = false;
+					//System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel);
+					for (Processor proc: processors){
+						PState currPState = proc.getPowerInterface().getPState();
+						//System.out.println(proc.getFullName() + " - checking");
+						if(currPState.getFrequency() >= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){
+							//System.out.println("operating same level");
+							procNumberWithoutChange++;
+							continue;
+						} 
+						if (proc.getFreeCores().size() == proc.getCores().size()){	
+							//System.out.println("free");
+							procNumberWithoutChange++;
+							continue;
+						} 
+		
+						double higherFrequency = proc.getPowerInterface().getLowestPState().getFrequency();
+						for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
+							PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
+							if(pState.getFrequency() < higherFrequency && pState.getFrequency() > currPState.getFrequency()){
+								higherFrequency = pState.getFrequency();
+							}
+						}
+						//System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency);
+						if(higherFrequency > currentFrequencyLevel){
+							//System.out.println(compRes.getFullName() + " - changing current frequency level");
+							currentFrequencyLevels.put(compRes.getFullName(), higherFrequency);
+							currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+						}
+						
+						if(higherFrequency != currPState.getFrequency()) {
+							//System.out.println(proc.getFullName() + " - lowering frequency");
+							proc.getPowerInterface().setFrequency(higherFrequency);
+							Node n = proc.getNode();
+							for(Device device: n.getParent().getResourceCharacteristic().getDevices()){
+								
+								if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+									Fan fan = (Fan) device;
+
+									if(fan.getChilledResources().contains(n.getFullName())){
+										fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2"));
 									}
 								}
-								improvement = true;
-							}
-							if(lowerFrequency == proc.getPowerInterface().getHighestPState().getFrequency()){
-								canDoBetter = false;
-							} else {
-								canDoBetter = true;
-							}
-							if(compRes.getPowerInterface().getRecentPowerUsage().getValue() <= powerCapsLevels.get(compRes.getFullName())){
-								overThreshold = false;
-								break;
-							}
-						}	
-						if(procNumberWithoutChange == processors.size() || improvement == false){
-							//System.out.println(compRes.getFullName() + " - failed to improve");
-							double nextFrequencyLevel = processors.get(0).getPowerInterface().getHighestPState().getFrequency();
-							for (Processor proc: processors){
-								for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
-									PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
-									if(pState.getFrequency() > nextFrequencyLevel && pState.getFrequency() < currentFrequencyLevel){
-										nextFrequencyLevel = pState.getFrequency();
-									} 
-								}
-							}
-							//System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel);
-							currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel);
-							currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-							if(currentFrequencyLevel == processors.get(0).getPowerInterface().getHighestPState().getFrequency()){
-								canDoBetter = false;
-							}
-							procNumberWithoutChange = 0;
+							}
+							improvement = true;
+						}
+						if(higherFrequency == proc.getPowerInterface().getLowestPState().getFrequency()){
+							canDoBetter = false;
+						} else {
+							canDoBetter = true;
+						}
+						if(compRes.getPowerInterface().getRecentPowerUsage().getValue() >= powerCapsLevels.get(compRes.getFullName())){
+							overThreshold = false;
+							break;
 						}
 					}
-
-				} else if (powerConsumption < powerUpgradesLevels.get(compRes.getFullName())) {
-					ComputeBox1 cb1 = (ComputeBox1) compRes;
-					List<Processor> processors = cb1.getProcessors();
-					
-					double currentFrequencyLevel = 0;
-					if(currentFrequencyLevels.get(compRes.getFullName()) != null){
-						currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-					} else {
-						currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
-					}
-					boolean overThreshold = true;
-					boolean canDoBetter = true;
-
-					while(overThreshold && canDoBetter){
-						//System.out.println(compRes.getFullName() + " - downgrading");
-						int procNumberWithoutChange = 0;
-						boolean improvement = false;
-						//System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel);
+					if(procNumberWithoutChange == processors.size() || improvement == false){
+						//System.out.println(compRes.getFullName() + " - failed to improve");
+						double nextFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
 						for (Processor proc: processors){
-							PState currPState = proc.getPowerInterface().getPState();
-							//System.out.println(proc.getFullName() + " - checking");
-							if(currPState.getFrequency() >= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){
-								//System.out.println("operating same level");
-								procNumberWithoutChange++;
-								continue;
-							} 
-							if (proc.getFreeCores().size() == proc.getCores().size()){	
-								//System.out.println("free");
-								procNumberWithoutChange++;
-								continue;
-							} 
-			
-							double higherFrequency = proc.getPowerInterface().getLowestPState().getFrequency();
 							for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
 								PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
-								if(pState.getFrequency() < higherFrequency && pState.getFrequency() > currPState.getFrequency()){
-									higherFrequency = pState.getFrequency();
-								}
-							}
-							//System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency);
-							if(higherFrequency > currentFrequencyLevel){
-								//System.out.println(compRes.getFullName() + " - changing current frequency level");
-								currentFrequencyLevels.put(compRes.getFullName(), higherFrequency);
-								currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-							}
-							
-							if(higherFrequency != currPState.getFrequency()) {
-								//System.out.println(proc.getFullName() + " - lowering frequency");
-								proc.getPowerInterface().setFrequency(higherFrequency);
-								Node n = proc.getNode();
-								for(Device device: n.getParent().getResourceCharacteristic().getDevices()){
-									
-									if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
-										Fan fan = (Fan) device;
-
-										if(fan.getChilledResources().contains(n.getFullName())){
-											fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2"));
-										}
-									}
-								}
-								improvement = true;
-							}
-							if(higherFrequency == proc.getPowerInterface().getLowestPState().getFrequency()){
-								canDoBetter = false;
-							} else {
-								canDoBetter = true;
-							}
-							if(compRes.getPowerInterface().getRecentPowerUsage().getValue() >= powerCapsLevels.get(compRes.getFullName())){
-								overThreshold = false;
-								break;
-							}
-						}
-						if(procNumberWithoutChange == processors.size() || improvement == false){
-							//System.out.println(compRes.getFullName() + " - failed to improve");
-							double nextFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
-							for (Processor proc: processors){
-								for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
-									PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
-									if(pState.getFrequency() < nextFrequencyLevel && pState.getFrequency() > currentFrequencyLevel){
-										nextFrequencyLevel = pState.getFrequency();
-									} 
-								}
-							}
-							//System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel);
-							currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel);
-							currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-							if(currentFrequencyLevel == processors.get(0).getPowerInterface().getLowestPState().getFrequency()){
-								canDoBetter = false;
-							}
-							procNumberWithoutChange = 0;
-						}
+								if(pState.getFrequency() < nextFrequencyLevel && pState.getFrequency() > currentFrequencyLevel){
+									nextFrequencyLevel = pState.getFrequency();
+								} 
+							}
+						}
+						//System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel);
+						currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel);
+						currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+						if(currentFrequencyLevel == processors.get(0).getPowerInterface().getLowestPState().getFrequency()){
+							canDoBetter = false;
+						}
+						procNumberWithoutChange = 0;
 					}
-
-				}
-			}
-			
-		} catch (ResourceException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
+				}
+
+			}
+		}
+
 	}
 	
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationHighPerf_PowerCapping_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationHighPerf_PowerCapping_SP.java	(revision 1440)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationHighPerf_PowerCapping_SP.java	(revision 1449)
@@ -9,5 +9,4 @@
 
 import schedframe.events.scheduling.SchedulingEvent;
-import schedframe.exceptions.ResourceException;
 import schedframe.resources.CoolEmAllResourceType;
 import schedframe.resources.ResourceStatus;
@@ -300,205 +299,200 @@
 	
 	private void powerCap(ResourceManager resManager){
-		try {
-			
-			for(ComputingResource compRes: resManager.getResourcesOfType(StandardResourceType.Rack)){
-				if(!powerCapsLevels.containsKey(compRes.getFullName()) || !powerUpgradesLevels.containsKey(compRes.getFullName())){
-					loadThresholds(compRes);
-				}
-				double powerConsumption = compRes.getPowerInterface().getRecentPowerUsage().getValue();
-				//System.out.println(compRes.getFullName() + " current: " + powerConsumption);
-				if(powerConsumption > powerCapsLevels.get(compRes.getFullName())){
-					ComputeBox1 cb1 = (ComputeBox1) compRes;
-					List<Processor> processors = cb1.getProcessors();
-					
-					double currentFrequencyLevel = 0;
-					if(currentFrequencyLevels.get(compRes.getFullName()) != null){
-						currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-					} else {
-						currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
-					}
-					boolean overThreshold = true;
-					boolean canDoBetter = true;
-
-					while(overThreshold && canDoBetter){
-						//System.out.println(compRes.getFullName() + " - downgrading");
-						int procNumberWithoutChange = 0;
-						boolean improvement = false;
-						//System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel);
+
+		for(ComputingResource compRes: resManager.getResourcesOfType(StandardResourceType.Rack)){
+			if(!powerCapsLevels.containsKey(compRes.getFullName()) || !powerUpgradesLevels.containsKey(compRes.getFullName())){
+				loadThresholds(compRes);
+			}
+			double powerConsumption = compRes.getPowerInterface().getRecentPowerUsage().getValue();
+			//System.out.println(compRes.getFullName() + " current: " + powerConsumption);
+			if(powerConsumption > powerCapsLevels.get(compRes.getFullName())){
+				ComputeBox1 cb1 = (ComputeBox1) compRes;
+				List<Processor> processors = cb1.getProcessors();
+				
+				double currentFrequencyLevel = 0;
+				if(currentFrequencyLevels.get(compRes.getFullName()) != null){
+					currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+				} else {
+					currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
+				}
+				boolean overThreshold = true;
+				boolean canDoBetter = true;
+
+				while(overThreshold && canDoBetter){
+					//System.out.println(compRes.getFullName() + " - downgrading");
+					int procNumberWithoutChange = 0;
+					boolean improvement = false;
+					//System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel);
+					for (Processor proc: processors){
+						PState currPState = proc.getPowerInterface().getPState();
+						//System.out.println(proc.getFullName() + " - checking");
+						if(currPState.getFrequency() <= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){
+							//System.out.println("operating same level");
+							procNumberWithoutChange++;
+							continue;
+						} 
+						if (proc.getFreeCores().size() == proc.getCores().size()){	
+							//System.out.println("free");
+							procNumberWithoutChange++;
+							continue;
+						} 
+		
+						double lowerFrequency = proc.getPowerInterface().getHighestPState().getFrequency();
+						for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
+							PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
+							if(pState.getFrequency() > lowerFrequency && pState.getFrequency() < currPState.getFrequency()){
+								lowerFrequency = pState.getFrequency();
+							}
+						}
+						//System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency);
+						if(lowerFrequency < currentFrequencyLevel){
+							//System.out.println(compRes.getFullName() + " - changing current frequency level");
+							currentFrequencyLevels.put(compRes.getFullName(), lowerFrequency);
+							currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+						}
+						
+						if(lowerFrequency != currPState.getFrequency()) {
+							//System.out.println(proc.getFullName() + " - lowering frequency");
+							proc.getPowerInterface().setFrequency(lowerFrequency);
+							Node n = proc.getNode();
+							for(Device device: n.getParent().getResourceCharacteristic().getDevices()){
+								
+								if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+									Fan fan = (Fan) device;
+
+									if(fan.getChilledResources().contains(n.getFullName())){
+										fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2"));
+									}
+								}
+							}
+							improvement = true;
+						}
+						if(lowerFrequency == proc.getPowerInterface().getHighestPState().getFrequency()){
+							canDoBetter = false;
+						} else {
+							canDoBetter = true;
+						}
+						if(compRes.getPowerInterface().getRecentPowerUsage().getValue() <= powerCapsLevels.get(compRes.getFullName())){
+							overThreshold = false;
+							break;
+						}
+					}	
+					if(procNumberWithoutChange == processors.size() || improvement == false){
+						//System.out.println(compRes.getFullName() + " - failed to improve");
+						double nextFrequencyLevel = processors.get(0).getPowerInterface().getHighestPState().getFrequency();
 						for (Processor proc: processors){
-							PState currPState = proc.getPowerInterface().getPState();
-							//System.out.println(proc.getFullName() + " - checking");
-							if(currPState.getFrequency() <= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){
-								//System.out.println("operating same level");
-								procNumberWithoutChange++;
-								continue;
-							} 
-							if (proc.getFreeCores().size() == proc.getCores().size()){	
-								//System.out.println("free");
-								procNumberWithoutChange++;
-								continue;
-							} 
-			
-							double lowerFrequency = proc.getPowerInterface().getHighestPState().getFrequency();
 							for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
 								PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
-								if(pState.getFrequency() > lowerFrequency && pState.getFrequency() < currPState.getFrequency()){
-									lowerFrequency = pState.getFrequency();
+								if(pState.getFrequency() > nextFrequencyLevel && pState.getFrequency() < currentFrequencyLevel){
+									nextFrequencyLevel = pState.getFrequency();
+								} 
+							}
+						}
+						//System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel);
+						currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel);
+						currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+						if(currentFrequencyLevel == processors.get(0).getPowerInterface().getHighestPState().getFrequency()){
+							canDoBetter = false;
+						}
+						procNumberWithoutChange = 0;
+					}
+				}
+
+			} else if (powerConsumption < powerUpgradesLevels.get(compRes.getFullName())) {
+				ComputeBox1 cb1 = (ComputeBox1) compRes;
+				List<Processor> processors = cb1.getProcessors();
+				
+				double currentFrequencyLevel = 0;
+				if(currentFrequencyLevels.get(compRes.getFullName()) != null){
+					currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+				} else {
+					currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
+				}
+				boolean overThreshold = true;
+				boolean canDoBetter = true;
+
+				while(overThreshold && canDoBetter){
+					//System.out.println(compRes.getFullName() + " - downgrading");
+					int procNumberWithoutChange = 0;
+					boolean improvement = false;
+					//System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel);
+					for (Processor proc: processors){
+						PState currPState = proc.getPowerInterface().getPState();
+						//System.out.println(proc.getFullName() + " - checking");
+						if(currPState.getFrequency() >= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){
+							//System.out.println("operating same level");
+							procNumberWithoutChange++;
+							continue;
+						} 
+						if (proc.getFreeCores().size() == proc.getCores().size()){	
+							//System.out.println("free");
+							procNumberWithoutChange++;
+							continue;
+						} 
+		
+						double higherFrequency = proc.getPowerInterface().getLowestPState().getFrequency();
+						for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
+							PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
+							if(pState.getFrequency() < higherFrequency && pState.getFrequency() > currPState.getFrequency()){
+								higherFrequency = pState.getFrequency();
+							}
+						}
+						//System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency);
+						if(higherFrequency > currentFrequencyLevel){
+							//System.out.println(compRes.getFullName() + " - changing current frequency level");
+							currentFrequencyLevels.put(compRes.getFullName(), higherFrequency);
+							currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+						}
+						
+						if(higherFrequency != currPState.getFrequency()) {
+							//System.out.println(proc.getFullName() + " - lowering frequency");
+							proc.getPowerInterface().setFrequency(higherFrequency);
+							Node n = proc.getNode();
+							for(Device device: n.getParent().getResourceCharacteristic().getDevices()){
+								
+								if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+									Fan fan = (Fan) device;
+
+									if(fan.getChilledResources().contains(n.getFullName())){
+										fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2"));
+									}
 								}
 							}
-							//System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency);
-							if(lowerFrequency < currentFrequencyLevel){
-								//System.out.println(compRes.getFullName() + " - changing current frequency level");
-								currentFrequencyLevels.put(compRes.getFullName(), lowerFrequency);
-								currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-							}
-							
-							if(lowerFrequency != currPState.getFrequency()) {
-								//System.out.println(proc.getFullName() + " - lowering frequency");
-								proc.getPowerInterface().setFrequency(lowerFrequency);
-								Node n = proc.getNode();
-								for(Device device: n.getParent().getResourceCharacteristic().getDevices()){
-									
-									if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
-										Fan fan = (Fan) device;
-
-										if(fan.getChilledResources().contains(n.getFullName())){
-											fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2"));
-										}
-									}
-								}
-								improvement = true;
-							}
-							if(lowerFrequency == proc.getPowerInterface().getHighestPState().getFrequency()){
-								canDoBetter = false;
-							} else {
-								canDoBetter = true;
-							}
-							if(compRes.getPowerInterface().getRecentPowerUsage().getValue() <= powerCapsLevels.get(compRes.getFullName())){
-								overThreshold = false;
-								break;
-							}
-						}	
-						if(procNumberWithoutChange == processors.size() || improvement == false){
-							//System.out.println(compRes.getFullName() + " - failed to improve");
-							double nextFrequencyLevel = processors.get(0).getPowerInterface().getHighestPState().getFrequency();
-							for (Processor proc: processors){
-								for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
-									PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
-									if(pState.getFrequency() > nextFrequencyLevel && pState.getFrequency() < currentFrequencyLevel){
-										nextFrequencyLevel = pState.getFrequency();
-									} 
-								}
-							}
-							//System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel);
-							currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel);
-							currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-							if(currentFrequencyLevel == processors.get(0).getPowerInterface().getHighestPState().getFrequency()){
-								canDoBetter = false;
-							}
-							procNumberWithoutChange = 0;
+							improvement = true;
+						}
+						if(higherFrequency == proc.getPowerInterface().getLowestPState().getFrequency()){
+							canDoBetter = false;
+						} else {
+							canDoBetter = true;
+						}
+						if(compRes.getPowerInterface().getRecentPowerUsage().getValue() >= powerCapsLevels.get(compRes.getFullName())){
+							overThreshold = false;
+							break;
 						}
 					}
-
-				} else if (powerConsumption < powerUpgradesLevels.get(compRes.getFullName())) {
-					ComputeBox1 cb1 = (ComputeBox1) compRes;
-					List<Processor> processors = cb1.getProcessors();
-					
-					double currentFrequencyLevel = 0;
-					if(currentFrequencyLevels.get(compRes.getFullName()) != null){
-						currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-					} else {
-						currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
-					}
-					boolean overThreshold = true;
-					boolean canDoBetter = true;
-
-					while(overThreshold && canDoBetter){
-						//System.out.println(compRes.getFullName() + " - downgrading");
-						int procNumberWithoutChange = 0;
-						boolean improvement = false;
-						//System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel);
+					if(procNumberWithoutChange == processors.size() || improvement == false){
+						//System.out.println(compRes.getFullName() + " - failed to improve");
+						double nextFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
 						for (Processor proc: processors){
-							PState currPState = proc.getPowerInterface().getPState();
-							//System.out.println(proc.getFullName() + " - checking");
-							if(currPState.getFrequency() >= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){
-								//System.out.println("operating same level");
-								procNumberWithoutChange++;
-								continue;
-							} 
-							if (proc.getFreeCores().size() == proc.getCores().size()){	
-								//System.out.println("free");
-								procNumberWithoutChange++;
-								continue;
-							} 
-			
-							double higherFrequency = proc.getPowerInterface().getLowestPState().getFrequency();
 							for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
 								PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
-								if(pState.getFrequency() < higherFrequency && pState.getFrequency() > currPState.getFrequency()){
-									higherFrequency = pState.getFrequency();
-								}
+								if(pState.getFrequency() < nextFrequencyLevel && pState.getFrequency() > currentFrequencyLevel){
+									nextFrequencyLevel = pState.getFrequency();
+								} 
 							}
-							//System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency);
-							if(higherFrequency > currentFrequencyLevel){
-								//System.out.println(compRes.getFullName() + " - changing current frequency level");
-								currentFrequencyLevels.put(compRes.getFullName(), higherFrequency);
-								currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-							}
-							
-							if(higherFrequency != currPState.getFrequency()) {
-								//System.out.println(proc.getFullName() + " - lowering frequency");
-								proc.getPowerInterface().setFrequency(higherFrequency);
-								Node n = proc.getNode();
-								for(Device device: n.getParent().getResourceCharacteristic().getDevices()){
-									
-									if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
-										Fan fan = (Fan) device;
-
-										if(fan.getChilledResources().contains(n.getFullName())){
-											fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2"));
-										}
-									}
-								}
-								improvement = true;
-							}
-							if(higherFrequency == proc.getPowerInterface().getLowestPState().getFrequency()){
-								canDoBetter = false;
-							} else {
-								canDoBetter = true;
-							}
-							if(compRes.getPowerInterface().getRecentPowerUsage().getValue() >= powerCapsLevels.get(compRes.getFullName())){
-								overThreshold = false;
-								break;
-							}
-						}
-						if(procNumberWithoutChange == processors.size() || improvement == false){
-							//System.out.println(compRes.getFullName() + " - failed to improve");
-							double nextFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
-							for (Processor proc: processors){
-								for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
-									PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
-									if(pState.getFrequency() < nextFrequencyLevel && pState.getFrequency() > currentFrequencyLevel){
-										nextFrequencyLevel = pState.getFrequency();
-									} 
-								}
-							}
-							//System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel);
-							currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel);
-							currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-							if(currentFrequencyLevel == processors.get(0).getPowerInterface().getLowestPState().getFrequency()){
-								canDoBetter = false;
-							}
-							procNumberWithoutChange = 0;
-						}
+						}
+						//System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel);
+						currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel);
+						currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+						if(currentFrequencyLevel == processors.get(0).getPowerInterface().getLowestPState().getFrequency()){
+							canDoBetter = false;
+						}
+						procNumberWithoutChange = 0;
 					}
-
-				}
-			}
-			
-		} catch (ResourceException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
+				}
+
+			}
+		}
+
 	}
 	
Index: DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationLowPower_PowerCapping_SP.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationLowPower_PowerCapping_SP.java	(revision 1440)
+++ DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox2/CB2_FCFS_ConsolidationLowPower_PowerCapping_SP.java	(revision 1449)
@@ -9,5 +9,4 @@
 
 import schedframe.events.scheduling.SchedulingEvent;
-import schedframe.exceptions.ResourceException;
 import schedframe.resources.CoolEmAllResourceType;
 import schedframe.resources.ResourceStatus;
@@ -218,205 +217,200 @@
 	
 	private void powerCap(ResourceManager resManager){
-		try {
-			
-			for(ComputingResource compRes: resManager.getResourcesOfType(StandardResourceType.Rack)){
-				if(!powerCapsLevels.containsKey(compRes.getFullName()) || !powerUpgradesLevels.containsKey(compRes.getFullName())){
-					loadThresholds(compRes);
-				}
-				double powerConsumption = compRes.getPowerInterface().getRecentPowerUsage().getValue();
-				//System.out.println(compRes.getFullName() + " current: " + powerConsumption);
-				if(powerConsumption > powerCapsLevels.get(compRes.getFullName())){
-					ComputeBox1 cb1 = (ComputeBox1) compRes;
-					List<Processor> processors = cb1.getProcessors();
-					
-					double currentFrequencyLevel = 0;
-					if(currentFrequencyLevels.get(compRes.getFullName()) != null){
-						currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-					} else {
-						currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
-					}
-					boolean overThreshold = true;
-					boolean canDoBetter = true;
-
-					while(overThreshold && canDoBetter){
-						//System.out.println(compRes.getFullName() + " - downgrading");
-						int procNumberWithoutChange = 0;
-						boolean improvement = false;
-						//System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel);
+
+		for(ComputingResource compRes: resManager.getResourcesOfType(StandardResourceType.Rack)){
+			if(!powerCapsLevels.containsKey(compRes.getFullName()) || !powerUpgradesLevels.containsKey(compRes.getFullName())){
+				loadThresholds(compRes);
+			}
+			double powerConsumption = compRes.getPowerInterface().getRecentPowerUsage().getValue();
+			//System.out.println(compRes.getFullName() + " current: " + powerConsumption);
+			if(powerConsumption > powerCapsLevels.get(compRes.getFullName())){
+				ComputeBox1 cb1 = (ComputeBox1) compRes;
+				List<Processor> processors = cb1.getProcessors();
+				
+				double currentFrequencyLevel = 0;
+				if(currentFrequencyLevels.get(compRes.getFullName()) != null){
+					currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+				} else {
+					currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
+				}
+				boolean overThreshold = true;
+				boolean canDoBetter = true;
+
+				while(overThreshold && canDoBetter){
+					//System.out.println(compRes.getFullName() + " - downgrading");
+					int procNumberWithoutChange = 0;
+					boolean improvement = false;
+					//System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel);
+					for (Processor proc: processors){
+						PState currPState = proc.getPowerInterface().getPState();
+						//System.out.println(proc.getFullName() + " - checking");
+						if(currPState.getFrequency() <= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){
+							//System.out.println("operating same level");
+							procNumberWithoutChange++;
+							continue;
+						} 
+						if (proc.getFreeCores().size() == proc.getCores().size()){	
+							//System.out.println("free");
+							procNumberWithoutChange++;
+							continue;
+						} 
+		
+						double lowerFrequency = proc.getPowerInterface().getHighestPState().getFrequency();
+						for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
+							PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
+							if(pState.getFrequency() > lowerFrequency && pState.getFrequency() < currPState.getFrequency()){
+								lowerFrequency = pState.getFrequency();
+							}
+						}
+						//System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency);
+						if(lowerFrequency < currentFrequencyLevel){
+							//System.out.println(compRes.getFullName() + " - changing current frequency level");
+							currentFrequencyLevels.put(compRes.getFullName(), lowerFrequency);
+							currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+						}
+						
+						if(lowerFrequency != currPState.getFrequency()) {
+							//System.out.println(proc.getFullName() + " - lowering frequency");
+							proc.getPowerInterface().setFrequency(lowerFrequency);
+							Node n = proc.getNode();
+							for(Device device: n.getParent().getResourceCharacteristic().getDevices()){
+								
+								if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+									Fan fan = (Fan) device;
+
+									if(fan.getChilledResources().contains(n.getFullName())){
+										fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2"));
+									}
+								}
+							}
+							improvement = true;
+						}
+						if(lowerFrequency == proc.getPowerInterface().getHighestPState().getFrequency()){
+							canDoBetter = false;
+						} else {
+							canDoBetter = true;
+						}
+						if(compRes.getPowerInterface().getRecentPowerUsage().getValue() <= powerCapsLevels.get(compRes.getFullName())){
+							overThreshold = false;
+							break;
+						}
+					}	
+					if(procNumberWithoutChange == processors.size() || improvement == false){
+						//System.out.println(compRes.getFullName() + " - failed to improve");
+						double nextFrequencyLevel = processors.get(0).getPowerInterface().getHighestPState().getFrequency();
 						for (Processor proc: processors){
-							PState currPState = proc.getPowerInterface().getPState();
-							//System.out.println(proc.getFullName() + " - checking");
-							if(currPState.getFrequency() <= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){
-								//System.out.println("operating same level");
-								procNumberWithoutChange++;
-								continue;
-							} 
-							if (proc.getFreeCores().size() == proc.getCores().size()){	
-								//System.out.println("free");
-								procNumberWithoutChange++;
-								continue;
-							} 
-			
-							double lowerFrequency = proc.getPowerInterface().getHighestPState().getFrequency();
 							for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
 								PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
-								if(pState.getFrequency() > lowerFrequency && pState.getFrequency() < currPState.getFrequency()){
-									lowerFrequency = pState.getFrequency();
-								}
-							}
-							//System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency);
-							if(lowerFrequency < currentFrequencyLevel){
-								//System.out.println(compRes.getFullName() + " - changing current frequency level");
-								currentFrequencyLevels.put(compRes.getFullName(), lowerFrequency);
-								currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-							}
-							
-							if(lowerFrequency != currPState.getFrequency()) {
-								//System.out.println(proc.getFullName() + " - lowering frequency");
-								proc.getPowerInterface().setFrequency(lowerFrequency);
-								Node n = proc.getNode();
-								for(Device device: n.getParent().getResourceCharacteristic().getDevices()){
-									
-									if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
-										Fan fan = (Fan) device;
-
-										if(fan.getChilledResources().contains(n.getFullName())){
-											fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2"));
-										}
+								if(pState.getFrequency() > nextFrequencyLevel && pState.getFrequency() < currentFrequencyLevel){
+									nextFrequencyLevel = pState.getFrequency();
+								} 
+							}
+						}
+						//System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel);
+						currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel);
+						currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+						if(currentFrequencyLevel == processors.get(0).getPowerInterface().getHighestPState().getFrequency()){
+							canDoBetter = false;
+						}
+						procNumberWithoutChange = 0;
+					}
+				}
+
+			} else if (powerConsumption < powerUpgradesLevels.get(compRes.getFullName())) {
+				ComputeBox1 cb1 = (ComputeBox1) compRes;
+				List<Processor> processors = cb1.getProcessors();
+				
+				double currentFrequencyLevel = 0;
+				if(currentFrequencyLevels.get(compRes.getFullName()) != null){
+					currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+				} else {
+					currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
+				}
+				boolean overThreshold = true;
+				boolean canDoBetter = true;
+
+				while(overThreshold && canDoBetter){
+					//System.out.println(compRes.getFullName() + " - downgrading");
+					int procNumberWithoutChange = 0;
+					boolean improvement = false;
+					//System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel);
+					for (Processor proc: processors){
+						PState currPState = proc.getPowerInterface().getPState();
+						//System.out.println(proc.getFullName() + " - checking");
+						if(currPState.getFrequency() >= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){
+							//System.out.println("operating same level");
+							procNumberWithoutChange++;
+							continue;
+						} 
+						if (proc.getFreeCores().size() == proc.getCores().size()){	
+							//System.out.println("free");
+							procNumberWithoutChange++;
+							continue;
+						} 
+		
+						double higherFrequency = proc.getPowerInterface().getLowestPState().getFrequency();
+						for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
+							PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
+							if(pState.getFrequency() < higherFrequency && pState.getFrequency() > currPState.getFrequency()){
+								higherFrequency = pState.getFrequency();
+							}
+						}
+						//System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency);
+						if(higherFrequency > currentFrequencyLevel){
+							//System.out.println(compRes.getFullName() + " - changing current frequency level");
+							currentFrequencyLevels.put(compRes.getFullName(), higherFrequency);
+							currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+						}
+						
+						if(higherFrequency != currPState.getFrequency()) {
+							//System.out.println(proc.getFullName() + " - lowering frequency");
+							proc.getPowerInterface().setFrequency(higherFrequency);
+							Node n = proc.getNode();
+							for(Device device: n.getParent().getResourceCharacteristic().getDevices()){
+								
+								if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
+									Fan fan = (Fan) device;
+
+									if(fan.getChilledResources().contains(n.getFullName())){
+										fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2"));
 									}
 								}
-								improvement = true;
-							}
-							if(lowerFrequency == proc.getPowerInterface().getHighestPState().getFrequency()){
-								canDoBetter = false;
-							} else {
-								canDoBetter = true;
-							}
-							if(compRes.getPowerInterface().getRecentPowerUsage().getValue() <= powerCapsLevels.get(compRes.getFullName())){
-								overThreshold = false;
-								break;
-							}
-						}	
-						if(procNumberWithoutChange == processors.size() || improvement == false){
-							//System.out.println(compRes.getFullName() + " - failed to improve");
-							double nextFrequencyLevel = processors.get(0).getPowerInterface().getHighestPState().getFrequency();
-							for (Processor proc: processors){
-								for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
-									PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
-									if(pState.getFrequency() > nextFrequencyLevel && pState.getFrequency() < currentFrequencyLevel){
-										nextFrequencyLevel = pState.getFrequency();
-									} 
-								}
-							}
-							//System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel);
-							currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel);
-							currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-							if(currentFrequencyLevel == processors.get(0).getPowerInterface().getHighestPState().getFrequency()){
-								canDoBetter = false;
-							}
-							procNumberWithoutChange = 0;
+							}
+							improvement = true;
+						}
+						if(higherFrequency == proc.getPowerInterface().getLowestPState().getFrequency()){
+							canDoBetter = false;
+						} else {
+							canDoBetter = true;
+						}
+						if(compRes.getPowerInterface().getRecentPowerUsage().getValue() >= powerCapsLevels.get(compRes.getFullName())){
+							overThreshold = false;
+							break;
 						}
 					}
-
-				} else if (powerConsumption < powerUpgradesLevels.get(compRes.getFullName())) {
-					ComputeBox1 cb1 = (ComputeBox1) compRes;
-					List<Processor> processors = cb1.getProcessors();
-					
-					double currentFrequencyLevel = 0;
-					if(currentFrequencyLevels.get(compRes.getFullName()) != null){
-						currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-					} else {
-						currentFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
-					}
-					boolean overThreshold = true;
-					boolean canDoBetter = true;
-
-					while(overThreshold && canDoBetter){
-						//System.out.println(compRes.getFullName() + " - downgrading");
-						int procNumberWithoutChange = 0;
-						boolean improvement = false;
-						//System.out.println(compRes.getFullName() + "; currentFrequencyLevel: " + currentFrequencyLevel);
+					if(procNumberWithoutChange == processors.size() || improvement == false){
+						//System.out.println(compRes.getFullName() + " - failed to improve");
+						double nextFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
 						for (Processor proc: processors){
-							PState currPState = proc.getPowerInterface().getPState();
-							//System.out.println(proc.getFullName() + " - checking");
-							if(currPState.getFrequency() >= currentFrequencyLevel && proc.getFreeCores().size() != proc.getCores().size()){
-								//System.out.println("operating same level");
-								procNumberWithoutChange++;
-								continue;
-							} 
-							if (proc.getFreeCores().size() == proc.getCores().size()){	
-								//System.out.println("free");
-								procNumberWithoutChange++;
-								continue;
-							} 
-			
-							double higherFrequency = proc.getPowerInterface().getLowestPState().getFrequency();
 							for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
 								PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
-								if(pState.getFrequency() < higherFrequency && pState.getFrequency() > currPState.getFrequency()){
-									higherFrequency = pState.getFrequency();
-								}
-							}
-							//System.out.println(proc.getFullName() + "; lower frequency: " + lowerFrequency);
-							if(higherFrequency > currentFrequencyLevel){
-								//System.out.println(compRes.getFullName() + " - changing current frequency level");
-								currentFrequencyLevels.put(compRes.getFullName(), higherFrequency);
-								currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-							}
-							
-							if(higherFrequency != currPState.getFrequency()) {
-								//System.out.println(proc.getFullName() + " - lowering frequency");
-								proc.getPowerInterface().setFrequency(higherFrequency);
-								Node n = proc.getNode();
-								for(Device device: n.getParent().getResourceCharacteristic().getDevices()){
-									
-									if(device.getType().equals(StandardResourceType.Fan) || device.getType().equals(StandardResourceType.Inlet) | device.getType().equals(StandardResourceType.Outlet)){
-										Fan fan = (Fan) device;
-
-										if(fan.getChilledResources().contains(n.getFullName())){
-											fan.getAirflowInterface().setAirflowState(new CustomAirflowStateName("2"));
-										}
-									}
-								}
-								improvement = true;
-							}
-							if(higherFrequency == proc.getPowerInterface().getLowestPState().getFrequency()){
-								canDoBetter = false;
-							} else {
-								canDoBetter = true;
-							}
-							if(compRes.getPowerInterface().getRecentPowerUsage().getValue() >= powerCapsLevels.get(compRes.getFullName())){
-								overThreshold = false;
-								break;
-							}
-						}
-						if(procNumberWithoutChange == processors.size() || improvement == false){
-							//System.out.println(compRes.getFullName() + " - failed to improve");
-							double nextFrequencyLevel = processors.get(0).getPowerInterface().getLowestPState().getFrequency();
-							for (Processor proc: processors){
-								for(String pStateName: proc.getPowerInterface().getSupportedPStates().keySet()){
-									PState pState = proc.getPowerInterface().getSupportedPStates().get(pStateName);
-									if(pState.getFrequency() < nextFrequencyLevel && pState.getFrequency() > currentFrequencyLevel){
-										nextFrequencyLevel = pState.getFrequency();
-									} 
-								}
-							}
-							//System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel);
-							currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel);
-							currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
-							if(currentFrequencyLevel == processors.get(0).getPowerInterface().getLowestPState().getFrequency()){
-								canDoBetter = false;
-							}
-							procNumberWithoutChange = 0;
-						}
+								if(pState.getFrequency() < nextFrequencyLevel && pState.getFrequency() > currentFrequencyLevel){
+									nextFrequencyLevel = pState.getFrequency();
+								} 
+							}
+						}
+						//System.out.println(compRes.getFullName() + "; nextFrequencyLevel: " + nextFrequencyLevel);
+						currentFrequencyLevels.put(compRes.getFullName(), nextFrequencyLevel);
+						currentFrequencyLevel = currentFrequencyLevels.get(compRes.getFullName());
+						if(currentFrequencyLevel == processors.get(0).getPowerInterface().getLowestPState().getFrequency()){
+							canDoBetter = false;
+						}
+						procNumberWithoutChange = 0;
 					}
-
-				}
-			}
-			
-		} catch (ResourceException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
+				}
+
+			}
+		}
+
 	}
 	
Index: DCWoRMS/branches/coolemall/src/example/globalplugin/GridFCFSRandomPlugin.java
===================================================================
--- DCWoRMS/branches/coolemall/src/example/globalplugin/GridFCFSRandomPlugin.java	(revision 1396)
+++ DCWoRMS/branches/coolemall/src/example/globalplugin/GridFCFSRandomPlugin.java	(revision 1449)
@@ -52,6 +52,6 @@
 		
 		for(int i = 0; i < size; i++) {
-			WorkloadUnit job = q.remove(0);
-			TaskInterface<?> task = (TaskInterface<?>)job;
+
+			TaskInterface<?> task = q.remove(0);
 			
 			resourceIdx = rand.nextInt(availableResources.size());
