- Timestamp:
- 10/11/12 09:07:11 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/trunk/src/example/localplugin/FCFSClusterLocalPlugin.java
r493 r497 57 57 58 58 /****************1. Choosing particular resources to perform execution****************/ 59 Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution 2(resourceManager, task);59 Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 60 60 if (choosenResources != null) { 61 61 addToSchedulingPlan(plan, task, choosenResources); … … 80 80 81 81 private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution( 82 ClusterResourceManager resourceManager, TaskInterface<?> task) {83 84 Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();85 86 int cpuRequest;87 try {88 cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue();89 } catch (NoSuchFieldException e) {90 cpuRequest = 1;91 }92 93 if (cpuRequest != 0) {94 List<ComputingResource> choosenResources = null;95 List<Processor> processors = null;96 processors = resourceManager.getProcessors();97 if (processors.size() < cpuRequest) {98 // log.warn("Task requires more cpus than is availiable in this resource.");99 return null;100 }101 102 choosenResources = new ArrayList<ComputingResource>();103 104 for (int i = 0; i < processors.size() && cpuRequest > 0; i++) {105 if (processors.get(i).getStatus() == ResourceStatus.FREE) {106 choosenResources.add(processors.get(i));107 cpuRequest--;108 }109 }110 if (cpuRequest > 0) {111 // log.info("Task " + task.getJobId() + "_" + task.getId() +112 // " requires more cpus than is availiable in this moment.");113 return null;114 }115 116 ProcessingElements result = new ProcessingElements(processors.get(0).getParent().getName());117 result.addAll(choosenResources);118 map.put(StandardResourceUnitName.PE, result);119 120 }121 int memoryRequest;122 try {123 memoryRequest = Double.valueOf(task.getMemoryRequest()).intValue();124 } catch (NoSuchFieldException e) {125 memoryRequest = 0;126 }127 if (memoryRequest != 0) {128 List<ComputingNode> nodes = resourceManager.getComputingNodes();129 130 Memory memory = null;131 for (ComputingNode node : nodes) {132 try{133 if (node.getFreeMemory() >= memoryRequest) {134 memory = new Memory(node.getMemory(), memoryRequest, memoryRequest);135 }136 } catch(NoSuchFieldException e){137 memory = null;138 }139 }140 if(memory != null)141 map.put(StandardResourceUnitName.MEMORY, memory);142 else return null;143 }144 145 return map;146 }147 148 149 private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution2(150 82 ClusterResourceManager resourceManager, TaskInterface<?> task) { 151 83 … … 204 136 return map; 205 137 } 206 } 138 } else return map; 207 139 } 208 140 }
Note: See TracChangeset
for help on using the changeset viewer.