Changeset 815 for DCWoRMS/trunk/src/schedframe/resources/computing
- Timestamp:
- 02/04/13 04:12:44 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/trunk/src/schedframe/resources/computing/description/ComputingResourceDescription.java
r752 r815 1 1 package schedframe.resources.computing.description; 2 2 3 import java.io.FileInputStream; 4 import java.io.FileNotFoundException; 5 import java.io.IOException; 3 6 import java.util.ArrayList; 4 7 import java.util.List; 8 import java.util.PropertyResourceBundle; 9 import java.util.ResourceBundle; 5 10 6 11 import schedframe.Parameter; … … 19 24 import schedframe.resources.computing.profiles.energy.power.Transition; 20 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; 21 29 import schedframe.resources.units.ResourceUnit; 22 30 import schedframe.resources.units.ResourceUnitFactory; 23 31 import schedframe.resources.utils.ResourceIdGenerator; 24 32 import schemas.ComputingResource; 33 import schemas.PowerUsage; 25 34 import schemas.Profile; 26 35 import simulator.utils.InstanceFactory; … … 32 41 protected PowerProfile powerProfile; 33 42 protected AirThroughputProfile airThroughputProfile; 43 protected ThermalProfile thermalProfile; 34 44 protected Location location; 35 45 protected String category; … … 39 49 40 50 super(ResourceTypeFactory.createResourceType(computingResource.getClazz())); 41 51 this.category = computingResource.getType(); 52 42 53 initId(computingResource); 43 this.category = computingResource.getType();44 54 45 55 if (computingResource.getComputingResourceTypeChoiceSequence() != null) { 46 56 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 } 47 76 initProfiles(computingResource.getComputingResourceTypeChoiceSequence().getProfile()); 48 77 initLocation(computingResource.getComputingResourceTypeChoiceSequence().getLocation()); … … 54 83 this.id = computingResource.getName() != null ? computingResource.getName() : type.toString(); 55 84 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())); 57 86 } 58 87 } … … 73 102 initPowerProfile(profile.getPowerProfile()); 74 103 initAirThroughputProfile(profile.getAirThroughputProfile()); 104 initThermalProfile(profile.getThermalProfile()); 75 105 } 76 106 } … … 83 113 List<PState> pStates = null; 84 114 if(powerProfileCharacteristic.getEnergyEstimationPlugin() != null){ 85 String 115 String energyEstimationPluginName = powerProfileCharacteristic.getEnergyEstimationPlugin().getName(); 86 116 if(energyEstimationPluginName != null) { 87 117 energyEstimationPlugin = (EnergyEstimationPlugin) InstanceFactory.createInstance( … … 109 139 transitions.add(transition); 110 140 } 141 //CoolEmAll DEBB description case 142 if(ps.getPowerUsage() == null){ 143 ps.setPowerUsage(new PowerUsage("0")); 144 } 111 145 PowerState powerState = new PowerState(PowerStateNameFactory.createPowerStateName(ps.getName()), ps 112 146 .getPowerUsage().getContent(), transitions); … … 119 153 if(powerProfileCharacteristic.getParameter() != null){ 120 154 pStates = new ArrayList<PState>(); 121 int parameterCount = 155 int parameterCount = powerProfileCharacteristic.getParameterCount(); 122 156 for(int i = 0; i < parameterCount; i++){ 123 157 schemas.Parameter parameter = powerProfileCharacteristic.getParameter(i); 124 158 if(parameter.getName().equals("pState")){ 125 PState.Builder builder = 159 PState.Builder builder = new PState.Builder(); 126 160 int propertyCount = parameter.getParameterTypeSequence().getPropertyCount(); 127 161 for(int j = 0; j < propertyCount; j++){ … … 166 200 if(airThroughputProfile.getAirThroughputStates() != null){ 167 201 airThroughputStates = new ArrayList<AirThroughputState>(); 168 int airThrouhputStateCount = 202 int airThrouhputStateCount = airThroughputProfile.getAirThroughputStates().getAirThroughputStateCount(); 169 203 for (int i = 0; i < airThrouhputStateCount; i++) { 170 204 schemas.AirThroughputState ats = airThroughputProfile.getAirThroughputStates().getAirThroughputState(i); … … 179 213 Parameters params = extractParameters(airThroughputProfile.getParameter()); 180 214 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); 181 238 } 182 239 } … … 260 317 } 261 318 319 public ThermalProfile getThermalProfile() { 320 return thermalProfile; 321 } 322 262 323 public Location getLocation() { 263 324 return location; … … 268 329 } 269 330 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 } 270 352 }
Note: See TracChangeset
for help on using the changeset viewer.