Changeset 1362 for DCWoRMS/branches
- Timestamp:
- 06/03/14 15:12:11 (11 years ago)
- Location:
- DCWoRMS/branches/coolemall/src
- Files:
-
- 1 added
- 1 deleted
- 14 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/ExecTask.java
r1207 r1362 1 1 package dcworms.schedframe.scheduling; 2 2 3 import java.util.Li st;3 import java.util.LinkedList; 4 4 5 import schedframe.scheduling.ExecutionHistoryItem; 6 import schedframe.scheduling.ResourceHistoryItem; 5 7 import schedframe.scheduling.tasks.TaskInterface; 6 8 import schedframe.scheduling.tasks.phases.ResourceConsumption; 7 import schedframe.scheduling.tasks.phases. ResourceConsumptionProfile;9 import schedframe.scheduling.tasks.phases.ExecutionProfile; 8 10 import schedframe.scheduling.tasks.requirements.ResourceParameterName; 9 11 … … 12 14 public boolean expectSpecificResource(ResourceParameterName resourceName); 13 15 public Object getExpectedSpecificResource(ResourceParameterName resourceName); 14 15 public void trackResource(String resName);16 public List<String> getVisitedResources();17 16 18 public ResourceConsumptionProfile getResourceConsumptionProfile(); 17 public LinkedList<ExecutionHistoryItem> getExecHistory(); 18 public LinkedList<ResourceHistoryItem> getAllocatedResources(); 19 20 public ExecutionProfile getResourceConsumptionProfile(); 19 21 public ResourceConsumption getCurrentResourceConsumption(); 22 23 public String getSchedulerName(); 20 24 } -
DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java
r1315 r1362 5 5 import gridsim.dcworms.DCWormsTags; 6 6 7 import java.util.ArrayList;8 7 import java.util.HashMap; 9 8 import java.util.LinkedList; … … 11 10 import java.util.Map; 12 11 13 import org.apache.commons.lang.ArrayUtils;14 12 import org.joda.time.DateTime; 15 13 import org.joda.time.DateTimeUtilsExt; … … 25 23 import schedframe.resources.units.ProcessingElements; 26 24 import schedframe.resources.units.StandardResourceUnitName; 25 import schedframe.scheduling.ExecutionHistoryItem; 27 26 import schedframe.scheduling.ResourceHistoryItem; 28 import schedframe.scheduling.UsedResourcesList;29 27 import schedframe.scheduling.WorkloadUnitHandler; 30 28 import schedframe.scheduling.manager.tasks.JobRegistryImpl; … … 33 31 import schedframe.scheduling.tasks.Task; 34 32 import schedframe.scheduling.tasks.phases.ResourceConsumption; 35 import schedframe.scheduling.tasks.phases. ResourceConsumptionProfile;33 import schedframe.scheduling.tasks.phases.ExecutionProfile; 36 34 import schedframe.scheduling.tasks.requirements.ResourceParameterName; 37 35 … … 53 51 54 52 protected int estimatedDuration; 55 //TO DO remove and benefit from visitedResources56 53 protected String schedName; 57 protected UsedResourcesList usedResources;58 //TO DO consider removing59 protected List<String> visitedResources;60 54 61 55 protected double submissionTime; 62 56 protected double arrivalTime; 63 protected double execStartTime 57 protected double execStartTime; 64 58 protected double totalCompletionTime; 65 59 protected double finishTime; 66 60 67 private ResourceConsumptionProfile resourceConsumptionProfile; 61 private boolean firstTime = true; 62 protected double execStartTimeFirst; 63 64 protected ExecutionProfile execProfile; 65 66 protected LinkedList<ExecutionHistoryItem> execHistory;; 67 protected LinkedList<ResourceHistoryItem> allocatedResources; 68 68 69 69 public Executable(Task t){ 70 70 this.task = t; 71 71 this.status = DCWormsTags.CREATED; 72 73 this. usedResources = new UsedResourcesList();74 this. visitedResources = new ArrayList<String>();72 73 this.allocatedResources = new LinkedList<ResourceHistoryItem>(); 74 this.execHistory = new LinkedList<ExecutionHistoryItem>(); 75 75 init(); 76 76 } … … 81 81 this.processesSetId = procesesSet.getId(); 82 82 83 this. usedResources = new UsedResourcesList();84 this. visitedResources = new ArrayList<String>();83 this.allocatedResources = new LinkedList<ResourceHistoryItem>(); 84 this.execHistory = new LinkedList<ExecutionHistoryItem>(); 85 85 init(); 86 86 } … … 88 88 protected void init() { 89 89 double currentTime = DateTimeUtilsExt.currentTimeMillis() / 1000; 90 this.arrivalTime = currentTime; 90 91 this.submissionTime = currentTime; 91 92 this.totalCompletionTime = 0.0; … … 168 169 } 169 170 170 if (newStatus < DCWormsTags.CREATED || newStatus > DCWormsTags. NEW_EXEC_PHASE) {171 if (newStatus < DCWormsTags.CREATED || newStatus > DCWormsTags.FAILED) { 171 172 throw new Exception("Executable.setStatuts() : Error - " + 172 "Invalid integer range for Exec iutable status.");173 "Invalid integer range for Executable status."); 173 174 } 174 175 … … 189 190 } 190 191 191 if(newStatus == DCWormsTags.SUBMITTED){192 /*if(newStatus == DCWormsTags.SUBMITTED){ 192 193 arrivalTime = GridSim.clock(); 193 } 194 195 if (prevStatus == DCWormsTags.INEXEC) { 196 if (status == DCWormsTags.CANCELED || status == DCWormsTags.PAUSED || 197 status == DCWormsTags.SUCCESS) { 194 }*/ 195 196 if ((prevStatus == DCWormsTags.INEXEC) && (status == DCWormsTags.CANCELED || status == DCWormsTags.PAUSED || 197 status == DCWormsTags.SUCCESS)){ 198 198 totalCompletionTime += (currentTime - execStartTime); 199 execStartTime = execStartTimeFirst; 200 } 201 202 /*if (prevStatus == DCWormsTags.RESUMED && status == DCWormsTags.SUCCESS) { 203 totalCompletionTime += (currentTime - execStartTime); 204 }*/ 205 206 if(prevStatus == DCWormsTags.PAUSED && status == DCWormsTags.RESUMED){ 207 208 } 209 if (status == DCWormsTags.INEXEC) { 210 211 execStartTime = currentTime; 212 if (firstTime){ 213 execStartTimeFirst = currentTime; 214 firstTime = false; 199 215 } 200 216 } 201 202 if (prevStatus == DCWormsTags.RESUMED && status == DCWormsTags.SUCCESS) {203 totalCompletionTime += (currentTime - execStartTime);204 }205 206 if (status == DCWormsTags.INEXEC ||207 (prevStatus == DCWormsTags.PAUSED && status == DCWormsTags.RESUMED) ) {208 execStartTime = currentTime;209 210 ProcessingElements pes = (ProcessingElements) getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE);211 for (ComputingResource resource : pes) {212 213 LinkedList<ComputingResource> toExamine = new LinkedList<ComputingResource>();214 toExamine.push(resource);215 216 while (!toExamine.isEmpty()) {217 ComputingResource compResource = toExamine.pop();218 List<ComputingResource> resources = compResource.getChildren();219 int numberOfRes = resources.size();220 for (int i = 0; i < numberOfRes; i++) {221 ComputingResource resourceChild = resources.get(i);222 trackResource(resourceChild.getFullName());223 toExamine.addLast(resourceChild);224 }225 }226 227 228 trackResource(resource.getFullName());229 230 ComputingResource parent = resource.getParent();231 List<String> visitedResource = getVisitedResources();232 String [] visitedResourcesArray = visitedResource.toArray(new String[visitedResource.size()]);233 while (parent != null && !ArrayUtils.contains(visitedResourcesArray, parent.getFullName())) {234 trackResource(parent.getFullName());235 parent = parent.getParent();236 }237 }238 }239 217 240 if(status == DCWormsTags.NEW_EXEC_PHASE){ 241 if(prevStatus == DCWormsTags.INEXEC){ 242 status = DCWormsTags.INEXEC; 243 setCompletionPercentage(0); 244 resourceConsumptionProfile.setCurrentPhase(resourceConsumptionProfile.getCurrentPhase() + 1); 245 246 DateTime currentDateTime = new DateTime(); 247 248 if(getUsedResources().getLast().getTimeStamp().getMillis() == currentDateTime.getMillis()){ 249 return; 250 } 251 ResourceHistoryItem resHistItem = new ResourceHistoryItem(getUsedResources().getLast().getResourceUnits(), currentDateTime); 252 resHistItem.setCompletionPercentage(0); 253 addUsedResources(resHistItem); 254 } 255 } 218 if(status == DCWormsTags.NEW_EXEC_PHASE && prevStatus == DCWormsTags.INEXEC){ 219 status = DCWormsTags.INEXEC; 220 completionPercentage = 0; 221 execProfile.setCurrentPhase(execProfile.getCurrentPhase() + 1); 222 } 223 256 224 } 257 225 … … 295 263 } 296 264 297 public void addUsedResources(ResourceHistoryItem usedResources){298 this.usedResources.add(usedResources);299 }300 301 public UsedResourcesList getUsedResources(){302 return this.usedResources;303 }304 305 265 public void setSchedulerName(int resourceId){ 306 266 this.schedName = GridSim.getEntityName(resourceId); 307 267 } 268 269 public void setSchedulerName(String resourceId){ 270 this.schedName = resourceId; 271 } 308 272 309 273 public String getSchedulerName(){ … … 326 290 task.register(jobRegistry); 327 291 } 328 329 public void trackResource(String resName){ 330 visitedResources.add(resName); 331 } 332 333 public List<String> getVisitedResources(){ 334 return visitedResources; 335 } 336 292 337 293 public ReadableDuration getExpectedDuration() throws NoSuchFieldException { 338 294 return task.getExpectedDuration(); … … 410 366 }*/ 411 367 412 public ResourceConsumptionProfile getResourceConsumptionProfile(){413 return resourceConsumptionProfile;368 public ExecutionProfile getResourceConsumptionProfile(){ 369 return execProfile; 414 370 } 415 371 416 372 public ResourceConsumption getCurrentResourceConsumption(){ 417 return resourceConsumptionProfile.getCurrentResourceConsumption();373 return execProfile.getCurrentResourceConsumption(); 418 374 } 419 375 … … 437 393 } 438 394 resourceConsumptionList.add(resConsumption); 439 } else{395 } else { 440 396 boolean found = false; 441 397 if(resourceType != null){ … … 473 429 474 430 usefulWork = (usefulWork != -1) ? usefulWork : this.getLength(); 475 this. resourceConsumptionProfile = new ResourceConsumptionProfile(resourceConsumptionList);476 this. resourceConsumptionProfile.setUsefulWork(usefulWork);431 this.execProfile = new ExecutionProfile(resourceConsumptionList); 432 this.execProfile.setUsefulWork(usefulWork); 477 433 478 434 } … … 480 436 private boolean loadResourceConsumptionProfile(){ 481 437 482 PEUnit peUnit = (PEUnit)get UsedResources().getLast().getResourceUnits()438 PEUnit peUnit = (PEUnit)getAllocatedResources().getLast().getResourceUnits() 483 439 .get(StandardResourceUnitName.PE); 484 440 if(peUnit instanceof ProcessingElements){ … … 513 469 514 470 } 471 472 public LinkedList<ExecutionHistoryItem> getExecHistory() { 473 return execHistory; 474 } 475 476 public void addExecHistory(ExecutionHistoryItem execHistoryItem) { 477 this.execHistory.add(execHistoryItem); 478 } 479 480 public LinkedList<ResourceHistoryItem> getAllocatedResources() { 481 return allocatedResources; 482 } 483 484 public void addAllocatedResources(ResourceHistoryItem allocatedResourcesItem) { 485 this.allocatedResources.add(allocatedResourcesItem); 486 } 515 487 } -
DCWoRMS/branches/coolemall/src/gridsim/dcworms/DCWormsTags.java
r1316 r1362 37 37 38 38 public static final int POWER_LIMIT_EXCEEDED = DCWORMSBASE + 8; 39 40 public static final int TASK_PAUSE = DCWORMSBASE + 9; 41 42 public static final int TASK_RESUME = DCWORMSBASE + 10; 43 44 public static final int TASK_MOVE = DCWORMSBASE + 11; 39 45 40 46 … … 48 54 49 55 public static final int INEXEC = 4; 56 57 public static final int NEW_EXEC_PHASE = 5; 58 59 public static final int PAUSED = 6; 50 60 51 public static final int SUCCESS = 5; 61 public static final int RESUMED = 7; 62 63 public static final int SUCCESS = 8; 52 64 53 public static final int FAILED = 6;65 public static final int CANCELED = 9; 54 66 55 public static final int CANCELED = 7; 56 57 public static final int PAUSED = 8; 58 59 public static final int RESUMED = 9; 60 61 public static final int NEW_EXEC_PHASE = 10; 62 67 public static final int FAILED = 10; 63 68 } -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/ResourceHistoryItem.java
r1317 r1362 1 1 package schedframe.scheduling; 2 2 3 import java.util.HashSet; 3 4 import java.util.Map; 4 5 import org.joda.time.DateTime; 5 import java.util.Set; 6 6 7 7 import schedframe.resources.units.ResourceUnit; 8 8 import schedframe.resources.units.ResourceUnitName; 9 9 10 //TODO - change name11 10 public class ResourceHistoryItem { 12 11 13 12 protected Map<ResourceUnitName, ResourceUnit> usedResources; 14 protected DateTime timeStamp; 15 protected double completionPercentage; 16 17 /** 18 * 19 * @param map hash map of resource units, which should be remembered 20 * @param time the moment in time when this resource configuration was created 21 */ 22 public ResourceHistoryItem(Map<ResourceUnitName, ResourceUnit> map, DateTime time){ 23 this.usedResources = map; 24 this.timeStamp = time; 13 protected Set<String> visitedResources; 14 15 public ResourceHistoryItem(Map<ResourceUnitName, ResourceUnit> usedResources){ 16 this.usedResources = usedResources; 17 this.visitedResources = new HashSet<String>(); 25 18 } 26 19 … … 29 22 } 30 23 31 public DateTime getTimeStamp(){32 return timeStamp;24 public void trackResource(String resName){ 25 visitedResources.add(resName); 33 26 } 34 35 public double getCompletionPercentage() { 36 return completionPercentage; 37 } 38 39 public void setCompletionPercentage(double completionPercentage) { 40 this.completionPercentage = completionPercentage; 27 28 public Set<String> getVisitedResources(){ 29 return visitedResources; 41 30 } 42 31 -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/Scheduler.java
r970 r1362 136 136 break; 137 137 } 138 139 138 // process the received event 140 139 processRequest(ev); … … 147 146 148 147 case GridSimTags.GRIDLET_SUBMIT: 149 processWorkloadUnitSubmit(ev, false); 150 break; 151 152 case GridSimTags.GRIDLET_SUBMIT_ACK: 153 processWorkloadUnitSubmit(ev, true); 154 break; 148 processWorkloadUnitSubmit(ev); 149 break; 150 155 151 156 152 case GridSimTags.GRIDLET_RETURN: … … 187 183 } 188 184 189 protected void processWorkloadUnitSubmit(Sim_event ev , boolean ack) {185 protected void processWorkloadUnitSubmit(Sim_event ev) { 190 186 WorkloadUnit job = (WorkloadUnit) ev.get_data(); 191 managementSystem.notifySubmittedWorkloadUnit(job , ack);187 managementSystem.notifySubmittedWorkloadUnit(job); 192 188 } 193 189 -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/tasks/AbstractJobRegistry.java
r1151 r1362 2 2 3 3 4 import gridsim.dcworms.DCWormsTags; 5 4 6 import java.util.ArrayList; 5 7 import java.util.List; 8 import java.util.Map; 6 9 import java.util.concurrent.ConcurrentHashMap; 7 10 11 import schedframe.resources.units.ResourceUnit; 12 import schedframe.resources.units.ResourceUnitName; 8 13 import schedframe.scheduling.tasks.Job; 9 14 import schedframe.scheduling.tasks.JobInterface; 10 15 import schedframe.scheduling.tasks.Task; 11 16 import schedframe.scheduling.tasks.TaskInterface; 17 import simulator.DataCenterWorkloadSimulator; 18 import dcworms.schedframe.scheduling.ExecTask; 12 19 13 20 14 21 public abstract class AbstractJobRegistry /*extends ConcurrentHashMap<String, Job>*/ implements JobRegistry, Cloneable{ 15 22 16 private static final long serialVersionUID = 8409060063583755824L;17 18 23 19 24 protected static final ConcurrentHashMap<String, JobInterface<?>> jobs = new ConcurrentHashMap<String, JobInterface<?>>(); … … 79 84 } 80 85 86 @Override 87 public boolean pauseTask(String jobId, String taskId) { 88 ExecTask execTask = getTask(jobId, taskId); 89 if (execTask == null) { 90 return false; 91 }else{ 92 String[] ids = new String[2]; 93 ids[0] = new String(jobId); 94 ids[1] = new String(taskId); 95 DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.TASK_PAUSE, ids); 96 return true; 97 } 98 } 99 100 public boolean resumeTask(String jobId, String taskId) { 101 ExecTask execTask = getTask(jobId, taskId); 102 if (execTask == null) { 103 return false; 104 }else{ 105 String[] ids = new String[2]; 106 ids[0] = new String(jobId); 107 ids[1] = new String(taskId); 108 DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.TASK_RESUME, ids); 109 return true; 110 } 111 } 112 113 public boolean migrateTask(String jobId, String taskId, Map<ResourceUnitName, ResourceUnit> choosenResources) { 114 ExecTask execTask = getTask(jobId, taskId); 115 if (execTask == null) { 116 return false; 117 }else{ 118 Object[] data = new Object[3]; 119 data[0] = new String(jobId); 120 data[1] = new String(taskId); 121 data[2] = choosenResources; 122 DataCenterWorkloadSimulator.getEventManager().sendToAllSchedulers(0, DCWormsTags.TASK_MOVE, data); 123 return true; 124 } 125 } 126 127 public boolean migrateTask(String jobId, String taskId, String nodeName) { 128 // TODO Auto-generated method stub 129 return false; 130 } 131 81 132 } -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/tasks/JobRegistry.java
r1151 r1362 3 3 4 4 import java.util.List; 5 import java.util.Map; 5 6 6 7 import dcworms.schedframe.scheduling.ExecTask; 7 8 8 9 import schedframe.ExecutablesList; 10 import schedframe.resources.units.ResourceUnit; 11 import schedframe.resources.units.ResourceUnitName; 9 12 import schedframe.scheduling.tasks.JobInterface; 10 13 import schedframe.scheduling.tasks.TaskInterface; … … 27 30 28 31 29 public List<ExecTask> getTasks(int status) 32 public List<ExecTask> getTasks(int status); 30 33 31 public List<ExecTask> getQueuedTasks() 34 public List<ExecTask> getQueuedTasks(); 32 35 33 public List<ExecTask> getRunningTasks() 36 public List<ExecTask> getRunningTasks(); 34 37 35 public List<ExecTask> getReadyTasks() 38 public List<ExecTask> getReadyTasks(); 36 39 37 40 public List<ExecTask> getFinishedTasks(); … … 39 42 40 43 public List<? extends TaskInterface<?>> getAvailableTasks(List<JobInterface<?>> jobsList); 44 45 46 public boolean pauseTask(String jobId, String taskId); 47 48 public boolean resumeTask(String jobId, String taskId); 49 50 public boolean migrateTask(String jobId, String taskId, Map<ResourceUnitName, ResourceUnit> choosenResources); 51 52 public boolean migrateTask(String jobId, String taskId, String nodeName); 53 41 54 42 55 } -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/tasks/JobRegistryImpl.java
r1151 r1362 5 5 import java.util.ArrayList; 6 6 import java.util.List; 7 8 import org.apache.commons.lang.ArrayUtils; 7 import java.util.Set; 8 9 9 import org.apache.commons.logging.Log; 10 10 import org.apache.commons.logging.LogFactory; … … 21 21 22 22 public class JobRegistryImpl extends AbstractJobRegistry { 23 24 private static final long serialVersionUID = 8030555906990767342L;25 23 26 24 private static Log log = LogFactory.getLog(JobRegistryImpl.class); … … 55 53 for (ExecTask task: executables) { 56 54 if (task.getStatus() == status) { 57 List<String> visitedResource = task.getVisitedResources(); 58 if(ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), context)) { 55 Set<String> visitedResource = task.getAllocatedResources().getLast().getVisitedResources(); 56 for(String res: visitedResource){ 57 if(res.contains(context)){ 58 taskList.add(task); 59 break; 60 } 61 } 62 if(task.getSchedulerName().contains(context)) { 59 63 taskList.add(task); 60 64 } -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/AbstractManagementSystem.java
r579 r1362 212 212 public abstract WorkloadUnitHandler getWorkloadUnitHandler(); 213 213 214 public abstract void notifySubmittedWorkloadUnit(WorkloadUnit wu , boolean ack);214 public abstract void notifySubmittedWorkloadUnit(WorkloadUnit wu); 215 215 216 216 public abstract void notifyReturnedWorkloadUnit(WorkloadUnit wu); -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/global/GlobalManagementSystem.java
r1357 r1362 71 71 } 72 72 73 public void notifySubmittedWorkloadUnit(WorkloadUnit wu , boolean ack) {73 public void notifySubmittedWorkloadUnit(WorkloadUnit wu) { 74 74 if (!pluginSupportsEvent(GridSimTags.GRIDLET_SUBMIT)) { 75 75 log.error("Plugin " + schedulingPlugin.getClass() -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java
r1357 r1362 1 1 package schedframe.scheduling.policy.local; 2 3 import dcworms.schedframe.scheduling.ExecTask;4 import dcworms.schedframe.scheduling.Executable;5 import eduni.simjava.Sim_event;6 import eduni.simjava.Sim_system;7 import gridsim.dcworms.DCWormsTags;8 import gridsim.dcworms.filter.ExecTaskFilter;9 2 10 3 import java.util.ArrayList; 11 4 import java.util.HashMap; 12 5 import java.util.Iterator; 6 import java.util.LinkedList; 13 7 import java.util.List; 14 8 import java.util.Map; 15 16 import org.apache.commons.lang.ArrayUtils; 9 import java.util.Set; 10 17 11 import org.apache.commons.logging.Log; 18 12 import org.apache.commons.logging.LogFactory; … … 38 32 import schedframe.resources.units.ResourceUnitName; 39 33 import schedframe.resources.units.StandardResourceUnitName; 34 import schedframe.scheduling.ExecutionHistoryItem; 40 35 import schedframe.scheduling.ResourceHistoryItem; 41 36 import schedframe.scheduling.Scheduler; 42 37 import schedframe.scheduling.TaskList; 43 38 import schedframe.scheduling.TaskListImpl; 44 import schedframe.scheduling.UsedResourcesList;45 39 import schedframe.scheduling.WorkloadUnitHandler; 46 40 import schedframe.scheduling.manager.resources.LocalResourceManager; … … 64 58 import simulator.stats.GSSAccumulator; 65 59 import simulator.utils.DoubleMath; 60 import dcworms.schedframe.scheduling.ExecTask; 61 import dcworms.schedframe.scheduling.Executable; 62 import eduni.simjava.Sim_event; 63 import eduni.simjava.Sim_system; 64 import gridsim.dcworms.DCWormsTags; 65 import gridsim.dcworms.filter.ExecTaskFilter; 66 66 67 67 public class LocalManagementSystem extends AbstractManagementSystem { … … 127 127 finalizeExecutable(execTask); 128 128 sendFinishedWorkloadUnit(execTask); 129 log.debug(execTask.getJobId() + "_" + execTask.getId() + " finished execution on " + new DateTime());130 log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad());131 129 if (pluginSupportsEvent(tag)) { 132 130 SchedulingEvent event = new TaskFinishedEvent(execTask.getJobId(), execTask.getId()); … … 164 162 break; 165 163 164 case DCWormsTags.TASK_PAUSE:{ 165 String[] ids = (String[]) ev.get_data(); 166 execTask = jobRegistry.getTask(ids[0], ids[1]); 167 taskPause(execTask); 168 if (pluginSupportsEvent(tag)) { 169 SchedulingEvent event = new SchedulingEvent(SchedulingEventType.TASK_PAUSED); 170 SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 171 queues, getJobRegistry(), getResourceManager(), moduleList); 172 executeSchedulingPlan(decision); 173 } 174 } 175 break; 176 177 case DCWormsTags.TASK_RESUME:{ 178 String[] ids = (String[]) ev.get_data(); 179 execTask = jobRegistry.getTask(ids[0], ids[1]); 180 taskResume(execTask, execTask.getAllocatedResources().getLast().getResourceUnits()); 181 if (pluginSupportsEvent(tag)) { 182 SchedulingEvent event = new StartTaskExecutionEvent(ids[0], ids[1]); 183 SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 184 queues, getJobRegistry(), getResourceManager(), moduleList); 185 executeSchedulingPlan(decision); 186 } 187 } 188 break; 189 190 case DCWormsTags.TASK_MOVE:{ 191 Object[] data = (Object[]) ev.get_data(); 192 execTask = jobRegistry.getTask((String)data[0], (String)data[1]); 193 taskMove(execTask, (Map<ResourceUnitName, ResourceUnit>)data[2]); 194 if (pluginSupportsEvent(tag)) { 195 SchedulingEvent event = new StartTaskExecutionEvent((String)data[0], (String)data[1]); 196 SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 197 queues, getJobRegistry(), getResourceManager(), moduleList); 198 executeSchedulingPlan(decision); 199 } 200 } 201 break; 166 202 167 203 case DCWormsTags.TASK_EXECUTION_CHANGED: 168 204 execTask = (ExecTask) ev.get_data(); 169 updateTaskExecution (execTask, SchedulingEventType.RESOURCE_STATE_CHANGED);205 updateTaskExecutionPhase(execTask, SchedulingEventType.RESOURCE_STATE_CHANGED); 170 206 break; 171 207 172 208 case DCWormsTags.UPDATE_PROCESSING: 173 updateProcessingTimes( ev);209 updateProcessingTimes(); 174 210 break; 175 211 … … 177 213 if (pluginSupportsEvent(tag)) { 178 214 SchedulingEvent event = new SchedulingEvent(SchedulingEventType.POWER_LIMIT_EXCEEDED); 179 schedulingPlugin.schedule(event,215 SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 180 216 queues, getJobRegistry(), getResourceManager(), moduleList); 217 executeSchedulingPlan(decision); 181 218 } 182 219 break; … … 184 221 } 185 222 223 224 public void taskPause(ExecTask execTask) { 225 if (execTask == null) { 226 return; 227 } else { 228 try { 229 execTask.setStatus(DCWormsTags.PAUSED); 230 231 Executable exec = (Executable) execTask; 232 Map<ResourceUnitName, ResourceUnit> lastUsed = exec.getAllocatedResources().getLast().getResourceUnits(); 233 getAllocationManager().freeResources(lastUsed); 234 235 saveExecutionHistory(exec, exec.getCompletionPercentage(), exec.getEstimatedDuration()); 236 237 ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), -1); 238 scheduler.sim_cancel(filter, null); 239 240 PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE); 241 updateComputingResources(peUnit, EnergyEventType.TASK_FINISHED, exec); 242 } catch (Exception e) { 243 // TODO Auto-generated catch block 244 e.printStackTrace(); 245 } 246 } 247 } 248 249 public void taskResume(ExecTask execTask, Map<ResourceUnitName, ResourceUnit> resources) { 250 if (execTask == null) { 251 return; 252 } else if (execTask.getStatus() == DCWormsTags.PAUSED) { 253 try { 254 execTask.setStatus(DCWormsTags.RESUMED); 255 Executable exec = (Executable) execTask; 256 257 boolean status = allocateResources(exec, resources); 258 if(status == false){ 259 TaskList newTasks = new TaskListImpl(); 260 newTasks.add(exec); 261 schedulingPlugin.placeTasksInQueues(newTasks, queues, getResourceManager(), moduleList); 262 exec.setStatus(DCWormsTags.READY); 263 } else { 264 runTask(execTask); 265 266 PEUnit peUnit = (PEUnit)resources.get(StandardResourceUnitName.PE); 267 updateComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec); 268 } 269 270 } catch (Exception e) { 271 // TODO Auto-generated catch block 272 e.printStackTrace(); 273 } 274 } 275 } 276 277 public void taskMove(ExecTask execTask, Map<ResourceUnitName, ResourceUnit> map) { 278 taskPause(execTask); 279 taskResume(execTask, map); 280 } 281 186 282 public void notifyReturnedWorkloadUnit(WorkloadUnit wu) { 187 283 if (pluginSupportsEvent(DCWormsTags.TASK_EXECUTION_FINISHED)) { … … 229 325 230 326 Executable exec = (Executable)task; 231 boolean allocationStatus = getAllocationManager().allocateResources(choosenResources);327 boolean allocationStatus = allocateResources(exec, choosenResources); 232 328 if(allocationStatus == false){ 233 329 log.info("Task " + task.getJobId() + "_" + task.getId() + " requires more resources than is available at this moment."); … … 239 335 log.debug(task.getJobId() + "_" + task.getId() + " starts executing on " + new DateTime()); 240 336 241 //if (phaseDuration < 0.0) 242 // return; 243 244 //exec.setEstimatedDuration(exec.getEstimatedDuration() + phaseDuration); 245 DateTime currentTime = new DateTime(); 246 ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime); 247 resHistItem.setCompletionPercentage(0); 248 exec.addUsedResources(resHistItem); 249 250 try { 251 exec.setStatus(DCWormsTags.INEXEC); 252 } catch (Exception e) { 253 // TODO Auto-generated catch block 254 e.printStackTrace(); 255 } 337 runTask(exec); 256 338 257 339 PEUnit peUnit = (PEUnit)choosenResources.get(StandardResourceUnitName.PE); 258 340 updateComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec); 259 341 260 updateTaskExecution(exec, SchedulingEventType.START_TASK_EXECUTION);261 //scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, exec);262 342 263 343 try { … … 269 349 } 270 350 271 log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad()); 272 273 } 274 351 log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad()); 352 } 353 354 private void runTask(ExecTask execTask){ 355 Executable exec = (Executable) execTask; 356 Map<ResourceUnitName, ResourceUnit> resources = exec.getAllocatedResources().getLast().getResourceUnits(); 357 358 try { 359 exec.setStatus(DCWormsTags.INEXEC); 360 } catch (Exception e) { 361 // TODO Auto-generated catch block 362 e.printStackTrace(); 363 } 364 365 int phaseDuration = Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.START_TASK_EXECUTION), 366 execTask, resources, exec.getCompletionPercentage())).intValue(); 367 368 saveExecutionHistory(exec, exec.getCompletionPercentage(), phaseDuration); 369 if(exec.getResourceConsumptionProfile().isLast()){ 370 scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_FINISHED, execTask);; 371 } else { 372 scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_CHANGED, execTask); 373 } 374 375 PEUnit peUnit = (PEUnit)resources.get(StandardResourceUnitName.PE); 376 updateComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec); 377 378 } 275 379 protected void finalizeExecutable(ExecTask execTask){ 276 380 … … 304 408 } 305 409 } 306 307 UsedResourcesList lastUsedList = exec.getUsedResources(); 308 Map<ResourceUnitName, ResourceUnit> lastUsed = lastUsedList.getLast() 309 .getResourceUnits(); 410 411 Map<ResourceUnitName, ResourceUnit> lastUsed = exec.getAllocatedResources().getLast().getResourceUnits(); 310 412 getAllocationManager().freeResources(lastUsed); 413 414 saveExecutionHistory(exec, 100,0); 311 415 312 416 PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE); 313 417 updateComputingResources(peUnit, EnergyEventType.TASK_FINISHED, exec); 418 419 log.debug(execTask.getJobId() + "_" + execTask.getId() + " finished execution on " + new DateTime()); 420 log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad()); 314 421 } 315 422 … … 326 433 ExecTask task = iter.next(); 327 434 Executable exec = (Executable)task; 328 329 if(exec.getUsedResources().size() > 1){ 330 //System.out.println("--- upadteProgressX: " + Sim_system.sim_clock() ); 331 //System.out.println("taskId: " + exec.getId() + "; completion percentage: " + exec.getCompletionPercentage() + "; timespan: " + timeSpan + "; estimatedDuration: " + exec.getEstimatedDuration()); 332 exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / (exec.getEstimatedDuration()) * (1.0 - exec.getUsedResources().get(exec.getUsedResources().size()-1).getCompletionPercentage()/100.0))); 333 //System.out.println("newProgress: " + exec.getCompletionPercentage() ); 334 } 335 else { 336 //System.out.println("--- upadteProgress2: " + Sim_system.sim_clock() ); 337 //System.out.println("taskId: " + exec.getId() + "; completion percentage: " + exec.getCompletionPercentage() + "; timespan: " + timeSpan + "; estimatedDuration: " + exec.getEstimatedDuration()); 338 exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / exec.getEstimatedDuration())); 339 //System.out.println("newProgress: " + exec.getCompletionPercentage() ); 340 } 435 ExecutionHistoryItem execHistItem = exec.getExecHistory().getLast(); 436 //System.out.println("--- upadteProgressX: " + Sim_system.sim_clock() ); 437 //System.out.println("taskId: " + exec.getId() + "; completion percentage: " + exec.getCompletionPercentage() + "; timespan: " + timeSpan + "; estimatedDuration: " + execHistItem.getCompletionPercentage()); 438 exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / (execHistItem.getEstimatedDuration()) * (1.0 - execHistItem.getCompletionPercentage()/100.0))); 439 //System.out.println("newProgress: " + exec.getCompletionPercentage() ); 440 341 441 } 342 442 } … … 368 468 } 369 469 370 protected void updateProcessingTimes( Sim_event ev) {470 protected void updateProcessingTimes() { 371 471 for (ExecTask execTask : jobRegistry.getRunningTasks()) { 372 472 Executable exec = (Executable)execTask; 373 473 374 Map<ResourceUnitName, ResourceUnit> choosenResources = exec.getUsedResources().getLast().getResourceUnits(); 375 double lastTimeStamp = exec.getUsedResources().getLast().getTimeStamp().getMillis()/1000; 474 475 Map<ResourceUnitName, ResourceUnit> choosenResources = exec.getAllocatedResources().getLast().getResourceUnits(); 476 376 477 int phaseDuration = Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.RESOURCE_STATE_CHANGED), 377 478 execTask, choosenResources, exec.getCompletionPercentage())).intValue(); 378 479 379 if(DoubleMath.subtract((lastTimeStamp + exec.getEstimatedDuration()), (new DateTime().getMillis()/1000 + phaseDuration)) == 0.0){ 480 ExecutionHistoryItem execHistItem = exec.getExecHistory().getLast(); 481 double lastTimeStamp = execHistItem.getTimeStamp().getMillis()/1000; 482 if(DoubleMath.subtract((lastTimeStamp + execHistItem.getEstimatedDuration()), (new DateTime().getMillis()/1000 + phaseDuration)) == 0.0){ 380 483 continue; 381 484 } 382 485 //System.out.println("=== upadteTIme: " + Sim_system.sim_clock() ); 383 //System.out.println("execId: " + exec.getId() + "; estimatedDuration " + exec .getEstimatedDuration());384 //System.out.println("execId: " + exec.getId() + "; difference " + DoubleMath.subtract((lastTimeStamp + exec .getEstimatedDuration()), (new DateTime().getMillis()/1000 + phaseDuration)));486 //System.out.println("execId: " + exec.getId() + "; estimatedDuration " + execHistItem.getEstimatedDuration()); 487 //System.out.println("execId: " + exec.getId() + "; difference " + DoubleMath.subtract((lastTimeStamp + execHistItem.getEstimatedDuration()), (new DateTime().getMillis()/1000 + phaseDuration))); 385 488 //System.out.println("completionPercantage: " + exec.getCompletionPercentage() + "; basic duration: " +exec.getResourceConsumptionProfile().getCurrentResourceConsumption().getDuration() + "; phaseDuration: " + phaseDuration); 386 489 387 exec.setEstimatedDuration(phaseDuration); 388 DateTime currentTime = new DateTime(); 389 ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime); 390 resHistItem.setCompletionPercentage(exec.getCompletionPercentage()); 391 exec.addUsedResources(resHistItem); 392 393 if(exec.getResourceConsumptionProfile().getCurrentResourceConsumption() == exec.getResourceConsumptionProfile().getResourceConsumptionList().getLast()){ 490 saveExecutionHistory(exec, exec.getCompletionPercentage(), phaseDuration); 491 492 if(exec.getResourceConsumptionProfile().isLast()){ 394 493 ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_EXECUTION_FINISHED); 395 494 scheduler.sim_cancel(filter, null); … … 407 506 } 408 507 409 protected void updateTaskExecution (ExecTask execTask, SchedulingEventType schedEvType) {508 protected void updateTaskExecutionPhase(ExecTask execTask, SchedulingEventType schedEvType) { 410 509 411 510 if (execTask.getStatus() == DCWormsTags.INEXEC) { … … 415 514 exec.setStatus(DCWormsTags.NEW_EXEC_PHASE); 416 515 } catch (Exception e) { 417 } 418 419 Map<ResourceUnitName, ResourceUnit> choosenResources = exec.getUsedResources().getLast().getResourceUnits(); 516 517 } 518 519 Map<ResourceUnitName, ResourceUnit> choosenResources = exec.getAllocatedResources().getLast().getResourceUnits(); 420 520 421 521 int phaseDuration = Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(schedEvType), 422 522 execTask, choosenResources, exec.getCompletionPercentage())).intValue(); 423 424 exec.setEstimatedDuration(phaseDuration);425 426 if(exec.getResourceConsumptionProfile(). getCurrentResourceConsumption() == exec.getResourceConsumptionProfile().getResourceConsumptionList().getLast()){523 524 saveExecutionHistory(exec, exec.getCompletionPercentage(), phaseDuration); 525 526 if(exec.getResourceConsumptionProfile().isLast()){ 427 527 scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_FINISHED, execTask); 428 PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE);429 updateComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec);430 528 } else { 431 529 scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_CHANGED, execTask); 432 PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 433 updateComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 434 } 530 } 531 532 PEUnit peUnit = (PEUnit)exec.getAllocatedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 533 updateComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 435 534 } 436 535 } … … 501 600 } 502 601 503 public void notifySubmittedWorkloadUnit(WorkloadUnit wu , boolean ack) {602 public void notifySubmittedWorkloadUnit(WorkloadUnit wu) { 504 603 //250314 505 604 //updateProcessingProgress(); … … 562 661 Executable exec = (Executable) task; 563 662 jobRegistry.addExecTask(exec); 564 565 exec.trackResource(scheduler.get_name()); 566 Scheduler parentScheduler = scheduler.getParent(); 567 List<String> visitedResource = exec.getVisitedResources(); 568 String [] visitedResourcesArray = visitedResource.toArray(new String[visitedResource.size()]); 569 while (parentScheduler != null && !ArrayUtils.contains(visitedResourcesArray, parentScheduler.get_name())) { 570 exec.trackResource(parentScheduler.get_name()); 571 parentScheduler = parentScheduler.getParent(); 572 } 573 exec.setSchedulerName(scheduler.get_id()); 663 664 exec.setSchedulerName(scheduler.getFullName()); 574 665 575 666 TaskList newTasks = new TaskListImpl(); … … 596 687 } 597 688 689 690 public void saveExecutionHistory(Executable exec, double completionPercentage, double estimatedDuration){ 691 692 ExecutionHistoryItem execHistoryItem = new ExecutionHistoryItem(new DateTime()); 693 execHistoryItem.setCompletionPercentage(completionPercentage); 694 execHistoryItem.setEstimatedDuration(estimatedDuration); 695 execHistoryItem.setResIndex(exec.getAllocatedResources().size() -1); 696 execHistoryItem.setStatus(exec.getStatus()); 697 exec.addExecHistory(execHistoryItem); 698 699 ProcessingElements pes = (ProcessingElements) exec.getAllocatedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 700 for (ComputingResource resource : pes) { 701 702 LinkedList<ComputingResource> toExamine = new LinkedList<ComputingResource>(); 703 toExamine.push(resource); 704 705 while (!toExamine.isEmpty()) { 706 ComputingResource compResource = toExamine.pop(); 707 List<ComputingResource> resources = compResource.getChildren(); 708 if(resources.isEmpty()){ 709 Set<String> visitedResources = exec.getAllocatedResources().getLast().getVisitedResources(); 710 if(!visitedResources.contains(compResource.getFullName())){ 711 exec.getAllocatedResources().getLast().trackResource(compResource.getFullName()); 712 } 713 } else { 714 for (int i = 0; i < resources.size(); i++) { 715 ComputingResource resourceChild = resources.get(i); 716 toExamine.addLast(resourceChild); 717 } 718 } 719 } 720 } 721 } 722 723 public boolean allocateResources(Executable exec, Map<ResourceUnitName, ResourceUnit> choosenResources){ 724 boolean allocationStatus = getAllocationManager().allocateResources(choosenResources); 725 if(allocationStatus){ 726 ResourceHistoryItem resourceHistoryItem = new ResourceHistoryItem(choosenResources); 727 exec.addAllocatedResources(resourceHistoryItem); 728 return true; 729 } 730 return false; 731 } 598 732 } -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Task.java
r1207 r1362 1 1 package schedframe.scheduling.tasks; 2 3 import gridsim.dcworms.DCWormsTags; 2 4 3 5 import java.io.StringReader; … … 439 441 public boolean isFinished(){ 440 442 if(processes == null) 441 return (status > 3 && status <= 6);443 return (status >= DCWormsTags.SUCCESS && status <= DCWormsTags.FAILED); 442 444 443 445 for(int i = 0; i < processes.size(); i++){ -
DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ExecutionProfile.java
r1207 r1362 3 3 import java.util.LinkedList; 4 4 5 public class ResourceConsumptionProfile {5 public class ExecutionProfile { 6 6 7 7 protected LinkedList<ResourceConsumption> resourceConsumptionList; 8 8 protected long usefulWork; 9 9 private int currentPhase; 10 11 public ResourceConsumptionProfile() { 12 this.resourceConsumptionList = new LinkedList<ResourceConsumption>(); 13 this.currentPhase = -1; 14 } 15 16 public ResourceConsumptionProfile(LinkedList<ResourceConsumption> resourceConsumptionList) { 10 11 public ExecutionProfile(LinkedList<ResourceConsumption> resourceConsumptionList) { 17 12 this.resourceConsumptionList = resourceConsumptionList; 18 this.currentPhase = -1;13 this.currentPhase = 0; 19 14 } 20 15 … … 24 19 25 20 public ResourceConsumption getCurrentResourceConsumption(){ 26 if(currentPhase < resourceConsumptionList.size()) 27 return resourceConsumptionList.get(currentPhase); 28 else 29 return null; 21 return resourceConsumptionList.get(currentPhase); 30 22 } 31 23 … … 45 37 this.usefulWork = usefulWork; 46 38 } 39 40 public boolean isLast(){ 41 if(currentPhase == resourceConsumptionList.size() - 1){ 42 return true; 43 } 44 return false; 45 } 47 46 } -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/DCWormsStatistics.java
r1357 r1362 16 16 import java.util.HashMap; 17 17 import java.util.HashSet; 18 import java.util.LinkedList; 18 19 import java.util.List; 19 20 import java.util.Map; … … 78 79 import schedframe.resources.units.ResourceUnitName; 79 80 import schedframe.resources.units.StandardResourceUnitName; 81 import schedframe.scheduling.ExecutionHistoryItem; 80 82 import schedframe.scheduling.ResourceHistoryItem; 81 83 import schedframe.scheduling.Scheduler; … … 104 106 import eduni.simjava.Sim_stat; 105 107 import example.energy.coolemall.CoolEmAllTestbedMeasurements; 108 import gridsim.dcworms.DCWormsTags; 106 109 107 110 public class DCWormsStatistics implements SimulationStatistics { … … 407 410 } 408 411 409 pesStats = gatherPEStats (jr.getTasks());412 pesStats = gatherPEStatsMulti(jr.getTasks()); 410 413 peStatsPostProcessing(pesStats); 411 414 basicResLoad = calculatePELoad(pesStats); … … 763 766 Executable exec = (Executable) execTask; 764 767 765 List<ResourceHistoryItem> resHistItemList = exec.getUsedResources(); 766 if(resHistItemList.size() == 0) 768 769 LinkedList<ResourceHistoryItem> resourceHistory = exec.getAllocatedResources(); 770 if(resourceHistory.size() == 0) 767 771 continue; 768 Map<ResourceUnitName, ResourceUnit> res = resHistItemList.get(resHistItemList.size() - 1).getResourceUnits();772 Map<ResourceUnitName, ResourceUnit> res = exec.getAllocatedResources().getLast().getResourceUnits(); 769 773 ResourceUnit resUnit = res.get(StandardResourceUnitName.PE); 770 774 //ProcessingElements pes = (ProcessingElements) resUnit ; … … 820 824 } 821 825 return basicResStats; 826 } 827 828 private Map<String, List<ResStat>> gatherPEStatsMulti(ExecutablesList executables) { 829 830 Map<String, List<ResStat>> basicResStats = new TreeMap<String, List<ResStat>>(new MapPEIdComparator()); 831 for (ExecTask execTask:executables) { 832 Executable exec = (Executable) execTask; 833 834 LinkedList<ResourceHistoryItem> resourceHistory = exec.getAllocatedResources(); 835 if(resourceHistory.size() == 0) 836 continue; 837 838 for(int i = 0; i < resourceHistory .size(); i++){ 839 ResourceHistoryItem resHistItem = resourceHistory.get(i); 840 Map<ResourceUnitName, ResourceUnit> res = resHistItem.getResourceUnits(); 841 ResourceUnit resUnit = res.get(StandardResourceUnitName.PE); 842 //ProcessingElements pes = (ProcessingElements) resUnit ; 843 LinkedList<ExecutionHistoryItem> execHistory = exec.getExecHistory(); 844 long st = -1, et; 845 for(int j = 0; j < execHistory .size(); j++){ 846 ExecutionHistoryItem execHistItem = execHistory.get(j); 847 if(execHistItem.getStatus() == DCWormsTags.PAUSED || execHistItem.getResIndex() != i){ 848 continue; 849 } 850 if(st == -1){ 851 st = execHistItem.getTimeStamp().getMillis(); 852 } 853 854 if(j < execHistory.size() - 1 && (execHistory.get(j + 1).getResIndex() != execHistItem.getResIndex() || execHistory.get(j + 1).getStatus() == DCWormsTags.PAUSED) || j + 1 == execHistory.size()){ 855 if(j < execHistory.size() -1 && (execHistory.get(j + 1).getResIndex() != execHistItem.getResIndex() || execHistory.get(j + 1).getStatus() == DCWormsTags.PAUSED)) 856 et = execHistory.get(j + 1).getTimeStamp().getMillis(); 857 else et = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC; 858 if(resUnit instanceof ProcessingElements){ 859 ProcessingElements pes = (ProcessingElements) resUnit; 860 for(ComputingResource pe: pes){ 861 String peName = pe.getFullName(); 862 long startDate = st; 863 long endDate; 864 if(i == resourceHistory.size() - 1){ 865 endDate = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC; 866 }else { 867 endDate = et; 868 } 869 870 String appID = getAppId(execTask); 871 872 ResStat resStat = new ResStat(peName, pe.getType(), startDate, endDate, appID); 873 874 List<ResStat> resStats = basicResStats.get(peName); 875 if (resStats == null) { 876 resStats = new ArrayList<ResStat>(); 877 resStats.add(resStat); 878 basicResStats.put(peName, resStats); 879 } else { 880 resStats.add(resStat); 881 } 882 883 String uniqueTaskID = getUniqueTaskId(execTask); 884 885 Set<ComputingResource> peNames = task_processorsMap.get(uniqueTaskID); 886 if (peNames == null) { 887 peNames = new HashSet<ComputingResource>(); 888 peNames.add(pe); 889 task_processorsMap.put(uniqueTaskID, peNames); 890 } else { 891 peNames.add(pe); 892 } 893 894 try{ 895 double usefulWork = execTask.getResourceConsumptionProfile().getUsefulWork()/pes.size(); 896 usefulWork = ((et - st) / (1000 * getExecutionTime(execTask))) * usefulWork; 897 GSSAccumulator uwAcc; 898 if(metCalc.getMetricsData().containsKey("UW_" + pe.getFullName())){ 899 uwAcc = metCalc.getMetricsData().get("UW_" + pe.getFullName()).get(0); 900 uwAcc.add(usefulWork); 901 } else { 902 uwAcc = new GSSAccumulator(); 903 uwAcc.add(usefulWork); 904 metCalc.addMetricsData("UW_" + pe.getFullName(), uwAcc); 905 } 906 } catch (Exception e){ 907 908 } 909 910 } 911 } 912 st = -1; 913 } 914 } 915 } 916 } 917 return basicResStats; 918 } 919 920 private double getExecutionTime(ExecTask execTask) { 921 double executionTime = 0; 922 long previousTimestamp = 0; 923 int previousStatus = DCWormsTags.CREATED; 924 for(ExecutionHistoryItem execHistItem: execTask.getExecHistory()){ 925 if(previousStatus == DCWormsTags.INEXEC){ 926 executionTime = executionTime + (execHistItem.getTimeStamp().getMillis()/1000 - previousTimestamp); 927 } 928 previousTimestamp = execHistItem.getTimeStamp().getMillis()/1000; 929 previousStatus = execHistItem.getStatus(); 930 } 931 return executionTime; 932 //return task.getFinishTime() - task.getExecStartTime(); 822 933 } 823 934 -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/TaskStats.java
r1247 r1362 1 1 package simulator.stats.implementation; 2 2 3 4 import gridsim.dcworms.DCWormsTags; 3 5 4 6 import java.util.HashSet; … … 11 13 import schedframe.resources.computing.Core; 12 14 import schedframe.resources.computing.Processor; 15 import schedframe.scheduling.ExecutionHistoryItem; 13 16 import simulator.stats.implementation.out.StatsSerializer; 14 17 import dcworms.schedframe.scheduling.Executable; … … 102 105 103 106 public double getExecutionTime() { 104 return task.getFinishTime() - task.getExecStartTime(); 107 double executionTime = 0; 108 long previousTimestamp = 0; 109 int previousStatus = DCWormsTags.CREATED; 110 for(ExecutionHistoryItem execHistItem: task.getExecHistory()){ 111 if(previousStatus == DCWormsTags.INEXEC){ 112 executionTime = executionTime + (execHistItem.getTimeStamp().getMillis()/1000 - previousTimestamp); 113 } 114 previousTimestamp = execHistItem.getTimeStamp().getMillis()/1000; 115 previousStatus = execHistItem.getStatus(); 116 } 117 return executionTime; 118 //return task.getFinishTime() - task.getExecStartTime(); 105 119 } 106 120
Note: See TracChangeset
for help on using the changeset viewer.