- Timestamp:
- 04/11/12 16:30:38 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
xssim/branches/tpiontek/src/example/localplugin/FCFSRandomClusterLocalPlugin.java
r192 r241 3 3 import gridsim.Gridlet; 4 4 5 import java.util.ArrayList; 5 6 import java.util.List; 6 7 import java.util.Properties; … … 11 12 import schedframe.scheduling.plugin.grid.ModuleList; 12 13 import test.rewolucja.GSSIMJobInterface; 14 import test.rewolucja.energy.profile.PStateType; 13 15 import test.rewolucja.resources.manager.implementation.ClusterResourceManager; 14 16 import test.rewolucja.resources.manager.interfaces.ResourceManagerInterface; 15 17 import test.rewolucja.resources.physical.implementation.ComputingNode; 18 import test.rewolucja.resources.physical.implementation.Processor; 16 19 import test.rewolucja.scheduling.JobRegistryInterface; 17 20 import test.rewolucja.scheduling.plan.SchedulingPlanInterfaceNew; … … 23 26 24 27 private Random rand; 28 private boolean init = true; 25 29 26 30 public FCFSRandomClusterLocalPlugin() { … … 30 34 public SchedulingPlanInterfaceNew schedule(SchedulingEvent event, QueueList queues, JobRegistryInterface jobRegistry, 31 35 ResourceManagerInterface resManager, ModuleList modules) { 36 37 ClusterResourceManager resourceManager = (ClusterResourceManager) resManager; 38 39 if( init) 40 { 41 List<Processor> cpus = resourceManager.getProcessors(); 42 43 for( Processor cpu : cpus) 44 cpu.getPowerInterface().setPState( PStateType.P3); 45 46 init = false; 47 } 48 32 49 33 ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;50 34 51 SchedulingPlanNew plan = new SchedulingPlanNew(); 35 52 // chose the events types to serve. … … 48 65 // if status of the tasks in READY 49 66 if (task.getStatus() == Gridlet.READY) { 50 String nodeName = chooseRandomProvider(resourceManager );67 String nodeName = chooseRandomProvider(resourceManager, task); 51 68 if (nodeName != null) { 52 69 addToSchedulingPlan(plan, task, nodeName); … … 59 76 } 60 77 61 private String chooseRandomProvider(ClusterResourceManager resourceManager) { 78 private List<ComputingNode> findSuitableNodes(int cpuRequest, List<ComputingNode> nodes){ 79 List<ComputingNode> avNodes = new ArrayList<ComputingNode>(); 80 for(ComputingNode node: nodes){ 81 if(node.getFreeProcessorsNumber() >= cpuRequest){ 82 avNodes.add(node); 83 } 84 } 85 return avNodes; 86 } 87 88 private String chooseRandomProvider(ClusterResourceManager resourceManager, TaskInterface<?> task) { 89 90 int cpuRequest; 91 try { 92 cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue(); 93 } catch (NoSuchFieldException e) { 94 cpuRequest = 1; 95 } 96 62 97 List<ComputingNode> nodes = resourceManager.getComputingNodes(); 98 99 nodes = findSuitableNodes(cpuRequest, nodes); 100 63 101 int nodeIdx = rand.nextInt(nodes.size()); 64 102 return nodes.get(nodeIdx).getName();
Note: See TracChangeset
for help on using the changeset viewer.