Ignore:
Timestamp:
03/04/13 08:25:34 (12 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/branches/coolemall/src/schedframe
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/schedframe/events/scheduling/SchedulingEventType.java

    r477 r896  
    2020 
    2121        //time related 
    22         TIMER(254), 
     22        TIMER(256), 
    2323         
    2424        //resource related 
     
    3333        RESERVATION_EXPIRED(16384), 
    3434         
    35         RESOURCE_STATE_CHANGED(32668) 
     35        RESOURCE_STATE_CHANGED(32768) 
    3636        ; 
    3737         
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java

    r822 r896  
    164164                        break; 
    165165                         
    166                 case DCWormsTags.PHASE_CHANGED: 
     166                case DCWormsTags.TASK_EXECUTION_CHANGED: 
    167167                        execTask = (ExecTask) ev.get_data(); 
    168                         //updatePhases(execTask); 
     168                        updateTaskExecution(execTask, SchedulingEventType.RESOURCE_STATE_CHANGED); 
    169169                        break; 
    170170                } 
     
    224224                removeFromQueue(task); 
    225225 
    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); 
    236232                DateTime currentTime = new DateTime(); 
    237233                ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime); 
    238234                exec.addUsedResources(resHistItem); 
     235                 
    239236                try { 
    240237                        exec.setStatus(DCWormsTags.INEXEC); 
     
    244241                } 
    245242                 
    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); 
    248245 
    249246                try { 
     
    251248                        scheduler.sendInternal(expectedDuration, DCWormsTags.TASK_REQUESTED_TIME_EXPIRED, exec); 
    252249                } 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); 
    255252                } 
    256253 
     
    261258                notifyComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec); 
    262259                 
    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                 }*/ 
    284260        } 
    285261         
     
    323299                PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE); 
    324300                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); 
    341301        } 
    342302         
     
    353313                        Executable exec = (Executable)task; 
    354314                        //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())); 
    357316                        UsedResourcesList usedResourcesList = exec.getUsedResources(); 
    358317                        PEUnit peUnit = (PEUnit)usedResourcesList.getLast().getResourceUnits() 
     
    364323         
    365324        private void notifyComputingResources(PEUnit peUnit, EnergyEventType eventType, Object obj){ 
    366  
    367325                if(peUnit instanceof ProcessingElements){ 
    368326                        ProcessingElements pes = (ProcessingElements) peUnit; 
     
    409367                for (ExecTask execTask : jobRegistry.getRunningTasks()) { 
    410368                        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 
    417370                        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),  
    419373                                        execTask, choosenResources, exec.getCompletionPercentage())).intValue(); 
    420374 
    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                        } 
    430397                } 
    431398        }        
    432          
    433          
    434         /*protected void updatePhases(ExecTask execTask) { 
    435                 updateProcessingProgress(); 
     399 
     400        protected void updateTaskExecution(ExecTask execTask, SchedulingEventType schedEvType) { 
    436401 
    437402                if (execTask.getStatus() == DCWormsTags.INEXEC) { 
    438403                        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        }        
    462424 
    463425        public double calculateTotalLoad(int size) { 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Task.java

    r887 r896  
    44import java.io.StringWriter; 
    55import java.util.ArrayList; 
     6import java.util.LinkedList; 
    67import java.util.List; 
    78 
     
    9697 
    9798        private void preparePhases() { 
    98                 List<ResourceConsumption> resourceConsumptionList = new ArrayList<ResourceConsumption>(); 
     99                LinkedList<ResourceConsumption> resourceConsumptionList = new LinkedList<ResourceConsumption>(); 
    99100                 
    100101                if(task.getExecution() == null || task.getExecution().getResourceConsumptionProfile() == null){ 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumption.java

    r883 r896  
    5151        } 
    5252 
    53         public void setReferenceHardware(String referenceHardware) { 
    54                 this.referenceHardware = referenceHardware; 
    55         } 
    56  
    5753        public long getDuration() { 
    5854                return duration; 
    59         } 
    60  
    61         public void setDuration(long duration) { 
    62                 this.duration = duration; 
    6355        } 
    6456 
     
    6759        } 
    6860 
    69         public void setBehaviourList(List<PhaseBehaviour> behaviourList) { 
    70                 this.phaseBehaviourList = behaviourList; 
    71         } 
    7261} 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumptionProfile.java

    r883 r896  
    11package schedframe.scheduling.tasks.phases; 
    22 
    3 import java.util.ArrayList; 
     3import java.util.LinkedList; 
    44import java.util.List; 
    55 
    66public class ResourceConsumptionProfile { 
    77         
    8         protected List<ResourceConsumption> resourceConsumptionList; 
     8        protected LinkedList<ResourceConsumption> resourceConsumptionList; 
     9        protected int currentPhase; 
    910         
    1011        public ResourceConsumptionProfile() { 
    11                 this.resourceConsumptionList = new ArrayList<ResourceConsumption>(); 
     12                this.resourceConsumptionList = new LinkedList<ResourceConsumption>(); 
     13                this.currentPhase = -1; 
    1214        } 
    1315         
    14         public ResourceConsumptionProfile(List<ResourceConsumption> resourceConsumptionList) { 
     16        public ResourceConsumptionProfile(LinkedList<ResourceConsumption> resourceConsumptionList) { 
    1517                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; 
    1638        } 
    1739} 
Note: See TracChangeset for help on using the changeset viewer.