Ignore:
Timestamp:
07/30/14 12:25:00 (11 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/branches/coolemall/src/example/load
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/example/load/ProcessorLoadEstimationPlugin.java

    r1415 r1423  
    11package example.load; 
    22 
     3import schedframe.resources.ResourceStatus; 
     4import schedframe.resources.computing.Core; 
    35import schedframe.resources.computing.Processor; 
    46import schedframe.resources.computing.profiles.energy.ResourceEvent; 
    57import schedframe.resources.devices.PhysicalResource; 
    68import schedframe.scheduling.manager.tasks.JobRegistry; 
    7 import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    8 import schedframe.scheduling.tasks.phases.PhaseSystemLoad; 
    9 import dcworms.schedframe.scheduling.ExecTask; 
    109 
    1110public class ProcessorLoadEstimationPlugin extends BaseLoadEstimationPlugin{ 
     
    1413                Processor proc = (Processor) resource; 
    1514                double sumCoresLoad = 0; 
    16                  
    17                 double nrOfThreadsOnCpu = proc.getCores().size(); 
    18                  
    19                 if(proc.getResourceCharacteristic().getParameters().get("threads") != null){ 
    20                         nrOfThreadsOnCpu = nrOfThreadsOnCpu * Integer.valueOf(proc.getResourceCharacteristic().getParameters().get("threads").get(0).getContent()).intValue(); 
     15                if(proc.getStatus().equals(ResourceStatus.BUSY)){ 
     16                        sumCoresLoad = 1; 
     17                } else { 
     18                        if(proc.getCores().size() > 0){ 
     19                                for(Core core: proc.getCores()){ 
     20                                        if(core.getStatus().equals(ResourceStatus.BUSY)){ 
     21                                                sumCoresLoad = sumCoresLoad + 1; 
     22                                        } 
     23                                } 
     24                                sumCoresLoad = sumCoresLoad / proc.getCores().size();    
     25                        } 
    2126                } 
    22  
    23  
    24                 JobRegistry jr = new JobRegistryImpl(proc.getFullName()); 
    25                 for(ExecTask task: jr.getRunningTasks()){ 
    26                         double cpuUsage = 1 / nrOfThreadsOnCpu; 
    27  
    28                         for(PhaseSystemLoad pb: task.getExecutionProfile().getCurrentResourceConsumption().getSystemLoad()){ 
    29                                 if(pb.getResouceName().equals("PM_CPU_Usage")){ 
    30                                         cpuUsage = pb.getUtilization(); 
    31                                 } 
    32                         } 
    33                         sumCoresLoad = sumCoresLoad + cpuUsage; 
    34  
    35                 } 
    36  
    3727 
    3828                double processorLoad = 100 * sumCoresLoad;       
Note: See TracChangeset for help on using the changeset viewer.