Changeset 896 for DCWoRMS/branches/coolemall
- Timestamp:
- 03/04/13 08:25:34 (12 years ago)
- Location:
- DCWoRMS/branches/coolemall/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java
r885 r896 25 25 import schedframe.scheduling.tasks.AbstractProcessesGroup; 26 26 import schedframe.scheduling.tasks.Task; 27 import schedframe.scheduling.tasks.phases.ResourceConsumption; 27 28 import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile; 28 29 import schedframe.scheduling.tasks.requirements.ResourceParameterName; … … 39 40 40 41 protected int status; 41 protected double length;42 42 protected Map<ResourceParameterName, Object> specificResources; 43 43 … … 158 158 } 159 159 160 if (newStatus < DCWormsTags.CREATED || newStatus > DCWormsTags. FAILED_RESOURCE_UNAVAILABLE) {160 if (newStatus < DCWormsTags.CREATED || newStatus > DCWormsTags.NEW_EXEC_PHASE) { 161 161 throw new Exception("Executable.setStatuts() : Error - " + 162 162 "Invalid integer range for Execiutable status."); … … 204 204 } 205 205 } 206 207 if(status == DCWormsTags.NEW_EXEC_PHASE){ 208 if(prevStatus == DCWormsTags.INEXEC){ 209 status = DCWormsTags.INEXEC; 210 setCompletionPercentage(0); 211 task.getResourceConsumptionProfile().setCurrentPhase(task.getResourceConsumptionProfile().getCurrentPhase() + 1); 212 213 DateTime currentDateTime = new DateTime(); 214 215 if(getUsedResources().getLast().getTimeStamp().getMillis() == currentDateTime.getMillis()){ 216 return; 217 } 218 ResourceHistoryItem resHistItem = new ResourceHistoryItem(getUsedResources().getLast().getResourceUnits(), currentDateTime); 219 addUsedResources(resHistItem); 220 } 221 } 206 222 } 207 223 … … 209 225 if(this.specificResources == null) 210 226 this.specificResources = new HashMap<ResourceParameterName, Object>(); 211 212 227 this.specificResources.put(resourceName, value); 213 228 } … … 216 231 if(this.specificResources == null) 217 232 return false; 218 219 233 return this.specificResources.containsKey(resourceName); 220 234 } … … 255 269 } 256 270 257 public void setSchedulerName(int resourceId) 258 { 271 public void setSchedulerName(int resourceId){ 259 272 this.schedName = GridSim.getEntityName(resourceId); 260 273 } 261 274 262 public String getSchedulerName() 263 { 275 public String getSchedulerName(){ 264 276 return schedName; 265 277 } … … 368 380 } 369 381 370 private int currentPhase = 0; 371 372 public int getCurrentPhase() { 373 return currentPhase; 374 } 375 376 public void setCurrentPhase(int currentPhase) { 377 this.currentPhase = currentPhase; 382 public ResourceConsumption getCurrentResourceConsumption(){ 383 return task.getResourceConsumptionProfile().getCurrentResourceConsumption(); 378 384 } 379 385 -
DCWoRMS/branches/coolemall/src/gridsim/dcworms/DCWormsTags.java
r808 r896 14 14 public static final int TO_SCHEDULERS = DCWORMSBASE - 3; 15 15 16 public static final int PHASE_CHANGED = DCWORMSBASE - 2;16 public static final int TASK_EXECUTION_CHANGED = DCWORMSBASE - 2; 17 17 18 18 public static final int UPDATE_PROCESSING = DCWORMSBASE - 1; … … 55 55 public static final int RESUMED = 9; 56 56 57 public static final int FAILED_RESOURCE_UNAVAILABLE = 10;57 public static final int NEW_EXEC_PHASE = 10; 58 58 59 59 } -
DCWoRMS/branches/coolemall/src/schedframe/events/scheduling/SchedulingEventType.java
r477 r896 20 20 21 21 //time related 22 TIMER(25 4),22 TIMER(256), 23 23 24 24 //resource related … … 33 33 RESERVATION_EXPIRED(16384), 34 34 35 RESOURCE_STATE_CHANGED(32 668)35 RESOURCE_STATE_CHANGED(32768) 36 36 ; 37 37 -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java
r822 r896 164 164 break; 165 165 166 case DCWormsTags. PHASE_CHANGED:166 case DCWormsTags.TASK_EXECUTION_CHANGED: 167 167 execTask = (ExecTask) ev.get_data(); 168 //updatePhases(execTask);168 updateTaskExecution(execTask, SchedulingEventType.RESOURCE_STATE_CHANGED); 169 169 break; 170 170 } … … 224 224 removeFromQueue(task); 225 225 226 SchedulingEvent event = new SchedulingEvent(SchedulingEventType.START_TASK_EXECUTION); 227 int time = Double.valueOf( 228 execTimeEstimationPlugin.execTimeEstimation(event, task, choosenResources, exec.getCompletionPercentage())).intValue(); 229 log.debug(task.getJobId() + "_" + task.getId() + " starts executing on " + new DateTime() 230 + " will finish after " + time); 231 232 if (time < 0.0) 233 return; 234 235 exec.setEstimatedDuration(time); 226 log.debug(task.getJobId() + "_" + task.getId() + " starts executing on " + new DateTime()); 227 228 //if (phaseDuration < 0.0) 229 // return; 230 231 //exec.setEstimatedDuration(exec.getEstimatedDuration() + phaseDuration); 236 232 DateTime currentTime = new DateTime(); 237 233 ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime); 238 234 exec.addUsedResources(resHistItem); 235 239 236 try { 240 237 exec.setStatus(DCWormsTags.INEXEC); … … 244 241 } 245 242 246 //updatePhases(exec);247 scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, exec);243 updateTaskExecution(exec, SchedulingEventType.START_TASK_EXECUTION); 244 //scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, exec); 248 245 249 246 try { … … 251 248 scheduler.sendInternal(expectedDuration, DCWormsTags.TASK_REQUESTED_TIME_EXPIRED, exec); 252 249 } catch (NoSuchFieldException e) { 253 double t = exec.getEstimatedDuration();254 scheduler.sendInternal(t, DCWormsTags.TASK_REQUESTED_TIME_EXPIRED, exec);250 //double t = exec.getEstimatedDuration(); 251 //scheduler.sendInternal(t, DCWormsTags.TASK_REQUESTED_TIME_EXPIRED, exec); 255 252 } 256 253 … … 261 258 notifyComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec); 262 259 263 /*if(peUnit instanceof ProcessingElements){264 ProcessingElements pes = (ProcessingElements) peUnit;265 for (ComputingResource resource : pes) {266 resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, exec));267 }268 } else {269 ComputingResource resource = null;270 try {271 resource = ResourceController.getComputingResourceByName(peUnit.getResourceId());272 } catch (ResourceException e) {273 return;274 }275 resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, exec));276 }277 */278 279 /*for(ExecTaskInterface etask : jobRegistry.getRunningTasks()){280 System.out.println(etask.getJobId());281 for(String taskId: etask.getVisitedResources())282 System.out.println("====="+taskId);283 }*/284 260 } 285 261 … … 323 299 PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE); 324 300 notifyComputingResources(peUnit, EnergyEventType.TASK_FINISHED, exec); 325 /*if(peUnit instanceof ProcessingElements){326 ProcessingElements pes = (ProcessingElements) peUnit;327 for (ComputingResource resource : pes) {328 resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec));329 }330 } else {331 ComputingResource resource = null;332 try {333 resource = ResourceController.getComputingResourceByName(peUnit.getResourceId());334 } catch (ResourceException e) {335 return;336 }337 resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec));338 }*/339 340 //sendFinishedWorkloadUnit(executable);341 301 } 342 302 … … 353 313 Executable exec = (Executable)task; 354 314 //exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * timeSpan/exec.getEstimatedDuration()); 355 exec.setCompletionPercentage(exec.getCompletionPercentage() + (100 - exec.getCompletionPercentage()) * timeSpan/(exec.getEstimatedDuration() - new DateTime().getMillis()/1000 + exec.getExecStartTime() + timeSpan)); 356 315 exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / exec.getEstimatedDuration())); 357 316 UsedResourcesList usedResourcesList = exec.getUsedResources(); 358 317 PEUnit peUnit = (PEUnit)usedResourcesList.getLast().getResourceUnits() … … 364 323 365 324 private void notifyComputingResources(PEUnit peUnit, EnergyEventType eventType, Object obj){ 366 367 325 if(peUnit instanceof ProcessingElements){ 368 326 ProcessingElements pes = (ProcessingElements) peUnit; … … 409 367 for (ExecTask execTask : jobRegistry.getRunningTasks()) { 410 368 Executable exec = (Executable)execTask; 411 List<String> visitedResource = exec.getVisitedResources(); 412 String originResource = ev.get_data().toString(); 413 if(!ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), originResource)){ 414 continue; 415 } 416 369 417 370 Map<ResourceUnitName, ResourceUnit> choosenResources = exec.getUsedResources().getLast().getResourceUnits(); 418 int time = Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.RESOURCE_STATE_CHANGED), 371 double lastTimeStamp = exec.getUsedResources().getLast().getTimeStamp().getMillis()/1000; 372 int phaseDuration = Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.RESOURCE_STATE_CHANGED), 419 373 execTask, choosenResources, exec.getCompletionPercentage())).intValue(); 420 374 421 //check if the new estimated end time is equal to the previous one; if yes the continue without update 422 if(DoubleMath.subtract((exec.getExecStartTime() + exec.getEstimatedDuration()), (new DateTime().getMillis()/1000 + time)) == 0.0){ 423 continue; 424 } 425 //exec.setEstimatedDuration(time); 426 exec.setEstimatedDuration(Long.valueOf(new DateTime().getMillis()/1000).intValue() - Double.valueOf(exec.getExecStartTime()).intValue() + time); 427 ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_EXECUTION_FINISHED); 428 scheduler.sim_cancel(filter, null); 429 scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, execTask); 375 if(DoubleMath.subtract((lastTimeStamp + exec.getEstimatedDuration()), (new DateTime().getMillis()/1000 + phaseDuration)) == 0.0){ 376 return; 377 } 378 379 exec.setEstimatedDuration(phaseDuration); 380 DateTime currentTime = new DateTime(); 381 ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime); 382 exec.addUsedResources(resHistItem); 383 384 if(exec.getResourceConsumptionProfile().getCurrentResourceConsumption() == exec.getResourceConsumptionProfile().getResourceConsumptionList().getLast()){ 385 ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_EXECUTION_FINISHED); 386 scheduler.sim_cancel(filter, null); 387 scheduler.sendInternal(phaseDuration , DCWormsTags.TASK_EXECUTION_FINISHED, execTask); 388 PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 389 notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 390 } else{ 391 ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_EXECUTION_CHANGED); 392 scheduler.sim_cancel(filter, null); 393 scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_CHANGED, execTask); 394 PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 395 notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 396 } 430 397 } 431 398 } 432 433 434 /*protected void updatePhases(ExecTask execTask) { 435 updateProcessingProgress(); 399 400 protected void updateTaskExecution(ExecTask execTask, SchedulingEventType schedEvType) { 436 401 437 402 if (execTask.getStatus() == DCWormsTags.INEXEC) { 438 403 Executable exec = (Executable)execTask; 439 440 double phaseLength = 0; 441 try{ 442 phaseLength = exec.getResourceConsumptionProfile().getResourceConsumption(exec.getCurrentPhase()).getResourceConsumptionTypeChoice().getPercentage()/100; 443 } catch(Exception e){ 444 ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_EXECUTION_FINISHED); 445 scheduler.sim_cancel(filter, null); 446 double t = DoubleMath.subtract((exec.getExecStartTime() + exec.getEstimatedDuration()), (new DateTime().getMillis()/1000)); 447 scheduler.sendInternal(t, DCWormsTags.TASK_EXECUTION_FINISHED, execTask); 448 PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 449 notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 450 } 451 if(phaseLength != 0){ 452 exec.setCurrentPhase(exec.getCurrentPhase() + 1); 453 ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.PHASE_CHANGED); 454 scheduler.sim_cancel(filter, null); 455 scheduler.sendInternal(phaseLength * exec.getEstimatedDuration(), DCWormsTags.PHASE_CHANGED, execTask); 456 PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 457 notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 458 } 459 System.out.println("===" + exec.getJobId() + ":" + phaseLength); 460 } 461 } */ 404 405 try { 406 exec.setStatus(DCWormsTags.NEW_EXEC_PHASE); 407 } catch (Exception e) { 408 } 409 410 Map<ResourceUnitName, ResourceUnit> choosenResources = exec.getUsedResources().getLast().getResourceUnits(); 411 412 int phaseDuration = Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(schedEvType), 413 execTask, choosenResources, exec.getCompletionPercentage())).intValue(); 414 415 exec.setEstimatedDuration(phaseDuration); 416 417 if(exec.getResourceConsumptionProfile().getCurrentResourceConsumption() == exec.getResourceConsumptionProfile().getResourceConsumptionList().getLast()){ 418 scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_FINISHED, execTask); 419 } else { 420 scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_CHANGED, execTask); 421 } 422 } 423 } 462 424 463 425 public double calculateTotalLoad(int size) { -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Task.java
r887 r896 4 4 import java.io.StringWriter; 5 5 import java.util.ArrayList; 6 import java.util.LinkedList; 6 7 import java.util.List; 7 8 … … 96 97 97 98 private void preparePhases() { 98 Li st<ResourceConsumption> resourceConsumptionList = new ArrayList<ResourceConsumption>();99 LinkedList<ResourceConsumption> resourceConsumptionList = new LinkedList<ResourceConsumption>(); 99 100 100 101 if(task.getExecution() == null || task.getExecution().getResourceConsumptionProfile() == null){ -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumption.java
r883 r896 51 51 } 52 52 53 public void setReferenceHardware(String referenceHardware) {54 this.referenceHardware = referenceHardware;55 }56 57 53 public long getDuration() { 58 54 return duration; 59 }60 61 public void setDuration(long duration) {62 this.duration = duration;63 55 } 64 56 … … 67 59 } 68 60 69 public void setBehaviourList(List<PhaseBehaviour> behaviourList) {70 this.phaseBehaviourList = behaviourList;71 }72 61 } -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumptionProfile.java
r883 r896 1 1 package schedframe.scheduling.tasks.phases; 2 2 3 import java.util. ArrayList;3 import java.util.LinkedList; 4 4 import java.util.List; 5 5 6 6 public class ResourceConsumptionProfile { 7 7 8 protected List<ResourceConsumption> resourceConsumptionList; 8 protected LinkedList<ResourceConsumption> resourceConsumptionList; 9 protected int currentPhase; 9 10 10 11 public ResourceConsumptionProfile() { 11 this.resourceConsumptionList = new ArrayList<ResourceConsumption>(); 12 this.resourceConsumptionList = new LinkedList<ResourceConsumption>(); 13 this.currentPhase = -1; 12 14 } 13 15 14 public ResourceConsumptionProfile(Li st<ResourceConsumption> resourceConsumptionList) {16 public ResourceConsumptionProfile(LinkedList<ResourceConsumption> resourceConsumptionList) { 15 17 this.resourceConsumptionList = resourceConsumptionList; 18 this.currentPhase = -1; 19 } 20 21 public LinkedList<ResourceConsumption> getResourceConsumptionList(){ 22 return resourceConsumptionList; 23 } 24 25 public ResourceConsumption getCurrentResourceConsumption(){ 26 if(currentPhase < resourceConsumptionList.size()) 27 return resourceConsumptionList.get(currentPhase); 28 else 29 return null; 30 } 31 32 public int getCurrentPhase() { 33 return currentPhase; 34 } 35 36 public void setCurrentPhase(int currentPhase) { 37 this.currentPhase = currentPhase; 16 38 } 17 39 } -
DCWoRMS/branches/coolemall/src/test/PhaseTimeEstimationPlugin.java
r883 r896 8 8 import schedframe.resources.units.ResourceUnitName; 9 9 import schedframe.resources.units.StandardResourceUnitName; 10 import schedframe.scheduling.tasks.phases.ResourceConsumption; 10 11 import dcworms.schedframe.scheduling.ExecTask; 11 12 import dcworms.schedframe.scheduling.Executable; … … 27 28 double completionPercentage) { 28 29 29 30 30 Executable exec = (Executable) task; 31 //System.out.println(exec.getJobId() +":"+ exec.getApplicationName());31 // System.out.println(exec.getJobId() +":"+ exec.getApplicationName()); 32 32 // collect all information necessary to do the calculation 33 33 PEUnit peUnit = (PEUnit) allocatedResources.get(StandardResourceUnitName.PE); … … 40 40 41 41 // estimate remainingTaskLength 42 double remainingLength = task.getLength() * (1 - completionPercentage/100);43 42 ResourceConsumption resConsumption = exec.getResourceConsumptionProfile().getCurrentResourceConsumption(); 43 44 44 // do the calculation 45 double execTime = ( remainingLength / (cnt * speed));45 double execTime = (1 - completionPercentage/100) * resConsumption.getDuration(); 46 46 47 47 // if the result is very close to 0, but less then one millisecond then round this result to 0.001
Note: See TracChangeset
for help on using the changeset viewer.