- Timestamp:
- 10/12/12 13:04:31 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/trunk/src/example/localplugin/FCFSCPUFreqScalingClusterLocalPlugin.java
r497 r512 9 9 10 10 import schedframe.events.scheduling.SchedulingEvent; 11 import schedframe.events.scheduling.TaskFinishedEvent;12 import schedframe.events.scheduling.TaskRequestedTimeExpiredEvent;13 11 import schedframe.resources.ResourceStatus; 14 12 import schedframe.resources.computing.ComputingResource; … … 18 16 import schedframe.resources.units.ResourceUnitName; 19 17 import schedframe.resources.units.StandardResourceUnitName; 20 import schedframe.scheduling.UsedResourcesList;21 18 import schedframe.scheduling.manager.resources.ClusterResourceManager; 22 19 import schedframe.scheduling.manager.resources.ResourceManager; … … 29 26 import schedframe.scheduling.tasks.TaskInterface; 30 27 import schedframe.scheduling.tasks.WorkloadUnit; 31 import dcworms.schedframe.scheduling.Executable;32 28 33 29 public class FCFSCPUFreqScalingClusterLocalPlugin extends BaseLocalSchedulingPlugin { … … 51 47 52 48 case START_TASK_EXECUTION: 53 49 case TASK_FINISHED: 54 50 // check all tasks in queue 55 51 for (int i = 0; i < q.size(); i++) { … … 62 58 if (choosenResources != null) { 63 59 addToSchedulingPlan(plan, task, choosenResources); 64 ProcessingElements pes = (ProcessingElements)choosenResources.get(StandardResourceUnitName.PE);65 List<Processor> processors = new ArrayList<Processor>();66 for(ComputingResource res : pes){67 processors.add((Processor) res);68 }69 adjustFrequency(ResourceStatus.BUSY,processors);70 60 } 71 61 } 72 62 } 73 break; 74 75 case TASK_FINISHED: 76 TaskFinishedEvent finEvent = (TaskFinishedEvent) event; 77 Executable exec = (Executable) jobRegistry.getExecutable(finEvent.getJobId(), finEvent.getTaskId()); 78 UsedResourcesList usedResourcesList = exec.getUsedResources(); 79 ProcessingElements pes = (ProcessingElements)usedResourcesList.getLast().getResourceUnits().get(StandardResourceUnitName.PE); 80 List<Processor> processors = new ArrayList<Processor>(); 81 for(ComputingResource res : pes){ 82 processors.add((Processor) res); 83 allocatedCPUs.add((Processor) res); 84 } 85 adjustFrequency(ResourceStatus.FREE, processors); 86 break; 87 88 case TASK_REQUESTED_TIME_EXPIRED: 89 TaskRequestedTimeExpiredEvent timExpEvent = (TaskRequestedTimeExpiredEvent) event; 90 exec = (Executable) jobRegistry.getExecutable(timExpEvent.getJobId(), timExpEvent.getTaskId()); 91 usedResourcesList = exec.getUsedResources(); 92 pes = (ProcessingElements)usedResourcesList.getLast().getResourceUnits().get(StandardResourceUnitName.PE); 93 processors = new ArrayList<Processor>(); 94 for(ComputingResource res : pes){ 95 allocatedCPUs.remove((Processor) res); 96 } 97 // check all tasks in queue 98 for (int i = 0; i < q.size(); i++) { 99 WorkloadUnit job = q.get(i); 100 TaskInterface<?> task = (TaskInterface<?>) job; 101 // if status of the tasks in READY 102 if (task.getStatus() == DCWormsTags.READY) { 103 104 Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 105 if (choosenResources != null) { 106 addToSchedulingPlan(plan, task, choosenResources); 107 pes = (ProcessingElements)choosenResources.get(StandardResourceUnitName.PE); 108 processors = new ArrayList<Processor>(); 109 for(ComputingResource res : pes){ 110 processors.add((Processor) res); 111 } 112 adjustFrequency(ResourceStatus.BUSY, processors); 113 } 114 } 115 } 116 break; 63 adjustFrequency(resourceManager.getProcessors()); 117 64 } 118 65 return plan; … … 160 107 return map; 161 108 } 109 110 private void adjustFrequency(List<Processor> processors){ 162 111 163 private void adjustFrequency(ResourceStatus status, List<Processor> processors){ 164 switch(status){ 165 case BUSY: 166 for(Processor cpu: processors){ 167 try { 168 if(cpu.getPowerInterface().getSupportedPStates().containsKey("P0")) 169 cpu.getPowerInterface().setPState("P0"); 170 } catch (NoSuchFieldException e) { 171 // TODO Auto-generated catch block 172 e.printStackTrace(); 173 } 112 for(Processor cpu: processors){ 113 if(cpu.getStatus() == ResourceStatus.FREE) { 114 if(cpu.getPowerInterface().getSupportedPStates().containsKey("P3")) 115 cpu.getPowerInterface().setPState("P3"); 174 116 } 175 break; 176 case FREE: 177 for(Processor cpu: processors){ 178 try { 179 if(cpu.getPowerInterface().getSupportedPStates().containsKey("P3")) 180 cpu.getPowerInterface().setPState("P3"); 181 } catch (NoSuchFieldException e) { 182 // TODO Auto-generated catch block 183 e.printStackTrace(); 184 } 117 else{ 118 if(cpu.getPowerInterface().getSupportedPStates().containsKey("P0")) 119 cpu.getPowerInterface().setPState("P0"); 185 120 } 186 break; 121 187 122 } 123 188 124 } 189 125 126 190 127 }
Note: See TracChangeset
for help on using the changeset viewer.