Changeset 270
- Timestamp:
- 04/13/12 10:51:18 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
xssim/branches/tpiontek/src/example/localplugin/FCFSConsolidationClusterLocalPlugin.java
r269 r270 2 2 3 3 import gridsim.Gridlet; 4 import gridsim.gssim.ResourceHistoryItem; 5 import gridsim.gssim.SubmittedTask; 4 6 5 7 import java.util.ArrayList; … … 12 14 import schedframe.scheduling.TaskInterface; 13 15 import schedframe.scheduling.events.SchedulingEvent; 16 import schedframe.scheduling.events.TaskFinishedEvent; 14 17 import schedframe.scheduling.plugin.grid.ModuleList; 18 import schedframe.scheduling.utils.ResourceParameterName; 15 19 import test.rewolucja.GSSIMJobInterface; 20 import test.rewolucja.resources.ProcessingElements; 21 import test.rewolucja.resources.ResourceStatus; 22 import test.rewolucja.resources.ResourceType; 16 23 import test.rewolucja.resources.manager.implementation.ClusterResourceManager; 17 24 import test.rewolucja.resources.manager.interfaces.ResourceManagerInterface; 25 import test.rewolucja.resources.physical.base.ComputingResource; 18 26 import test.rewolucja.resources.physical.implementation.ComputingNode; 27 import test.rewolucja.resources.physical.implementation.Processor; 19 28 import test.rewolucja.scheduling.JobRegistryInterface; 29 import test.rewolucja.scheduling.UsedResourceList; 20 30 import test.rewolucja.scheduling.plan.SchedulingPlanInterfaceNew; 21 31 import test.rewolucja.scheduling.plan.SchedulingPlanNew; … … 38 48 // Different actions for different events are possible. 39 49 switch (event.getType()) { 40 case START_TASK_EXECUTION:41 50 case TASK_FINISHED: 51 if( scenario == 1) 52 { 53 TaskFinishedEvent finEvent = (TaskFinishedEvent) event; 54 SubmittedTask subTask = jobRegistry.getSubmittedTask(finEvent.getJobId(), finEvent.getTaskId()); 55 UsedResourceList<ResourceHistoryItem> usedResourcesList = subTask.getUsedResources(); 56 ProcessingElements pes = (ProcessingElements)usedResourcesList.getLast().getResourceUnits().get(ResourceParameterName.PROCESSINGELEMENTS); 57 58 ComputingNode cn = ((Processor)pes.get(0)).getComputingNode(); 59 if( cn.getFreeProcessors().size() == cn.getProcessorsNumber()) 60 cn.getPowerInterface().setPowerState( PowerState.OFF); 61 } 62 case START_TASK_EXECUTION: 42 63 // our tasks are placed only in first queue (see 43 64 // BaseLocalPlugin.placeJobsInQueues() method) … … 52 73 53 74 ComputingNode node = chooseResourcesForExecution(resourceManager, PowerState.ON, task); 75 54 76 if (node != null) { 55 System.out.println("Uruchamiam na zasobie: " + node.getName()); 56 addToSchedulingPlan(plan, task, node.getName()); 77 List<Processor> cpus = chooseProcessorsForExecution(node, ResourceStatus.FREE, task); 78 //System.out.println("Uruchamiam na zasobie: " + node.getName()); 79 addToSchedulingPlan(plan, task, cpus); 57 80 } 58 81 else … … 62 85 if( node != null) 63 86 { 64 System.out.println("Wlaczam wezel: " + node.getName());87 //System.out.println("Wlaczam wezel: " + node.getName()); 65 88 node.getPowerInterface().setPowerState( PowerState.ON); 66 89 i--; … … 78 101 if( node.getFreeProcessors().size() == node.getProcessorsNumber()) 79 102 { 103 //System.out.println("Wylaczam zasob" + node.getName()); 80 104 node.getPowerInterface().setPowerState( PowerState.OFF); 105 //System.out.println("Zasob w stanie: " + node.getPowerInterface().getPowerState()); 81 106 } 82 107 break; … … 86 111 break; 87 112 } 113 88 114 return plan; 89 115 } … … 91 117 private ComputingNode chooseResourcesForExecution(ClusterResourceManager resourceManager, PowerState status, TaskInterface<?> task) { 92 118 119 //System.out.println("Szukam zasobow w stanie: " +status); 120 93 121 List<ComputingNode> nodes = resourceManager.getComputingNodes(); 94 122 nodes = findSuitableNodes(task, status, nodes); … … 107 135 108 136 private List<ComputingNode> findSuitableNodes(TaskInterface<?> task, PowerState status, List<ComputingNode> nodes){ 109 int cpuRequest; 110 try { 111 cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue(); 112 } catch (NoSuchFieldException e) { 113 cpuRequest = 1; 114 } 137 138 int cpuRequest = getCpuRequest(task); 115 139 116 140 List<ComputingNode> suitableNodes = new ArrayList<ComputingNode>(); 141 117 142 for(ComputingNode node: nodes) 118 143 { 144 if( node.getPowerInterface().getPowerState() == status) 119 145 switch( status) 120 146 { 121 147 case ON: 122 148 if(node.getFreeProcessorsNumber() >= cpuRequest) 149 { 123 150 suitableNodes.add(node); 151 } 124 152 break; 125 153 case OFF: … … 140 168 // no extra initialization is expected. 141 169 } 170 171 private List<Processor> chooseProcessorsForExecution( 172 ComputingNode node, ResourceStatus status, TaskInterface<?> task) { 173 174 int cpuRequest = getCpuRequest(task); 142 175 176 List<Processor> cpus = (List<Processor>)node.getDescendantsByTypeAndStatus( ResourceType.CPU, status); 177 178 return cpus.subList(0, cpuRequest); 179 } 180 181 private int getCpuRequest( TaskInterface<?> task) 182 { 183 int cpuRequest; 184 185 try { 186 cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue(); 187 } catch (NoSuchFieldException e) { 188 cpuRequest = 1; 189 } 190 191 return cpuRequest; 192 } 143 193 }
Note: See TracChangeset
for help on using the changeset viewer.