Changeset 1298 for DCWoRMS/branches
- Timestamp:
- 03/19/14 18:19:43 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java
r1207 r1298 5 5 import eduni.simjava.Sim_event; 6 6 import eduni.simjava.Sim_system; 7 import gridsim.Accumulator;8 import gridsim.ResourceCalendar;9 7 import gridsim.dcworms.DCWormsTags; 10 8 import gridsim.dcworms.filter.ExecTaskFilter; … … 31 29 import schedframe.events.scheduling.TaskRequestedTimeExpiredEvent; 32 30 import schedframe.exceptions.ResourceException; 31 import schedframe.resources.StandardResourceType; 33 32 import schedframe.resources.computing.ComputingResource; 34 33 import schedframe.resources.computing.profiles.energy.EnergyEvent; … … 54 53 import schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin; 55 54 import schedframe.scheduling.plugin.grid.ModuleListImpl; 56 import schedframe.scheduling.plugin.grid.ModuleType;57 55 import schedframe.scheduling.policy.AbstractManagementSystem; 58 56 import schedframe.scheduling.queue.TaskQueueList; … … 64 62 import schedframe.scheduling.tasks.WorkloadUnit; 65 63 import simulator.DCWormsConstants; 64 import simulator.stats.GSSAccumulator; 66 65 import simulator.utils.DoubleMath; 67 66 … … 71 70 72 71 protected double lastUpdateTime; 73 74 protected Accumulator accTotalLoad;75 72 76 73 public LocalManagementSystem(String providerId, String entityName, SchedulingPlugin schedPlugin, … … 85 82 this.schedulingPlugin = schedPlugin; 86 83 this.moduleList = new ModuleListImpl(1); 87 88 this.accTotalLoad = new Accumulator();89 84 } 90 85 91 86 public void init(Scheduler sched, ManagedResources managedResources) { 92 87 super.init(sched, managedResources); 93 double load = 0;94 accTotalLoad.add(load);95 88 } 96 89 … … 135 128 sendFinishedWorkloadUnit(execTask); 136 129 log.debug(execTask.getJobId() + "_" + execTask.getId() + " finished execution on " + new DateTime()); 137 log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad( jobRegistry.getRunningTasks().size()));130 log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad()); 138 131 if (pluginSupportsEvent(tag)) { 139 132 SchedulingEvent event = new TaskFinishedEvent(execTask.getJobId(), execTask.getId()); … … 178 171 execTask = (ExecTask) ev.get_data(); 179 172 updateTaskExecution(execTask, SchedulingEventType.RESOURCE_STATE_CHANGED); 173 break; 174 175 case DCWormsTags.POWER_LIMIT_EXCEEDED: 176 if (pluginSupportsEvent(tag)) { 177 SchedulingEvent event = new SchedulingEvent(SchedulingEventType.POWER_LIMIT_EXCEEDED); 178 schedulingPlugin.schedule(event, 179 queues, getJobRegistry(), getResourceManager(), moduleList); 180 } 180 181 break; 181 182 } … … 263 264 } 264 265 265 log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad( jobRegistry.getRunningTasks().size()));266 log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad()); 266 267 267 268 PEUnit peUnit = (PEUnit)choosenResources.get(StandardResourceUnitName.PE); … … 323 324 ExecTask task = iter.next(); 324 325 Executable exec = (Executable)task; 325 exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / exec.getEstimatedDuration()));326 UsedResourcesList usedResourcesList = exec.getUsedResources();327 PEUnit peUnit = (PEUnit)usedResourcesList.getLast().getResourceUnits()328 .get(StandardResourceUnitName.PE);329 double load = getMIShare(timeSpan, peUnit);330 addTotalLoad(load);326 if( exec.getUsedResources().size() > 1){ 327 exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / exec.getEstimatedDuration() * (1.0 - exec.getCompletionPercentage()/100.0))); 328 } 329 else { 330 exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / exec.getEstimatedDuration())); 331 } 331 332 } 332 333 } … … 357 358 } 358 359 } 359 360 private double getMIShare(double timeSpan, PEUnit pes) {361 double localLoad;362 ResourceCalendar resCalendar = (ResourceCalendar) moduleList.getModule(ModuleType.RESOURCE_CALENDAR);363 if (resCalendar == null)364 localLoad = 0;365 else366 // 1 - localLoad_ = available MI share percentage367 localLoad = resCalendar.getCurrentLoad();368 369 int speed = pes.getSpeed();370 int cnt = pes.getAmount();371 372 double totalMI = speed * cnt * timeSpan * (1 - localLoad);373 return totalMI;374 }375 360 376 361 protected void updateProcessingTimes(Sim_event ev) { 377 updateProcessingProgress();378 362 for (ExecTask execTask : jobRegistry.getRunningTasks()) { 379 363 Executable exec = (Executable)execTask; … … 385 369 386 370 if(DoubleMath.subtract((lastTimeStamp + exec.getEstimatedDuration()), (new DateTime().getMillis()/1000 + phaseDuration)) == 0.0){ 387 return;371 continue; 388 372 } 389 373 … … 438 422 } 439 423 440 public double calculateTotalLoad(int size) { 441 // background load, defined during initialization 442 double load; 443 ResourceCalendar resCalendar = (ResourceCalendar) moduleList.getModule(ModuleType.RESOURCE_CALENDAR); 444 if (resCalendar == null) 445 load = 0; 446 else 447 load = resCalendar.getCurrentLoad(); 448 449 int numberOfPE = 0; 424 public double calculateTotalLoad() { 425 426 GSSAccumulator loadAcc = new GSSAccumulator(); 450 427 try { 451 for(ResourceUnit resUnit : getResourceManager().getPE()){ 452 numberOfPE = numberOfPE + resUnit.getAmount(); 453 } 454 } catch (Exception e) { 455 numberOfPE = 1; 456 } 457 double tasksPerPE = (double) size / numberOfPE; 458 load += Math.min(1.0 - load, tasksPerPE); 459 460 return load; 461 } 462 463 public Accumulator getTotalLoad() { 464 return accTotalLoad; 465 } 466 467 protected void addTotalLoad(double load) { 468 accTotalLoad.add(load); 469 } 470 428 for(ComputingResource compRes: getResourceManager().getResourcesOfType(StandardResourceType.Node)){ 429 loadAcc.add(compRes.getLoadInterface().getRecentUtilization().getValue()); 430 } 431 } catch (ResourceException e) { 432 // TODO Auto-generated catch block 433 e.printStackTrace(); 434 } 435 436 return loadAcc.getMean(); 437 } 438 471 439 private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(String resourceName, 472 440 ExecTask task) {
Note: See TracChangeset
for help on using the changeset viewer.