Changeset 1299 for DCWoRMS/branches/coolemall/src/simulator
- Timestamp:
- 03/19/14 18:22:27 (11 years ago)
- Location:
- DCWoRMS/branches/coolemall/src/simulator
- Files:
-
- 1 added
- 5 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/branches/coolemall/src/simulator/ConfigurationOptions.java
r1279 r1299 8 8 import java.util.PropertyResourceBundle; 9 9 import java.util.ResourceBundle; 10 11 import test.CoolingModelData; 10 12 11 13 /** … … 189 191 public String [] resForUtilizationChart; 190 192 191 public static double pressureDrop; 192 public static double outletRoomAirTempeature; 193 public static double inletRoomAirTempeature; 194 public static double ambientAirTempeature; 195 public static double airFlowVolume; 196 public static double alpha 197 ; 193 public double pressureDrop; 194 public double outletRoomAirTempeature; 195 public double inletRoomAirTempeature; 196 public double ambientAirTempeature; 197 public double airFlowVolume; 198 public double alpha; 199 200 public static CoolingModelData coolingData; 198 201 /** 199 202 * An empty constructor. … … 389 392 390 393 try { 391 ConfigurationOptions.pressureDrop = Double.valueOf(bundle.getString(PRESSURE_DROP)).doubleValue(); 392 } catch(MissingResourceException e){ 393 ConfigurationOptions.pressureDrop = 65; 394 } 395 396 try { 397 ConfigurationOptions.outletRoomAirTempeature = Double.valueOf(bundle.getString(OUTLET_ROOM_AIR_TEMPERATURE)).doubleValue(); 398 } catch(MissingResourceException e){ 399 ConfigurationOptions.outletRoomAirTempeature = 23; 400 } 401 402 try { 403 ConfigurationOptions.inletRoomAirTempeature = Double.valueOf(bundle.getString(INLET_ROOM_AIR_TEMPERATURE)).doubleValue(); 404 } catch(MissingResourceException e){ 405 ConfigurationOptions.inletRoomAirTempeature = 17; 406 } 407 408 try { 409 ConfigurationOptions.ambientAirTempeature = Double.valueOf(bundle.getString(AMBIENT_AIR_TEMPERATURE)).doubleValue(); 410 } catch(MissingResourceException e){ 411 ConfigurationOptions.ambientAirTempeature = 17; 412 } 413 414 try { 415 ConfigurationOptions.airFlowVolume = Double.valueOf(bundle.getString(AIR_FLOW_VOLUME)).doubleValue(); 416 } catch(MissingResourceException e){ 417 ConfigurationOptions.airFlowVolume = 4; 418 } 419 420 try { 421 ConfigurationOptions.alpha = Double.valueOf(bundle.getString(ALPHA)).doubleValue(); 422 } catch(MissingResourceException e){ 423 ConfigurationOptions.alpha = 0.2; 424 } 425 394 co.pressureDrop = Double.valueOf(bundle.getString(PRESSURE_DROP)).doubleValue(); 395 } catch(MissingResourceException e){ 396 co.pressureDrop = -1; 397 } 398 399 try { 400 co.outletRoomAirTempeature = Double.valueOf(bundle.getString(OUTLET_ROOM_AIR_TEMPERATURE)).doubleValue(); 401 } catch(MissingResourceException e){ 402 co.outletRoomAirTempeature = -1; 403 } 404 405 try { 406 co.inletRoomAirTempeature = Double.valueOf(bundle.getString(INLET_ROOM_AIR_TEMPERATURE)).doubleValue(); 407 } catch(MissingResourceException e){ 408 co.inletRoomAirTempeature = -1; 409 } 410 411 try { 412 co.ambientAirTempeature = Double.valueOf(bundle.getString(AMBIENT_AIR_TEMPERATURE)).doubleValue(); 413 } catch(MissingResourceException e){ 414 co.ambientAirTempeature = -1; 415 } 416 417 try { 418 co.airFlowVolume = Double.valueOf(bundle.getString(AIR_FLOW_VOLUME)).doubleValue(); 419 } catch(MissingResourceException e){ 420 co.airFlowVolume = -1; 421 } 422 423 try { 424 co.alpha = Double.valueOf(bundle.getString(ALPHA)).doubleValue(); 425 } catch(MissingResourceException e){ 426 co.alpha = -1; 427 } 428 429 ConfigurationOptions.coolingData = new CoolingModelData(co.pressureDrop, co.outletRoomAirTempeature, co.inletRoomAirTempeature, co.ambientAirTempeature, co.airFlowVolume, co.alpha); 426 430 return co; 427 431 } -
DCWoRMS/branches/coolemall/src/simulator/DCWormsUsers.java
r1207 r1299 74 74 sendJobsIds = new HashSet<String>(); 75 75 returnedJobsIds = new HashSet<String>(); 76 76 returnedJobs = new ArrayList<JobInterface<?>>(); 77 77 this.xsltTransformer = new XsltTransformations(); 78 78 } … … 80 80 @Override 81 81 public void body() { 82 sendJobs(); 83 collectJobs(); 82 if(workloadLoader != null){ 83 sendJobs(); 84 collectJobs(); 85 } else { 86 submissionStartTime = 0; 87 } 84 88 85 89 //GridSim dependent code for shutting down the simulation … … 93 97 */ 94 98 protected void collectJobs() { 95 final int FACTOR = Math.min(10 , workloadLoader.getTaskCount()); //the refresh rate of the gauge: at most 10 times99 final int FACTOR = Math.min(100, workloadLoader.getTaskCount() > 0 ? workloadLoader.getTaskCount() : 1); //the refresh rate of the gauge: at most 10 times 96 100 final int denominator = workloadLoader.getTaskCount() / FACTOR; 97 101 allTasksAreFinished = true; 98 returnedJobs = new ArrayList<JobInterface<?>>();99 102 int counter = 0; 100 103 int oldRemeinder = 0; … … 244 247 245 248 public List<JobDescription> getAllSentJobs() { 249 if (workloadLoader == null) 250 return new ArrayList<JobDescription>(); 246 251 return (List<JobDescription>) workloadLoader.getJobs(); 247 252 } … … 349 354 350 355 public boolean isSimStartTimeDefined(){ 356 if(workloadLoader == null){ 357 return false; 358 } 351 359 return workloadLoader.isSimStartTimeDefined(); 352 360 } -
DCWoRMS/branches/coolemall/src/simulator/DataCenterWorkloadSimulator.java
r1207 r1299 21 21 import org.joda.time.DateTimeUtilsExt; 22 22 23 import schedframe.Initializable;24 23 import schedframe.SimulatedEnvironment; 25 24 import simulator.reader.ResourceReader; … … 252 251 // (default 1) 253 252 254 Date date = workload.getSimulationStartTime();255 253 Calendar calendar = Calendar.getInstance(); 256 if (date == null)254 if(workload == null){ 257 255 calendar.setTimeInMillis(0L); 258 else 259 calendar.setTime(date); 256 } else { 257 Date date = workload.getSimulationStartTime(); 258 if (date == null) 259 calendar.setTimeInMillis(0L); 260 else 261 calendar.setTime(date); 262 } 263 260 264 261 265 boolean traceFlag = true; // means: trace GridSim events/activities … … 268 272 ResourceReader resourceReader = new ResourceReader( 269 273 options.resdescFileName); 270 SimulatedEnvironment rc = resourceReader.read(); 271 eventManager = new EventManager("eventManager", rc); 272 273 for(Initializable initObj: rc.getToInit()){ 274 SimulatedEnvironment simEnv = resourceReader.read(); 275 276 eventManager = new EventManager("eventManager", simEnv); 277 278 /*for(Initializable initObj: rc.getToInit()){ 274 279 initObj.initiate(); 275 280 } 276 rc.setInitList(null); 281 rc.setInitList(null);*/ 277 282 278 283 DCWormsUsers users = new DCWormsUsers("Users", 279 rc.getScheduler().get_name(), workload);284 simEnv.getScheduler().get_name(), workload); 280 285 281 286 System.out.println("Starting simulation..."); … … 287 292 288 293 DCWormsStatistics stats = new DCWormsStatistics(simulationIdentifier, 289 options, users, statsOutputPath, rc);294 options, users, statsOutputPath, simEnv); 290 295 accumulatedStatistics.add(stats); 291 296 if (log.isInfoEnabled()) … … 309 314 private WorkloadLoader loadWorkload(ConfigurationOptions options) throws IOException, MarshalException, ValidationException{ 310 315 XMLJobReader<org.qcg.broker.schemas.jobdesc.Job> xmlJobReader = null; 311 WAReader<org.qcg.broker.schemas.jobdesc.Job> swfReader = null;316 WAReader<org.qcg.broker.schemas.jobdesc.Job> workloadReader = null; 312 317 313 318 String wlFileName = options.inputWorkloadFileName; 314 319 315 String appProfilesFolder = options.appProfilesFolder; 320 if(wlFileName == null){ 321 return null; 322 } 323 316 324 if (options.inputFolder != null) { 317 File f = null; 318 if (options.inputTar != null) { 319 f = new File(options.inputFolder + File.separator 320 + options.inputTar); 321 } else { 322 f = new File(options.inputFolder); 323 } 324 325 File f = new File(options.inputFolder); 325 326 xmlJobReader = new QcgXmlJobReader(f); 326 327 … … 329 330 } 330 331 331 swfReader = AbstractWAReader.getInstace(wlFileName); 332 333 WorkloadLoader workload = new WorkloadLoader(xmlJobReader, swfReader, appProfilesFolder); 332 workloadReader = AbstractWAReader.getInstace(wlFileName); 333 334 String appProfilesFolderName = options.appProfilesFolder; 335 336 WorkloadLoader workload = new WorkloadLoader(xmlJobReader, workloadReader, appProfilesFolderName); 334 337 workload.load(); 335 338 -
DCWoRMS/branches/coolemall/src/simulator/stats/AbstractMetricsCalculator.java
r1207 r1299 7 7 8 8 import simulator.stats.implementation.MetricsStats; 9 import example.energy.coolemall.CoolEmAllTestbedMeasurements;10 9 11 public class MetricsCalculator{10 public abstract class AbstractMetricsCalculator implements MetricsCalculator{ 12 11 13 12 protected static final double MILLI_SEC = 1000; … … 15 14 16 15 protected Map<String, List<GSSAccumulator>> metricsData = new HashMap<String, List<GSSAccumulator>>(); 17 protected long timestamp; 16 18 17 protected long startTime; 19 18 protected long endTime; 20 21 public List<MetricsStats> calulateMetrics(long timestamp){ 19 protected long timestamp; 20 21 public AbstractMetricsCalculator(long startTime, long endTime, long timestamp) { 22 super(); 23 this.startTime = startTime; 24 this.endTime = endTime; 22 25 this.timestamp = timestamp; 23 List<MetricsStats> metrics = new ArrayList<MetricsStats>();24 /*for(String resourceTypeName: metricsData.keySet()){25 MetricsStats metric = new MetricsStats(resourceTypeName, "energyUsage", metricsData.get(resourceTypeName).getMax());26 metrics.add(metric);}27 }*/28 metrics.add(calculateITComputingEnergyConsumption());29 metrics.add(calculateITEnergyConsumption());30 metrics.add(calculateNodeGroupFansEnergyConsumption());31 32 metrics.add(calculateRackEnergyConsumption());33 metrics.add(calculateDataCenterFansEnergyConsumption());34 metrics.add(calculateCoolingDeviceEnergyConsumption());35 metrics.add(calculateOtherDevicesEnergyConsumption());36 37 metrics.add(calculateTotalEnergyConsumption());38 39 metrics.add(calculateMeanRackPower());40 metrics.add(calculateMeanPower());41 metrics.add(calculateMaxRackPower());42 metrics.add(calculateMaxPower());43 44 metrics.add(calculatePUE());45 metrics.add(calculatePUELevel4());46 metrics.add(calculateEnergyWasteRate());47 48 metrics.add(calculateUsefulWork());49 metrics.add(calculateProductivity());50 51 return metrics;52 26 } 27 28 abstract public List<MetricsStats> calulateMetrics(); 53 29 54 30 public void addMetricsData(String resourceTypeName, GSSAccumulator resourceEnergyAccumulator){ … … 64 40 return metricsData; 65 41 } 66 67 private MetricsStats calculateTotalEnergyConsumption(){68 69 MetricsStats metric;70 try{71 72 double roomPower = 0;73 for(GSSAccumulator acc: metricsData.get("Room")){74 roomPower = roomPower + acc.getSum();75 }76 metric = new MetricsStats("CoolEmAllTestbed", "Total_energy_consumption", roomPower, timestamp, "Wh");77 } catch (Exception e){78 metric = new MetricsStats("CoolEmAllTestbed", "Total_energy_consumption", -1, timestamp, "Wh");79 }80 return metric;81 }82 83 private MetricsStats calculateITComputingEnergyConsumption(){84 85 MetricsStats metric;86 try{87 double itComputingPower = 0;88 for(GSSAccumulator acc: metricsData.get("Processor")){89 itComputingPower = itComputingPower + acc.getSum();90 }91 metric = new MetricsStats("CoolEmAllTestbed", "Total_processors_energy_consumption", (itComputingPower), timestamp, "Wh");92 } catch (Exception e){93 metric = new MetricsStats("CoolEmAllTestbed", "Total_processors_energy_consumption", -1, timestamp, "Wh");94 }95 return metric;96 }97 98 private MetricsStats calculateITEnergyConsumption(){99 100 MetricsStats metric;101 try{102 double totalSitePower = 0;103 for(GSSAccumulator acc: metricsData.get("Rack")){104 totalSitePower = totalSitePower + acc.getSum();105 }106 double nodeComputingPower = 0;107 for(GSSAccumulator acc: metricsData.get("Node")){108 nodeComputingPower = nodeComputingPower+ acc.getSum();109 }110 double itComputingPower = 0;111 for(GSSAccumulator acc: metricsData.get("Processor")){112 itComputingPower = itComputingPower + acc.getSum();113 }114 double fanPowerConumspion = nodeComputingPower - itComputingPower;115 metric = new MetricsStats("CoolEmAllTestbed", "Total_IT_energy_consumption", (totalSitePower * CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY - fanPowerConumspion), timestamp, "Wh");116 } catch (Exception e){117 metric = new MetricsStats("CoolEmAllTestbed", "Total_IT_energy_consumption", -1, timestamp, "Wh");118 }119 return metric;120 }121 122 private MetricsStats calculateNodeGroupFansEnergyConsumption(){123 124 MetricsStats metric;125 try{126 double nodeComputingPower = 0;127 for(GSSAccumulator acc: metricsData.get("Node")){128 nodeComputingPower = nodeComputingPower+ acc.getSum();129 }130 double itComputingPower = 0;131 for(GSSAccumulator acc: metricsData.get("Processor")){132 itComputingPower = itComputingPower + acc.getSum();133 }134 double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;135 metric = new MetricsStats("CoolEmAllTestbed", "Total_node_group_fans_energy_consumption", nodeGroupFansPowerConumspion, timestamp, "Wh");136 } catch (Exception e){137 metric = new MetricsStats("CoolEmAllTestbed", "Total_node_group_fans_energy_consumption", -1, timestamp, "Wh");138 }139 return metric;140 }141 142 private MetricsStats calculatePUELevel4(){143 144 MetricsStats metric;145 try{146 147 double roomPower = 0;148 for(GSSAccumulator acc: metricsData.get("Room")){149 roomPower = roomPower + acc.getSum();150 }151 152 double totalSitePower = 0;153 for(GSSAccumulator acc: metricsData.get("Rack")){154 totalSitePower = totalSitePower + acc.getSum();155 }156 157 158 double nodeComputingPower = 0;159 for(GSSAccumulator acc: metricsData.get("Node")){160 nodeComputingPower = nodeComputingPower+ acc.getSum();161 }162 double itComputingPower = 0;163 for(GSSAccumulator acc: metricsData.get("Processor")){164 itComputingPower = itComputingPower + acc.getSum();165 }166 double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;167 42 168 metric = new MetricsStats("CoolEmAllTestbed", "PUE_Level_4", roomPower/(totalSitePower * CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY - nodeGroupFansPowerConumspion), timestamp, "");169 } catch (Exception e){170 metric = new MetricsStats("CoolEmAllTestbed", "PUE_Level_4", -1, timestamp, "");171 }172 return metric;173 }174 175 private MetricsStats calculatePUE(){176 177 MetricsStats metric;178 try{179 180 double roomPower = 0;181 for(GSSAccumulator acc: metricsData.get("Room")){182 roomPower = roomPower + acc.getSum();183 }184 185 double totalSitePower = 0;186 for(GSSAccumulator acc: metricsData.get("Rack")){187 totalSitePower = totalSitePower + acc.getSum();188 }189 190 191 metric = new MetricsStats("CoolEmAllTestbed", "PUE", roomPower/totalSitePower, timestamp, "");192 } catch (Exception e){193 metric = new MetricsStats("CoolEmAllTestbed", "PUE", -1, timestamp, "");194 }195 return metric;196 }197 198 private MetricsStats calculateUsefulWork(){199 200 MetricsStats metric;201 try{202 double usefulWork = 0;203 for(String key: metricsData.keySet()){204 if(key.contains("/")){205 for(GSSAccumulator acc: metricsData.get(key)){206 usefulWork= usefulWork + acc.getSum();207 }208 }209 }210 metric = new MetricsStats("CoolEmAllTestbed", "Useful_Work", usefulWork, timestamp, "UW units");211 } catch (Exception e){212 metric = new MetricsStats("CoolEmAllTestbed", "Useful_Work", -1, timestamp, "UW units");213 }214 215 return metric;216 }217 218 private MetricsStats calculateProductivity(){219 220 MetricsStats metric;221 try{222 double usefulWork = 0;223 for(String key: metricsData.keySet()){224 if(key.contains("/")){225 for(GSSAccumulator acc: metricsData.get(key)){226 usefulWork= usefulWork + acc.getSum();227 }228 }229 }230 double totalSitePower = 0;231 for(GSSAccumulator acc: metricsData.get("Rack")){232 totalSitePower = totalSitePower + acc.getSum();233 }234 235 metric = new MetricsStats("CoolEmAllTestbed", "Productivity", usefulWork/totalSitePower, timestamp, "UW units/Wh");236 } catch (Exception e){237 metric = new MetricsStats("CoolEmAllTestbed", "Productivity", -1, timestamp, "UW units/Wh");238 }239 240 return metric;241 }242 243 244 private MetricsStats calculateMaxRackPower(){245 246 MetricsStats metric;247 try{248 double maxPower = 0;249 250 for(GSSAccumulator acc: metricsData.get("Rack_MAX")){251 maxPower = maxPower + acc.getSum();252 }253 254 metric = new MetricsStats("CoolEmAllTestbed", "Max_rack_power", maxPower, timestamp, "W");255 } catch (Exception e){256 metric = new MetricsStats("CoolEmAllTestbed", "Max_rack_power", -1, timestamp, "W");257 }258 259 return metric;260 }261 262 private MetricsStats calculateMaxPower(){263 264 MetricsStats metric;265 try{266 double maxPower = 0;267 268 for(GSSAccumulator acc: metricsData.get("Room_MAX")){269 maxPower = maxPower + acc.getSum();270 }271 272 metric = new MetricsStats("CoolEmAllTestbed", "Max_power", maxPower, timestamp, "W");273 } catch (Exception e){274 metric = new MetricsStats("CoolEmAllTestbed", "Max_power", -1, timestamp, "W");275 }276 277 return metric;278 }279 280 private MetricsStats calculateDataCenterFansEnergyConsumption(){281 282 MetricsStats metric;283 try{284 double inletsPower = 0;285 for(GSSAccumulator acc: metricsData.get("Inlet")){286 inletsPower = inletsPower + acc.getSum();287 }288 289 double outletsPower = 0;290 for(GSSAccumulator acc: metricsData.get("Outlet")){291 outletsPower = outletsPower + acc.getSum();292 }293 294 double nodeComputingPower = 0;295 for(GSSAccumulator acc: metricsData.get("Node")){296 nodeComputingPower = nodeComputingPower+ acc.getSum();297 }298 double itComputingPower = 0;299 for(GSSAccumulator acc: metricsData.get("Processor")){300 itComputingPower = itComputingPower + acc.getSum();301 }302 double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;303 304 metric = new MetricsStats("CoolEmAllTestbed", "Total_data_center_fans_energy_consumption", (inletsPower + outletsPower - nodeGroupFansPowerConumspion), timestamp, "Wh");305 } catch (Exception e){306 metric = new MetricsStats("CoolEmAllTestbed", "Total_data_center_fans_energy_consumption", -1, timestamp, "Wh");307 }308 return metric;309 }310 311 312 private MetricsStats calculateRackEnergyConsumption(){313 314 MetricsStats metric;315 try{316 double roomPower = 0;317 for(GSSAccumulator acc: metricsData.get("Rack")){318 roomPower = roomPower + acc.getSum();319 }320 metric = new MetricsStats("CoolEmAllTestbed", "Total_rack_energy_consumption", roomPower, timestamp, "Wh");321 } catch (Exception e){322 metric = new MetricsStats("CoolEmAllTestbed", "Total_rack_device_consumption", -1, timestamp, "Wh");323 }324 return metric;325 }326 327 private MetricsStats calculateCoolingDeviceEnergyConsumption(){328 329 MetricsStats metric;330 try{331 double coolingDevicePower = 0;332 for(GSSAccumulator acc: metricsData.get("CoolingDevice")){333 coolingDevicePower = coolingDevicePower + acc.getSum();334 }335 metric = new MetricsStats("CoolEmAllTestbed", "Total_cooling_device_energy_consumption", coolingDevicePower, timestamp, "Wh");336 } catch (Exception e){337 metric = new MetricsStats("CoolEmAllTestbed", "Total_cooling_device_consumption", -1, timestamp, "Wh");338 }339 return metric;340 }341 342 private MetricsStats calculateOtherDevicesEnergyConsumption(){343 344 MetricsStats metric;345 try{346 double roomPower = 0;347 for(GSSAccumulator acc: metricsData.get("Room")){348 roomPower = roomPower + acc.getSum();349 }350 351 double totalSitePower = 0;352 for(GSSAccumulator acc: metricsData.get("Rack")){353 totalSitePower = totalSitePower + acc.getSum();354 }355 356 double coolingDevicePower = 0;357 for(GSSAccumulator acc: metricsData.get("CoolingDevice")){358 coolingDevicePower = coolingDevicePower + acc.getSum();359 }360 361 double inletsPower = 0;362 for(GSSAccumulator acc: metricsData.get("Inlet")){363 inletsPower = inletsPower + acc.getSum();364 }365 366 double outletsPower = 0;367 for(GSSAccumulator acc: metricsData.get("Outlet")){368 outletsPower = outletsPower + acc.getSum();369 }370 371 double nodeComputingPower = 0;372 for(GSSAccumulator acc: metricsData.get("Node")){373 nodeComputingPower = nodeComputingPower+ acc.getSum();374 }375 double itComputingPower = 0;376 for(GSSAccumulator acc: metricsData.get("Processor")){377 itComputingPower = itComputingPower + acc.getSum();378 }379 double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;380 381 metric = new MetricsStats("CoolEmAllTestbed", "Total_other_devices_energy_consumption", roomPower - (totalSitePower + coolingDevicePower + (inletsPower + outletsPower - nodeGroupFansPowerConumspion)), timestamp, "Wh");382 } catch (Exception e){383 metric = new MetricsStats("CoolEmAllTestbed", "Total_other_devices_consumption", -1, timestamp, "Wh");384 }385 return metric;386 }387 388 389 private MetricsStats calculateMeanPower(){390 391 MetricsStats metric;392 try{393 394 double roomPower = 0;395 for(GSSAccumulator acc: metricsData.get("Room")){396 roomPower = roomPower + acc.getSum();397 }398 metric = new MetricsStats("CoolEmAllTestbed", "Mean_power", roomPower/((this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC)), timestamp, "W");399 } catch (Exception e){400 metric = new MetricsStats("CoolEmAllTestbed", "Mean_power", -1, timestamp, "W");401 }402 return metric;403 }404 405 406 private MetricsStats calculateMeanRackPower(){407 408 MetricsStats metric;409 try{410 411 double roomPower = 0;412 for(GSSAccumulator acc: metricsData.get("Rack")){413 roomPower = roomPower + acc.getSum();414 }415 metric = new MetricsStats("CoolEmAllTestbed", "Mean_rack_power", roomPower/((this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC)), timestamp, "W");416 } catch (Exception e){417 metric = new MetricsStats("CoolEmAllTestbed", "Mean_rack_power", -1, timestamp, "W");418 }419 return metric;420 }421 422 private MetricsStats calculateEnergyWasteRate(){423 424 MetricsStats metric;425 try{426 double itComputingEnergy = 0;427 for(GSSAccumulator acc: metricsData.get("Processor_CALC")){428 itComputingEnergy = itComputingEnergy + acc.getSum();429 }430 itComputingEnergy = itComputingEnergy + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION * (this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC);431 double itEnergy = calculateITEnergyConsumption().getValue();432 433 metric = new MetricsStats("CoolEmAllTestbed", "Energy_waste_rate", (1 - itComputingEnergy/itEnergy) * 100, timestamp, "%");434 } catch (Exception e){435 metric = new MetricsStats("CoolEmAllTestbed", "Energy_waste_rate", -1, timestamp, "%");436 }437 return metric;438 }439 440 public long getStartTime() {441 return startTime;442 }443 444 public void setStartTime(long startTime) {445 this.startTime = startTime;446 }447 448 public long getEndTime() {449 return endTime;450 }451 452 public void setEndTime(long endTime) {453 this.endTime = endTime;454 }455 43 } -
DCWoRMS/branches/coolemall/src/simulator/stats/MetricsCalculator.java
r1207 r1299 1 1 package simulator.stats; 2 2 3 import java.util.ArrayList;4 import java.util.HashMap;5 3 import java.util.List; 6 4 import java.util.Map; 7 5 8 6 import simulator.stats.implementation.MetricsStats; 9 import example.energy.coolemall.CoolEmAllTestbedMeasurements;10 7 11 public classMetricsCalculator {8 public interface MetricsCalculator { 12 9 13 protected static final double MILLI_SEC = 1000; 14 protected static final double SEC_IN_HOUR = 3600; 10 public List<MetricsStats> calulateMetrics(); 15 11 16 protected Map<String, List<GSSAccumulator>> metricsData = new HashMap<String, List<GSSAccumulator>>(); 17 protected long timestamp; 18 protected long startTime; 19 protected long endTime; 20 21 public List<MetricsStats> calulateMetrics(long timestamp){ 22 this.timestamp = timestamp; 23 List<MetricsStats> metrics = new ArrayList<MetricsStats>(); 24 /*for(String resourceTypeName: metricsData.keySet()){ 25 MetricsStats metric = new MetricsStats(resourceTypeName, "energyUsage", metricsData.get(resourceTypeName).getMax()); 26 metrics.add(metric);} 27 }*/ 28 metrics.add(calculateITComputingEnergyConsumption()); 29 metrics.add(calculateITEnergyConsumption()); 30 metrics.add(calculateNodeGroupFansEnergyConsumption()); 31 32 metrics.add(calculateRackEnergyConsumption()); 33 metrics.add(calculateDataCenterFansEnergyConsumption()); 34 metrics.add(calculateCoolingDeviceEnergyConsumption()); 35 metrics.add(calculateOtherDevicesEnergyConsumption()); 36 37 metrics.add(calculateTotalEnergyConsumption()); 38 39 metrics.add(calculateMeanRackPower()); 40 metrics.add(calculateMeanPower()); 41 metrics.add(calculateMaxRackPower()); 42 metrics.add(calculateMaxPower()); 43 44 metrics.add(calculatePUE()); 45 metrics.add(calculatePUELevel4()); 46 metrics.add(calculateEnergyWasteRate()); 47 48 metrics.add(calculateUsefulWork()); 49 metrics.add(calculateProductivity()); 50 51 return metrics; 52 } 12 public void addMetricsData(String resourceTypeName, GSSAccumulator resourceEnergyAccumulator); 53 13 54 public void addMetricsData(String resourceTypeName, GSSAccumulator resourceEnergyAccumulator){ 55 List<GSSAccumulator> resourceEnergyAccumulatorList = metricsData.get(resourceTypeName); 56 if(resourceEnergyAccumulatorList == null){ 57 resourceEnergyAccumulatorList = new ArrayList<GSSAccumulator>(); 58 } 59 resourceEnergyAccumulatorList.add(resourceEnergyAccumulator); 60 metricsData.put(resourceTypeName, resourceEnergyAccumulatorList); 61 } 14 public Map<String, List<GSSAccumulator>> getMetricsData(); 62 15 63 public Map<String, List<GSSAccumulator>> getMetricsData(){64 return metricsData;65 }66 67 private MetricsStats calculateTotalEnergyConsumption(){68 69 MetricsStats metric;70 try{71 72 double roomPower = 0;73 for(GSSAccumulator acc: metricsData.get("Room")){74 roomPower = roomPower + acc.getSum();75 }76 metric = new MetricsStats("CoolEmAllTestbed", "Total_energy_consumption", roomPower, timestamp, "Wh");77 } catch (Exception e){78 metric = new MetricsStats("CoolEmAllTestbed", "Total_energy_consumption", -1, timestamp, "Wh");79 }80 return metric;81 }82 83 private MetricsStats calculateITComputingEnergyConsumption(){84 85 MetricsStats metric;86 try{87 double itComputingPower = 0;88 for(GSSAccumulator acc: metricsData.get("Processor")){89 itComputingPower = itComputingPower + acc.getSum();90 }91 metric = new MetricsStats("CoolEmAllTestbed", "Total_processors_energy_consumption", (itComputingPower), timestamp, "Wh");92 } catch (Exception e){93 metric = new MetricsStats("CoolEmAllTestbed", "Total_processors_energy_consumption", -1, timestamp, "Wh");94 }95 return metric;96 }97 98 private MetricsStats calculateITEnergyConsumption(){99 100 MetricsStats metric;101 try{102 double totalSitePower = 0;103 for(GSSAccumulator acc: metricsData.get("Rack")){104 totalSitePower = totalSitePower + acc.getSum();105 }106 double nodeComputingPower = 0;107 for(GSSAccumulator acc: metricsData.get("Node")){108 nodeComputingPower = nodeComputingPower+ acc.getSum();109 }110 double itComputingPower = 0;111 for(GSSAccumulator acc: metricsData.get("Processor")){112 itComputingPower = itComputingPower + acc.getSum();113 }114 double fanPowerConumspion = nodeComputingPower - itComputingPower;115 metric = new MetricsStats("CoolEmAllTestbed", "Total_IT_energy_consumption", (totalSitePower * CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY - fanPowerConumspion), timestamp, "Wh");116 } catch (Exception e){117 metric = new MetricsStats("CoolEmAllTestbed", "Total_IT_energy_consumption", -1, timestamp, "Wh");118 }119 return metric;120 }121 122 private MetricsStats calculateNodeGroupFansEnergyConsumption(){123 124 MetricsStats metric;125 try{126 double nodeComputingPower = 0;127 for(GSSAccumulator acc: metricsData.get("Node")){128 nodeComputingPower = nodeComputingPower+ acc.getSum();129 }130 double itComputingPower = 0;131 for(GSSAccumulator acc: metricsData.get("Processor")){132 itComputingPower = itComputingPower + acc.getSum();133 }134 double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;135 metric = new MetricsStats("CoolEmAllTestbed", "Total_node_group_fans_energy_consumption", nodeGroupFansPowerConumspion, timestamp, "Wh");136 } catch (Exception e){137 metric = new MetricsStats("CoolEmAllTestbed", "Total_node_group_fans_energy_consumption", -1, timestamp, "Wh");138 }139 return metric;140 }141 142 private MetricsStats calculatePUELevel4(){143 144 MetricsStats metric;145 try{146 147 double roomPower = 0;148 for(GSSAccumulator acc: metricsData.get("Room")){149 roomPower = roomPower + acc.getSum();150 }151 152 double totalSitePower = 0;153 for(GSSAccumulator acc: metricsData.get("Rack")){154 totalSitePower = totalSitePower + acc.getSum();155 }156 157 158 double nodeComputingPower = 0;159 for(GSSAccumulator acc: metricsData.get("Node")){160 nodeComputingPower = nodeComputingPower+ acc.getSum();161 }162 double itComputingPower = 0;163 for(GSSAccumulator acc: metricsData.get("Processor")){164 itComputingPower = itComputingPower + acc.getSum();165 }166 double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;167 168 metric = new MetricsStats("CoolEmAllTestbed", "PUE_Level_4", roomPower/(totalSitePower * CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY - nodeGroupFansPowerConumspion), timestamp, "");169 } catch (Exception e){170 metric = new MetricsStats("CoolEmAllTestbed", "PUE_Level_4", -1, timestamp, "");171 }172 return metric;173 }174 175 private MetricsStats calculatePUE(){176 177 MetricsStats metric;178 try{179 180 double roomPower = 0;181 for(GSSAccumulator acc: metricsData.get("Room")){182 roomPower = roomPower + acc.getSum();183 }184 185 double totalSitePower = 0;186 for(GSSAccumulator acc: metricsData.get("Rack")){187 totalSitePower = totalSitePower + acc.getSum();188 }189 190 191 metric = new MetricsStats("CoolEmAllTestbed", "PUE", roomPower/totalSitePower, timestamp, "");192 } catch (Exception e){193 metric = new MetricsStats("CoolEmAllTestbed", "PUE", -1, timestamp, "");194 }195 return metric;196 }197 198 private MetricsStats calculateUsefulWork(){199 200 MetricsStats metric;201 try{202 double usefulWork = 0;203 for(String key: metricsData.keySet()){204 if(key.contains("/")){205 for(GSSAccumulator acc: metricsData.get(key)){206 usefulWork= usefulWork + acc.getSum();207 }208 }209 }210 metric = new MetricsStats("CoolEmAllTestbed", "Useful_Work", usefulWork, timestamp, "UW units");211 } catch (Exception e){212 metric = new MetricsStats("CoolEmAllTestbed", "Useful_Work", -1, timestamp, "UW units");213 }214 215 return metric;216 }217 218 private MetricsStats calculateProductivity(){219 220 MetricsStats metric;221 try{222 double usefulWork = 0;223 for(String key: metricsData.keySet()){224 if(key.contains("/")){225 for(GSSAccumulator acc: metricsData.get(key)){226 usefulWork= usefulWork + acc.getSum();227 }228 }229 }230 double totalSitePower = 0;231 for(GSSAccumulator acc: metricsData.get("Rack")){232 totalSitePower = totalSitePower + acc.getSum();233 }234 235 metric = new MetricsStats("CoolEmAllTestbed", "Productivity", usefulWork/totalSitePower, timestamp, "UW units/Wh");236 } catch (Exception e){237 metric = new MetricsStats("CoolEmAllTestbed", "Productivity", -1, timestamp, "UW units/Wh");238 }239 240 return metric;241 }242 243 244 private MetricsStats calculateMaxRackPower(){245 246 MetricsStats metric;247 try{248 double maxPower = 0;249 250 for(GSSAccumulator acc: metricsData.get("Rack_MAX")){251 maxPower = maxPower + acc.getSum();252 }253 254 metric = new MetricsStats("CoolEmAllTestbed", "Max_rack_power", maxPower, timestamp, "W");255 } catch (Exception e){256 metric = new MetricsStats("CoolEmAllTestbed", "Max_rack_power", -1, timestamp, "W");257 }258 259 return metric;260 }261 262 private MetricsStats calculateMaxPower(){263 264 MetricsStats metric;265 try{266 double maxPower = 0;267 268 for(GSSAccumulator acc: metricsData.get("Room_MAX")){269 maxPower = maxPower + acc.getSum();270 }271 272 metric = new MetricsStats("CoolEmAllTestbed", "Max_power", maxPower, timestamp, "W");273 } catch (Exception e){274 metric = new MetricsStats("CoolEmAllTestbed", "Max_power", -1, timestamp, "W");275 }276 277 return metric;278 }279 280 private MetricsStats calculateDataCenterFansEnergyConsumption(){281 282 MetricsStats metric;283 try{284 double inletsPower = 0;285 for(GSSAccumulator acc: metricsData.get("Inlet")){286 inletsPower = inletsPower + acc.getSum();287 }288 289 double outletsPower = 0;290 for(GSSAccumulator acc: metricsData.get("Outlet")){291 outletsPower = outletsPower + acc.getSum();292 }293 294 double nodeComputingPower = 0;295 for(GSSAccumulator acc: metricsData.get("Node")){296 nodeComputingPower = nodeComputingPower+ acc.getSum();297 }298 double itComputingPower = 0;299 for(GSSAccumulator acc: metricsData.get("Processor")){300 itComputingPower = itComputingPower + acc.getSum();301 }302 double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;303 304 metric = new MetricsStats("CoolEmAllTestbed", "Total_data_center_fans_energy_consumption", (inletsPower + outletsPower - nodeGroupFansPowerConumspion), timestamp, "Wh");305 } catch (Exception e){306 metric = new MetricsStats("CoolEmAllTestbed", "Total_data_center_fans_energy_consumption", -1, timestamp, "Wh");307 }308 return metric;309 }310 311 312 private MetricsStats calculateRackEnergyConsumption(){313 314 MetricsStats metric;315 try{316 double roomPower = 0;317 for(GSSAccumulator acc: metricsData.get("Rack")){318 roomPower = roomPower + acc.getSum();319 }320 metric = new MetricsStats("CoolEmAllTestbed", "Total_rack_energy_consumption", roomPower, timestamp, "Wh");321 } catch (Exception e){322 metric = new MetricsStats("CoolEmAllTestbed", "Total_rack_device_consumption", -1, timestamp, "Wh");323 }324 return metric;325 }326 327 private MetricsStats calculateCoolingDeviceEnergyConsumption(){328 329 MetricsStats metric;330 try{331 double coolingDevicePower = 0;332 for(GSSAccumulator acc: metricsData.get("CoolingDevice")){333 coolingDevicePower = coolingDevicePower + acc.getSum();334 }335 metric = new MetricsStats("CoolEmAllTestbed", "Total_cooling_device_energy_consumption", coolingDevicePower, timestamp, "Wh");336 } catch (Exception e){337 metric = new MetricsStats("CoolEmAllTestbed", "Total_cooling_device_consumption", -1, timestamp, "Wh");338 }339 return metric;340 }341 342 private MetricsStats calculateOtherDevicesEnergyConsumption(){343 344 MetricsStats metric;345 try{346 double roomPower = 0;347 for(GSSAccumulator acc: metricsData.get("Room")){348 roomPower = roomPower + acc.getSum();349 }350 351 double totalSitePower = 0;352 for(GSSAccumulator acc: metricsData.get("Rack")){353 totalSitePower = totalSitePower + acc.getSum();354 }355 356 double coolingDevicePower = 0;357 for(GSSAccumulator acc: metricsData.get("CoolingDevice")){358 coolingDevicePower = coolingDevicePower + acc.getSum();359 }360 361 double inletsPower = 0;362 for(GSSAccumulator acc: metricsData.get("Inlet")){363 inletsPower = inletsPower + acc.getSum();364 }365 366 double outletsPower = 0;367 for(GSSAccumulator acc: metricsData.get("Outlet")){368 outletsPower = outletsPower + acc.getSum();369 }370 371 double nodeComputingPower = 0;372 for(GSSAccumulator acc: metricsData.get("Node")){373 nodeComputingPower = nodeComputingPower+ acc.getSum();374 }375 double itComputingPower = 0;376 for(GSSAccumulator acc: metricsData.get("Processor")){377 itComputingPower = itComputingPower + acc.getSum();378 }379 double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower;380 381 metric = new MetricsStats("CoolEmAllTestbed", "Total_other_devices_energy_consumption", roomPower - (totalSitePower + coolingDevicePower + (inletsPower + outletsPower - nodeGroupFansPowerConumspion)), timestamp, "Wh");382 } catch (Exception e){383 metric = new MetricsStats("CoolEmAllTestbed", "Total_other_devices_consumption", -1, timestamp, "Wh");384 }385 return metric;386 }387 388 389 private MetricsStats calculateMeanPower(){390 391 MetricsStats metric;392 try{393 394 double roomPower = 0;395 for(GSSAccumulator acc: metricsData.get("Room")){396 roomPower = roomPower + acc.getSum();397 }398 metric = new MetricsStats("CoolEmAllTestbed", "Mean_power", roomPower/((this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC)), timestamp, "W");399 } catch (Exception e){400 metric = new MetricsStats("CoolEmAllTestbed", "Mean_power", -1, timestamp, "W");401 }402 return metric;403 }404 405 406 private MetricsStats calculateMeanRackPower(){407 408 MetricsStats metric;409 try{410 411 double roomPower = 0;412 for(GSSAccumulator acc: metricsData.get("Rack")){413 roomPower = roomPower + acc.getSum();414 }415 metric = new MetricsStats("CoolEmAllTestbed", "Mean_rack_power", roomPower/((this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC)), timestamp, "W");416 } catch (Exception e){417 metric = new MetricsStats("CoolEmAllTestbed", "Mean_rack_power", -1, timestamp, "W");418 }419 return metric;420 }421 422 private MetricsStats calculateEnergyWasteRate(){423 424 MetricsStats metric;425 try{426 double itComputingEnergy = 0;427 for(GSSAccumulator acc: metricsData.get("Processor_CALC")){428 itComputingEnergy = itComputingEnergy + acc.getSum();429 }430 itComputingEnergy = itComputingEnergy + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION * (this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC);431 double itEnergy = calculateITEnergyConsumption().getValue();432 433 metric = new MetricsStats("CoolEmAllTestbed", "Energy_waste_rate", (1 - itComputingEnergy/itEnergy) * 100, timestamp, "%");434 } catch (Exception e){435 metric = new MetricsStats("CoolEmAllTestbed", "Energy_waste_rate", -1, timestamp, "%");436 }437 return metric;438 }439 440 public long getStartTime() {441 return startTime;442 }443 444 public void setStartTime(long startTime) {445 this.startTime = startTime;446 }447 448 public long getEndTime() {449 return endTime;450 }451 452 public void setEndTime(long endTime) {453 this.endTime = endTime;454 }455 16 } -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/DCWormsStatistics.java
r1207 r1299 62 62 import schedframe.resources.UserResourceType; 63 63 import schedframe.resources.computing.ComputingResource; 64 import schedframe.resources.computing.Processor; 64 65 import schedframe.resources.computing.extensions.Extension; 65 66 import schedframe.resources.computing.extensions.ExtensionList; 66 67 import schedframe.resources.computing.extensions.ExtensionType; 67 68 import schedframe.resources.computing.profiles.energy.EnergyExtension; 69 import schedframe.resources.computing.profiles.energy.MeasurementHistory; 68 70 import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue; 69 71 import schedframe.resources.computing.profiles.energy.power.PowerUsage; 70 72 import schedframe.resources.computing.profiles.energy.thermal.TemperatureValue; 73 import schedframe.resources.computing.profiles.load.LoadExtension; 71 74 import schedframe.resources.devices.Device; 72 75 import schedframe.resources.devices.PhysicalResource; … … 85 88 import simulator.DataCenterWorkloadSimulator; 86 89 import simulator.GenericUser; 90 import simulator.stats.CoolEmAllMetricsCalculator; 91 import simulator.stats.DCwormsMetricsCalculator; 87 92 import simulator.stats.GSSAccumulator; 88 93 import simulator.stats.MetricsCalculator; 89 94 import simulator.stats.SimulationStatistics; 90 import simulator.stats.implementation.out.AbstractStringSerializer;91 95 import simulator.stats.implementation.out.CoolEmAllStringSerializer; 92 96 import simulator.stats.implementation.out.StringSerializer; … … 110 114 protected static final int MILLI_SEC = 1000; 111 115 112 protected static final String RAW_TASKS_STATISTICS_OUTPUT_FILE_NAME = "Tasks.txt";116 protected static final String TASKS_STATISTICS_OUTPUT_FILE_NAME = "Tasks.txt"; 113 117 protected static final String JOBS_STATISTICS_OUTPUT_FILE_NAME = "Jobs.txt"; 114 118 115 119 protected static final String SIMULATION_STATISTICS_OUTPUT_FILE_NAME = "Simulation.txt"; 120 protected static final String RESOURCEOCCUPANCY_STATISTICS_OUTPUT_FILE_NAME = "ResourceOccupancy.txt"; 116 121 protected static final String RESOURCEUTILIZATION_STATISTICS_OUTPUT_FILE_NAME = "ResourceUtilization.txt"; 117 122 protected static final String ENERGYUSAGE_STATISTICS_OUTPUT_FILE_NAME = "EnergyUsage.txt"; … … 141 146 protected SimulatedEnvironment resourceController; 142 147 protected boolean generateDiagrams = true; 143 protected AbstractStringSerializer serializer;148 protected StringSerializer serializer; 144 149 protected long startSimulationTime; 145 150 protected long endSimulationTime; 146 151 147 152 //RESOURCES 148 protected Map<String, List<ResStat>> basicResStats;153 protected Map<String, List<ResStat>> pesStats; 149 154 protected Map<String, Double> basicResLoad; 150 155 … … 156 161 protected Map<String, List<XYDataset>> resourceAirFlowDiagrams; 157 162 protected Map<String, List<XYDataset>> resourceTemperatureDiagrams; 158 protected Map<String, List<XYDataset>> resourceLoadDiagrams; 163 protected Map<String, List<XYDataset>> resourceOccupancyDiagrams; 164 protected Map<String, List<XYDataset>> resourceUtilizationDiagrams; 159 165 160 166 //TASKS … … 178 184 179 185 this.outputFolderName = outputFolderName; 180 181 this.serializer = new StringSerializer();182 183 if(DataCenterWorkloadSimulator.MODE.equals("CoolEmAll")){184 this.serializer = new CoolEmAllStringSerializer();185 }186 this.serializer.setDefaultNumberFormat(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT);187 188 186 this.resourceController = resourceController; 189 187 this.jr = new JobRegistryImpl(""); 190 init(); 191 metCalc = new MetricsCalculator(); 192 } 193 194 public void generateStatistics() { 195 188 196 189 if(users.isSimStartTimeDefined()) 197 190 this.startSimulationTime = DateTimeUtilsExt.getOffsetTime().getTimeInMillis(); 198 191 else 199 192 this.startSimulationTime = new DateTime(users.getSubmissionStartTime() * 1000l).getMillis(); 193 200 194 this.endSimulationTime = DateTimeUtilsExt.currentTimeMillis(); 201 195 202 metCalc.setStartTime(startSimulationTime); 203 metCalc.setEndTime(endSimulationTime); 196 init(); 197 } 198 199 public void generateStatistics() { 204 200 205 201 long s = 0; … … 234 230 accStats = new GSSAccumulatorsStats(); 235 231 statsData = new HashMap<String, GSSAccumulator>(); 232 233 this.serializer = new StringSerializer(); 234 this.metCalc = new DCwormsMetricsCalculator(startSimulationTime, endSimulationTime, endSimulationTime); 235 236 if(DataCenterWorkloadSimulator.MODE.equals("CoolEmAll")){ 237 this.serializer = new CoolEmAllStringSerializer(); 238 this.metCalc = new CoolEmAllMetricsCalculator(startSimulationTime, endSimulationTime, endSimulationTime); 239 } 240 this.serializer.setDefaultNumberFormat(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT); 236 241 } 237 242 … … 262 267 System.out.println("#STATS " + "===== Performance statistics ====="); 263 268 System.out.println("#STATS " + "Makespan: " + df.format(accStats.makespan.getMean()) + " [s]"); 264 System.out.println("#STATS " + "Task completion time - " + "min: " + df.format(accStats.meanTaskCompletionTime.getMin()) + " [s]" + "; max: " + df.format(accStats.meanTaskCompletionTime.getMax()) + " [s]" );269 System.out.println("#STATS " + "Task completion time - " + "min: " + df.format(accStats.meanTaskCompletionTime.getMin()) + " [s]" + "; max: " + df.format(accStats.meanTaskCompletionTime.getMax()) + " [s]" + "; mean: " + df.format(accStats.meanTaskCompletionTime.getMean()) + " [s]"); 265 270 System.out.println("#STATS " + "Mean task execution time: " + df.format(accStats.meanTaskExecutionTime.getMean()) + " [s]"); 271 System.out.println("#STATS " + "System occupancy: " + df.format(accStats.meanTotalOccupancy.getMean() * 100) + " [%]"); 266 272 System.out.println("#STATS " + "System load: " + df.format(accStats.meanTotalLoad.getMean() * 100) + " [%]"); 273 267 274 268 275 simulationStatsFile.println(txt); … … 300 307 taskGanttMap = new HashMap<String, TimetableEventGroup>(); 301 308 302 resourceLoadDiagrams = new HashMap<String, List<XYDataset>>(); 309 resourceOccupancyDiagrams = new HashMap<String, List<XYDataset>>(); 310 resourceUtilizationDiagrams = new HashMap<String, List<XYDataset>>(); 303 311 resourcePowerUsageDiagrams = new HashMap<String, List<XYDataset>>(); 304 312 resourceAirFlowDiagrams = new HashMap<String, List<XYDataset>>(); … … 309 317 310 318 311 PrintStream resourceLoadStatsFile = null; 319 PrintStream resourceOccupancyStatsFile = null; 320 try { 321 File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 322 + simulationIdentifier + "_" 323 + RESOURCEOCCUPANCY_STATISTICS_OUTPUT_FILE_NAME); 324 resourceOccupancyStatsFile = new PrintStream(new FileOutputStream(file)); 325 } catch (IOException e) { 326 resourceOccupancyStatsFile = null; 327 } 328 329 PrintStream resourceUtilizationStatsFile = null; 312 330 try { 313 331 File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 314 332 + simulationIdentifier + "_" 315 333 + RESOURCEUTILIZATION_STATISTICS_OUTPUT_FILE_NAME); 316 resource LoadStatsFile = new PrintStream(new FileOutputStream(file));334 resourceUtilizationStatsFile = new PrintStream(new FileOutputStream(file)); 317 335 } catch (IOException e) { 318 resource LoadStatsFile = null;336 resourceUtilizationStatsFile = null; 319 337 } 320 338 … … 389 407 } 390 408 391 basicResStats = gatherPEStats(jr.getTasks());392 peStatsPostProcessing( basicResStats);393 basicResLoad = calculatePELoad( basicResStats);409 pesStats = gatherPEStats(jr.getTasks()); 410 peStatsPostProcessing(pesStats); 411 basicResLoad = calculatePELoad(pesStats); 394 412 395 413 if (configuration.creatediagrams_gantt) { 396 createPEGanttDiagram( basicResStats);414 createPEGanttDiagram(pesStats); 397 415 } 398 416 … … 412 430 413 431 for(ComputingResource compResource: compResources){ 414 ResourceUsageStats resourceUsage = null; 432 ResourceUsageStats resourceUtilization = null; 433 ResourceUsageStats resourceOccupancy = null; 415 434 ResourcePowerStats energyUsage = null; 416 435 ResourceAirFlowStats airFlow = null; … … 418 437 ResourceUsefulWorkStats usefulWork = null; 419 438 if(type_stats.get(resourceTypeName).contains(Stats.textLoad)){ 420 resource Usage = gatherResourceLoadStats(compResource, basicResStats);421 resource Usage.setMeanValue(calculateMeanValue(resourceUsage));422 if (resource LoadStatsFile != null) {423 Object txt = resource Usage.serialize(serializer);424 resource LoadStatsFile.print(txt);439 resourceOccupancy = gatherResourceOccupancyStats(compResource, pesStats); 440 resourceOccupancy.setMeanValue(calculateMeanValue(resourceOccupancy)); 441 if (resourceOccupancyStatsFile != null) { 442 Object txt = resourceOccupancy.serialize(serializer); 443 resourceOccupancyStatsFile.print(txt); 425 444 } 426 445 446 resourceUtilization = gatherResourceUtlizationStats(compResource); 447 resourceUtilization.setMeanValue(calculateMeanValue(resourceUtilization)); 448 if (resourceUtilizationStatsFile != null) { 449 Object txt = resourceUtilization.serialize(serializer); 450 resourceUtilizationStatsFile.print(txt); 451 } 427 452 } 428 453 if(type_stats.get(resourceTypeName).contains(Stats.chartLoad)){ 429 454 if (configuration.creatediagrams_resutilization) { 430 createResourceLoadDiagram(resourceUsage); 455 createResourceOccupancyDiagram(resourceOccupancy); 456 createResourceUtilizationDiagram(resourceUtilization); 431 457 } 432 458 } … … 437 463 resourceEnergyAccumulator.add(energyUsage.getSumValue()); 438 464 maxResourceEnergyAccumulator.add(calculateMaxValue(energyUsage)); 439 double cal ulcationsEnergy = 0;465 double calculationsEnergy = 0; 440 466 try { 441 /*boolean doCalc = false;442 double prevTimestamp = 0;443 for(Long key: resourceUsage.getHistory().keySet()){444 if(doCalc){445 System.out.println(energyUsage.getHistory().get(key));446 calulcationsEnergy = calulcationsEnergy + energyUsage.getHistory().get(prevTimestamp) * (key - prevTimestamp) /(3600 * MILLI_SEC);447 doCalc = false;448 }449 if(resourceUsage.getHistory().get(key)>0){450 prevTimestamp = key;451 doCalc = true;452 }453 }*/454 467 boolean doCalc = false; 468 double load = 0; 455 469 long prevTimestamp = 0; 456 470 for(Long key: energyUsage.getHistory().keySet()){ 457 471 if(doCalc){ 458 double load = 0; 459 if(resourceUsage.getHistory().get(prevTimestamp)!= null){ 460 load = resourceUsage.getHistory().get(prevTimestamp); 472 if(resourceTypeName.equals("Rack")){ 473 calculationsEnergy = calculationsEnergy + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION * (key - prevTimestamp) /(3600.0 * MILLI_SEC); 474 }/* else if(resourceTypeName.equals("Processor")){ 475 Processor proc =( Processor) compResource; 476 double maxPower = proc.getPowerInterface().getLowestPState().getLoadPowerUsage().get(100.0); 477 calculationsEnergy = calculationsEnergy + load * maxPower * (key - prevTimestamp) /(3600.0 * MILLI_SEC); 478 }*/ 479 else 480 calculationsEnergy = calculationsEnergy + load * energyUsage.getHistory().get(prevTimestamp) * (key - prevTimestamp) /(3600.0 * MILLI_SEC); 481 doCalc = false; 482 load = 0; 483 } 484 485 if(resourceUtilization.getHistory().get(key) != null){ 486 load = resourceUtilization.getHistory().get(key); 487 if(load > 0 ){ 488 doCalc = true; 489 prevTimestamp = key; 461 490 } 462 calulcationsEnergy = calulcationsEnergy + load * energyUsage.getHistory().get(prevTimestamp) * (key - prevTimestamp) /(3600.0 * MILLI_SEC);463 doCalc = false;464 }465 if(energyUsage.getHistory().get(key) > compResource.getPowerInterface().getSupportedPowerStates().get(0).getPowerUsage() - CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION){466 467 prevTimestamp = key;468 doCalc = true;469 491 } 470 492 } 471 //calulcationsEnergy = energyUsage.getSumValue() - 472 // ((1 - resourceUsage.getMeanValue()) * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)) * 473 // (compResource.getPowerInterface().getSupportedPowerStates().get(0).getPowerUsage() - CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION); 474 //System.out.println(compResource.getFullName() + ";" + resourceUsage.getMeanValue() +":"+ calulcationsEnergy + ":" + energyUsage.getSumValue()); 475 calculationsEnergyAccumulator.add(calulcationsEnergy); 493 494 calculationsEnergyAccumulator.add(calculationsEnergy); 476 495 } catch (Exception e) { 477 496 e.printStackTrace(); … … 510 529 devAccumulator.add(deviceEnergyUsage.getSumValue()); 511 530 metCalc.addMetricsData(device.getType().getName(), devAccumulator); 531 metCalc.addMetricsData(device.getFullName(), devAccumulator); 512 532 if (deviceStatsFile != null) { 513 533 Object txt = deviceEnergyUsage.serialize(serializer); … … 666 686 //log.info("#STATS " + "Metrics"); 667 687 System.out.println("#STATS " + "===== Metrics ====="); 668 for(MetricsStats metric: metCalc.calulateMetrics( endSimulationTime)){688 for(MetricsStats metric: metCalc.calulateMetrics()){ 669 689 Object txt = metric.serialize(serializer); 670 690 //log.info("#STATS " + metric.getResourceName() + " " + metric.getMetricName() + ": " + metric.getValue()); … … 676 696 } 677 697 } 678 saveResource UsageDiagrams();698 saveResourceDiagrams(); 679 699 createAccumulatedResourceSimulationStatistic(); 680 700 … … 688 708 energyStatsFile.close(); 689 709 } 690 if (resourceLoadStatsFile != null) { 691 resourceLoadStatsFile.close(); 710 if (resourceOccupancyStatsFile != null) { 711 resourceOccupancyStatsFile.close(); 712 } 713 if (resourceUtilizationStatsFile != null) { 714 resourceUtilizationStatsFile.close(); 692 715 } 693 716 … … 813 836 814 837 815 private ResourceUsageStats gatherResource LoadStats(ComputingResource resource, Map<String, List<ResStat>> basicStats) {838 private ResourceUsageStats gatherResourceOccupancyStats(ComputingResource resource, Map<String, List<ResStat>> basicStats) { 816 839 String usageType = null; 817 840 if(resource.getResourceCharacteristic().getParameters().get("load-sensor")!= null){ … … 844 867 int usedResources = 0; 845 868 for(ComputingResource compResource: resource.getChildren()){ 846 double meanLoad = calculateMeanValue(gatherResource LoadStats(compResource, basicResStats));869 double meanLoad = calculateMeanValue(gatherResourceOccupancyStats(compResource, pesStats)); 847 870 if(meanLoad > 0){ 848 871 usedResources++; … … 916 939 } 917 940 941 private ResourceUsageStats gatherResourceUtlizationStats(PhysicalResource resource) { 942 943 String usageType = null; 944 if(resource.getResourceCharacteristic().getParameters().get("load-sensor")!= null){ 945 usageType = resource.getResourceCharacteristic().getParameters().get("load-sensor").get(0).getContent(); 946 } 947 ResourceUsageStats resUtlization = new ResourceUsageStats(resource.getFullName(), resource.getType(), usageType); 948 Map<Long, Double> usage = resUtlization.getHistory(); 949 950 ExtensionList extensionList = resource.getExtensionList(); 951 if(extensionList != null){ 952 for (Extension extension : extensionList) { 953 if (extension.getType() == ExtensionType.LOAD_EXTENSION) { 954 LoadExtension le = (LoadExtension)extension; 955 if(le.getLoadProfile() == null) 956 break; 957 List<MeasurementHistory> loadHistory = le.getLoadProfile().getUtilizationHistory(); 958 if(loadHistory.size() == 0) 959 break; 960 long endSimulationTime = DateTimeUtilsExt.currentTimeMillis(); 961 962 loadHistory.add(new MeasurementHistory(endSimulationTime, le.getLoadProfile().getUtilizationHistory().get(le.getLoadProfile().getUtilizationHistory().size() - 1).getValue()/100)); 963 for(MeasurementHistory l:loadHistory){ 964 usage.put(l.getTimestamp(), l.getValue()/100); 965 } 966 } 967 } 968 } 969 return resUtlization; 970 } 918 971 919 972 private ResourcePowerStats gatherResourcePowerConsumptionStats(PhysicalResource resource) { … … 921 974 922 975 String usageType = null; 923 if(resource.getResourceCharacteristic().getParameters().get("power-sensor") != null){976 if(resource.getResourceCharacteristic().getParameters().get("power-sensor") != null){ 924 977 usageType = resource.getResourceCharacteristic().getParameters().get("power-sensor").get(0).getContent(); 925 978 } … … 954 1007 } 955 1008 956 957 1009 private ResourceAirFlowStats gatherResourceAirFlowStats(PhysicalResource resource) { 958 1010 959 1011 String usageType = null; 960 if(resource.getResourceCharacteristic().getParameters().get("airflow_volume-sensor") != null){1012 if(resource.getResourceCharacteristic().getParameters().get("airflow_volume-sensor") != null){ 961 1013 usageType = resource.getResourceCharacteristic().getParameters().get("airflow_volume-sensor").get(0).getContent(); 962 1014 } … … 1016 1068 } 1017 1069 1018 private void createResource LoadDiagram(ResourceUsageStats resLoadStats) {1070 private void createResourceOccupancyDiagram(ResourceUsageStats resLoadStats) { 1019 1071 1020 1072 for(Long key: resLoadStats.getHistory().keySet()){ … … 1026 1078 startSimulationTime, endSimulationTime); 1027 1079 1028 List<XYDataset> loadDiagram = resourceLoadDiagrams.get(resLoadStats.getResourceType().getName());1029 if( loadDiagram == null){1030 loadDiagram = new ArrayList<XYDataset>();1031 loadDiagram.add(dataset);1032 resource LoadDiagrams.put(resLoadStats.getResourceType().getName(), loadDiagram);1080 List<XYDataset> occupancyDiagram = resourceOccupancyDiagrams.get(resLoadStats.getResourceType().getName()); 1081 if(occupancyDiagram == null){ 1082 occupancyDiagram = new ArrayList<XYDataset>(); 1083 occupancyDiagram.add(dataset); 1084 resourceOccupancyDiagrams.put(resLoadStats.getResourceType().getName(), occupancyDiagram); 1033 1085 } else { 1034 loadDiagram.add(dataset); 1086 occupancyDiagram.add(dataset); 1087 } 1088 } 1089 1090 private void createResourceUtilizationDiagram(ResourceUsageStats resLoadStats) { 1091 1092 for(Long key: resLoadStats.getHistory().keySet()){ 1093 Double value = resLoadStats.getHistory().get(key) * 100; 1094 resLoadStats.getHistory().put(key, value); 1095 } 1096 1097 XYDataset dataset = createResourceChartDataSet(resLoadStats, 1098 startSimulationTime, endSimulationTime); 1099 1100 List<XYDataset> utilizationDiagram = resourceUtilizationDiagrams.get(resLoadStats.getResourceType().getName()); 1101 if(utilizationDiagram == null){ 1102 utilizationDiagram = new ArrayList<XYDataset>(); 1103 utilizationDiagram.add(dataset); 1104 resourceUtilizationDiagrams.put(resLoadStats.getResourceType().getName(), utilizationDiagram); 1105 } else { 1106 utilizationDiagram.add(dataset); 1035 1107 } 1036 1108 } … … 1109 1181 } 1110 1182 1111 private boolean saveResource UsageDiagrams() {1183 private boolean saveResourceDiagrams() { 1112 1184 1113 1185 if (!generateDiagrams) … … 1133 1205 chartName = "Load diagram for " 1134 1206 + DataCenterWorkloadSimulator.SIMULATOR_NAME; 1135 JFreeChart resourceLoadDiagram = null; 1207 JFreeChart resourceOccupancyDiagram = null; 1208 if (configuration.creatediagrams_resutilization) { 1209 String axisName = "OCCUPANCY [%]"; 1210 for(String resType: resourceOccupancyDiagrams.keySet()){ 1211 resourceOccupancyDiagram = getResourceDynamicDiagram(resourceOccupancyDiagrams.get(resType), simulationTime, chartName, 1212 subtitle, axisName); 1213 if (!saveXYPlotChart(resourceOccupancyDiagram, fileName + "ResourcesOccupancy_" + resType)) 1214 return false; 1215 } 1216 } 1217 1218 chartName = "Utilization diagram for " 1219 + DataCenterWorkloadSimulator.SIMULATOR_NAME; 1220 JFreeChart resourceUtilizationDiagram = null; 1136 1221 if (configuration.creatediagrams_resutilization) { 1137 1222 String axisName = "UTILIZATION [%]"; 1138 for(String resType: resource LoadDiagrams.keySet()){1139 resource LoadDiagram = getResourceDynamicDiagram(resourceLoadDiagrams.get(resType), simulationTime, chartName,1223 for(String resType: resourceUtilizationDiagrams.keySet()){ 1224 resourceUtilizationDiagram = getResourceDynamicDiagram(resourceUtilizationDiagrams.get(resType), simulationTime, chartName, 1140 1225 subtitle, axisName); 1141 if (!saveXYPlotChart(resource LoadDiagram, fileName + "ResourcesLoad_" + resType))1226 if (!saveXYPlotChart(resourceUtilizationDiagram, fileName + "ResourcesUtilization_" + resType)) 1142 1227 return false; 1143 1228 } … … 1322 1407 //double load = calculateMeanValue(resourceUsage); 1323 1408 double load = calculateResourceLoad(compRes, basicResLoad); 1324 accStats.meanTotalLoad.add(load); 1409 accStats.meanTotalOccupancy.add(load); 1410 1411 ResourceUsageStats resourceUtilization = gatherResourceUtlizationStats(compRes); 1412 accStats.meanTotalLoad.add(calculateMeanValue(resourceUtilization)); 1325 1413 /*ResourceEnergyStats energyUsage = gatherResourceEnergyStats(compRes); 1326 1414 energyUsage.setMeanUsage(calculateEnergyLoad(energyUsage)); … … 1365 1453 1366 1454 1367 private double calculateMeanValue(ResourceDynamicStats resDynamicStats 1455 private double calculateMeanValue(ResourceDynamicStats resDynamicStats){ 1368 1456 double meanValue = 0; 1369 1457 long time = -1; … … 1387 1475 1388 1476 1389 private double calculateMaxValue(ResourceDynamicStats resDynamicStats 1477 private double calculateMaxValue(ResourceDynamicStats resDynamicStats){ 1390 1478 double maxValue = 0; 1391 1479 … … 1414 1502 try { 1415 1503 File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX + simulationIdentifier + "_" 1416 + RAW_TASKS_STATISTICS_OUTPUT_FILE_NAME);1504 + TASKS_STATISTICS_OUTPUT_FILE_NAME); 1417 1505 taskStatsFile = new PrintStream(new FileOutputStream(file)); 1418 1506 } catch (IOException e) { … … 1634 1722 chartName = "Task waiting times diagram for " + DataCenterWorkloadSimulator.SIMULATOR_NAME; 1635 1723 if (configuration.creatediagrams_taskswaitingtime) { 1636 waitingTimeDiagram = get WaitingTimeDiagram(chartName, subtitle, simulationTime);1724 waitingTimeDiagram = getTaskWaitingTimeDiagram(chartName, subtitle, simulationTime); 1637 1725 if (!saveCategoryChart(waitingTimeDiagram, fileName + "Waiting_Time", null /* "Task {1} at {0}" */)) 1638 1726 return false; … … 1655 1743 } 1656 1744 1657 private JFreeChart get WaitingTimeDiagram(String chartName, Title subtitle, String simulationTime) {1745 private JFreeChart getTaskWaitingTimeDiagram(String chartName, Title subtitle, String simulationTime) { 1658 1746 String tasks = "Tasks"; 1659 1747 boolean urls = false; … … 1878 1966 textTemperature, 1879 1967 chartTemperature, 1880 textUsefulWor l;1968 textUsefulWork; 1881 1969 }
Note: See TracChangeset
for help on using the changeset viewer.