Ignore:
Timestamp:
02/04/13 04:12:44 (12 years ago)
Author:
wojtekp
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/trunk/src/schedframe/resources/computing/description/ComputingResourceDescription.java

    r752 r815  
    11package schedframe.resources.computing.description; 
    22 
     3import java.io.FileInputStream; 
     4import java.io.FileNotFoundException; 
     5import java.io.IOException; 
    36import java.util.ArrayList; 
    47import java.util.List; 
     8import java.util.PropertyResourceBundle; 
     9import java.util.ResourceBundle; 
    510 
    611import schedframe.Parameter; 
     
    1924import schedframe.resources.computing.profiles.energy.power.Transition; 
    2025import schedframe.resources.computing.profiles.energy.power.plugin.EnergyEstimationPlugin; 
     26import schedframe.resources.computing.profiles.energy.thermal.ThermalProfile; 
     27import schedframe.resources.computing.profiles.energy.thermal.plugin.DefaultTemperatureEstimationPlugin; 
     28import schedframe.resources.computing.profiles.energy.thermal.plugin.TemperatureEstimationPlugin; 
    2129import schedframe.resources.units.ResourceUnit; 
    2230import schedframe.resources.units.ResourceUnitFactory; 
    2331import schedframe.resources.utils.ResourceIdGenerator; 
    2432import schemas.ComputingResource; 
     33import schemas.PowerUsage; 
    2534import schemas.Profile; 
    2635import simulator.utils.InstanceFactory; 
     
    3241        protected PowerProfile powerProfile; 
    3342        protected AirThroughputProfile airThroughputProfile; 
     43        protected ThermalProfile thermalProfile; 
    3444        protected Location location; 
    3545        protected String category; 
     
    3949 
    4050                super(ResourceTypeFactory.createResourceType(computingResource.getClazz())); 
    41  
     51                this.category = computingResource.getType(); 
     52                 
    4253                initId(computingResource); 
    43                 this.category = computingResource.getType(); 
    4454 
    4555                if (computingResource.getComputingResourceTypeChoiceSequence() != null) { 
    4656                        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                        } 
    4776                        initProfiles(computingResource.getComputingResourceTypeChoiceSequence().getProfile()); 
    4877                        initLocation(computingResource.getComputingResourceTypeChoiceSequence().getLocation()); 
     
    5483                this.id = computingResource.getName() != null ? computingResource.getName() : type.toString(); 
    5584                if(computingResource.getCount() > 1 || computingResource.getName() == null){ 
    56                         this.id = id + "_" + String.valueOf(ResourceIdGenerator.getId(type)); 
     85                        this.id = id + "_" + String.valueOf(ResourceIdGenerator.getId(type.toString())); 
    5786                } 
    5887        } 
     
    73102                        initPowerProfile(profile.getPowerProfile()); 
    74103                        initAirThroughputProfile(profile.getAirThroughputProfile()); 
     104                        initThermalProfile(profile.getThermalProfile()); 
    75105                } 
    76106        } 
     
    83113                        List<PState> pStates = null; 
    84114                        if(powerProfileCharacteristic.getEnergyEstimationPlugin() != null){ 
    85                                 String  energyEstimationPluginName = powerProfileCharacteristic.getEnergyEstimationPlugin().getName(); 
     115                                String energyEstimationPluginName = powerProfileCharacteristic.getEnergyEstimationPlugin().getName(); 
    86116                                if(energyEstimationPluginName != null) { 
    87117                                        energyEstimationPlugin = (EnergyEstimationPlugin) InstanceFactory.createInstance( 
     
    109139                                                transitions.add(transition); 
    110140                                        } 
     141                                        //CoolEmAll DEBB description case 
     142                                        if(ps.getPowerUsage() == null){ 
     143                                                ps.setPowerUsage(new PowerUsage("0")); 
     144                                        } 
    111145                                        PowerState powerState = new PowerState(PowerStateNameFactory.createPowerStateName(ps.getName()), ps 
    112146                                                        .getPowerUsage().getContent(), transitions); 
     
    119153                        if(powerProfileCharacteristic.getParameter() != null){ 
    120154                                pStates = new ArrayList<PState>(); 
    121                                 int parameterCount =  powerProfileCharacteristic.getParameterCount(); 
     155                                int parameterCount = powerProfileCharacteristic.getParameterCount(); 
    122156                                for(int i = 0; i < parameterCount; i++){ 
    123157                                        schemas.Parameter parameter = powerProfileCharacteristic.getParameter(i); 
    124158                                        if(parameter.getName().equals("pState")){ 
    125                                                 PState.Builder builder =  new PState.Builder(); 
     159                                                PState.Builder builder = new PState.Builder(); 
    126160                                                int propertyCount = parameter.getParameterTypeSequence().getPropertyCount(); 
    127161                                                for(int j = 0; j < propertyCount; j++){ 
     
    166200                        if(airThroughputProfile.getAirThroughputStates() != null){ 
    167201                                airThroughputStates = new ArrayList<AirThroughputState>(); 
    168                                 int airThrouhputStateCount =  airThroughputProfile.getAirThroughputStates().getAirThroughputStateCount(); 
     202                                int airThrouhputStateCount = airThroughputProfile.getAirThroughputStates().getAirThroughputStateCount(); 
    169203                                for (int i = 0; i < airThrouhputStateCount; i++) { 
    170204                                        schemas.AirThroughputState ats = airThroughputProfile.getAirThroughputStates().getAirThroughputState(i); 
     
    179213                        Parameters params = extractParameters(airThroughputProfile.getParameter()); 
    180214                        this.airThroughputProfile.init(params); 
     215                } 
     216        } 
     217         
     218        private void initThermalProfile(schemas.ThermalProfile thermalProfile) { 
     219                 
     220                if (thermalProfile != null) { 
     221                         
     222                        TemperatureEstimationPlugin temperatureEstimationPlugin = null; 
     223 
     224                        if(thermalProfile.getTemperatureEstimationPlugin() != null){ 
     225                                String temperatureEstimationPluginName = thermalProfile.getTemperatureEstimationPlugin().getName(); 
     226                                if(temperatureEstimationPluginName != null) { 
     227                                        temperatureEstimationPlugin = (TemperatureEstimationPlugin) InstanceFactory.createInstance( 
     228                                                        temperatureEstimationPluginName, TemperatureEstimationPlugin.class);                     
     229                                } else { 
     230                                        temperatureEstimationPlugin = new DefaultTemperatureEstimationPlugin(); 
     231                                } 
     232                                Parameters params = extractParameters(thermalProfile.getTemperatureEstimationPlugin().getParameter()); 
     233                                temperatureEstimationPlugin.init(params); 
     234                        } 
     235                        this.thermalProfile = new ThermalProfile(); 
     236                        Parameters params = extractParameters(thermalProfile.getParameter()); 
     237                        this.thermalProfile.init(params); 
    181238                } 
    182239        } 
     
    260317        } 
    261318 
     319        public ThermalProfile getThermalProfile() { 
     320                return thermalProfile; 
     321        } 
     322         
    262323        public Location getLocation() { 
    263324                return location; 
     
    268329        } 
    269330 
     331 
     332        /***COOLEMALL CASE RELATED***/ 
     333 
     334        private static ResourceBundle recsBundle; 
     335         
     336        private ResourceBundle getRecsBundle(String fileName) throws FileNotFoundException, IOException{ 
     337                if(recsBundle == null){ 
     338                        recsBundle = new PropertyResourceBundle(new FileInputStream(fileName)); 
     339                } 
     340                return recsBundle; 
     341        } 
     342         
     343        protected String getEEP(String query, String fileName) throws FileNotFoundException, IOException{ 
     344                ResourceBundle recsBundle = getRecsBundle(fileName); 
     345                return recsBundle.getString(query); 
     346        } 
     347         
     348        protected String createEEPQuery(ComputingResource compRes) { 
     349                String query = compRes.getClazz() + "EEP"; 
     350                return query; 
     351        } 
    270352} 
Note: See TracChangeset for help on using the changeset viewer.