Ignore:
Timestamp:
11/26/13 11:56:07 (11 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/branches/coolemall/src/schedframe
Files:
19 added
45 edited
3 copied
2 moved

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/schedframe/SimulatedEnvironment.java

    r768 r1207  
    33import gridsim.GridSim; 
    44 
     5import java.util.ArrayList; 
    56import java.util.HashSet; 
    67import java.util.Iterator; 
     
    1011 
    1112import schedframe.exceptions.ResourceException; 
     13import schedframe.resources.ResourceHistoryChanges; 
    1214import schedframe.resources.computing.ComputingResource; 
    1315import schedframe.scheduling.Scheduler; 
    1416 
    15 public class ResourceController { 
     17public class SimulatedEnvironment { 
    1618 
    1719        protected static Scheduler scheduler; 
     
    1921        protected List<Initializable> toInit; 
    2022        protected Set<String> compResLayers; 
     23        protected static List<ResourceHistoryChanges> compResHistory = new ArrayList<ResourceHistoryChanges>(); 
    2124         
    22         public ResourceController(Scheduler logicalStructure, List<ComputingResource> compResources){ 
     25        public SimulatedEnvironment(Scheduler logicalStructure, List<ComputingResource> compResources){ 
    2326                scheduler = logicalStructure; 
    2427                computingResources = compResources; 
     
    3740                for (int i = 0; i < computingResources.size() && resourceWithName == null; i++) { 
    3841                        ComputingResource resource = computingResources.get(i); 
    39                         if (resource.getName().equals(resourceName)) 
     42                        if (resource.getFullName().equals(resourceName)) 
    4043                                resourceWithName = resource; 
    4144                        else 
     
    152155        } 
    153156 
     157        public static void traceResource(long timestamp, String resourceName, String operation, String paramter){ 
     158                ResourceHistoryChanges rhc = new ResourceHistoryChanges(timestamp, resourceName, operation, paramter); 
     159                compResHistory.add(rhc); 
     160        } 
     161 
     162        public static List<ResourceHistoryChanges> getCompResHistory() { 
     163                return compResHistory; 
     164        } 
    154165} 
  • DCWoRMS/branches/coolemall/src/schedframe/events/ResourceEventCommand.java

    r477 r1207  
    11package schedframe.events; 
    22 
    3 import schedframe.resources.computing.ComputingResource; 
     3import schedframe.resources.devices.PhysicalResource; 
    44 
    55public class ResourceEventCommand implements EventCommand { 
    66 
    7         private ComputingResource compResource; 
     7        private PhysicalResource resource; 
    88         
    9         public ResourceEventCommand(ComputingResource compResource) { 
    10                 this.compResource = compResource; 
     9        public ResourceEventCommand(PhysicalResource resource) { 
     10                this.resource = resource; 
    1111        } 
    1212         
     
    1717 
    1818        public void execute(Event event) { 
    19                 compResource.getEventHandler().handleResourceEvent(event); 
     19                resource.getEventHandler().handleResourceEvent(event); 
    2020        } 
    2121 
  • DCWoRMS/branches/coolemall/src/schedframe/events/scheduling/SchedulingEventCommand.java

    r477 r1207  
    1616        public void execute(EventType evType) { 
    1717                SchedulingEvent ev = new SchedulingEvent(evType); 
    18                 ev.setSource(compResource.getName()); 
     18                ev.setSource(compResource.getFullName()); 
    1919                compResource.getEventHandler().handleSchedulingEvent(ev); 
    2020        } 
     
    2222        public void execute(Event event) { 
    2323                SchedulingEvent ev = new SchedulingEvent(event.getType()); 
    24                 ev.setSource(compResource.getName()); 
     24                ev.setSource(compResource.getFullName()); 
    2525                compResource.getEventHandler().handleSchedulingEvent(ev); 
    2626        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/CoolEmAllResourceType.java

    r1095 r1207  
    33public enum CoolEmAllResourceType implements ResourceType { 
    44         
    5         ComputeBox2, 
    6         ComputeBox1, 
    7         NodeGroup, 
    8         Node, 
    9         Processor, 
    10         Core; 
    11  
     5        ComputeBox2("Room"), 
     6        ComputeBox1("Rack"), 
     7        NodeGroup("NodeGroup"), 
     8        Node("Node"), 
     9        Processor("Processor"), 
     10        Core("Core"); 
     11         
     12        private String label; 
     13         
     14        CoolEmAllResourceType(String label){ 
     15                this.label = label; 
     16        } 
    1217        public String getName() { 
    1318                return toString(); 
    1419        } 
     20        public String getLabel(){ 
     21                return label; 
     22        } 
    1523} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/Resource.java

    r893 r1207  
    11package schedframe.resources; 
     2 
    23 
    34 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/ResourceTypeFactory.java

    r1097 r1207  
    55         
    66        public static ResourceType createResourceType(String typeName){ 
    7                  
     7 
    88                if(typeName.equals(StandardResourceType.Grid.getName())) 
    99                        return StandardResourceType.Grid; 
     
    1515                        return StandardResourceType.Rack; 
    1616 
    17                 else if (typeName.equals(StandardResourceType.ComputingNode.getName())) 
    18                         return StandardResourceType.ComputingNode; 
     17                else if (typeName.equals(StandardResourceType.Node.getName())) 
     18                        return StandardResourceType.Node; 
    1919                 
    2020                else if (typeName.equals(StandardResourceType.Processor.getName())) 
     
    2424                        return StandardResourceType.Core; 
    2525                 
     26                else if (typeName.equals(CoolEmAllResourceType.ComputeBox2.getName())) 
     27                        return CoolEmAllResourceType.ComputeBox2; 
     28                 
    2629                else if (typeName.equals(CoolEmAllResourceType.ComputeBox1.getName())) 
    2730                        return CoolEmAllResourceType.ComputeBox1; 
     
    3033                        return CoolEmAllResourceType.NodeGroup; 
    3134                 
    32                 else if (typeName.equals(CoolEmAllResourceType.Node.getName())) 
    33                         return CoolEmAllResourceType.Node; 
     35                else if (typeName.equals(StandardResourceType.CRAH.getName())) 
     36                        return StandardResourceType.CRAH; 
     37                 
     38                else if (typeName.equals(StandardResourceType.Fan.getName())) 
     39                        return StandardResourceType.Fan; 
     40                 
     41                else if (typeName.equals(StandardResourceType.Inlet.getName())) 
     42                        return StandardResourceType.Inlet; 
     43                 
     44                else if (typeName.equals(StandardResourceType.Outlet.getName())) 
     45                        return StandardResourceType.Outlet; 
     46                 
     47                else if (typeName.equals(StandardResourceType.CoolingDevice.getName())) 
     48                        return StandardResourceType.CoolingDevice; 
     49                 
     50                else if (typeName.equals(StandardResourceType.Heatsink.getName())) 
     51                        return StandardResourceType.Heatsink; 
    3452                 
    3553                else if (typeName.equals(StandardResourceType.ResourceProvider.getName())) 
     
    4260                        return StandardResourceType.LS; 
    4361                 
    44                 else return new UserResourceType(typeName); 
     62                return new UserResourceType(typeName); 
    4563        } 
    4664} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/StandardResourceType.java

    r1095 r1207  
    77        DataCenter, 
    88        Rack, 
    9         ComputingNode, 
     9        Node, 
    1010        Processor, 
    1111        Core, 
     
    1313        ResourceProvider, 
    1414        GS, 
    15         LS; 
     15        LS, 
     16        Fan, 
     17        Refrigeration, 
     18        Heatpipe, 
     19        ILC, 
     20        LCU, 
     21        CRAH, 
     22        HVAC, 
     23        Inlet, 
     24        Outlet, 
     25        Heatsink, 
     26        Sensor, 
     27        Network, 
     28        CoolingDevice, 
     29        PowerSupply; 
    1630 
    1731        public String getName() { 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingNode.java

    r756 r1207  
    33import java.util.List; 
    44import java.util.Properties; 
    5  
    65 
    76import schedframe.resources.ResourceStatus; 
     
    109import schedframe.resources.computing.extensions.ExtensionType; 
    1110import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    12 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputInterfaceFactory; 
    13 import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 
    14 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    1511import schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface; 
    16 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    1712import schedframe.resources.computing.properties.ComputingNodePropertiesBuilder; 
    1813import schedframe.resources.computing.properties.PropertiesDirector; 
     
    3227                //accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 
    3328                //accept(new EnergyExtension(pi, resDesc.getPowerProfile(), ai, resDesc.getAirThroughputProfile()));     
    34         } 
    35          
    36         /*public ComputingNode (String resourceName, ResourceCharacteristics resourceCharacteristic, Category cat, PowerInterface powerInterface) { 
    37                 super(resourceName, ResourceType.COMPUTING_NODE, resourceCharacteristic); 
    38                 category = cat; 
    39                 accept(powerInterface); 
    40         //      extensionList.add(new EnergyExtension(this, "example.energy.ComputingNodeEnergyEstimationPlugin")); 
    41         }*/ 
    42          
     29        }        
    4330         
    4431        public ComputingNodePowerInterface getPowerInterface(){ 
     
    8673         
    8774        public Memory getMemory() throws NoSuchFieldException { 
    88                 return (Memory) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.MEMORY); 
     75                return (Memory) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.MEMORY); 
    8976        } 
    9077         
     
    9582         
    9683        private Cost getCost() throws NoSuchFieldException { 
    97                 return (Cost) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.COST); 
     84                return (Cost) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.COST); 
    9885        } 
    9986 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResource.java

    r1005 r1207  
    99import java.util.Properties; 
    1010 
    11 import schedframe.Initializable; 
    1211import schedframe.events.Event; 
    1312import schedframe.events.EventHandler; 
     
    1716import schedframe.events.scheduling.SchedulingEventCommand; 
    1817import schedframe.exceptions.ResourceException; 
    19 import schedframe.resources.Resource; 
    2018import schedframe.resources.ResourceStatus; 
    2119import schedframe.resources.ResourceType; 
    2220import schedframe.resources.computing.description.ComputingResourceDescription; 
    2321import schedframe.resources.computing.extensions.Extension; 
    24 import schedframe.resources.computing.extensions.ExtensionList; 
    2522import schedframe.resources.computing.extensions.ExtensionListImpl; 
    26 import schedframe.resources.computing.extensions.ExtensionType; 
    2723import schedframe.resources.computing.profiles.energy.EnergyEvent; 
    2824import schedframe.resources.computing.profiles.energy.EnergyEventType; 
    2925import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    30 import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 
    31 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    32 import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface; 
    3326import schedframe.resources.computing.properties.DefaultPropertiesBuilder; 
    3427import schedframe.resources.computing.properties.PropertiesDirector; 
     
    3831import schedframe.resources.computing.validator.ResourceTypeValidator; 
    3932import schedframe.resources.computing.validator.ResourceValidator; 
    40 import schedframe.resources.units.PEUnit; 
    41 import schedframe.resources.units.ResourceUnit; 
    42 import schedframe.resources.units.StandardResourceUnitName; 
     33import schedframe.resources.devices.Device; 
     34import schedframe.resources.devices.PhysicalResource; 
    4335import schedframe.scheduling.Scheduler; 
    4436 
    45 public class ComputingResource implements Resource, Initializable{ 
    46          
    47         protected String name; 
    48         protected ResourceType type; 
    49         protected String category; 
    50         protected ResourceStatus status; 
     37public class ComputingResource extends PhysicalResource{ 
    5138 
    5239        protected ComputingResource parent; 
     
    5441         
    5542        protected Scheduler scheduler; 
    56         protected ResourceCharacteristics resourceCharacteristic; 
    57         protected ExtensionList extensionList; 
    58          
    59  
    60         public ExtensionList getExtensionList() { 
    61                 return extensionList; 
    62         } 
     43        //protected ResourceCharacteristics resourceCharacteristic; 
     44 
    6345 
    6446        public ComputingResource(ComputingResourceDescription resDesc) { 
     
    6951                this.extensionList = new ExtensionListImpl(1); 
    7052                initCharacteristics(resDesc); 
    71                 accept(new EnergyExtension(this, resDesc.getPowerProfile(), resDesc.getAirThroughputProfile(), resDesc.getThermalProfile()));    
    72                 addFakeProcessors(); 
    73         } 
    74  
    75         //TODO remove if possible (check if all scenarios can be realized - statistics issue), since it's a temporary method 
    76         private void addFakeProcessors() { 
    77                 if(getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.PE) != null){ 
    78                         for(ResourceUnit resUnit: getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.PE)){ 
    79                                 PEUnit peUnit = (PEUnit) resUnit; 
    80                                 for(int i = 0; i < peUnit.getAmount(); i++){ 
    81                                         schemas.ComputingResource fakeCompResource = new schemas.ComputingResource(); 
    82                                         fakeCompResource.setClazz("Processor"); 
    83                                         addChild(ResourceFactory.createResource(new ComputingResourceDescription(fakeCompResource))); 
    84                                 } 
    85                         } 
    86                 } 
     53                accept(new EnergyExtension.Builder().resource(this).powerProfile(resDesc.getPowerProfile()).airFlowProfile(resDesc.getAirThroughputProfile()).thermalProfile(resDesc.getThermalProfile()).build());      
    8754        } 
    8855 
    8956        protected void initCharacteristics(ComputingResourceDescription resDesc){ 
    90                 resourceCharacteristic = new ResourceCharacteristics.Builder().resourceUnits(resDesc.getResourceUnits()).location(resDesc.getLocation()).parameters(resDesc.getParameters()).build(); 
     57                resourceCharacteristic = ComputingResourceCharacteristics.builder().resourceUnits(resDesc.getResourceUnits()).location(resDesc.getLocation()).parameters(resDesc.getParameters()).device(resDesc.getDevices()).build(); 
     58                for(Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()){ 
     59                        device.setComputingResource(this); 
     60                } 
    9161        } 
    9262         
     
    11282        } 
    11383 
    114         public String getName() { 
    115                 return name; 
    116         } 
    117          
    11884        public String getFullName() { 
    11985                if(this.getResourceCharacteristic().getParameters().get("fullPath") != null){ 
     
    12793        } 
    12894 
    129         public ResourceType getType() { 
    130                 return type; 
    131         } 
    132  
    133         public ResourceCharacteristics getResourceCharacteristic() { 
    134                 return resourceCharacteristic; 
    135         } 
    136  
    137         public ResourceStatus getStatus() { 
    138                 return status; 
     95        public ComputingResourceCharacteristics getResourceCharacteristic() { 
     96                return (ComputingResourceCharacteristics)resourceCharacteristic; 
    13997        } 
    14098 
     
    245203        } 
    246204         
    247         public String getCategory(){ 
    248                 return category; 
    249         } 
    250          
    251         public PowerInterface getPowerInterface(){ 
    252                 Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION); 
    253                 if(extension != null){ 
    254                         EnergyExtension ee = (EnergyExtension)extension; 
    255                         return ee.getPowerInterface(); 
    256                 } 
    257                 return null; 
    258         } 
    259          
    260         public AirThroughputInterface getAirThroughputInterface(){ 
    261                 Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION); 
    262                 if(extension != null){ 
    263                         EnergyExtension ee = (EnergyExtension)extension; 
    264                         return ee.getAirThroughputInterface(); 
    265                 } 
    266                 return null; 
    267         } 
    268          
    269         public ThermalInterface getThermalInterface(){ 
    270                 Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION); 
    271                 if(extension != null){ 
    272                         EnergyExtension ee = (EnergyExtension)extension; 
    273                         return ee.getThermalInterface(); 
    274                 } 
    275                 return null; 
    276         } 
    277  
    278         private Extension getExtension(ExtensionType type){ 
    279                 if (extensionList != null) { 
    280                         for (Extension extension : extensionList) { 
    281                                 if (extension.getType() == type) { 
    282                                         return extension; 
    283                                 } 
    284                         } 
    285                 } 
    286                 return null; 
    287         } 
    288          
    289205        public Scheduler getScheduler() { 
    290206                return scheduler; 
     
    307223                                        if (extension.supportsEvent(event)) { 
    308224                                                extension.handleEvent(event); 
     225                                        } 
     226                                } 
     227                                 
     228                                for (Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()) { 
     229                                        for (Extension extension : device.getExtensionList()) { 
     230                                                if (extension.supportsEvent(event)) { 
     231                                                        //extension.handleEvent(event); 
     232                                                } 
    309233                                        } 
    310234                                } 
     
    332256        } 
    333257         
    334         public void initiate(){ 
    335                  
     258        public final void initiate(){ 
     259                for(Device dev: this.getResourceCharacteristic().getDevices()){ 
     260                        dev.initiate(); 
     261                } 
    336262                ResourceEventCommand rec = new ResourceEventCommand(this); 
    337263                EnergyEvent event = new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller"); 
     
    343269                rec.execute(event); 
    344270                 
     271                rec = new ResourceEventCommand(this); 
     272                event = new EnergyEvent(EnergyEventType.TEMPERATURE_CHANGED, "Resource controller"); 
     273                event.setReason(EventReason.SIM_INIT); 
     274                rec.execute(event); 
     275                 
    345276                //alternative way 
    346277                //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller")); 
    347278                //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller")); 
    348279        } 
    349          
    350          
    351         private void accept(EnergyExtension e){ 
    352                 extensionList.add(e); 
    353         } 
     280 
     281 
    354282} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Core.java

    r756 r1207  
    11package schedframe.resources.computing; 
    22 
     3import schedframe.resources.StandardResourceType; 
    34import schedframe.resources.computing.description.ComputingResourceDescription; 
    4 import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    5 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    6 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    75import schedframe.resources.units.CpuSpeed; 
    86import schedframe.resources.units.StandardResourceUnitName; 
     
    1816 
    1917        public Processor getProcessor(){ 
    20                 return (Processor)parent; 
     18                ComputingResource compRes = parent; 
     19                while(compRes != null && !compRes.getType().equals(StandardResourceType.Processor)){ 
     20                        compRes = compRes.getParent(); 
     21                } 
     22                Processor proc = null; 
     23                try{ 
     24                        proc = (Processor)compRes; 
     25                } catch(ClassCastException e) { 
     26                } 
     27                return proc; 
     28        } 
     29         
     30        public ComputingNode getNode(){ 
     31                ComputingResource compRes = parent; 
     32                while(compRes != null && !compRes.getType().equals(StandardResourceType.Node)){ 
     33                        compRes = compRes.getParent(); 
     34                } 
     35                ComputingNode compNode = null; 
     36                try{ 
     37                        compNode = (ComputingNode)compRes; 
     38                } catch(ClassCastException e) { 
     39                } 
     40                return compNode; 
    2141        } 
    2242         
     
    4262 
    4363        private CpuSpeed getSpeedUnit() throws NoSuchFieldException{ 
    44                 return (CpuSpeed) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.CPUSPEED); 
     64                return (CpuSpeed) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.CPUSPEED); 
    4565        } 
    4666 
     
    4868                super.initCharacteristics(resDesc); 
    4969                try{ 
    50                         resourceCharacteristic.addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0)); 
     70                        ((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0)); 
    5171                } catch(Exception e){ 
    52                         resourceCharacteristic.addResourceUnit(new CpuSpeed(name,  1, 0)); 
     72                        ((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name,  1, 0)); 
    5373                } 
    5474        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/DataCenter.java

    r756 r1207  
    2020        @SuppressWarnings("unchecked") 
    2121        public List<ComputingNode> getComputingNodes(){ 
    22                 return (List<ComputingNode>) getDescendantsByType(StandardResourceType.ComputingNode); 
     22                return (List<ComputingNode>) getDescendantsByType(StandardResourceType.Node); 
    2323        } 
    2424         
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Processor.java

    r883 r1207  
    99import schedframe.resources.computing.extensions.ExtensionType; 
    1010import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    11 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    12 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    1311import schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface; 
    1412import schedframe.resources.computing.properties.CpuPropertiesBuilder; 
     
    2725        } 
    2826 
    29  
    30         public ComputingNode getComputingNode(){ 
    31                 return (ComputingNode)parent; 
     27        public ComputingNode getNode(){ 
     28                ComputingResource compRes = parent; 
     29                while(compRes != null && !compRes.getType().equals(StandardResourceType.Node)){ 
     30                        compRes = compRes.getParent(); 
     31                } 
     32                ComputingNode compNode = null; 
     33                try{ 
     34                        compNode = (ComputingNode)compRes; 
     35                } catch(Exception e) { 
     36                } 
     37                return compNode; 
    3238        } 
    3339         
     
    6369 
    6470        private CpuSpeed getSpeedUnit() throws NoSuchFieldException{ 
    65                 return (CpuSpeed) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.CPUSPEED); 
     71                return (CpuSpeed) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.CPUSPEED); 
    6672        } 
    6773         
     
    8086                super.initCharacteristics(resDesc); 
    8187                try{ 
    82                         resourceCharacteristic.addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0)); 
     88                        ((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0)); 
    8389                } catch(Exception e){ 
    84                         resourceCharacteristic.addResourceUnit(new CpuSpeed(name,  1, 0)); 
     90                        ((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name,  1, 0)); 
    8591                } 
    8692        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Rack.java

    r756 r1207  
    55import schedframe.resources.StandardResourceType; 
    66import schedframe.resources.computing.description.ComputingResourceDescription; 
    7 import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    8 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    9 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    107 
    118public class Rack extends ComputingResource{ 
     
    2017        @SuppressWarnings("unchecked") 
    2118        public List<ComputingNode> getComputingNodes(){ 
    22                 return (List<ComputingNode>) getDescendantsByType(StandardResourceType.ComputingNode); 
     19                return (List<ComputingNode>) getDescendantsByType(StandardResourceType.Node); 
    2320        } 
    2421         
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ResourceCharacteristics.java

    r1007 r1207  
    11package schedframe.resources.computing; 
    2  
    3 import java.util.ArrayList; 
    4 import java.util.HashMap; 
    5 import java.util.List; 
    6 import java.util.Map; 
    72 
    83import schedframe.Parameters; 
    94import schedframe.resources.computing.location.Location; 
    10 import schedframe.resources.units.ResourceUnit; 
    11 import schedframe.resources.units.ResourceUnitName; 
    125 
    136 
     
    169        private static final long serialVersionUID = 2719535186621622647L; 
    1710 
    18         protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 
     11        protected Location location; 
    1912        protected Parameters parameters; 
    20         protected Location location; 
     13        //protected Location location; 
     14        //protected List<Device> devices; 
    2115 
    2216        /*public ResourceCharacteristics(Map<ResourceUnitName, List<AbstractResourceUnit>> resUnits){ 
     
    3226        }*/ 
    3327         
    34         public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() { 
    35                 if(resUnits == null) 
    36                         return new HashMap<ResourceUnitName, List<ResourceUnit>>(); 
    37                 return resUnits; 
    38         } 
     28 
    3929         
    40         public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException{ 
    41                 if(getResourceUnits().containsKey(unitName)) 
    42                         return getResourceUnits().get(unitName).get(0); 
    43                 else throw new NoSuchFieldException("Resource unit " + unitName +  
    44                                 " is not available in this resource "); 
    45         } 
    46          
    47         public void addResourceUnit(ResourceUnit unit){  
    48                 if(resUnits == null){ 
    49                         resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(2); 
    50                 } 
    51                 List<ResourceUnit> list = null; 
    52                 if(resUnits.containsKey(unit.getName())){ 
    53                         list = resUnits.get(unit.getName()); 
    54                 } else { 
    55                         list = new ArrayList<ResourceUnit>(1); 
    56                         resUnits.put(unit.getName(), list); 
    57                 } 
    58                 list.add(unit); 
    59         } 
    60          
    61          
    62         public static class Builder { 
    63                    
    64                 protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 
    65                 protected Location location; 
    66                 protected Parameters parameters; 
    67                  
    68                 public Builder location(Location loc){this.location = loc; return this; } 
    69         public Builder parameters(Parameters params){this.parameters = params; return this; } 
    70         public Builder resourceUnits(Map<ResourceUnitName, List<ResourceUnit>> units){this.resUnits = units; return this; } 
    71         public Builder resourceUnits(){this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(2); return this; } 
    72          
    73         public ResourceCharacteristics build() { 
    74             return new ResourceCharacteristics(this); 
    75         } 
    76         } 
    77          
    78         private ResourceCharacteristics(Builder builder) { 
    79                 this.location = builder.location; 
    80                 this.parameters = builder.parameters; 
    81                 this.resUnits = builder.resUnits; 
    82         } 
    83  
    8430        public Parameters getParameters() { 
    8531                if(parameters == null) 
     
    9137                return location; 
    9238        } 
     39         
     40        protected ResourceCharacteristics(Builder<?> builder) { 
     41                //this.location = builder.location; 
     42                this.parameters = builder.parameters; 
     43                this.location = builder.location; 
     44                //this.devices = builder.devices; 
     45        } 
     46         
     47    public static abstract class Builder<T extends Builder<T>> { 
     48           
     49                protected Location location; 
     50                protected Parameters parameters; 
     51 
     52        public T parameters(Parameters params){this.parameters = params; return self(); } 
     53                public T location(Location loc){this.location = loc; return self(); } 
     54                 
     55        protected abstract T self(); 
     56 
     57        public ResourceCharacteristics build() { 
     58            return new ResourceCharacteristics(this); 
     59        } 
     60    } 
     61    private static class Builder2 extends Builder<Builder2> { 
     62        @Override 
     63        protected Builder2 self() { 
     64            return this; 
     65        } 
     66    } 
     67 
     68    public static Builder<?> builder() { 
     69        return new Builder2(); 
     70    } 
     71         
     72        /*public static class Builder { 
     73                   
     74                protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 
     75                //protected Location location; 
     76                protected Parameters parameters; 
     77                //protected List<Device> devices; 
     78                 
     79                //public Builder location(Location loc){this.location = loc; return this; } 
     80        public Builder parameters(Parameters params){this.parameters = params; return this; } 
     81        //public Builder device(List<Device> dev){this.devices = dev; return this; } 
     82        public Builder resourceUnits(Map<ResourceUnitName, List<ResourceUnit>> units){this.resUnits = units; return this; } 
     83        public Builder resourceUnits(){this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(2); return this; } 
     84         
     85        public ResourceCharacteristics build() { 
     86            return new ResourceCharacteristics(this); 
     87        } 
     88        } 
     89        */ 
     90 
    9391 
    9492} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ResourceFactory.java

    r1095 r1207  
    11package schedframe.resources.computing; 
    22 
    3 import schedframe.resources.CoolEmAllResourceType; 
    43import schedframe.resources.StandardResourceType; 
    54import schedframe.resources.computing.description.ComputingResourceDescription; 
    6 import schedframe.resources.computing.recs.ComputeBox1; 
    7 import schedframe.resources.computing.recs.Node; 
    8 import schedframe.resources.computing.recs.NodeGroup; 
    95import schedframe.scheduling.Scheduler; 
    106import schedframe.scheduling.manager.resources.ManagedResources; 
    117import schedframe.scheduling.plugin.SchedulingPlugin; 
    128import schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin; 
    13 import schedframe.scheduling.policy.AbstractManagementSystem; 
    14 import schedframe.scheduling.policy.global.GridBroker; 
    15 import schedframe.scheduling.policy.local.LocalManagementSystem; 
    169import schedframe.scheduling.queue.TaskQueueList; 
    17 import simulator.DCWormsConstants; 
    1810 
    1911 
    20 public class ResourceFactory { 
     12public interface ResourceFactory { 
    2113 
    22         public static ComputingResource createResource(ComputingResourceDescription resDesc){ 
    23                  
    24                 if (resDesc.getType().equals(StandardResourceType.DataCenter)) 
    25                         return new DataCenter(resDesc); 
    26                 else if (resDesc.getType().equals(StandardResourceType.Rack)) 
    27                         return new Rack(resDesc); 
    28                 else if (resDesc.getType().equals(StandardResourceType.ComputingNode)) 
    29                         return new ComputingNode(resDesc); 
    30                 else if (resDesc.getType().equals(StandardResourceType.Processor)) 
    31                         return new Processor(resDesc); 
    32                 else if (resDesc.getType().equals(StandardResourceType.Core)) 
    33                         return new Core(resDesc); 
    34                 else if (resDesc.getType().equals(CoolEmAllResourceType.ComputeBox1)) 
    35                         return new ComputeBox1(resDesc); 
    36                 else if (resDesc.getType().equals(CoolEmAllResourceType.NodeGroup)) 
    37                         return new NodeGroup(resDesc); 
    38                 else if (resDesc.getType().equals(CoolEmAllResourceType.Node)) 
    39                         return new Node(resDesc); 
    40                 else if (resDesc.getType().equals(CoolEmAllResourceType.Processor)) 
    41                         return new Processor(resDesc); 
    42                 else if (resDesc.getType().equals(CoolEmAllResourceType.Core)) 
    43                         return new Core(resDesc); 
    44                 else 
    45                         return new ComputingResource(resDesc); 
     14        public ComputingResource createComputingResource(ComputingResourceDescription resDesc); 
     15 
     16        //public Device createDevice(DeviceDescription devDesc); 
    4617         
    47                 /*switch(resDesc.getType()){ 
    48                         case Grid: return new Grid(resDesc); 
    49                         case DataCenter: return new DataCenter(resDesc); 
    50                         case ComputingNode: return new ComputingNode(resDesc); 
    51                         case Processor: return new Processor(resDesc); 
    52                 default: 
    53                         return new ComputingResource(resDesc); 
    54                 }*/ 
    55         } 
    56  
    57         public static Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception{ 
    58                 AbstractManagementSystem ms; 
    59                 switch(type){ 
    60                         case GS: { 
    61                                 ms = new GridBroker("grid", 
    62                                                 schedulingPlugin, execTimeEstimationPlugin, queues); 
    63                                 return new Scheduler(ms, type, managedResources); 
    64                         } 
    65                         case LS: { 
    66                                 ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, 
    67                                                 schedulingPlugin, execTimeEstimationPlugin, queues); 
    68                                 return new Scheduler(ms, type, managedResources); 
    69                         } 
    70  
    71                 default:{ 
    72                                 ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, 
    73                                                 schedulingPlugin, execTimeEstimationPlugin, queues); 
    74                                 return new Scheduler(ms, type, managedResources); 
    75                         } 
    76                 } 
    77         } 
     18        public Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception; 
    7819} 
    7920 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/ComputeBox1.java

    r1098 r1207  
    1 package schedframe.resources.computing.recs; 
     1package schedframe.resources.computing.coolemall; 
    22 
    33import java.util.List; 
     
    66import schedframe.resources.StandardResourceType; 
    77import schedframe.resources.computing.ComputingNode; 
    8 import schedframe.resources.computing.Processor; 
    98import schedframe.resources.computing.Rack; 
    109import schedframe.resources.computing.description.ComputingResourceDescription; 
     
    2322        @SuppressWarnings("unchecked") 
    2423        public List<ComputingNode> getNodes(){ 
    25                 return (List<ComputingNode>) getDescendantsByType(CoolEmAllResourceType.Node); 
    26         } 
    27          
    28         @SuppressWarnings("unchecked") 
    29         public List<Processor> getProcessors(){ 
    30                 return (List<Processor>) getDescendantsByType(StandardResourceType.Processor); 
     24                return (List<ComputingNode>) getDescendantsByType(StandardResourceType.Node); 
    3125        } 
    3226 
     27 
    3328} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/Node.java

    r785 r1207  
    1 package schedframe.resources.computing.recs; 
     1package schedframe.resources.computing.coolemall; 
     2 
     3import java.util.ArrayList; 
     4import java.util.List; 
    25 
    36import schedframe.resources.computing.ComputingNode; 
     7import schedframe.resources.computing.Core; 
     8import schedframe.resources.computing.Processor; 
    49import schedframe.resources.computing.description.ComputingResourceDescription; 
    510 
     
    1015                // TODO Auto-generated constructor stub 
    1116        } 
     17         
     18        public List<Core> getCores(){ 
     19                List<Core> cores = new ArrayList<Core>(); 
     20                for(Processor proc: getProcessors()){ 
     21                        cores.addAll(proc.getCores()); 
     22                } 
     23                return cores; 
     24        } 
     25 
     26        public List<Core> getFreeCores(){ 
     27                List<Core> freeCores = new ArrayList<Core>(); 
     28                for(Processor proc: getProcessors()){ 
     29                        freeCores.addAll(proc.getFreeCores()); 
     30                } 
     31                return freeCores; 
     32        } 
    1233 
    1334} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/NodeGroup.java

    r1098 r1207  
    1 package schedframe.resources.computing.recs; 
     1package schedframe.resources.computing.coolemall; 
    22 
    33import java.util.List; 
    44 
    5 import schedframe.resources.CoolEmAllResourceType; 
    65import schedframe.resources.StandardResourceType; 
    76import schedframe.resources.computing.ComputingResource; 
     
    1716        @SuppressWarnings("unchecked") 
    1817        public List<Node> getNodes(){ 
    19                 return (List<Node>) getDescendantsByType(CoolEmAllResourceType.Node); 
     18                return (List<Node>) getDescendantsByType(StandardResourceType.Node); 
    2019        } 
    2120         
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ComputingResourceDescription.java

    r1113 r1207  
    11package schedframe.resources.computing.description; 
    22 
    3 import java.io.FileInputStream; 
    4 import java.io.FileNotFoundException; 
    5 import java.io.IOException; 
    63import java.util.ArrayList; 
     4import java.util.Collection; 
     5import java.util.HashMap; 
     6import java.util.Iterator; 
    77import java.util.List; 
    8 import java.util.PropertyResourceBundle; 
    9 import java.util.ResourceBundle; 
     8import java.util.Map; 
    109 
    11 import schedframe.Parameter; 
    1210import schedframe.Parameters; 
    13 import schedframe.Property; 
    1411import schedframe.resources.ResourceTypeFactory; 
    15 import schedframe.resources.computing.location.Location; 
    16 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 
    17 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 
    18 import schedframe.resources.computing.profiles.energy.airthroughput.plugin.AirThroughputEstimationPlugin; 
    19 import schedframe.resources.computing.profiles.energy.airthroughput.plugin.DefaultAirThroughputEstimationPlugin; 
    20 import schedframe.resources.computing.profiles.energy.power.PState; 
    21 import schedframe.resources.computing.profiles.energy.power.PowerProfile; 
    22 import schedframe.resources.computing.profiles.energy.power.PowerState; 
    23 import schedframe.resources.computing.profiles.energy.power.PowerStateNameFactory; 
    24 import schedframe.resources.computing.profiles.energy.power.Transition; 
    25 import schedframe.resources.computing.profiles.energy.power.plugin.EnergyEstimationPlugin; 
    26 import schedframe.resources.computing.profiles.energy.thermal.ThermalProfile; 
    27 import schedframe.resources.computing.profiles.energy.thermal.plugin.DefaultTemperatureEstimationPlugin; 
    28 import schedframe.resources.computing.profiles.energy.thermal.plugin.TemperatureEstimationPlugin; 
     12import schedframe.resources.devices.Device; 
     13import schedframe.resources.devices.description.DeviceDescription; 
     14import schedframe.resources.devices.description.PhysicalResourceDescription; 
    2915import schedframe.resources.units.ResourceUnit; 
    3016import schedframe.resources.units.ResourceUnitFactory; 
     17import schedframe.resources.units.ResourceUnitName; 
    3118import schedframe.resources.utils.ResourceIdGenerator; 
    3219import schemas.ComputingResource; 
    33 import schemas.PowerUsage; 
    34 import schemas.Profile; 
    35 import simulator.utils.InstanceFactory; 
    36 import example.energy.DefaultEnergyEstimationPlugin; 
    3720 
    38 public class ComputingResourceDescription extends ExecutingResourceDescription { 
    3921 
    40         //protected Map<ResourceUnitName, List<AbstractResourceUnit>> resUnits; 
    41         protected PowerProfile powerProfile; 
    42         protected AirThroughputProfile airThroughputProfile; 
    43         protected ThermalProfile thermalProfile; 
    44         protected Location location; 
    45         protected String category; 
    46         //protected Parameters parameters; 
     22public class ComputingResourceDescription extends PhysicalResourceDescription implements ExecutingResourceDescription { 
    4723 
     24        protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 
     25        protected List<Device> devices; 
     26         
    4827        public ComputingResourceDescription(ComputingResource computingResource) { 
    4928 
     
    5534                if (computingResource.getComputingResourceTypeChoiceSequence() != null) { 
    5635                        initResourceUnits(computingResource.getComputingResourceTypeChoiceSequence().getResourceUnit()); 
    57                         try { 
    58                                 if(System.getProperty("coolemall.resdesc") != null){ 
    59                                         schemas.EnergyEstimationPlugin eep = new schemas.EnergyEstimationPlugin(); 
    60                                         eep.setName(getEEP(createEEPQuery(computingResource), System.getProperty("coolemall.resdesc"))); 
    61                                         if(computingResource.getComputingResourceTypeChoiceSequence().getProfile() != null) { 
    62                                                 if(computingResource.getComputingResourceTypeChoiceSequence().getProfile().getPowerProfile() != null) { 
    63                                                         computingResource.getComputingResourceTypeChoiceSequence().getProfile().getPowerProfile().setEnergyEstimationPlugin(eep); 
    64                                                 } 
    65                                         } else { 
    66                                                 schemas.Profile p = new schemas.Profile(); 
    67                                                 computingResource.getComputingResourceTypeChoiceSequence().setProfile(p); 
    68                                                 schemas.PowerProfile pp = new schemas.PowerProfile(); 
    69                                                 computingResource.getComputingResourceTypeChoiceSequence().getProfile().setPowerProfile(pp); 
    70                                                 computingResource.getComputingResourceTypeChoiceSequence().getProfile().getPowerProfile().setEnergyEstimationPlugin(eep); 
    71                                         } 
    72                                 } 
    73                         } catch (FileNotFoundException e) { 
    74                         } catch (IOException e) { 
    75                         } 
     36 
    7637                        initProfiles(computingResource.getComputingResourceTypeChoiceSequence().getProfile()); 
    7738                        initLocation(computingResource.getComputingResourceTypeChoiceSequence().getLocation()); 
     39                        initDevices(computingResource.getComputingResourceTypeChoiceSequence().getDevice()); 
    7840                        this.parameters = extractParameters(computingResource.getComputingResourceTypeChoiceSequence().getParameter()); 
    7941                } 
     
    9759                } 
    9860        } 
    99  
    100         private void initProfiles(Profile profile) { 
    101                 if (profile != null) { 
    102                         initPowerProfile(profile.getPowerProfile()); 
    103                         initAirThroughputProfile(profile.getAirThroughputProfile()); 
    104                         initThermalProfile(profile.getThermalProfile()); 
    105                 } 
    106         } 
    10761         
    108         private void initPowerProfile(schemas.PowerProfile powerProfileCharacteristic) { 
    109                  
    110                 if (powerProfileCharacteristic != null) { 
    111                         EnergyEstimationPlugin energyEstimationPlugin = null; 
    112                         List<PowerState> powerStates = null; 
    113                         List<PState> pStates = null; 
    114                         if(powerProfileCharacteristic.getEnergyEstimationPlugin() != null){ 
    115                                 String energyEstimationPluginName = powerProfileCharacteristic.getEnergyEstimationPlugin().getName(); 
    116                                 if(energyEstimationPluginName != null) { 
    117                                         energyEstimationPlugin = (EnergyEstimationPlugin) InstanceFactory.createInstance( 
    118                                                         energyEstimationPluginName, EnergyEstimationPlugin.class);                       
    119                                 } else { 
    120                                         energyEstimationPlugin = new DefaultEnergyEstimationPlugin(); 
    121                                 } 
    122                                 Parameters params = extractParameters(powerProfileCharacteristic.getEnergyEstimationPlugin().getParameter()); 
    123                                 energyEstimationPlugin.init(params); 
     62        private void initDevices(schemas.Device[] dev) { 
     63                if (dev != null){ 
     64                        this.devices = new ArrayList<Device>(); 
     65                        for(int i = 0; i < dev.length; i++){ 
     66                                Device device = new Device(new DeviceDescription(dev[i])); 
     67                                this.devices.add(device); 
    12468                        } 
    125                          
    126                         if(powerProfileCharacteristic.getPowerStates() != null) { 
    127                                 powerStates = new ArrayList<PowerState>(); 
    128                                 int powerStateCount = powerProfileCharacteristic.getPowerStates().getPowerStateCount(); 
    129                                 for (int i = 0; i < powerStateCount ; i++) { 
    130                                         schemas.PowerState ps = powerProfileCharacteristic.getPowerStates().getPowerState(i); 
    131                                         List<Transition> transitions = new ArrayList<Transition>(); 
    132                                         int transitionCount = ps.getTransitionCount(); 
    133                                         for (int j = 0; j < transitionCount; j++) { 
    134                                                 schemas.Transition t = ps.getTransition(j); 
    135                                                 Transition transition = new Transition(PowerStateNameFactory.createPowerStateName(t.getTo()), t 
    136                                                                 .getPowerUsage().getContent(), t.getTime().getContent()); 
    137                                                 Parameters params = extractParameters(t.getParameter()); 
    138                                                 transition.init(params); 
    139                                                 transitions.add(transition); 
    140                                         } 
    141                                         //CoolEmAll DEBB description case 
    142                                         if(ps.getPowerUsage() == null){ 
    143                                                 ps.setPowerUsage(new PowerUsage("0")); 
    144                                         } 
    145                                         PowerState powerState = new PowerState(PowerStateNameFactory.createPowerStateName(ps.getName()), ps 
    146                                                         .getPowerUsage().getContent(), transitions); 
    147                                         Parameters params = extractParameters(ps.getParameter()); 
    148                                         powerState.init(params); 
    149                                         powerStates.add(powerState); 
    150                                 } 
    151                         } 
    152                          
    153                         if(powerProfileCharacteristic.getParameter() != null){ 
    154                                 pStates = new ArrayList<PState>(); 
    155                                 int parameterCount = powerProfileCharacteristic.getParameterCount(); 
    156                                 for(int i = 0; i < parameterCount; i++){ 
    157                                         schemas.Parameter parameter = powerProfileCharacteristic.getParameter(i); 
    158                                         if(parameter.getName().equals("pState")){ 
    159                                                 PState.Builder builder = new PState.Builder(); 
    160                                                 int propertyCount = parameter.getParameterTypeSequence().getPropertyCount(); 
    161                                                 for(int j = 0; j < propertyCount; j++){ 
    162                                                         schemas.Property property = parameter.getParameterTypeSequence().getProperty(j); 
    163                                                         if(property.getName().equals("name")){ 
    164                                                                  builder = builder.name(property.getStringValueWithUnit(0).getContent()); 
    165                                                         } else if (property.getName().equals("frequency")){ 
    166                                                                  builder = builder.frequency(Double.valueOf(property.getStringValueWithUnit(0).getContent())); 
    167                                                         } else if (property.getName().equals("voltage")){ 
    168                                                                 builder = builder.voltage(Double.valueOf(property.getStringValueWithUnit(0).getContent())); 
    169                                                         } else if (property.getName().equals("powerUsage")){ 
    170                                                                 if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){ 
    171                                                                         builder = builder.powerUsage(Double.valueOf(property.getStringValueWithUnit(0).getContent()));   
    172                                                                 } 
    173                                                         } else if (property.getName().equals("powerUsageMin")){ 
    174                                                                 if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){ 
    175                                                                         builder = builder.powerUsageMin(Double.valueOf(property.getStringValueWithUnit(0).getContent()));        
    176                                                                 } 
    177                                                         } else if (property.getName().equals("powerUsageMax")){ 
    178                                                                 if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){ 
    179                                                                         builder = builder.powerUsageMax(Double.valueOf(property.getStringValueWithUnit(0).getContent()));        
    180                                                                 } 
    181                                                         } 
    182                                                 } 
    183                                                 PState pState = builder.build(); 
    184                                                 pStates.add(pState); 
    185                                         } 
    186                                 }        
    187                         } 
    188                         this.powerProfile = new PowerProfile(energyEstimationPlugin, powerStates, pStates); 
    189                         Parameters params = extractParameters(powerProfileCharacteristic.getParameter()); 
    190                         this.powerProfile.init(params); 
    19169                } 
    19270        } 
    19371 
    194         private void initAirThroughputProfile(schemas.AirThroughputProfile airThroughputProfile) { 
    195                 if (airThroughputProfile != null) { 
    196                          
    197                         AirThroughputEstimationPlugin airThroughputEstimationPlugin = null; 
    198                         List<AirThroughputState> airThroughputStates = null; 
    199                         if(airThroughputProfile.getAirThroughputEstimationPlugin() != null){ 
    200                                 String airThroughputEstimationPluginName = airThroughputProfile.getAirThroughputEstimationPlugin().getName(); 
    201                                 if(airThroughputEstimationPluginName != null) { 
    202                                         airThroughputEstimationPlugin = (AirThroughputEstimationPlugin) InstanceFactory.createInstance( 
    203                                                         airThroughputEstimationPluginName, AirThroughputEstimationPlugin.class);                         
    204                                 } else { 
    205                                         airThroughputEstimationPlugin = new DefaultAirThroughputEstimationPlugin(); 
    206                                 } 
    207                                 Parameters params = extractParameters(airThroughputProfile.getAirThroughputEstimationPlugin().getParameter()); 
    208                                 airThroughputEstimationPlugin.init(params); 
    209                         } 
    210                         if(airThroughputProfile.getAirThroughputStates() != null){ 
    211                                 airThroughputStates = new ArrayList<AirThroughputState>(); 
    212                                 int airThrouhputStateCount = airThroughputProfile.getAirThroughputStates().getAirThroughputStateCount(); 
    213                                 for (int i = 0; i < airThrouhputStateCount; i++) { 
    214                                         schemas.AirThroughputState ats = airThroughputProfile.getAirThroughputStates().getAirThroughputState(i); 
    215                                         AirThroughputState airThroughputState = new AirThroughputState(ats.getName(), ats.getValue() 
    216                                                         .getContent(), ats.getPowerUsage().getContent()); 
    217                                         Parameters params = extractParameters(ats.getParameter()); 
    218                                         airThroughputState.init(params); 
    219                                         airThroughputStates.add(airThroughputState); 
    220                                 } 
    221                         } 
    222                         this.airThroughputProfile = new AirThroughputProfile(airThroughputEstimationPlugin, airThroughputStates); 
    223                         Parameters params = extractParameters(airThroughputProfile.getParameter()); 
    224                         this.airThroughputProfile.init(params); 
    225                 } 
     72        public String getCompResourceParameterValue(String name){ 
     73                return getParameters().get(name).get(0).getContent(); 
    22674        } 
    227          
    228         private void initThermalProfile(schemas.ThermalProfile thermalProfile) { 
    229                  
    230                 if (thermalProfile != null) { 
    231                          
    232                         TemperatureEstimationPlugin temperatureEstimationPlugin = null; 
    233  
    234                         if(thermalProfile.getTemperatureEstimationPlugin() != null){ 
    235                                 String temperatureEstimationPluginName = thermalProfile.getTemperatureEstimationPlugin().getName(); 
    236                                 if(temperatureEstimationPluginName != null) { 
    237                                         temperatureEstimationPlugin = (TemperatureEstimationPlugin) InstanceFactory.createInstance( 
    238                                                         temperatureEstimationPluginName, TemperatureEstimationPlugin.class);                     
    239                                 } else { 
    240                                         temperatureEstimationPlugin = new DefaultTemperatureEstimationPlugin(); 
    241                                 } 
    242                                 Parameters params = extractParameters(thermalProfile.getTemperatureEstimationPlugin().getParameter()); 
    243                                 temperatureEstimationPlugin.init(params); 
    244                         } 
    245                         this.thermalProfile = new ThermalProfile(); 
    246                         Parameters params = extractParameters(thermalProfile.getParameter()); 
    247                         this.thermalProfile.init(params); 
    248                 } 
    249         } 
    250          
    251         private void initLocation(schemas.Location l) { 
    252                 if (location != null) { 
    253                         this.location = new Location(l.getHorizontal(), l.getVertical(), l.getDepth()); 
    254                         Parameters params = extractParameters(l.getParameter()); 
    255                         this.location.init(params); 
    256                 } 
    257         } 
    258  
    25975 
    26076        /*private Properties initProperties(schemas.Parameter[] parameters){ 
     
    285101                return prop; 
    286102        }*/ 
    287          
    288         private Parameters extractParameters(schemas.Parameter[] parameters){ 
    289                  
    290                 Parameters params = null; 
    291                  
    292                 if(parameters.length != 0) 
    293                         params = new Parameters(); 
    294                  
    295                 for(int i = 0; i < parameters.length; i++){ 
    296                         schemas.Parameter parameter = parameters[i]; 
    297                         Parameter param = new Parameter(parameter.getName()); 
    298                         if(parameter.getParameterTypeSequence() != null && parameter.getParameterTypeSequence().getProperty() != null) 
    299                         {                                                        
    300                                 int propertyCount = parameter.getParameterTypeSequence().getPropertyCount(); 
    301                                 for(int j = 0; j < propertyCount; j++){ 
    302                                         schemas.Property property = parameter.getParameterTypeSequence().getProperty(j); 
    303                                         Property prop = new Property(property.getName()); 
    304                                         int stringValueWithUnitCount = property.getStringValueWithUnitCount(); 
    305                                         for(int k = 0; k < stringValueWithUnitCount; k++){ 
    306                                                 prop.add(property.getStringValueWithUnit(k)); 
    307                                         } 
    308                                         param.addProperty(prop); 
    309                                 } 
    310                         } else { 
    311                                 int stringValueWithUnitCount =  parameter.getStringValueWithUnitCount(); 
    312                                 for(int j = 0; j < stringValueWithUnitCount; j++){ 
    313                                         param.add(parameter.getStringValueWithUnit(j)); 
    314                                 } 
    315                         } 
    316                         params.put(parameter.getName(), param); 
    317                 } 
    318                 return params; 
    319         } 
    320103 
    321         public PowerProfile getPowerProfile() { 
    322                 return powerProfile; 
    323         } 
    324104 
    325         public AirThroughputProfile getAirThroughputProfile() { 
    326                 return airThroughputProfile; 
    327         } 
    328  
    329         public ThermalProfile getThermalProfile() { 
    330                 return thermalProfile; 
    331         } 
    332          
    333         public Location getLocation() { 
    334                 return location; 
    335         } 
    336  
    337         public String getCategory() { 
    338                 return category; 
     105        public List<Device> getDevices() { 
     106                return devices; 
    339107        } 
    340108 
    341109 
    342         /***COOLEMALL CASE RELATED***/ 
    343  
    344         private static ResourceBundle recsBundle; 
    345          
    346         private ResourceBundle getRecsBundle(String fileName) throws FileNotFoundException, IOException{ 
    347                 if(recsBundle == null){ 
    348                         recsBundle = new PropertyResourceBundle(new FileInputStream(fileName)); 
     110        public void addResourceUnit(ResourceUnit unit) { 
     111                if (this.resUnits == null) 
     112                        this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(1); 
     113                List<ResourceUnit> list = null; 
     114                if (this.resUnits.containsKey(unit.getName())) { 
     115                        list = this.resUnits.get(unit.getName()); 
     116                } else { 
     117                        list = new ArrayList<ResourceUnit>(1); 
     118                        this.resUnits.put(unit.getName(), list); 
    349119                } 
    350                 return recsBundle; 
     120                list.add(unit); 
    351121        } 
    352122         
    353         protected String getEEP(String query, String fileName) throws FileNotFoundException, IOException{ 
    354                 ResourceBundle recsBundle = getRecsBundle(fileName); 
    355                 return recsBundle.getString(query); 
     123        public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException { 
     124                return getResourceUnitList(unitName).get(0); 
    356125        } 
    357          
    358         protected String createEEPQuery(ComputingResource compRes) { 
    359                 String query = compRes.getClazz() + "EEP"; 
    360                 return query; 
     126 
     127        public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException { 
     128                if (resUnits.containsKey(unitName)) 
     129                        return resUnits.get(unitName); 
     130                else 
     131                        throw new NoSuchFieldException("Resource unit " + unitName + " is not available in resource " + this.id); 
     132        } 
     133 
     134        public Collection<ResourceUnit> getResourceUnit() { 
     135                if (resUnits == null) 
     136                        return null; 
     137                List<ResourceUnit> values = new ArrayList<ResourceUnit>(); 
     138                Collection<List<ResourceUnit>> lists = resUnits.values(); 
     139                Iterator<List<ResourceUnit>> itr = lists.iterator(); 
     140 
     141                while (itr.hasNext()) { 
     142                        List<ResourceUnit> list = itr.next(); 
     143                        values.addAll(list); 
     144                } 
     145 
     146                return values; 
     147        } 
     148 
     149        public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() { 
     150                return resUnits; 
    361151        } 
    362152} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ExecutingResourceDescription.java

    r477 r1207  
    11package schedframe.resources.computing.description; 
    22 
    3 import java.util.ArrayList; 
    43import java.util.Collection; 
    5 import java.util.HashMap; 
    6 import java.util.Iterator; 
    74import java.util.List; 
    85import java.util.Map; 
    96 
    10 import schedframe.Parameters; 
    11 import schedframe.resources.ResourceType; 
    127import schedframe.resources.units.ResourceUnit; 
    138import schedframe.resources.units.ResourceUnitName; 
    149 
    15 public class ExecutingResourceDescription extends AbstractResourceDescription { 
     10public interface ExecutingResourceDescription { 
     11         
     12        public void addResourceUnit(ResourceUnit unit); 
     13         
     14        public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException ; 
    1615 
    17         protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 
    18         protected Parameters parameters; 
     16        public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException; 
     17 
     18        public Collection<ResourceUnit> getResourceUnit(); 
    1919         
    20         public ExecutingResourceDescription(ResourceType type) { 
    21                 super(type); 
    22         } 
    23  
    24         public Parameters getParameters() { 
    25                 return parameters; 
    26         } 
    27          
    28         public String getCompResourceParameterValue(String name){ 
    29                 return getParameters().get(name).get(0).getContent(); 
    30         } 
    31          
    32         public void addResourceUnit(ResourceUnit unit) { 
    33                 if (this.resUnits == null) 
    34                         this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(1); 
    35                 List<ResourceUnit> list = null; 
    36                 if (this.resUnits.containsKey(unit.getName())) { 
    37                         list = this.resUnits.get(unit.getName()); 
    38                 } else { 
    39                         list = new ArrayList<ResourceUnit>(1); 
    40                         this.resUnits.put(unit.getName(), list); 
    41                 } 
    42                 list.add(unit); 
    43         } 
    44          
    45         public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException { 
    46                 return getResourceUnitList(unitName).get(0); 
    47         } 
    48  
    49         public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException { 
    50                 if (resUnits.containsKey(unitName)) 
    51                         return resUnits.get(unitName); 
    52                 else 
    53                         throw new NoSuchFieldException("Resource unit " + unitName + " is not available in resource " + this.id); 
    54         } 
    55  
    56         public Collection<ResourceUnit> getResourceUnit() { 
    57                 if (resUnits == null) 
    58                         return null; 
    59                 List<ResourceUnit> values = new ArrayList<ResourceUnit>(); 
    60                 Collection<List<ResourceUnit>> lists = resUnits.values(); 
    61                 Iterator<List<ResourceUnit>> itr = lists.iterator(); 
    62  
    63                 while (itr.hasNext()) { 
    64                         List<ResourceUnit> list = itr.next(); 
    65                         values.addAll(list); 
    66                 } 
    67  
    68                 return values; 
    69         } 
    70  
    71         public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() { 
    72                 return resUnits; 
    73         } 
     20        public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits(); 
    7421} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ResourceDescription.java

    r477 r1207  
    55import java.util.List; 
    66 
     7import schedframe.Parameters; 
    78import schedframe.resources.ResourceType; 
    89 
    910 
    10 public abstract class AbstractResourceDescription { 
     11public abstract class ResourceDescription { 
    1112 
    1213        protected String id; 
    1314        protected ResourceType type; 
    14         protected List<AbstractResourceDescription> children; 
     15        protected List<ResourceDescription> children; 
     16        protected Parameters parameters; 
    1517         
    16         public AbstractResourceDescription(ResourceType type){ 
     18        public ResourceDescription(ResourceType type){ 
    1719                this.type = type; 
    18                 this.children = null; 
    1920        } 
    2021 
    21         public List<AbstractResourceDescription> getChildren() { 
     22        public List<ResourceDescription> getChildren() { 
    2223                return children; 
    2324        } 
    2425         
    25         public void setChildren(List<AbstractResourceDescription> children) { 
     26        public void setChildren(List<ResourceDescription> children) { 
    2627                this.children = children; 
    2728        } 
    2829         
    29         public void addChildren(AbstractResourceDescription child) { 
     30        public void addChildren(ResourceDescription child) { 
    3031                //child.setParent(this); 
    3132                if(children == null) 
    32                         children = new ArrayList<AbstractResourceDescription> (1); 
     33                        children = new ArrayList<ResourceDescription> (1); 
    3334                this.children.add(child); 
    3435        } 
     
    4041        public ResourceType getType() { 
    4142                return type; 
     43        } 
     44         
     45        public Parameters getParameters() { 
     46                return parameters; 
    4247        } 
    4348         
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java

    r1165 r1207  
    77 
    88import schedframe.events.Event; 
    9 import schedframe.resources.computing.ComputingResource; 
    109import schedframe.resources.computing.extensions.Extension; 
    1110import schedframe.resources.computing.extensions.ExtensionException; 
     
    2019import schedframe.resources.computing.profiles.energy.thermal.ThermalProfile; 
    2120import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface; 
     21import schedframe.resources.devices.PhysicalResource; 
    2222import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
     23import simulator.DataCenterWorkloadSimulator; 
    2324 
    2425public class EnergyExtension implements Extension{ 
     
    3536        protected ThermalProfile thermalProfile; 
    3637         
    37         protected ComputingResource computingResource; 
    38  
    39  
    40         public EnergyExtension(ComputingResource computingResource, PowerInterface powerInterface, PowerProfile powerProfile) { 
     38        protected PhysicalResource resource; 
     39 
     40 
     41        /*public EnergyExtension(PhysicalResource resource, PowerInterface powerInterface, PowerProfile powerProfile) { 
     42                super(); 
     43                this.resource = resource; 
    4144                this.powerProfile = powerProfile; 
    42                 this.powerInterface = PowerInterfaceFactory.createPowerInterface(computingResource, powerProfile); 
    43         } 
    44          
    45         public EnergyExtension(ComputingResource computingResource, PowerProfile powerProfile, 
     45                this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); 
     46        } 
     47         
     48        public EnergyExtension(PhysicalResource resource, PowerProfile powerProfile, 
    4649                        AirThroughputProfile airFlowProfile) { 
    4750                super(); 
    48                 this.computingResource = computingResource; 
     51                this.resource = resource; 
    4952                this.powerProfile = powerProfile; 
    50                 this.powerInterface = PowerInterfaceFactory.createPowerInterface(computingResource, powerProfile); 
     53                this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); 
    5154                this.airFlowProfile = airFlowProfile; 
    52                 this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(computingResource, airFlowProfile); 
    53         } 
    54          
    55         public EnergyExtension(ComputingResource computingResource, PowerProfile powerProfile, 
     55                this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(resource, airFlowProfile); 
     56        } 
     57         
     58        public EnergyExtension(PhysicalResource resource, PowerProfile powerProfile, 
    5659                        AirThroughputProfile airFlowProfile, ThermalProfile thermalProfile) { 
    5760                super(); 
    58                 this.computingResource = computingResource; 
     61                this.resource = resource; 
    5962                this.powerProfile = powerProfile; 
    60                 this.powerInterface = PowerInterfaceFactory.createPowerInterface(computingResource, powerProfile); 
     63                this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); 
    6164                this.airFlowProfile = airFlowProfile; 
    62                 this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(computingResource, airFlowProfile); 
     65                this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(resource, airFlowProfile); 
    6366                this.thermalProfile = thermalProfile; 
    64                 this.thermalInterface = ThermalInterfaceFactory.createThermalInterface(computingResource, thermalProfile); 
    65         } 
    66  
     67                this.thermalInterface = ThermalInterfaceFactory.createThermalInterface(resource, thermalProfile); 
     68        }*/ 
     69 
     70        public static class Builder { 
     71                   
     72                protected PhysicalResource resource; 
     73                protected PowerInterface powerInterface; 
     74                protected PowerProfile powerProfile; 
     75                 
     76                protected AirThroughputInterface airFlowInterface; 
     77                protected AirThroughputProfile airFlowProfile; 
     78                 
     79                protected ThermalInterface thermalInterface; 
     80                protected ThermalProfile thermalProfile; 
     81                 
     82                public Builder resource(PhysicalResource res) {this.resource = res; return this;} 
     83                 
     84                public Builder powerProfile(PowerProfile pp){this.powerProfile = pp; this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); return this; } 
     85 
     86        public Builder airFlowProfile(AirThroughputProfile atp){this.airFlowProfile = atp; this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(resource, airFlowProfile); return this; } 
     87 
     88        public Builder thermalProfile(ThermalProfile tp){this.thermalProfile = tp; this.thermalInterface = ThermalInterfaceFactory.createThermalInterface(resource, thermalProfile); return this; } 
     89 
     90        public EnergyExtension build() { 
     91            return new EnergyExtension(this); 
     92        } 
     93        } 
     94         
     95        private EnergyExtension(Builder builder) { 
     96                this.resource = builder.resource; 
     97                this.powerInterface = builder.powerInterface; 
     98                this.powerProfile = builder.powerProfile; 
     99                 
     100                this.airFlowInterface = builder.airFlowInterface ; 
     101                this.airFlowProfile = builder.airFlowProfile; 
     102                 
     103                this.thermalInterface = builder.thermalInterface; 
     104                this.thermalProfile = builder.thermalProfile; 
     105        } 
     106 
     107         
    67108        public boolean supportsEvent(Event event) { 
    68109 
     
    82123                if(event.getType().getName().equals(EnergyEventType.AIRFLOW_STATE_CHANGED.getName())) 
    83124                        return true; 
     125                if(event.getType().getName().equals(EnergyEventType.TEMPERATURE_CHANGED.getName())) 
     126                        return true; 
    84127                 
    85128                else return false; 
     
    90133                EnergyEvent enEvent = (EnergyEvent)event; 
    91134                double power = 0; 
    92                 double temperature = 0; 
     135                boolean status = false; 
    93136                try{ 
    94137                        switch (enEvent.getType()) { 
    95138                         
    96139                        case POWER_STATE_CHANGED: 
    97                                 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
     140                                power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 
    98141                                /*if(computingResource instanceof ComputingNode){ 
    99142                                        ComputingNode node = (ComputingNode)computingResource; 
     
    109152                                        } 
    110153                                } 
    111                                 else*/ powerProfile.addToPowerUsageHistory(power); 
    112                                 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    113                                 thermalProfile.addToTemperatureHistory(temperature); 
     154                                else*/  
     155                                 
     156                                status = powerProfile.addToPowerUsageHistory(power); 
    114157                                break; 
    115158                                 
    116159                        case FREQUENCY_CHANGED: 
    117                                 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    118                                 powerProfile.addToPowerUsageHistory(power); 
    119                                 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    120                                 thermalProfile.addToTemperatureHistory(temperature); 
     160                                power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 
     161                                status = powerProfile.addToPowerUsageHistory(power); 
    121162                                break; 
    122163                                 
    123164                        case TASK_STARTED: 
    124                                 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    125                                 powerProfile.addToPowerUsageHistory(power); 
    126                                 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    127                                 thermalProfile.addToTemperatureHistory(temperature); 
     165                                power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 
     166                                status = powerProfile.addToPowerUsageHistory(power); 
    128167                                break; 
    129168         
    130169                        case TASK_FINISHED: 
    131                                 //System.out.println(this.resource.getName() + " - ENERGY EXTENSION: TASK FINISHED"); 
    132                                 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    133                                 //System.out.println(this.resource.getName() + " - ESTIMATED ENERGY:" + power); 
    134                                 powerProfile.addToPowerUsageHistory(power); 
    135                                 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    136                                 thermalProfile.addToTemperatureHistory(temperature); 
     170                                power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 
     171                                status = powerProfile.addToPowerUsageHistory(power); 
    137172                                break; 
    138173                                 
    139174                        case RESOURCE_UTILIZATION_CHANGED: 
    140                                 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    141                                 powerProfile.addToPowerUsageHistory(power); 
    142                                 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    143                                 thermalProfile.addToTemperatureHistory(temperature); 
     175                                power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 
     176                                status = powerProfile.addToPowerUsageHistory(power); 
    144177                                break; 
    145178                                 
    146179                        case AIRFLOW_STATE_CHANGED: 
    147                                 double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    148                                 airFlowProfile.addToPowerUsageHistory(airFlow); 
    149                                 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    150                                 powerProfile.addToPowerUsageHistory(power); 
    151                                 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
     180                                double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 
     181                                airFlowProfile.addToAirFlowHistory(airFlow); 
     182                                break; 
     183                                 
     184                        case TEMPERATURE_CHANGED: 
     185                                double temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 
    152186                                thermalProfile.addToTemperatureHistory(temperature); 
    153187                                break; 
     
    156190                         
    157191                } 
     192                if(status){ 
     193                        DataCenterWorkloadSimulator.getEventManager().sendToResources(resource.getType(), 0, new EnergyEvent(EnergyEventType.TEMPERATURE_CHANGED, resource.getFullName())); 
     194                } 
    158195        } 
    159196 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputInterfaceFactory.java

    r753 r1207  
    11package schedframe.resources.computing.profiles.energy.airthroughput; 
    22 
     3import schedframe.resources.StandardResourceType; 
    34import schedframe.resources.computing.ComputingResource; 
    45import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 
    56import schedframe.resources.computing.profiles.energy.airthroughput.ui.ComputingResourceAirThroughputInterface; 
     7import schedframe.resources.devices.PhysicalResource; 
     8import schedframe.resources.devices.PhysicalResourceAirThroughputInterface; 
     9import schedframe.resources.devices.coolemall.FanAirThroughputInterface; 
    610 
    711public class AirThroughputInterfaceFactory { 
    812         
    9         public static AirThroughputInterface createAirThroughputInterface(ComputingResource resource, AirThroughputProfile atp){ 
     13        public static AirThroughputInterface createAirThroughputInterface(PhysicalResource resource, AirThroughputProfile atp){ 
    1014                if(atp == null) 
    1115                        return null; 
    12                 AirThroughputInterface airThroughputInterface = new ComputingResourceAirThroughputInterface(resource, atp); 
    13  
     16                AirThroughputInterface airThroughputInterface = null; 
     17                if(resource.getType().getName().equals(StandardResourceType.CRAH.getName())) 
     18                        airThroughputInterface = new PhysicalResourceAirThroughputInterface(resource, atp); 
     19                else if(resource.getType().getName().equals(StandardResourceType.Fan.getName())) 
     20                        airThroughputInterface = new FanAirThroughputInterface(resource, atp); 
     21                else if(resource.getType().getName().equals(StandardResourceType.Inlet.getName())) 
     22                        airThroughputInterface = new FanAirThroughputInterface(resource, atp); 
     23                else if(resource.getType().getName().equals(StandardResourceType.Outlet.getName())) 
     24                        airThroughputInterface = new FanAirThroughputInterface(resource, atp); 
     25                else if(resource.getType().getName().equals(StandardResourceType.CoolingDevice.getName())) 
     26                        airThroughputInterface = new PhysicalResourceAirThroughputInterface(resource, atp); 
     27                else 
     28                        airThroughputInterface = new ComputingResourceAirThroughputInterface((ComputingResource)resource, atp); 
    1429                return airThroughputInterface; 
    1530        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java

    r495 r1207  
    2828        } 
    2929         
    30         public void addToPowerUsageHistory(double airFlow) { 
     30        public void addToAirFlowHistory(double airFlow) { 
    3131 
    3232                if (airFlowHistory.size() == 0) { 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/StandardAirThroughputStateName.java

    r753 r1207  
    33public enum  StandardAirThroughputStateName implements AirThroughputStateName{ 
    44 
    5         FAN_ON, 
    6         FAN_OFF; 
     5        ON, 
     6        OFF; 
    77 
    88        public String getName() { 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/AirThroughputInterface.java

    r754 r1207  
    44 
    55import schedframe.Parameters; 
     6import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue; 
    67import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 
    78import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputStateName; 
     
    910public interface AirThroughputInterface { 
    1011         
    11         public AirThroughputStateName  getAirThroughputState(); 
     12        public AirThroughputStateName getAirThroughputState(); 
    1213         
    1314        public boolean setAirThroughputState(AirThroughputStateName airThroughputState); 
     
    2122        public double getPowerConsumption(AirThroughputStateName state) throws NoSuchFieldException; 
    2223         
     24        public AirFlowValue getRecentAirFlow(); 
     25         
     26        List<AirFlowValue> getAirFlowHistory(); 
     27         
    2328        public Parameters getParameters(); 
     29         
     30         
    2431} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/ComputingResourceAirThroughputInterface.java

    r754 r1207  
    44import java.util.List; 
    55 
     6import org.joda.time.DateTimeUtils; 
     7 
    68import schedframe.Parameters; 
    79import schedframe.resources.computing.ComputingResource; 
    810import schedframe.resources.computing.profiles.energy.EnergyEvent; 
    911import schedframe.resources.computing.profiles.energy.EnergyEventType; 
     12import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue; 
    1013import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 
    1114import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 
     
    2225                this.resource = resource; 
    2326                this.airThroughputProfile = airThroughputProfile; 
    24                 this.currentAirThroughputState = StandardAirThroughputStateName.FAN_ON; 
     27                this.currentAirThroughputState = StandardAirThroughputStateName.ON; 
    2528        } 
    2629         
     
    3437                         
    3538                        //TO DO - notifications should be called for all resources starting form the lowest layer 
    36                         resource.handleEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, resource.getName())); 
     39                        resource.handleEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, resource.getFullName())); 
     40                        resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName())); 
    3741                        return true; 
    3842                } 
     
    8387        } 
    8488         
     89        public AirFlowValue getRecentAirFlow() { 
     90                AirFlowValue airFlow = null; 
     91                int lastIdx = getAirFlowHistory().size() - 1; 
     92                if(lastIdx >= 0) 
     93                        airFlow = getAirFlowHistory().get(lastIdx); 
     94                else {   
     95                        try { 
     96                                airFlow = new AirFlowValue(DateTimeUtils.currentTimeMillis(), getAirFlow(currentAirThroughputState)); 
     97                        } catch (NoSuchFieldException e) { 
     98                        } 
     99                } 
     100                return airFlow; 
     101        } 
     102         
     103        public List<AirFlowValue> getAirFlowHistory(){ 
     104                return airThroughputProfile.getAirThroughputHistory(); 
     105        } 
     106         
     107         
    85108        public Parameters getParameters() { 
    86109                return airThroughputProfile.getParameters(); 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PState.java

    r1119 r1207  
    11package schedframe.resources.computing.profiles.energy.power; 
     2 
     3import java.util.Map; 
     4import java.util.TreeMap; 
    25 
    36public class PState { 
     
    912        protected double powerUsageMin; 
    1013        protected double powerUsageMax; 
    11  
     14        //protected List<LoadPowerUsage> loadPowerUsageList; 
     15        protected Map<Double, Double> loadPowerUsage; 
     16         
    1217        /*public PState(PStateType name, double frequency, double voltage, double power) { 
    1318                super(); 
     
    3843                return powerUsageMax; 
    3944        } 
    40          
     45        /*public List<LoadPowerUsage> getLoadPowerUsageList() { 
     46                return loadPowerUsageList; 
     47        }*/ 
     48        public Map<Double, Double> getLoadPowerUsage() { 
     49                if(loadPowerUsage == null) { 
     50                        return new TreeMap<Double, Double>(); 
     51                } 
     52                return loadPowerUsage; 
     53        } 
     54 
    4155        public static class Builder { 
    4256           
     
    4761                protected double powerUsageMin; 
    4862                protected double powerUsageMax; 
     63                //protected List<LoadPowerUsage> loadPowerUsageList = new ArrayList<LoadPowerUsage>(); 
     64                protected Map<Double, Double> loadPowerUsage = new TreeMap<Double, Double>(); 
    4965                 
    5066                public Builder name(String name){this.name = name; return this; } 
     
    5470        public Builder powerUsageMin(double rate){this.powerUsageMin = rate; return this; } 
    5571        public Builder powerUsageMax(double rate){this.powerUsageMax = rate; return this; } 
     72        //public Builder loadPowerUsage(LoadPowerUsage lpu){this.loadPowerUsageList.add(lpu); return this; } 
     73        public Builder loadPowerUsage(double load, double power){this.loadPowerUsage.put(load, power); return this; } 
    5674         
    5775        public PState build() { 
     
    6785                this.powerUsageMin = builder.powerUsageMin; 
    6886                this.powerUsageMax = builder.powerUsageMax; 
     87                //this.loadPowerUsageList = builder.loadPowerUsageList; 
     88                this.loadPowerUsage = builder.loadPowerUsage; 
    6989        } 
     90 
     91 
    7092} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PowerInterfaceFactory.java

    r1104 r1207  
    11package schedframe.resources.computing.profiles.energy.power; 
    22 
    3 import schedframe.resources.CoolEmAllResourceType; 
    43import schedframe.resources.StandardResourceType; 
    54import schedframe.resources.computing.ComputingResource; 
    65import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
     6import schedframe.resources.devices.PhysicalResource; 
     7import schedframe.resources.devices.PhysicalResourcePowerInterface; 
    78 
    89public class PowerInterfaceFactory { 
    910 
    10  
    11  
    12         //new1 
    13         /*public static PowerInterface createPowerProfile(ResourceType resourceType, List<PowerState> powerStates, List<PState> pStates, String eepn){ 
    14  
    15                 PowerInterface powerProfile; 
    16  
    17                 switch(resourceType){ 
    18                         case DataCenter: powerProfile = new DataCenterPowerInterfaceNew(eepn, powerStates); break; 
    19                         case ComputingNode: powerProfile = new ComputingNodePowerInterfaceNew(eepn, powerStates); break; 
    20                         case Processor: powerProfile = new CPUPowerInterfaceNew(eepn, powerStates, pStates); break; 
    21                         default: 
    22                                 throw new IllegalArgumentException("ResourceType " + resourceType + " is not supported."); 
    23                 } 
    24  
    25                 return powerProfile; 
    26         }*/ 
    2711         
    28         public static PowerInterface createPowerInterface(ComputingResource resource, PowerProfile pp){ 
     12        public static PowerInterface createPowerInterface(PhysicalResource resource, PowerProfile pp){ 
    2913                if(pp == null) 
    3014                        return null; 
    3115                PowerInterface powerInterface; 
    32  
     16                 
    3317                if(resource.getType().getName().equals(StandardResourceType.DataCenter.getName())) 
    34                         powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.DataCenterPowerInterface(resource, pp); 
    35                 else if (resource.getType().getName().equals(StandardResourceType.ComputingNode.getName())) 
    36                         powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface(resource, pp); 
     18                        powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.DataCenterPowerInterface((ComputingResource)resource, pp); 
     19                else if (resource.getType().getName().equals(StandardResourceType.Node.getName())) 
     20                        powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface((ComputingResource)resource, pp); 
    3721                else if (resource.getType().getName().equals(StandardResourceType.Processor.getName())) 
    38                         powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface(resource, pp); 
    39                 else if (resource.getType().getName().equals(CoolEmAllResourceType.Node.getName())) 
    40                         powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface(resource, pp); 
     22                        powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface((ComputingResource)resource, pp); 
     23                else if (resource.getType().getName().equals(StandardResourceType.CRAH.getName())) 
     24                        powerInterface = new PhysicalResourcePowerInterface(resource, pp); 
     25                else if (resource.getType().getName().equals(StandardResourceType.Fan.getName())) 
     26                        powerInterface = new PhysicalResourcePowerInterface(resource, pp); 
     27                else if (resource.getType().getName().equals(StandardResourceType.Inlet.getName())) 
     28                        powerInterface = new PhysicalResourcePowerInterface(resource, pp); 
     29                else if (resource.getType().getName().equals(StandardResourceType.Outlet.getName())) 
     30                        powerInterface = new PhysicalResourcePowerInterface(resource, pp); 
     31                else if (resource.getType().getName().equals(StandardResourceType.CoolingDevice.getName())) 
     32                        powerInterface = new PhysicalResourcePowerInterface(resource, pp); 
     33                else if (resource.getType().getName().equals(StandardResourceType.Heatsink.getName())) 
     34                        powerInterface = new PhysicalResourcePowerInterface(resource, pp); 
    4135                else  
    42                         powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingResourcePowerInterface(resource, pp); 
     36                        powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingResourcePowerInterface((ComputingResource)resource, pp); 
    4337 
    4438                /*switch(resource.getType()){ 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java

    r1167 r1207  
    2424        public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates) { 
    2525                this.energyEstimationPlugin = energyEstimationPlugin; 
     26                this.supportedPowerStates = powerStates; 
    2627                this.powerUsage = new ArrayList<PowerUsage>(); 
    27                 this.supportedPowerStates = powerStates; 
     28                initDefaultPowerStates(); 
    2829        } 
    2930         
    30         public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates,  List<PState> pStates) { 
     31        public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates, List<PState> pStates) { 
    3132                this.energyEstimationPlugin = energyEstimationPlugin; 
    3233                this.supportedPowerStates = powerStates; 
     
    3738                        supportedPStates.put(pState.getName(), pState); 
    3839                } 
     40                initDefaultPowerStates(); 
    3941        } 
    4042         
     
    6062        } 
    6163         
    62         public List<PowerState> getSupportedPowerStates() throws NoSuchFieldException{ 
     64        public List<PowerState> getSupportedPowerStates() { 
    6365                if(supportedPowerStates == null) 
    64                         throw new NoSuchFieldException("Supported power states are not defined."); 
     66                        return new ArrayList<PowerState>(); 
    6567                return supportedPowerStates; 
    6668        } 
     
    111113        } 
    112114 
    113  
     115        protected void initDefaultPowerStates(){ 
     116                boolean supportsON = false; 
     117                boolean supportsOFF = false; 
     118                if(supportedPowerStates == null){ 
     119                        supportedPowerStates = new ArrayList<PowerState>(); 
     120                } 
     121                for(PowerState ps: supportedPowerStates){ 
     122                        if(ps.getName().equals(StandardPowerStateName.ON)){ 
     123                                supportsON = true; 
     124                        } else if (ps.getName().equals(StandardPowerStateName.OFF)){ 
     125                                supportsOFF = true; 
     126                        } 
     127                } 
     128                 
     129                if(!supportsON){ 
     130                        supportedPowerStates.add(new PowerState(StandardPowerStateName.ON, -1, new ArrayList<Transition>())); 
     131                } 
     132                if(!supportsOFF){ 
     133                        supportedPowerStates.add(new PowerState(StandardPowerStateName.OFF, -1, new ArrayList<Transition>())); 
     134                } 
     135        } 
    114136} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/plugin/EnergyEstimationPlugin.java

    r477 r1207  
    22 
    33import schedframe.Plugin; 
    4 import schedframe.resources.computing.ComputingResource; 
    54import schedframe.resources.computing.profiles.energy.EnergyEvent; 
     5import schedframe.resources.devices.PhysicalResource; 
    66import schedframe.scheduling.manager.tasks.JobRegistry; 
    77 
    88public interface EnergyEstimationPlugin extends Plugin { 
    99         
    10         public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 
     10        public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource); 
    1111 
    12         public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 
     12        public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource); 
    1313 
    14         public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 
     14        public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource); 
    1515 
    1616} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingNodePowerInterface.java

    r1166 r1207  
    11package schedframe.resources.computing.profiles.energy.power.ui; 
    22 
     3 
     4 
     5import org.joda.time.DateTime; 
     6 
     7import schedframe.SimulatedEnvironment; 
    38import schedframe.resources.ResourceStatus; 
    49import schedframe.resources.computing.ComputingNode; 
     
    3843                 
    3944                if(!pePowerStateChangeStatus){ 
    40                         computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getName())); 
     45                        computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getFullName())); 
    4146                } 
    4247 
     
    4853                } 
    4954                //computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getName())); 
     55                //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName()); 
    5056                return true; 
    5157        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingResourcePowerInterface.java

    r579 r1207  
    44import java.util.List; 
    55 
     6import org.joda.time.DateTime; 
    67import org.joda.time.DateTimeUtils; 
    78 
    89import schedframe.Parameters; 
     10import schedframe.SimulatedEnvironment; 
    911import schedframe.resources.ResourceStatus; 
    1012import schedframe.resources.computing.ComputingResource; 
     
    4648                        } 
    4749                        //notifications from all levels 
    48                         resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getName())); 
     50                        resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName())); 
    4951 
    5052                        //notification from last level 
    5153                        //if (resource.getChildren() == null) resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource)); 
    5254                         
     55                        //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName()); 
    5356                        return true; 
    5457                } 
     
    7073 
    7174        public boolean supportPowerState(PowerStateName state) { 
    72                 try { 
    73                         for(PowerState powerState: powerProfile.getSupportedPowerStates()){ 
    74                                 if(powerState.getName().equals(state)){ 
    75                                         return true; 
    76                                 } 
     75                for(PowerState powerState: powerProfile.getSupportedPowerStates()){ 
     76                        if(powerState.getName().equals(state)){ 
     77                                return true; 
    7778                        } 
    78                 } catch (NoSuchFieldException e) { 
    79                         return false; 
    8079                } 
    8180                return false; 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/DataCenterPowerInterface.java

    r495 r1207  
    11package schedframe.resources.computing.profiles.energy.power.ui; 
    22 
     3import org.joda.time.DateTime; 
     4 
     5import schedframe.SimulatedEnvironment; 
    36import schedframe.resources.computing.ComputingResource; 
    47import schedframe.resources.computing.DataCenter; 
     
    2326                        child.getPowerInterface().setPowerState(state); 
    2427                } 
    25  
     28                //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName()); 
    2629                return true; 
    2730        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java

    r782 r1207  
    44import java.util.Map; 
    55 
     6import org.joda.time.DateTime; 
     7 
     8import schedframe.SimulatedEnvironment; 
    69import schedframe.resources.ResourceStatus; 
    710import schedframe.resources.computing.ComputingResource; 
     
    1619 
    1720        protected PState currentPState; 
    18  
    1921 
    2022        public ProcessorPowerInterface(ComputingResource resource, PowerProfile pp){ 
     
    3436                                resource.setStatus(ResourceStatus.FREE); 
    3537                        } 
    36                         resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getName()));          
     38                        resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName()));              
    3739                } 
    3840 
     
    6870                        //speed.setAmount(Double.valueOf(currentPState.getFrequency()).intValue()); 
    6971                        //new ResourceEventCommand(resource).execute(EnergyEventType.FREQUENCY_CHANGED); 
    70                         resource.handleEvent(new EnergyEvent(EnergyEventType.FREQUENCY_CHANGED, resource.getName())); 
     72                        resource.handleEvent(new EnergyEvent(EnergyEventType.FREQUENCY_CHANGED, resource.getFullName())); 
    7173                        //resource.getScheduler().sendInternal(GridSimTags.SCHEDULE_NOW, DCWormsTags.UPDATE, resource.getName()); 
     74                         
     75                        //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "PSTATE_CHANGED", pStateName); 
    7276                        return true; 
    7377                } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/thermal/ThermalInterfaceFactory.java

    r803 r1207  
    11package schedframe.resources.computing.profiles.energy.thermal; 
    22 
     3import schedframe.resources.StandardResourceType; 
    34import schedframe.resources.computing.ComputingResource; 
    45import schedframe.resources.computing.profiles.energy.thermal.ui.ComputingResourceThermalInterface; 
    56import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface; 
     7import schedframe.resources.devices.PhysicalResource; 
     8import schedframe.resources.devices.PhysicalResourceThermalInterface; 
    69 
    710public class ThermalInterfaceFactory { 
    8         public static ThermalInterface createThermalInterface(ComputingResource resource, ThermalProfile tp){ 
     11        public static ThermalInterface createThermalInterface(PhysicalResource resource, ThermalProfile tp){ 
    912                if(tp == null) 
    1013                        return null; 
    11                 ThermalInterface thermalInterface = new ComputingResourceThermalInterface(resource, tp); 
    12  
     14                ThermalInterface thermalInterface; 
     15                if (resource.getType().getName().equals(StandardResourceType.CRAH.getName())) 
     16                        thermalInterface = new PhysicalResourceThermalInterface(resource, tp); 
     17                else if (resource.getType().getName().equals(StandardResourceType.Fan.getName())) 
     18                        thermalInterface = new PhysicalResourceThermalInterface(resource, tp); 
     19                else  
     20                        thermalInterface = new ComputingResourceThermalInterface((ComputingResource)resource, tp); 
    1321                return thermalInterface; 
    1422        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/properties/ResourceProperties.java

    r477 r1207  
    33import java.util.Properties; 
    44 
    5 import schedframe.resources.computing.description.AbstractResourceDescription; 
     5import schedframe.resources.computing.description.ResourceDescription; 
    66 
    77public class ResourceProperties extends Properties{ 
     
    1616        } 
    1717         
    18         public ResourceProperties(AbstractResourceDescription ard){ 
     18        public ResourceProperties(ResourceDescription ard){ 
    1919                 
    2020        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/validator/ResourceNameValidator.java

    r477 r1207  
    1313        @Override 
    1414        public boolean validate(ComputingResource resource) { 
    15                 return resource.getName().equals(name); 
     15                return resource.getFullName().equals(name); 
    1616        } 
    1717 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/utils/ResourceIdGenerator.java

    r816 r1207  
    22 
    33import java.util.HashMap; 
    4  
    5 import schedframe.resources.ResourceType; 
    64 
    75public class ResourceIdGenerator { 
     
    119        public static int getId(String key){ 
    1210 
    13                 int value = 0; 
     11                int value = 1; 
    1412                if(resourceCounter.containsKey(key)){ 
    1513                        value = resourceCounter.get(key); 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/ResourceHistoryItem.java

    r477 r1207  
    88import schedframe.resources.units.ResourceUnitName; 
    99 
     10//TODO - change name 
    1011public class ResourceHistoryItem { 
    1112 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/SchedulerDescription.java

    r477 r1207  
    22 
    33import java.util.ArrayList; 
     4import java.util.Collection; 
    45import java.util.HashMap; 
    56import java.util.Iterator; 
     
    910import schedframe.resources.StandardResourceType; 
    1011import schedframe.resources.computing.description.ExecutingResourceDescription; 
     12import schedframe.resources.computing.description.ResourceDescription; 
    1113import schedframe.resources.providers.ResourceProvider; 
    12 import schedframe.resources.units.AbstractResourceUnit; 
    1314import schedframe.resources.units.ResourceUnit; 
    1415import schedframe.resources.units.ResourceUnitName; 
    1516import schedframe.scheduling.queue.QueueDescription; 
    1617 
    17 public class SchedulerDescription extends ExecutingResourceDescription{ 
     18public class SchedulerDescription extends ResourceDescription implements ExecutingResourceDescription{ 
    1819 
    1920        protected ResourceProvider provider; 
    2021        protected List<QueueDescription> accesQueues; 
     22        protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 
    2123 
    2224        public SchedulerDescription(ResourceProvider provider){ 
     
    6264                return provider; 
    6365        } 
     66         
     67        public void addResourceUnit(ResourceUnit unit) { 
     68                if (this.resUnits == null) 
     69                        this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(1); 
     70                List<ResourceUnit> list = null; 
     71                if (this.resUnits.containsKey(unit.getName())) { 
     72                        list = this.resUnits.get(unit.getName()); 
     73                } else { 
     74                        list = new ArrayList<ResourceUnit>(1); 
     75                        this.resUnits.put(unit.getName(), list); 
     76                } 
     77                list.add(unit); 
     78        } 
     79         
     80        public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException { 
     81                return getResourceUnitList(unitName).get(0); 
     82        } 
     83 
     84        public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException { 
     85                if (resUnits.containsKey(unitName)) 
     86                        return resUnits.get(unitName); 
     87                else 
     88                        throw new NoSuchFieldException("Resource unit " + unitName + " is not available in resource " + this.id); 
     89        } 
     90 
     91        public Collection<ResourceUnit> getResourceUnit() { 
     92                if (resUnits == null) 
     93                        return null; 
     94                List<ResourceUnit> values = new ArrayList<ResourceUnit>(); 
     95                Collection<List<ResourceUnit>> lists = resUnits.values(); 
     96                Iterator<List<ResourceUnit>> itr = lists.iterator(); 
     97 
     98                while (itr.hasNext()) { 
     99                        List<ResourceUnit> list = itr.next(); 
     100                        values.addAll(list); 
     101                } 
     102 
     103                return values; 
     104        } 
     105 
     106        public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() { 
     107                return resUnits; 
     108        } 
    64109} 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/resources/ClusterResourceManager.java

    r477 r1207  
    2323        public List<ComputingNode> getComputingNodes(){ 
    2424                try { 
    25                         return (List<ComputingNode>) getResourcesOfType(StandardResourceType.ComputingNode); 
     25                        return (List<ComputingNode>) getResourcesOfType(StandardResourceType.Node); 
    2626                } catch (ResourceException e) { 
    2727                        return new ArrayList<ComputingNode>(); 
     
    4040        @SuppressWarnings("unchecked") 
    4141        public List<ComputingNode> getComputingNodes(Properties properties){ 
    42                 properties.setProperty("type", StandardResourceType.ComputingNode.toString()); 
     42                properties.setProperty("type", StandardResourceType.Node.toString()); 
    4343                return (List<ComputingNode>) filterResources(properties); 
    4444 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/resources/LocalResourceManager.java

    r1054 r1207  
    1919import schedframe.resources.StandardResourceType; 
    2020import schedframe.resources.computing.ComputingResource; 
     21import schedframe.resources.computing.ComputingResourceCharacteristics; 
    2122import schedframe.resources.computing.ResourceCharacteristics; 
    2223import schedframe.resources.computing.validator.ResourcePropertiesValidator; 
     
    138139                for (int i = 0; i < computingResources.size() && resourceWithName == null; i++) { 
    139140                        ComputingResource resource = computingResources.get(i); 
    140                         if (resource.getName().equals(resourceName)) 
     141                        if (resource.getFullName().equals(resourceName)) 
    141142                                resourceWithName = resource; 
    142143                        else 
     
    154155                        while (!toExamine.isEmpty()) { 
    155156                                ComputingResource resource = toExamine.pop(); 
    156                                 ResourceCharacteristics resourceCharacteristic = resource.getResourceCharacteristic(); 
     157                                ComputingResourceCharacteristics resourceCharacteristic = (ComputingResourceCharacteristics)resource.getResourceCharacteristic(); 
    157158                                List<ResourceUnit> units = null; 
    158159                                units = resourceCharacteristic.getResourceUnits().get(unitName); 
     
    266267                for(int i = 0 ; i < computingResources.size() && resourceWithName == null; i++){ 
    267268                        ComputingResource resource = computingResources.get(i); 
    268                         if(resource.getName().equals(resName)) 
     269                        if(resource.getFullName().equals(resName)) 
    269270                                resourceWithName = resource; 
    270271                        else 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java

    r1162 r1207  
    2424 
    2525import qcg.shared.constants.BrokerConstants; 
    26 import schedframe.ResourceController; 
     26import schedframe.SimulatedEnvironment; 
    2727import schedframe.events.scheduling.SchedulingEvent; 
    2828import schedframe.events.scheduling.SchedulingEventType; 
     
    323323                        ExecTask task = iter.next(); 
    324324                        Executable exec = (Executable)task; 
    325                         //exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * timeSpan/exec.getEstimatedDuration()); 
    326325                        exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / exec.getEstimatedDuration())); 
    327326                        UsedResourcesList usedResourcesList = exec.getUsedResources(); 
     
    338337                        for (ComputingResource resource : pes) { 
    339338                                resource.handleEvent(new EnergyEvent(eventType, obj)); 
     339                                //DataCenterWorkloadSimulator.getEventManager().sendToResources(resource.getType(), 0, new EnergyEvent(eventType, obj)); 
    340340                        } 
    341341                        /*try { 
     
    350350                        ComputingResource resource = null; 
    351351                        try { 
    352                                 resource = ResourceController.getComputingResourceByName(peUnit.getResourceId()); 
     352                                resource = SimulatedEnvironment.getComputingResourceByName(peUnit.getResourceId()); 
    353353                        } catch (ResourceException e) { 
    354354                                return; 
     
    428428                        if(exec.getResourceConsumptionProfile().getCurrentResourceConsumption() == exec.getResourceConsumptionProfile().getResourceConsumptionList().getLast()){ 
    429429                                scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_FINISHED, execTask); 
     430                                PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 
     431                                notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 
    430432                        } else { 
    431433                                scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_CHANGED, execTask); 
     434                                PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 
     435                                notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 
    432436                        } 
    433437                } 
     
    540544                                        job.setStatus((int)BrokerConstants.JOB_STATUS_SUBMITTED); 
    541545                        } catch (Exception e) { 
    542                                 // TODO Auto-generated catch block 
    543546                                e.printStackTrace(); 
    544547                        } 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Job.java

    r1159 r1207  
    77import org.qcg.broker.schemas.resreqs.types.TaskStatesName; 
    88 
    9 import gridsim.dcworms.DCWormsTags; 
    109 
    1110import java.io.StringWriter; 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Task.java

    r1194 r1207  
    44import java.io.StringWriter; 
    55import java.util.ArrayList; 
    6 import java.util.LinkedList; 
    76import java.util.List; 
    87 
     
    2221import org.qcg.broker.schemas.resreqs.ProcessesResourceRequirements; 
    2322import org.qcg.broker.schemas.resreqs.Requirements; 
    24 import org.qcg.broker.schemas.resreqs.ResourceConsumptionType; 
    2523import org.qcg.broker.schemas.resreqs.TaskResourceRequirements; 
    2624import org.qcg.broker.schemas.resreqs.TimePeriod; 
     
    3129import schedframe.scheduling.WorkloadUnitHandler; 
    3230import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    33 import schedframe.scheduling.tasks.phases.ResourceConsumption; 
    34 import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile; 
    3531import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
    3632 
     
    7571        private long workloadLogWaitTime; 
    7672         
    77         private ResourceConsumptionProfile resourceConsumptionProfile; 
    7873 
    7974        public Task(org.qcg.broker.schemas.resreqs.Task task){ 
     
    9691        } 
    9792 
    98         private void preparePhases() { 
    99                 LinkedList<ResourceConsumption> resourceConsumptionList = new LinkedList<ResourceConsumption>(); 
    100                  
    101                 if(task.getExecution() == null || task.getExecution().getResourceConsumptionProfile() == null){ 
    102                         ResourceConsumption resConsumption = null; 
    103                         try { 
    104                                 resConsumption = new ResourceConsumption(this.length, getComputingResourceRequirements()); 
    105                         } catch (NoSuchFieldException e) { 
    106                                 // TODO Auto-generated catch block 
    107                                 e.printStackTrace(); 
    108                         } 
    109                         resourceConsumptionList.add(resConsumption); 
    110                 } 
    111                 else{ 
    112                         for(ResourceConsumptionType resConsumption: task.getExecution().getResourceConsumptionProfile().getResourceConsumption()){ 
    113                                 ResourceConsumption resourceConsumption = new ResourceConsumption(resConsumption); 
    114                                 resourceConsumptionList.add(resourceConsumption); 
    115                         } 
    116                 } 
    117                 this.resourceConsumptionProfile = new ResourceConsumptionProfile(resourceConsumptionList); 
    118                  
    119         //      System.out.println("======"+task.getExecution().getExecutable().getApplication().getName()); 
    120         } 
     93         
    12194         
    12295        public DateTime getExecutionStartTime() throws NoSuchFieldException { 
     
    310283        } 
    311284         
    312         protected ComputingResourceBaseTypeItem[] getComputingResourceRequirements() throws NoSuchFieldException{ 
     285        public ComputingResourceBaseTypeItem[] getComputingResourceRequirements() throws NoSuchFieldException{ 
    313286                 
    314287                Requirements req = this.task.getRequirements(); 
     
    450423        public void setLength(long length) { 
    451424                this.length = length; 
    452                 preparePhases(); 
    453425        } 
    454426 
     
    515487                wuh.handleTask(this); 
    516488        } 
    517          
    518         public ResourceConsumptionProfile getResourceConsumptionProfile(){ 
    519                 return resourceConsumptionProfile; 
    520         } 
    521          
     489 
    522490        public String getApplicationName(){ 
    523491                try{ 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/TaskInterface.java

    r1190 r1207  
    77 
    88import schedframe.DescriptionContainer; 
    9 import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile; 
    109import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
    1110 
     
    111110        public long getWorkloadLogWaitTime(); 
    112111         
    113         public ResourceConsumptionProfile getResourceConsumptionProfile(); 
     112        //public ResourceConsumptionProfile getResourceConsumptionProfile(); 
    114113         
    115114        public String getApplicationName(); 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumption.java

    r1129 r1207  
    99import org.qcg.broker.schemas.resreqs.ComputingResourceParameterType; 
    1010import org.qcg.broker.schemas.resreqs.PhaseBehaviourType; 
    11 import org.qcg.broker.schemas.resreqs.ReferenceType; 
     11import org.qcg.broker.schemas.resreqs.StringParameterType; 
     12 
    1213import org.qcg.broker.schemas.resreqs.ResourceConsumptionType; 
    1314 
     
    3637        if(resConsumptionType.getReferenceHardware() != null){ 
    3738                for (int i = 0; i < resConsumptionType.getReferenceHardware().getReference().length; i++){ 
    38                         ReferenceType rt = resConsumptionType.getReferenceHardware().getReference(i); 
    39                         referenceHardware.put(rt.getName(), rt.getContent()); 
     39                        StringParameterType spt = resConsumptionType.getReferenceHardware().getReference(i); 
     40                        referenceHardware.put(spt.getName(), spt.getContent()); 
    4041                } 
    4142        } 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumptionProfile.java

    r896 r1207  
    22 
    33import java.util.LinkedList; 
    4 import java.util.List; 
    54 
    65public class ResourceConsumptionProfile { 
    76         
    87        protected LinkedList<ResourceConsumption> resourceConsumptionList; 
    9         protected int currentPhase; 
     8        protected long usefulWork; 
     9        private int currentPhase; 
    1010         
    1111        public ResourceConsumptionProfile() { 
     
    3737                this.currentPhase = currentPhase; 
    3838        } 
     39 
     40        public long getUsefulWork() { 
     41                return usefulWork; 
     42        } 
     43 
     44        public void setUsefulWork(long usefulWork) { 
     45                this.usefulWork = usefulWork; 
     46        } 
    3947} 
Note: See TracChangeset for help on using the changeset viewer.