Changeset 1298 for DCWoRMS/branches


Ignore:
Timestamp:
03/19/14 18:19:43 (11 years ago)
Author:
wojtekp
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java

    r1207 r1298  
    55import eduni.simjava.Sim_event; 
    66import eduni.simjava.Sim_system; 
    7 import gridsim.Accumulator; 
    8 import gridsim.ResourceCalendar; 
    97import gridsim.dcworms.DCWormsTags; 
    108import gridsim.dcworms.filter.ExecTaskFilter; 
     
    3129import schedframe.events.scheduling.TaskRequestedTimeExpiredEvent; 
    3230import schedframe.exceptions.ResourceException; 
     31import schedframe.resources.StandardResourceType; 
    3332import schedframe.resources.computing.ComputingResource; 
    3433import schedframe.resources.computing.profiles.energy.EnergyEvent; 
     
    5453import schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin; 
    5554import schedframe.scheduling.plugin.grid.ModuleListImpl; 
    56 import schedframe.scheduling.plugin.grid.ModuleType; 
    5755import schedframe.scheduling.policy.AbstractManagementSystem; 
    5856import schedframe.scheduling.queue.TaskQueueList; 
     
    6462import schedframe.scheduling.tasks.WorkloadUnit; 
    6563import simulator.DCWormsConstants; 
     64import simulator.stats.GSSAccumulator; 
    6665import simulator.utils.DoubleMath; 
    6766 
     
    7170 
    7271        protected double lastUpdateTime; 
    73  
    74         protected Accumulator accTotalLoad; 
    7572 
    7673        public LocalManagementSystem(String providerId, String entityName, SchedulingPlugin schedPlugin, 
     
    8582                this.schedulingPlugin =  schedPlugin; 
    8683                this.moduleList = new ModuleListImpl(1); 
    87                  
    88                 this.accTotalLoad = new Accumulator(); 
    8984        } 
    9085 
    9186        public void init(Scheduler sched, ManagedResources managedResources) { 
    9287                super.init(sched, managedResources); 
    93                 double load = 0; 
    94                 accTotalLoad.add(load); 
    9588        } 
    9689 
     
    135128                                sendFinishedWorkloadUnit(execTask); 
    136129                                log.debug(execTask.getJobId() + "_" + execTask.getId() + " finished execution on " + new DateTime()); 
    137                                 log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
     130                                log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad()); 
    138131                                if (pluginSupportsEvent(tag)) { 
    139132                                        SchedulingEvent event = new TaskFinishedEvent(execTask.getJobId(), execTask.getId()); 
     
    178171                        execTask = (ExecTask) ev.get_data(); 
    179172                        updateTaskExecution(execTask, SchedulingEventType.RESOURCE_STATE_CHANGED); 
     173                        break; 
     174                         
     175                case DCWormsTags.POWER_LIMIT_EXCEEDED: 
     176                        if (pluginSupportsEvent(tag)) { 
     177                                SchedulingEvent event = new SchedulingEvent(SchedulingEventType.POWER_LIMIT_EXCEEDED); 
     178                                schedulingPlugin.schedule(event, 
     179                                                queues,  getJobRegistry(), getResourceManager(), moduleList); 
     180                        } 
    180181                        break; 
    181182                } 
     
    263264                } 
    264265 
    265                 log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
     266                log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad()); 
    266267                 
    267268                PEUnit peUnit = (PEUnit)choosenResources.get(StandardResourceUnitName.PE); 
     
    323324                        ExecTask task = iter.next(); 
    324325                        Executable exec = (Executable)task; 
    325                         exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / exec.getEstimatedDuration())); 
    326                         UsedResourcesList usedResourcesList = exec.getUsedResources(); 
    327                         PEUnit peUnit = (PEUnit)usedResourcesList.getLast().getResourceUnits() 
    328                                         .get(StandardResourceUnitName.PE); 
    329                         double load = getMIShare(timeSpan, peUnit); 
    330                         addTotalLoad(load); 
     326                        if( exec.getUsedResources().size() > 1){          
     327                                exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / exec.getEstimatedDuration() * (1.0 - exec.getCompletionPercentage()/100.0))); 
     328                        } 
     329                        else { 
     330                                exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / exec.getEstimatedDuration())); 
     331                        } 
    331332                } 
    332333        } 
     
    357358                } 
    358359        } 
    359          
    360         private double getMIShare(double timeSpan, PEUnit pes) { 
    361                 double localLoad; 
    362                 ResourceCalendar resCalendar = (ResourceCalendar) moduleList.getModule(ModuleType.RESOURCE_CALENDAR); 
    363                 if (resCalendar == null) 
    364                         localLoad = 0; 
    365                 else 
    366                         // 1 - localLoad_ = available MI share percentage 
    367                         localLoad = resCalendar.getCurrentLoad(); 
    368  
    369                 int speed = pes.getSpeed(); 
    370                 int cnt = pes.getAmount(); 
    371  
    372                 double totalMI = speed * cnt * timeSpan * (1 - localLoad); 
    373                 return totalMI; 
    374         } 
    375360 
    376361        protected void updateProcessingTimes(Sim_event ev) { 
    377                 updateProcessingProgress(); 
    378362                for (ExecTask execTask : jobRegistry.getRunningTasks()) { 
    379363                        Executable exec = (Executable)execTask; 
     
    385369 
    386370                        if(DoubleMath.subtract((lastTimeStamp + exec.getEstimatedDuration()), (new DateTime().getMillis()/1000 + phaseDuration)) == 0.0){ 
    387                                 return; 
     371                                continue; 
    388372                        } 
    389373 
     
    438422        }        
    439423 
    440         public double calculateTotalLoad(int size) { 
    441                 // background load, defined during initialization 
    442                 double load; 
    443                 ResourceCalendar resCalendar = (ResourceCalendar) moduleList.getModule(ModuleType.RESOURCE_CALENDAR); 
    444                 if (resCalendar == null) 
    445                         load = 0; 
    446                 else 
    447                         load = resCalendar.getCurrentLoad(); 
    448  
    449                 int numberOfPE = 0; 
     424        public double calculateTotalLoad() { 
     425 
     426                GSSAccumulator loadAcc = new GSSAccumulator(); 
    450427                try { 
    451                         for(ResourceUnit resUnit : getResourceManager().getPE()){ 
    452                                 numberOfPE = numberOfPE + resUnit.getAmount(); 
    453                         } 
    454                 } catch (Exception e) { 
    455                         numberOfPE = 1; 
    456                 } 
    457                 double tasksPerPE = (double) size / numberOfPE; 
    458                 load += Math.min(1.0 - load, tasksPerPE); 
    459  
    460                 return load; 
    461         } 
    462  
    463         public Accumulator getTotalLoad() { 
    464                 return accTotalLoad; 
    465         } 
    466  
    467         protected void addTotalLoad(double load) { 
    468                 accTotalLoad.add(load); 
    469         } 
    470          
     428                        for(ComputingResource compRes: getResourceManager().getResourcesOfType(StandardResourceType.Node)){ 
     429                                loadAcc.add(compRes.getLoadInterface().getRecentUtilization().getValue());                               
     430                        } 
     431                } catch (ResourceException e) { 
     432                        // TODO Auto-generated catch block 
     433                        e.printStackTrace(); 
     434                } 
     435                 
     436                return loadAcc.getMean(); 
     437        } 
     438 
    471439        private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution(String resourceName, 
    472440                        ExecTask task) { 
Note: See TracChangeset for help on using the changeset viewer.