source: DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingNode.java @ 1207

Revision 1207, 3.5 KB checked in by wojtekp, 11 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package schedframe.resources.computing;
2
3import java.util.List;
4import java.util.Properties;
5
6import schedframe.resources.ResourceStatus;
7import schedframe.resources.StandardResourceType;
8import schedframe.resources.computing.description.ComputingResourceDescription;
9import schedframe.resources.computing.extensions.ExtensionType;
10import schedframe.resources.computing.profiles.energy.EnergyExtension;
11import schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface;
12import schedframe.resources.computing.properties.ComputingNodePropertiesBuilder;
13import schedframe.resources.computing.properties.PropertiesDirector;
14import schedframe.resources.units.Cost;
15import schedframe.resources.units.Memory;
16import schedframe.resources.units.StandardResourceUnitName;
17
18public class ComputingNode extends ComputingResource{
19       
20
21        public ComputingNode (ComputingResourceDescription resDesc) {
22                super(resDesc);
23               
24                //extensionList.add(new EnergyExtension(this, resDesc.getPowerInterface(), resDesc.getEnergyEstimationPlugin()));
25                //PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile());
26                //AirThroughputInterface ai = AirThroughputInterfaceFactory.createAirThroughputInterface(this, resDesc.getAirThroughputProfile());
27                //accept(new EnergyExtension(pi, resDesc.getPowerProfile()));
28                //accept(new EnergyExtension(pi, resDesc.getPowerProfile(), ai, resDesc.getAirThroughputProfile()));   
29        }       
30       
31        public ComputingNodePowerInterface getPowerInterface(){
32                ComputingNodePowerInterface powerInterface = null;
33                if(extensionList.isExtensionAvailable(ExtensionType.ENERGY_EXTENSION)){
34                        EnergyExtension ee = (EnergyExtension)extensionList.getExtension(ExtensionType.ENERGY_EXTENSION);
35                        powerInterface = (ComputingNodePowerInterface)ee.getPowerInterface();
36                }
37                return powerInterface;
38        }
39
40        @SuppressWarnings("unchecked")
41        public List<Processor> getProcessors(){
42                return (List<Processor>) getDescendantsByType(StandardResourceType.Processor);
43        }
44       
45        @SuppressWarnings("unchecked")
46        public List<Processor> getFreeProcessors(){
47                return (List<Processor>) getDescendantsByTypeAndStatus(StandardResourceType.Processor, ResourceStatus.FREE);
48        }
49
50        public int getProcessorsNumber() {
51                return getProcessors().size();
52        }
53
54        public int getFreeProcessorsNumber() {
55                return getFreeProcessors().size();
56        }
57       
58       
59        //MEMORY
60        public int getFreeMemory() throws NoSuchFieldException {
61                return getMemory().getFreeAmount();
62        }
63       
64        public int getTotalMemory() throws NoSuchFieldException {
65                return getMemory().getAmount();
66        }
67
68        public boolean isMemRequirementSatisfied(int memoryReq) throws NoSuchFieldException {
69                if (getFreeMemory() < memoryReq)
70                        return false;
71                return true;
72        }
73       
74        public Memory getMemory() throws NoSuchFieldException {
75                return (Memory) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.MEMORY);
76        }
77       
78        //COST
79        public int getProcessingCost() throws NoSuchFieldException {
80                return getCost().getAmount();
81        }
82       
83        private Cost getCost() throws NoSuchFieldException {
84                return (Cost) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.COST);
85        }
86
87       
88        public Properties getProperties(){
89                PropertiesDirector propDirector = new PropertiesDirector();
90                propDirector.setPropertiesBuilder(new ComputingNodePropertiesBuilder());
91                propDirector.constructProperties(this);
92                return propDirector.getProperties();
93        }
94       
95       
96        /*private void accept(EnergyExtension e){
97                extensionList.add(e);
98                e.setResource(this);
99        }*/
100}
Note: See TracBrowser for help on using the repository browser.