Ignore:
Timestamp:
07/15/14 16:26:31 (11 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/global/GlobalManagementSystem.java

    r1385 r1415  
    7878                        return; 
    7979                } 
    80                  
    8180                registerWorkloadUnit(wu); 
    8281 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java

    r1396 r1415  
    1919import schedframe.events.scheduling.StartTaskExecutionEvent; 
    2020import schedframe.events.scheduling.TaskFinishedEvent; 
     21import schedframe.events.scheduling.TaskPausedEvent; 
    2122import schedframe.events.scheduling.TaskRequestedTimeExpiredEvent; 
     23import schedframe.events.scheduling.TaskResumedEvent; 
    2224import schedframe.exceptions.ResourceException; 
    2325import schedframe.resources.StandardResourceType; 
    2426import schedframe.resources.computing.ComputingResource; 
    25 import schedframe.resources.computing.profiles.energy.EnergyEvent; 
    26 import schedframe.resources.computing.profiles.energy.EnergyEventType; 
     27import schedframe.resources.computing.profiles.energy.ResourceEvent; 
     28import schedframe.resources.computing.profiles.energy.ResourceEventType; 
    2729import schedframe.resources.units.PEUnit; 
    2830import schedframe.resources.units.ProcessingElements; 
     
    163165                        String[] ids = (String[]) ev.get_data(); 
    164166                        execTask = jobRegistry.getTask(ids[0], ids[1]); 
    165                         taskPause(execTask); 
     167                        pauseTask(execTask); 
    166168                        if (pluginSupportsEvent(tag)) { 
    167                                 SchedulingEvent event = new SchedulingEvent(SchedulingEventType.TASK_PAUSED); 
     169                                SchedulingEvent event = new TaskPausedEvent(ids[0], ids[1]); 
    168170                                SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 
    169171                                                queues, jobRegistry, getResourceManager(), moduleList); 
     
    176178                        String[] ids = (String[]) ev.get_data(); 
    177179                        execTask = jobRegistry.getTask(ids[0], ids[1]); 
    178                         taskResume(execTask, execTask.getAllocatedResources().getLast().getResourceUnits(), true); 
     180                        resumeTask(execTask, execTask.getAllocatedResources().getLast().getResourceUnits(), true); 
    179181                        if (pluginSupportsEvent(tag)) { 
    180                                 SchedulingEvent event = new StartTaskExecutionEvent(ids[0], ids[1]); 
     182                                SchedulingEvent event = new TaskResumedEvent(ids[0], ids[1]); 
    181183                                SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 
    182184                                                queues, jobRegistry, getResourceManager(), moduleList); 
     
    189191                        Object[] data = (Object[]) ev.get_data(); 
    190192                        execTask = jobRegistry.getTask((String)data[0], (String)data[1]); 
    191                         double migrationTime = execTimeEstimationPlugin.estimateMigrationTime(new StartTaskExecutionEvent((String)data[0], (String)data[1]), execTask, execTask.getAllocatedResources().getLast().getResourceUnits(), (Map<ResourceUnitName, ResourceUnit>)data[2]); 
     193                        double migrationTime = execTimeEstimationPlugin.estimateMigrationTime(new StartTaskExecutionEvent((String)data[0],  
     194                                        (String)data[1]), execTask, execTask.getAllocatedResources().getLast().getResourceUnits(), (Map<ResourceUnitName, ResourceUnit>)data[2]); 
    192195                        scheduler.sendInternal(migrationTime, DCWormsTags.TASK_MOVE, data); 
    193196                } 
     
    197200                        Object[] data = (Object[]) ev.get_data(); 
    198201                        execTask = jobRegistry.getTask((String)data[0], (String)data[1]); 
    199                         taskMove(execTask, (Map<ResourceUnitName, ResourceUnit>)data[2]); 
     202                        moveTask(execTask, (Map<ResourceUnitName, ResourceUnit>)data[2]); 
    200203                        if (pluginSupportsEvent(tag)) { 
    201204                                SchedulingEvent event = new StartTaskExecutionEvent((String)data[0], (String)data[1]); 
     
    209212                case DCWormsTags.TASK_EXECUTION_CHANGED: 
    210213                        execTask = (ExecTask) ev.get_data(); 
    211                         updateTaskExecutionPhase(execTask, SchedulingEventType.RESOURCE_STATE_CHANGED); 
     214                        updateTaskExecutionPhase(execTask); 
    212215                        break; 
    213216 
     
    231234                        } 
    232235                        break; 
    233                 } 
    234         } 
    235  
    236  
    237         public void taskPause(ExecTask execTask) { 
     236                default:                 
     237                         
     238                        break; 
     239                } 
     240        } 
     241 
     242 
     243        protected void pauseTask(ExecTask execTask) { 
    238244                if (execTask == null) { 
    239245                        return; 
     
    246252                                getAllocationManager().freeResources(lastUsed, true); 
    247253                                 
    248                                 saveExecutionHistory(exec, exec.getCompletionPercentage(), exec.getEstimatedDuration()); 
     254                                saveExecutionHistory(exec, exec.getExecutionProfile().getCompletionPercentage(), exec.getEstimatedDuration()); 
    249255                                 
    250256                                ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), -1); 
     
    252258                                 
    253259                                PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE); 
    254                                 updateComputingResources(peUnit, EnergyEventType.TASK_FINISHED, exec); 
     260                                updateComputingResources(peUnit, ResourceEventType.TASK_FINISHED, exec); 
    255261                        } catch (Exception e) { 
    256262                                // TODO Auto-generated catch block 
     
    260266        } 
    261267         
    262         public void taskResume(ExecTask execTask, Map<ResourceUnitName, ResourceUnit> resources, boolean exclusive) { 
     268        protected void resumeTask(ExecTask execTask, Map<ResourceUnitName, ResourceUnit> resources, boolean exclusive) { 
    263269                if (execTask == null) { 
    264270                        return; 
     
    278284                                         
    279285                                        PEUnit peUnit = (PEUnit)resources.get(StandardResourceUnitName.PE); 
    280                                         updateComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec); 
     286                                        updateComputingResources(peUnit, ResourceEventType.TASK_STARTED, exec); 
    281287                                } 
    282288 
     
    288294        } 
    289295         
    290         public void taskMove(ExecTask execTask, Map<ResourceUnitName, ResourceUnit> map) { 
    291                 taskPause(execTask); 
    292                 taskResume(execTask, map, false); 
     296        protected void moveTask(ExecTask execTask, Map<ResourceUnitName, ResourceUnit> map) { 
     297                pauseTask(execTask); 
     298                resumeTask(execTask, map, false); 
    293299        } 
    294300         
     
    351357                 
    352358                PEUnit peUnit = (PEUnit)choosenResources.get(StandardResourceUnitName.PE); 
    353                 updateComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 
     359                updateComputingResources(peUnit, ResourceEventType.UTILIZATION_CHANGED, exec); 
    354360                 
    355361 
     
    377383 
    378384                int phaseDuration = Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.START_TASK_EXECUTION),  
    379                                 execTask, resources, exec.getCompletionPercentage())).intValue(); 
    380  
    381                 saveExecutionHistory(exec, exec.getCompletionPercentage(), phaseDuration); 
     385                                execTask, resources, exec.getExecutionProfile().getCompletionPercentage())).intValue(); 
     386 
     387                saveExecutionHistory(exec, exec.getExecutionProfile().getCompletionPercentage(), phaseDuration); 
    382388                if(exec.getExecutionProfile().isLast()){ 
    383389                        scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_FINISHED, execTask);; 
     
    387393                 
    388394                PEUnit peUnit = (PEUnit)resources.get(StandardResourceUnitName.PE); 
    389                 updateComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec); 
     395                updateComputingResources(peUnit, ResourceEventType.TASK_STARTED, exec); 
    390396                 
    391397        } 
     
    429435                 
    430436                PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE); 
    431                 updateComputingResources(peUnit, EnergyEventType.TASK_FINISHED, exec); 
     437                updateComputingResources(peUnit, ResourceEventType.TASK_FINISHED, exec); 
    432438                 
    433439                log.debug(execTask.getJobId() + "_" + execTask.getId() + " finished execution on " + new DateTime()); 
    434440                log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad()); 
    435441                 
    436                 updateComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 
     442                updateComputingResources(peUnit, ResourceEventType.UTILIZATION_CHANGED, exec); 
    437443        } 
    438444         
     
    452458                        //System.out.println("--- upadteProgressX: " + Sim_system.sim_clock() ); 
    453459                        //System.out.println("taskId: " + exec.getId() + "; completion percentage: " + exec.getCompletionPercentage() + "; timespan: " + timeSpan + "; estimatedDuration: " +  execHistItem.getCompletionPercentage()); 
    454                         exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / (execHistItem.getEstimatedDuration()) * (1.0 - execHistItem.getCompletionPercentage()/100.0))); 
     460                        exec.getExecutionProfile().setCompletionPercentage(exec.getExecutionProfile().getCompletionPercentage() + 100 * (timeSpan / (execHistItem.getEstimatedDuration()) * (1.0 - execHistItem.getCompletionPercentage()/100.0))); 
     461                        exec.setTotalCompletionPercentage(exec.getTotalCompletionPercentage() + 100 * (timeSpan / execHistItem.getEstimatedDuration()) * exec.getExecutionProfile().getCurrentResourceConsumption().getLenght() / exec.getExecutionProfile().getLength()); 
    455462                        //System.out.println("newProgress: " + exec.getCompletionPercentage()  );        
    456463 
     
    458465        } 
    459466         
    460         private void updateComputingResources(PEUnit peUnit, EnergyEventType eventType, Object obj){ 
     467        private void updateComputingResources(PEUnit peUnit, ResourceEventType eventType, Object obj){ 
    461468                if(peUnit instanceof ProcessingElements){ 
    462469                        ProcessingElements pes = (ProcessingElements) peUnit; 
    463470                        for (ComputingResource resource : pes) { 
    464                                 resource.handleEvent(new EnergyEvent(eventType, obj, scheduler.getFullName())); 
     471                                resource.handleEvent(new ResourceEvent(eventType, obj, scheduler.getFullName())); 
    465472                                //DataCenterWorkloadSimulator.getEventManager().sendToResources(resource.getType(), 0, new EnergyEvent(eventType, obj)); 
    466473                        } 
     
    480487                                return; 
    481488                        } 
    482                         resource.handleEvent(new EnergyEvent(eventType, obj, scheduler.getFullName())); 
     489                        resource.handleEvent(new ResourceEvent(eventType, obj, scheduler.getFullName())); 
    483490                } 
    484491        } 
     
    492499 
    493500                        int phaseDuration = Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.RESOURCE_STATE_CHANGED),  
    494                                         execTask, choosenResources, exec.getCompletionPercentage())).intValue(); 
     501                                        execTask, choosenResources, exec.getExecutionProfile().getCompletionPercentage())).intValue(); 
    495502 
    496503                        ExecutionHistoryItem execHistItem = exec.getExecutionHistory().getLast(); 
    497                         double lastTimeStamp = execHistItem.getTimeStamp().getMillis()/1000; 
    498                         if(DoubleMath.subtract((lastTimeStamp + execHistItem.getEstimatedDuration()), (new DateTime().getMillis()/1000 + phaseDuration)) == 0.0){ 
     504                        double lastTimeStamp = execHistItem.getTimeStamp().getMillis() / 1000; 
     505                        if(DoubleMath.subtract((lastTimeStamp + execHistItem.getEstimatedDuration()), (new DateTime().getMillis() / 1000 + phaseDuration)) == 0.0){ 
    499506                                continue; 
    500507                        } 
     
    504511                        //System.out.println("completionPercantage: " + exec.getCompletionPercentage() + "; basic duration: " +exec.getResourceConsumptionProfile().getCurrentResourceConsumption().getDuration() +   "; phaseDuration: " +  phaseDuration); 
    505512 
    506                         saveExecutionHistory(exec, exec.getCompletionPercentage(), phaseDuration); 
     513                        saveExecutionHistory(exec, exec.getExecutionProfile().getCompletionPercentage(), phaseDuration); 
    507514                         
    508515                        if(exec.getExecutionProfile().isLast()){ 
     
    522529        }        
    523530 
    524         protected void updateTaskExecutionPhase(ExecTask execTask, SchedulingEventType schedEvType) { 
     531        protected void updateTaskExecutionPhase(ExecTask execTask) { 
    525532 
    526533                if (execTask.getStatus() == DCWormsTags.INEXEC) { 
     
    535542                        Map<ResourceUnitName, ResourceUnit> choosenResources = exec.getAllocatedResources().getLast().getResourceUnits(); 
    536543 
    537                         int phaseDuration = Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(schedEvType),  
    538                                         execTask, choosenResources, exec.getCompletionPercentage())).intValue(); 
    539                          
    540                         saveExecutionHistory(exec, exec.getCompletionPercentage(), phaseDuration); 
     544                        int phaseDuration = Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.TASK_EXECUTION_CHANGED),  
     545                                        execTask, choosenResources, exec.getExecutionProfile().getCompletionPercentage())).intValue(); 
     546                         
     547                        saveExecutionHistory(exec, exec.getExecutionProfile().getCompletionPercentage(), phaseDuration); 
    541548                         
    542549                        if(exec.getExecutionProfile().isLast()){ 
     
    547554                         
    548555                        PEUnit peUnit = (PEUnit)exec.getAllocatedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 
    549                         updateComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 
     556                        updateComputingResources(peUnit, ResourceEventType.UTILIZATION_CHANGED, exec); 
    550557                } 
    551558        }        
    552559 
    553         public double calculateTotalLoad() { 
     560        protected double calculateTotalLoad() { 
    554561 
    555562                DCwormsAccumulator loadAcc = new DCwormsAccumulator(); 
    556                 try { 
    557                         for(ComputingResource compRes: getResourceManager().getResourcesOfType(StandardResourceType.Node)){ 
    558                                 loadAcc.add(compRes.getLoadInterface().getRecentUtilization().getValue());                               
    559                         } 
    560                 } catch (ResourceException e) { 
    561                         // TODO Auto-generated catch block 
    562                         e.printStackTrace(); 
    563                 } 
    564                  
     563 
     564                for(ComputingResource compRes: getResourceManager().getResourcesOfType(StandardResourceType.Node)){ 
     565                        loadAcc.add(compRes.getLoadInterface().getRecentUtilization().getValue());                               
     566                } 
     567 
    565568                return loadAcc.getMean(); 
    566569        } 
     
    703706         
    704707        private void saveExecutionHistory(Executable exec, double completionPercentage, double estimatedDuration){ 
    705  
    706708                ExecutionHistoryItem execHistoryItem = new ExecutionHistoryItem(new DateTime()); 
    707709                execHistoryItem.setCompletionPercentage(completionPercentage); 
     
    710712                execHistoryItem.setStatus(exec.getStatus()); 
    711713                exec.addExecHistory(execHistoryItem); 
    712                  
    713714        } 
    714715         
Note: See TracChangeset for help on using the changeset viewer.