Changeset 512


Ignore:
Timestamp:
10/12/12 13:04:31 (13 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/trunk/src/example/localplugin/FCFSCPUFreqScalingClusterLocalPlugin.java

    r497 r512  
    99 
    1010import schedframe.events.scheduling.SchedulingEvent; 
    11 import schedframe.events.scheduling.TaskFinishedEvent; 
    12 import schedframe.events.scheduling.TaskRequestedTimeExpiredEvent; 
    1311import schedframe.resources.ResourceStatus; 
    1412import schedframe.resources.computing.ComputingResource; 
     
    1816import schedframe.resources.units.ResourceUnitName; 
    1917import schedframe.resources.units.StandardResourceUnitName; 
    20 import schedframe.scheduling.UsedResourcesList; 
    2118import schedframe.scheduling.manager.resources.ClusterResourceManager; 
    2219import schedframe.scheduling.manager.resources.ResourceManager; 
     
    2926import schedframe.scheduling.tasks.TaskInterface; 
    3027import schedframe.scheduling.tasks.WorkloadUnit; 
    31 import dcworms.schedframe.scheduling.Executable; 
    3228 
    3329public class FCFSCPUFreqScalingClusterLocalPlugin extends BaseLocalSchedulingPlugin { 
     
    5147                 
    5248                case START_TASK_EXECUTION: 
    53  
     49                case TASK_FINISHED: 
    5450                        // check all tasks in queue 
    5551                        for (int i = 0; i < q.size(); i++) { 
     
    6258                                        if (choosenResources  != null) { 
    6359                                                addToSchedulingPlan(plan, task, choosenResources); 
    64                                                 ProcessingElements pes = (ProcessingElements)choosenResources.get(StandardResourceUnitName.PE); 
    65                                                 List<Processor> processors =  new ArrayList<Processor>(); 
    66                                                 for(ComputingResource res : pes){ 
    67                                                         processors.add((Processor) res); 
    68                                                 } 
    69                                                 adjustFrequency(ResourceStatus.BUSY,processors); 
    7060                                        }  
    7161                                } 
    7262                        } 
    73                         break; 
    74                          
    75                 case TASK_FINISHED: 
    76                         TaskFinishedEvent finEvent = (TaskFinishedEvent) event; 
    77                         Executable exec = (Executable) jobRegistry.getExecutable(finEvent.getJobId(), finEvent.getTaskId()); 
    78                         UsedResourcesList usedResourcesList = exec.getUsedResources(); 
    79                         ProcessingElements pes = (ProcessingElements)usedResourcesList.getLast().getResourceUnits().get(StandardResourceUnitName.PE); 
    80                         List<Processor> processors =  new ArrayList<Processor>(); 
    81                         for(ComputingResource res : pes){ 
    82                                 processors.add((Processor) res); 
    83                                 allocatedCPUs.add((Processor) res); 
    84                         } 
    85                         adjustFrequency(ResourceStatus.FREE, processors); 
    86                         break; 
    87                          
    88                 case TASK_REQUESTED_TIME_EXPIRED: 
    89                         TaskRequestedTimeExpiredEvent timExpEvent = (TaskRequestedTimeExpiredEvent) event; 
    90                         exec = (Executable) jobRegistry.getExecutable(timExpEvent.getJobId(), timExpEvent.getTaskId()); 
    91                         usedResourcesList = exec.getUsedResources(); 
    92                         pes = (ProcessingElements)usedResourcesList.getLast().getResourceUnits().get(StandardResourceUnitName.PE); 
    93                         processors =  new ArrayList<Processor>(); 
    94                         for(ComputingResource res : pes){ 
    95                                 allocatedCPUs.remove((Processor) res); 
    96                         } 
    97                         // check all tasks in queue 
    98                         for (int i = 0; i < q.size(); i++) { 
    99                                 WorkloadUnit job = q.get(i); 
    100                                 TaskInterface<?> task = (TaskInterface<?>) job; 
    101                                 // if status of the tasks in READY 
    102                                 if (task.getStatus() == DCWormsTags.READY) { 
    103  
    104                                         Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 
    105                                         if (choosenResources  != null) { 
    106                                                 addToSchedulingPlan(plan, task, choosenResources); 
    107                                                 pes = (ProcessingElements)choosenResources.get(StandardResourceUnitName.PE); 
    108                                                 processors =  new ArrayList<Processor>(); 
    109                                                 for(ComputingResource res : pes){ 
    110                                                         processors.add((Processor) res); 
    111                                                 } 
    112                                                 adjustFrequency(ResourceStatus.BUSY, processors); 
    113                                         }  
    114                                 } 
    115                         } 
    116                         break; 
     63                        adjustFrequency(resourceManager.getProcessors()); 
    11764                } 
    11865                return plan; 
     
    160107                return map; 
    161108        } 
     109         
     110        private void adjustFrequency(List<Processor> processors){ 
    162111 
    163         private void adjustFrequency(ResourceStatus status, List<Processor> processors){ 
    164                 switch(status){ 
    165                 case BUSY: 
    166                         for(Processor cpu: processors){ 
    167                                 try { 
    168                                         if(cpu.getPowerInterface().getSupportedPStates().containsKey("P0")) 
    169                                                 cpu.getPowerInterface().setPState("P0"); 
    170                                 } catch (NoSuchFieldException e) { 
    171                                         // TODO Auto-generated catch block 
    172                                         e.printStackTrace(); 
    173                                 } 
     112                for(Processor cpu: processors){ 
     113                        if(cpu.getStatus() == ResourceStatus.FREE) { 
     114                                if(cpu.getPowerInterface().getSupportedPStates().containsKey("P3")) 
     115                                        cpu.getPowerInterface().setPState("P3"); 
    174116                        } 
    175                         break; 
    176                 case FREE: 
    177                         for(Processor cpu: processors){ 
    178                                 try { 
    179                                         if(cpu.getPowerInterface().getSupportedPStates().containsKey("P3")) 
    180                                                 cpu.getPowerInterface().setPState("P3"); 
    181                                 } catch (NoSuchFieldException e) { 
    182                                         // TODO Auto-generated catch block 
    183                                         e.printStackTrace(); 
    184                                 } 
     117                        else{ 
     118                                if(cpu.getPowerInterface().getSupportedPStates().containsKey("P0")) 
     119                                        cpu.getPowerInterface().setPState("P0"); 
    185120                        } 
    186                         break; 
     121 
    187122                } 
     123 
    188124        } 
    189125 
     126 
    190127} 
  • DCWoRMS/trunk/src/schedframe/ResourceController.java

    r490 r512  
    1818        protected static Scheduler scheduler; 
    1919        protected static List<ComputingResource> computingResources; 
    20         protected Deque<Initializable> toInit; 
     20        protected List<Initializable> toInit; 
    2121        protected Set<String> compResLayers; 
    2222         
     
    137137        } 
    138138 
    139         public void setInitList(Deque<Initializable> toI) { 
     139        public void setInitList(List<Initializable> toI) { 
    140140                toInit = toI; 
    141141        } 
    142142 
    143         public Deque<Initializable> getToInit() { 
     143        public List<Initializable> getToInit() { 
    144144                return toInit; 
    145145        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/ComputingResource.java

    r495 r512  
    4646        protected String name; 
    4747        protected ResourceType type; 
     48        protected String category; 
    4849        protected ResourceStatus status; 
    4950 
     
    6364                this.type = resDesc.getType(); 
    6465                this.name = resDesc.getId(); 
     66                this.category = resDesc.getCategory(); 
    6567                this.status = ResourceStatus.FREE; 
    6668                this.extensionList = new ExtensionListImpl(1); 
     
    230232        } 
    231233         
     234        public String getCategory(){ 
     235                return category; 
     236        } 
     237         
    232238        public PowerInterface getPowerInterface(){ 
    233239                if (extensionList != null) { 
     
    297303        public void initiate(){ 
    298304                 
    299                 ResourceEventCommand rec = new ResourceEventCommand(this); 
     305                /*ResourceEventCommand rec = new ResourceEventCommand(this); 
    300306                EnergyEvent event = new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller"); 
    301307                event.setReason(EventReason.SIM_INIT); 
    302                 rec.execute(event); 
    303                  
    304                 rec = new ResourceEventCommand(this); 
    305                 event = new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller"); 
     308                rec.execute(event);*/ 
     309                ResourceEventCommand rec = new ResourceEventCommand(this); 
     310                EnergyEvent event = new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller"); 
    306311                event.setReason(EventReason.SIM_INIT); 
    307312                rec.execute(event); 
  • DCWoRMS/trunk/src/schedframe/resources/computing/description/ComputingResourceDescription.java

    r477 r512  
    3333        protected AirThroughputProfile airThroughputProfile; 
    3434        protected Location location; 
     35        protected String category; 
    3536        //protected Parameters parameters; 
    3637 
     
    4041 
    4142                initId(computingResource); 
     43                this.category = computingResource.getType(); 
    4244 
    4345                if (computingResource.getComputingResourceTypeChoiceSequence() != null) { 
     
    263265        } 
    264266 
    265  
     267        public String getCategory() { 
     268                return category; 
     269        } 
    266270 
    267271} 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java

    r495 r512  
    6666        } 
    6767         
    68         public Map<String, PState> getSupportedPStates() throws NoSuchFieldException { 
     68        public Map<String, PState> getSupportedPStates() { 
    6969                if(supportedPStates == null) 
    70                         throw new NoSuchFieldException("Supported p-states are not defined."); 
     70                        return new HashMap<String, PState>(); 
    7171                return supportedPStates; 
    7272        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java

    r506 r512  
    11package schedframe.resources.computing.profiles.energy.power.ui; 
    22 
    3  
    4 import gridsim.GridSimTags; 
    5 import gridsim.dcworms.DCWormsTags; 
    63 
    74import java.util.Map; 
     
    1512import schedframe.resources.computing.profiles.energy.power.PowerStateName; 
    1613import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 
    17 import schedframe.resources.units.CpuSpeed; 
    18 import schedframe.resources.units.StandardResourceUnitName; 
    1914 
    2015public class ProcessorPowerInterface extends ComputingResourcePowerInterface { 
     
    2621                super(resource, pp); 
    2722                currentPowerState = StandardPowerStateName.ON; 
    28                 try { 
    29                         currentPState = getSupportedPStates().get("P0"); 
    30                 } catch (NoSuchFieldException e) { 
    31                         currentPState = null; 
    32                 } 
     23                currentPState = getSupportedPStates().get("P0"); 
    3324        } 
    3425         
     
    5344        } 
    5445         
    55         public Map<String, PState> getSupportedPStates() throws NoSuchFieldException { 
     46        public Map<String, PState> getSupportedPStates() { 
    5647                return powerProfile.getSupportedPStates(); 
    5748        } 
    5849         
    5950        public boolean supportPState(PState pState) { 
    60                 try { 
    61                         for(String pStateName: getSupportedPStates().keySet()){ 
    62                                 if(pState.getName().equals(pStateName)){ 
    63                                         return true; 
    64                                 } 
     51 
     52                for(String pStateName: getSupportedPStates().keySet()){ 
     53                        if(pState.getName().equals(pStateName)){ 
     54                                return true; 
    6555                        } 
    66                 } catch (NoSuchFieldException e) { 
    67                         return false; 
    6856                } 
    6957                return false; 
     
    7159         
    7260        public boolean setPState(String pStateName){ 
    73                 PState newPState; 
    74                 try { 
    75                         newPState = getSupportedPStates().get(pStateName); 
    76                 } catch (NoSuchFieldException e) { 
    77                         return false; 
    78                 } 
     61                PState newPState = getSupportedPStates().get(pStateName); 
    7962 
    80                 if(newPState != currentPState){ 
     63 
     64                if(newPState != null && newPState != currentPState){ 
    8165                        //double factor = newPState.getFrequency()/currentPState.getFrequency(); 
    8266                        currentPState = newPState; 
     
    9781 
    9882        public boolean setFrequency(double freq) { 
    99                 try { 
    100                         for(String pStateName: getSupportedPStates().keySet()){ 
    101                                 if(getSupportedPStates().get(pStateName).getFrequency() == freq){ 
    102                                         setPState(pStateName); 
    103                                         return true; 
    104                                 } 
     83 
     84                for(String pStateName: getSupportedPStates().keySet()){ 
     85                        if(getSupportedPStates().get(pStateName).getFrequency() == freq){ 
     86                                setPState(pStateName); 
     87                                return true; 
    10588                        } 
    106                 } catch (NoSuchFieldException e) { 
    107                         return false; 
    10889                } 
    10990                return false; 
  • DCWoRMS/trunk/src/simulator/DataCenterWorkloadSimulator.java

    r494 r512  
    262262                ResourceController rc = resourceReader.read(); 
    263263 
    264                 while(!rc.getToInit().isEmpty()){ 
    265                         Initializable initObj = rc.getToInit().pop(); 
     264                for(Initializable initObj: rc.getToInit()){ 
    266265                        initObj.initiate(); 
    267266                } 
  • DCWoRMS/trunk/src/simulator/reader/ResourceReader.java

    r509 r512  
    99import java.util.ArrayDeque; 
    1010import java.util.ArrayList; 
     11import java.util.Collections; 
     12import java.util.Comparator; 
    1113import java.util.Deque; 
    1214import java.util.HashMap; 
     
    2729import schedframe.ResourceController; 
    2830import schedframe.exceptions.ResourceException; 
     31import schedframe.resources.Resource; 
    2932import schedframe.resources.StandardResourceType; 
    3033import schedframe.resources.computing.ComputingResource; 
     
    5154 
    5255        protected ResourceCalendar resourceCalendar; 
    53         protected Deque<Initializable> toInit = new ArrayDeque<Initializable>(); 
     56        protected List<Initializable> toInit = new ArrayList<Initializable>(); 
    5457         
    5558        private ExecutionTimeEstimationPlugin execTimeEstimationPlugin; 
     
    8588 
    8689                ResourceController rc = new ResourceController(mainScheduler, computingResources); 
     90                Collections.sort(toInit, new ResourceTypeComparator(new ArrayList<String>(compResLayers))); 
    8791                rc.setInitList(toInit); 
    8892                rc.setCompResLayers(compResLayers); 
     
    430434        } 
    431435         
     436        class ResourceTypeComparator implements Comparator<Initializable>{ 
     437                 
     438                List<String> order; 
     439                ResourceTypeComparator(List<String> order) { 
     440                        this.order = order; 
     441                } 
     442                public int compare(Initializable init1, Initializable init2) { 
     443                        String type1 = ((Resource)init1).getType().getName(); 
     444                        String type2 = ((Resource)init2).getType().getName(); 
     445                        if(order.indexOf(type1) > order.indexOf(type2)) 
     446                                return -1; 
     447                        else if (order.indexOf(type1) < order.indexOf(type2)) 
     448                                return 1; 
     449                        else return 0; 
     450                         
     451                } 
     452        } 
     453         
    432454} 
  • DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java

    r501 r512  
    331331                                                energyUsage.setSumValue(energyUsage.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 
    332332                                                 
    333                                                 EnergyExtension een = (EnergyExtension )(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
     333                                                EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
    334334                                                if(resourceController.getComputingResources().contains(resource)) { 
    335335                                                        if( een != null /*&& een.getPp() != null*/ ){ 
     
    339339                                                } else if( een != null && een.getPowerProfile() != null ){ 
    340340                                                        ComputingResource parent = resource.getParent(); 
    341                                                         een = (EnergyExtension )(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
     341                                                        een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
    342342                                                        boolean top = true; 
    343343                                                        while(parent != null){ 
Note: See TracChangeset for help on using the changeset viewer.