- Timestamp:
- 07/15/14 16:26:31 (11 years ago)
- Location:
- DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/global/GlobalManagementSystem.java
r1385 r1415 78 78 return; 79 79 } 80 81 80 registerWorkloadUnit(wu); 82 81 -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java
r1396 r1415 19 19 import schedframe.events.scheduling.StartTaskExecutionEvent; 20 20 import schedframe.events.scheduling.TaskFinishedEvent; 21 import schedframe.events.scheduling.TaskPausedEvent; 21 22 import schedframe.events.scheduling.TaskRequestedTimeExpiredEvent; 23 import schedframe.events.scheduling.TaskResumedEvent; 22 24 import schedframe.exceptions.ResourceException; 23 25 import schedframe.resources.StandardResourceType; 24 26 import schedframe.resources.computing.ComputingResource; 25 import schedframe.resources.computing.profiles.energy. EnergyEvent;26 import schedframe.resources.computing.profiles.energy. EnergyEventType;27 import schedframe.resources.computing.profiles.energy.ResourceEvent; 28 import schedframe.resources.computing.profiles.energy.ResourceEventType; 27 29 import schedframe.resources.units.PEUnit; 28 30 import schedframe.resources.units.ProcessingElements; … … 163 165 String[] ids = (String[]) ev.get_data(); 164 166 execTask = jobRegistry.getTask(ids[0], ids[1]); 165 taskPause(execTask);167 pauseTask(execTask); 166 168 if (pluginSupportsEvent(tag)) { 167 SchedulingEvent event = new SchedulingEvent(SchedulingEventType.TASK_PAUSED);169 SchedulingEvent event = new TaskPausedEvent(ids[0], ids[1]); 168 170 SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 169 171 queues, jobRegistry, getResourceManager(), moduleList); … … 176 178 String[] ids = (String[]) ev.get_data(); 177 179 execTask = jobRegistry.getTask(ids[0], ids[1]); 178 taskResume(execTask, execTask.getAllocatedResources().getLast().getResourceUnits(), true);180 resumeTask(execTask, execTask.getAllocatedResources().getLast().getResourceUnits(), true); 179 181 if (pluginSupportsEvent(tag)) { 180 SchedulingEvent event = new StartTaskExecutionEvent(ids[0], ids[1]);182 SchedulingEvent event = new TaskResumedEvent(ids[0], ids[1]); 181 183 SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 182 184 queues, jobRegistry, getResourceManager(), moduleList); … … 189 191 Object[] data = (Object[]) ev.get_data(); 190 192 execTask = jobRegistry.getTask((String)data[0], (String)data[1]); 191 double migrationTime = execTimeEstimationPlugin.estimateMigrationTime(new StartTaskExecutionEvent((String)data[0], (String)data[1]), execTask, execTask.getAllocatedResources().getLast().getResourceUnits(), (Map<ResourceUnitName, ResourceUnit>)data[2]); 193 double migrationTime = execTimeEstimationPlugin.estimateMigrationTime(new StartTaskExecutionEvent((String)data[0], 194 (String)data[1]), execTask, execTask.getAllocatedResources().getLast().getResourceUnits(), (Map<ResourceUnitName, ResourceUnit>)data[2]); 192 195 scheduler.sendInternal(migrationTime, DCWormsTags.TASK_MOVE, data); 193 196 } … … 197 200 Object[] data = (Object[]) ev.get_data(); 198 201 execTask = jobRegistry.getTask((String)data[0], (String)data[1]); 199 taskMove(execTask, (Map<ResourceUnitName, ResourceUnit>)data[2]);202 moveTask(execTask, (Map<ResourceUnitName, ResourceUnit>)data[2]); 200 203 if (pluginSupportsEvent(tag)) { 201 204 SchedulingEvent event = new StartTaskExecutionEvent((String)data[0], (String)data[1]); … … 209 212 case DCWormsTags.TASK_EXECUTION_CHANGED: 210 213 execTask = (ExecTask) ev.get_data(); 211 updateTaskExecutionPhase(execTask , SchedulingEventType.RESOURCE_STATE_CHANGED);214 updateTaskExecutionPhase(execTask); 212 215 break; 213 216 … … 231 234 } 232 235 break; 233 } 234 } 235 236 237 public void taskPause(ExecTask execTask) { 236 default: 237 238 break; 239 } 240 } 241 242 243 protected void pauseTask(ExecTask execTask) { 238 244 if (execTask == null) { 239 245 return; … … 246 252 getAllocationManager().freeResources(lastUsed, true); 247 253 248 saveExecutionHistory(exec, exec.get CompletionPercentage(), exec.getEstimatedDuration());254 saveExecutionHistory(exec, exec.getExecutionProfile().getCompletionPercentage(), exec.getEstimatedDuration()); 249 255 250 256 ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), -1); … … 252 258 253 259 PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE); 254 updateComputingResources(peUnit, EnergyEventType.TASK_FINISHED, exec);260 updateComputingResources(peUnit, ResourceEventType.TASK_FINISHED, exec); 255 261 } catch (Exception e) { 256 262 // TODO Auto-generated catch block … … 260 266 } 261 267 262 p ublic void taskResume(ExecTask execTask, Map<ResourceUnitName, ResourceUnit> resources, boolean exclusive) {268 protected void resumeTask(ExecTask execTask, Map<ResourceUnitName, ResourceUnit> resources, boolean exclusive) { 263 269 if (execTask == null) { 264 270 return; … … 278 284 279 285 PEUnit peUnit = (PEUnit)resources.get(StandardResourceUnitName.PE); 280 updateComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec);286 updateComputingResources(peUnit, ResourceEventType.TASK_STARTED, exec); 281 287 } 282 288 … … 288 294 } 289 295 290 p ublic void taskMove(ExecTask execTask, Map<ResourceUnitName, ResourceUnit> map) {291 taskPause(execTask);292 taskResume(execTask, map, false);296 protected void moveTask(ExecTask execTask, Map<ResourceUnitName, ResourceUnit> map) { 297 pauseTask(execTask); 298 resumeTask(execTask, map, false); 293 299 } 294 300 … … 351 357 352 358 PEUnit peUnit = (PEUnit)choosenResources.get(StandardResourceUnitName.PE); 353 updateComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec);359 updateComputingResources(peUnit, ResourceEventType.UTILIZATION_CHANGED, exec); 354 360 355 361 … … 377 383 378 384 int phaseDuration = Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.START_TASK_EXECUTION), 379 execTask, resources, exec.get CompletionPercentage())).intValue();380 381 saveExecutionHistory(exec, exec.get CompletionPercentage(), phaseDuration);385 execTask, resources, exec.getExecutionProfile().getCompletionPercentage())).intValue(); 386 387 saveExecutionHistory(exec, exec.getExecutionProfile().getCompletionPercentage(), phaseDuration); 382 388 if(exec.getExecutionProfile().isLast()){ 383 389 scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_FINISHED, execTask);; … … 387 393 388 394 PEUnit peUnit = (PEUnit)resources.get(StandardResourceUnitName.PE); 389 updateComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec);395 updateComputingResources(peUnit, ResourceEventType.TASK_STARTED, exec); 390 396 391 397 } … … 429 435 430 436 PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE); 431 updateComputingResources(peUnit, EnergyEventType.TASK_FINISHED, exec);437 updateComputingResources(peUnit, ResourceEventType.TASK_FINISHED, exec); 432 438 433 439 log.debug(execTask.getJobId() + "_" + execTask.getId() + " finished execution on " + new DateTime()); 434 440 log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad()); 435 441 436 updateComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec);442 updateComputingResources(peUnit, ResourceEventType.UTILIZATION_CHANGED, exec); 437 443 } 438 444 … … 452 458 //System.out.println("--- upadteProgressX: " + Sim_system.sim_clock() ); 453 459 //System.out.println("taskId: " + exec.getId() + "; completion percentage: " + exec.getCompletionPercentage() + "; timespan: " + timeSpan + "; estimatedDuration: " + execHistItem.getCompletionPercentage()); 454 exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / (execHistItem.getEstimatedDuration()) * (1.0 - execHistItem.getCompletionPercentage()/100.0))); 460 exec.getExecutionProfile().setCompletionPercentage(exec.getExecutionProfile().getCompletionPercentage() + 100 * (timeSpan / (execHistItem.getEstimatedDuration()) * (1.0 - execHistItem.getCompletionPercentage()/100.0))); 461 exec.setTotalCompletionPercentage(exec.getTotalCompletionPercentage() + 100 * (timeSpan / execHistItem.getEstimatedDuration()) * exec.getExecutionProfile().getCurrentResourceConsumption().getLenght() / exec.getExecutionProfile().getLength()); 455 462 //System.out.println("newProgress: " + exec.getCompletionPercentage() ); 456 463 … … 458 465 } 459 466 460 private void updateComputingResources(PEUnit peUnit, EnergyEventType eventType, Object obj){467 private void updateComputingResources(PEUnit peUnit, ResourceEventType eventType, Object obj){ 461 468 if(peUnit instanceof ProcessingElements){ 462 469 ProcessingElements pes = (ProcessingElements) peUnit; 463 470 for (ComputingResource resource : pes) { 464 resource.handleEvent(new EnergyEvent(eventType, obj, scheduler.getFullName()));471 resource.handleEvent(new ResourceEvent(eventType, obj, scheduler.getFullName())); 465 472 //DataCenterWorkloadSimulator.getEventManager().sendToResources(resource.getType(), 0, new EnergyEvent(eventType, obj)); 466 473 } … … 480 487 return; 481 488 } 482 resource.handleEvent(new EnergyEvent(eventType, obj, scheduler.getFullName()));489 resource.handleEvent(new ResourceEvent(eventType, obj, scheduler.getFullName())); 483 490 } 484 491 } … … 492 499 493 500 int phaseDuration = Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.RESOURCE_STATE_CHANGED), 494 execTask, choosenResources, exec.get CompletionPercentage())).intValue();501 execTask, choosenResources, exec.getExecutionProfile().getCompletionPercentage())).intValue(); 495 502 496 503 ExecutionHistoryItem execHistItem = exec.getExecutionHistory().getLast(); 497 double lastTimeStamp = execHistItem.getTimeStamp().getMillis() /1000;498 if(DoubleMath.subtract((lastTimeStamp + execHistItem.getEstimatedDuration()), (new DateTime().getMillis() /1000 + phaseDuration)) == 0.0){504 double lastTimeStamp = execHistItem.getTimeStamp().getMillis() / 1000; 505 if(DoubleMath.subtract((lastTimeStamp + execHistItem.getEstimatedDuration()), (new DateTime().getMillis() / 1000 + phaseDuration)) == 0.0){ 499 506 continue; 500 507 } … … 504 511 //System.out.println("completionPercantage: " + exec.getCompletionPercentage() + "; basic duration: " +exec.getResourceConsumptionProfile().getCurrentResourceConsumption().getDuration() + "; phaseDuration: " + phaseDuration); 505 512 506 saveExecutionHistory(exec, exec.get CompletionPercentage(), phaseDuration);513 saveExecutionHistory(exec, exec.getExecutionProfile().getCompletionPercentage(), phaseDuration); 507 514 508 515 if(exec.getExecutionProfile().isLast()){ … … 522 529 } 523 530 524 protected void updateTaskExecutionPhase(ExecTask execTask , SchedulingEventType schedEvType) {531 protected void updateTaskExecutionPhase(ExecTask execTask) { 525 532 526 533 if (execTask.getStatus() == DCWormsTags.INEXEC) { … … 535 542 Map<ResourceUnitName, ResourceUnit> choosenResources = exec.getAllocatedResources().getLast().getResourceUnits(); 536 543 537 int phaseDuration = Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent( schedEvType),538 execTask, choosenResources, exec.get CompletionPercentage())).intValue();539 540 saveExecutionHistory(exec, exec.get CompletionPercentage(), phaseDuration);544 int phaseDuration = Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.TASK_EXECUTION_CHANGED), 545 execTask, choosenResources, exec.getExecutionProfile().getCompletionPercentage())).intValue(); 546 547 saveExecutionHistory(exec, exec.getExecutionProfile().getCompletionPercentage(), phaseDuration); 541 548 542 549 if(exec.getExecutionProfile().isLast()){ … … 547 554 548 555 PEUnit peUnit = (PEUnit)exec.getAllocatedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 549 updateComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec);556 updateComputingResources(peUnit, ResourceEventType.UTILIZATION_CHANGED, exec); 550 557 } 551 558 } 552 559 553 p ublicdouble calculateTotalLoad() {560 protected double calculateTotalLoad() { 554 561 555 562 DCwormsAccumulator loadAcc = new DCwormsAccumulator(); 556 try { 557 for(ComputingResource compRes: getResourceManager().getResourcesOfType(StandardResourceType.Node)){ 558 loadAcc.add(compRes.getLoadInterface().getRecentUtilization().getValue()); 559 } 560 } catch (ResourceException e) { 561 // TODO Auto-generated catch block 562 e.printStackTrace(); 563 } 564 563 564 for(ComputingResource compRes: getResourceManager().getResourcesOfType(StandardResourceType.Node)){ 565 loadAcc.add(compRes.getLoadInterface().getRecentUtilization().getValue()); 566 } 567 565 568 return loadAcc.getMean(); 566 569 } … … 703 706 704 707 private void saveExecutionHistory(Executable exec, double completionPercentage, double estimatedDuration){ 705 706 708 ExecutionHistoryItem execHistoryItem = new ExecutionHistoryItem(new DateTime()); 707 709 execHistoryItem.setCompletionPercentage(completionPercentage); … … 710 712 execHistoryItem.setStatus(exec.getStatus()); 711 713 exec.addExecHistory(execHistoryItem); 712 713 714 } 714 715
Note: See TracChangeset
for help on using the changeset viewer.