Changeset 896


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

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java

    r885 r896  
    2525import schedframe.scheduling.tasks.AbstractProcessesGroup; 
    2626import schedframe.scheduling.tasks.Task; 
     27import schedframe.scheduling.tasks.phases.ResourceConsumption; 
    2728import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile; 
    2829import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
     
    3940         
    4041        protected int status;  
    41         protected double length; 
    4242        protected Map<ResourceParameterName, Object> specificResources; 
    4343         
     
    158158        } 
    159159 
    160         if (newStatus < DCWormsTags.CREATED || newStatus > DCWormsTags.FAILED_RESOURCE_UNAVAILABLE) { 
     160        if (newStatus < DCWormsTags.CREATED || newStatus > DCWormsTags.NEW_EXEC_PHASE) { 
    161161            throw new Exception("Executable.setStatuts() : Error - " + 
    162162                    "Invalid integer range for Execiutable status."); 
     
    204204                } 
    205205        } 
     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        } 
    206222        } 
    207223         
     
    209225                if(this.specificResources == null) 
    210226                        this.specificResources = new HashMap<ResourceParameterName, Object>(); 
    211                  
    212227                this.specificResources.put(resourceName, value); 
    213228        } 
     
    216231                if(this.specificResources == null) 
    217232                        return false; 
    218  
    219233                return this.specificResources.containsKey(resourceName); 
    220234        } 
     
    255269        } 
    256270         
    257     public void setSchedulerName(int resourceId) 
    258     { 
     271    public void setSchedulerName(int resourceId){ 
    259272        this.schedName = GridSim.getEntityName(resourceId); 
    260273    } 
    261274 
    262     public String getSchedulerName() 
    263     { 
     275    public String getSchedulerName(){ 
    264276        return schedName; 
    265277    } 
     
    368380        } 
    369381 
    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(); 
    378384        } 
    379385         
  • DCWoRMS/branches/coolemall/src/gridsim/dcworms/DCWormsTags.java

    r808 r896  
    1414        public static final int TO_SCHEDULERS = DCWORMSBASE - 3; 
    1515         
    16         public static final int PHASE_CHANGED = DCWORMSBASE - 2; 
     16        public static final int TASK_EXECUTION_CHANGED = DCWORMSBASE - 2; 
    1717         
    1818        public static final int UPDATE_PROCESSING = DCWORMSBASE - 1; 
     
    5555    public static final int RESUMED = 9; 
    5656 
    57     public static final int FAILED_RESOURCE_UNAVAILABLE = 10; 
     57    public static final int NEW_EXEC_PHASE = 10; 
    5858 
    5959} 
  • 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} 
  • DCWoRMS/branches/coolemall/src/test/PhaseTimeEstimationPlugin.java

    r883 r896  
    88import schedframe.resources.units.ResourceUnitName; 
    99import schedframe.resources.units.StandardResourceUnitName; 
     10import schedframe.scheduling.tasks.phases.ResourceConsumption; 
    1011import dcworms.schedframe.scheduling.ExecTask; 
    1112import dcworms.schedframe.scheduling.Executable; 
     
    2728                        double completionPercentage) { 
    2829 
    29                  
    3030                Executable exec = (Executable) task; 
    31         //      System.out.println(exec.getJobId() +":"+ exec.getApplicationName()); 
     31                // System.out.println(exec.getJobId() +":"+ exec.getApplicationName()); 
    3232                // collect all information necessary to do the calculation 
    3333                PEUnit peUnit = (PEUnit) allocatedResources.get(StandardResourceUnitName.PE); 
     
    4040 
    4141                // estimate remainingTaskLength 
    42                 double remainingLength =  task.getLength() * (1 - completionPercentage/100); 
    43                  
     42                ResourceConsumption resConsumption = exec.getResourceConsumptionProfile().getCurrentResourceConsumption(); 
     43 
    4444                // do the calculation 
    45                 double execTime = (remainingLength / (cnt * speed)); 
     45                double execTime = (1 - completionPercentage/100) * resConsumption.getDuration(); 
    4646 
    4747                // 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.