Changeset 495 for DCWoRMS/trunk/src/simulator/stats/implementation
- Timestamp:
- 10/10/12 12:12:06 (13 years ago)
- Location:
- DCWoRMS/trunk/src/simulator/stats/implementation
- Files:
-
- 1 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java
r494 r495 62 62 import schedframe.resources.computing.extensions.ExtensionType; 63 63 import schedframe.resources.computing.profiles.energy.EnergyExtension; 64 import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue; 64 65 import schedframe.resources.computing.profiles.energy.power.PowerUsage; 65 66 import schedframe.resources.units.PEUnit; … … 81 82 import simulator.stats.SimulationStatistics; 82 83 import simulator.stats.implementation.out.AbstractStringSerializer; 83 import simulator.stats.implementation.out.FormatedStringSerializer;84 84 import simulator.stats.implementation.out.StringSerializer; 85 85 import csiro.mit.utils.jfreechart.timetablechart.TimetableChartFactory; … … 98 98 protected static float ALPHA = 0.5f; 99 99 protected static int GANTT_WIDTH = 1200; 100 101 //protected static final int BITS = 8; 100 102 101 protected static final int MILLI_SEC = 1000; 103 102 … … 106 105 107 106 protected static final String SIMULATION_STATISTICS_OUTPUT_FILE_NAME = "Simulation.txt"; 108 protected static final String ENERGYUSAGE_STATISTICS_OUTPUT_FILE_NAME = "Energy.txt"; 109 protected static final String RESOURCEUSAGE_STATISTICS_OUTPUT_FILE_NAME = "ResourceUtilization.txt"; 107 protected static final String RESOURCEUTILIZATION_STATISTICS_OUTPUT_FILE_NAME = "ResourceUtilization.txt"; 108 protected static final String ENERGYUSAGE_STATISTICS_OUTPUT_FILE_NAME = "EnergyUsage.txt"; 109 protected static final String AIRFLOW_STATISTICS_OUTPUT_FILE_NAME = "AirThroughput.txt"; 110 110 111 111 protected static final String DIAGRAMS_FILE_NAME_PREFIX = "Chart_"; … … 123 123 protected Map<String, GSSAccumulator> statsData; 124 124 125 pr ivateGenericUser users;125 protected GenericUser users; 126 126 protected ResourceController resourceController; 127 127 protected boolean generateDiagrams = true; … … 132 132 //RESOURCES 133 133 protected Timetable ganttDiagramPeTimetable; 134 protected Map<ResourceType, List<XYDataset>> resourceEnergyDiagrams; 134 protected Map<ResourceType, List<XYDataset>> resourcePowerUsageDiagrams; 135 protected Map<ResourceType, List<XYDataset>> resourceAirFlowDiagrams; 135 136 protected Map<ResourceType, List<XYDataset>> resourceLoadDiagrams; 136 137 protected Map<String,List<ResStat>> basicResStats; … … 161 162 this.outputFolderName = outputFolderName; 162 163 163 164 164 this.serializer = new StringSerializer(); 165 166 165 this.serializer.setDefaultNumberFormat(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT); 167 166 168 167 this.resourceController = resourceController; 169 jr = new JobRegistryImpl("");168 this.jr = new JobRegistryImpl(""); 170 169 init(); 171 170 } … … 174 173 175 174 this.startSimulationTime = DateTimeUtilsExt.getOffsetTime().getTimeInMillis(); 176 177 175 this.endSimulationTime = DateTimeUtilsExt.currentTimeMillis(); 178 176 … … 235 233 private void gatherResourceStatistics() { 236 234 237 238 //TEMPORARY CONFIGURATION SECTION239 240 235 HashMap<String, List<Stats>> type_stats = new HashMap<String, List<Stats>>(); 241 236 … … 248 243 if(ArrayUtils.contains(configuration.resForEnergyChart, resourceName)) 249 244 cStats.add(Stats.chartEnergy); 245 cStats.add(Stats.textAirFlow); 246 if(ArrayUtils.contains(configuration.resForAirFlowChart, resourceName)) 247 cStats.add(Stats.chartAirFlow); 250 248 type_stats.put(resourceName, cStats); 251 249 } 252 250 253 251 peGanttMap = new HashMap<String, TimetableEventSource>(); 254 taskGanttMap = new HashMap<String, TimetableEventGroup>(); 255 252 taskGanttMap = new HashMap<String, TimetableEventGroup>(); 256 253 257 254 resourceLoadDiagrams = new HashMap<ResourceType, List<XYDataset>>(); 258 resourceEnergyDiagrams = new HashMap<ResourceType, List<XYDataset>>(); 255 resourcePowerUsageDiagrams = new HashMap<ResourceType, List<XYDataset>>(); 256 resourceAirFlowDiagrams = new HashMap<ResourceType, List<XYDataset>>(); 259 257 260 258 ganttDiagramPeTimetable = new Timetable(new FixedMillisecond( … … 265 263 File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 266 264 + simulationIdentifier + "_" 267 + RESOURCEU SAGE_STATISTICS_OUTPUT_FILE_NAME);265 + RESOURCEUTILIZATION_STATISTICS_OUTPUT_FILE_NAME); 268 266 resourceLoadStatsFile = new PrintStream(new FileOutputStream(file)); 269 267 } catch (IOException e) { … … 280 278 energyStatsFile = null; 281 279 } 282 JobRegistry jr = new JobRegistryImpl("stats"); 280 281 PrintStream airFlowStatsFile = null; 282 try { 283 File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 284 + simulationIdentifier + "_" 285 + AIRFLOW_STATISTICS_OUTPUT_FILE_NAME); 286 airFlowStatsFile = new PrintStream(new FileOutputStream(file)); 287 } catch (IOException e) { 288 airFlowStatsFile = null; 289 } 290 283 291 basicResStats = gatherPEStats(jr.getExecutableTasks()); 284 292 peStatsPostProcessing(basicResStats); … … 291 299 for(String resourceName: resourceController.getComputingResourceLayers()){ 292 300 List<ComputingResource> resources = null; 293 try { 294 resources = new ArrayList<ComputingResource>(); 295 for(ComputingResource compRes: resourceController.getComputingResources() ){ 296 resources.addAll(compRes.getDescendantsByType(new UserResourceType(resourceName))); 297 } 298 if(resourceController.getComputingResources().get(0).getType().getName().equals(resourceName)) 299 resources.addAll(resourceController.getComputingResources()); 300 } catch (Exception e) { 301 continue; 302 } 301 302 resources = new ArrayList<ComputingResource>(); 303 for(ComputingResource compRes: resourceController.getComputingResources() ){ 304 resources.addAll(compRes.getDescendantsByType(new UserResourceType(resourceName))); 305 } 306 if(resourceController.getComputingResources().get(0).getType().getName().equals(resourceName)) 307 resources.addAll(resourceController.getComputingResources()); 308 303 309 if(type_stats.containsKey(resourceName)){ 304 Map<String, GSSAccumulator> energyCategoryStats = new TreeMap<String, GSSAccumulator>();305 Map<String, GSSAccumulator> loadCategoryStats = new TreeMap<String, GSSAccumulator>();306 310 for(ComputingResource resource: resources){ 307 311 ResourceUsageStats resourceUsage = null; 308 312 ResourceEnergyStats energyUsage = null; 313 ResourceAirFlowStats airFlow = null; 309 314 if(type_stats.get(resourceName).contains(Stats.textLoad)){ 310 315 resourceUsage = gatherResourceLoadStats(resource, basicResStats); … … 358 363 } 359 364 360 /*if(resType == ResourceType.ComputingNode){ 361 ComputingNode compNode = (ComputingNode) resource; 362 if(energyCategoryStats.containsKey(resType+"#"+compNode.getCategory().getName())){ 363 GSSAccumulator acc = energyCategoryStats.get(resType+"#"+compNode.getCategory().getName()); 364 acc.add(energyUsage.meanUsage); 365 energyCategoryStats.put(resType+"#"+compNode.getCategory().getName(), acc); 366 } else{ 367 GSSAccumulator acc = new GSSAccumulator(); 368 acc.add(energyUsage.meanUsage); 369 energyCategoryStats.put(resType+"#"+compNode.getCategory().getName(), acc); 365 if(type_stats.get(resourceName).contains(Stats.textAirFlow)){ 366 airFlow = gatherResourceAirFlowStats(resource); 367 airFlow.setMeanUsage(calculateAirFlowLoad(airFlow)); 368 airFlow.setSumUsage(airFlow.getMeanUsage() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 369 370 EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 371 if(resourceController.getComputingResources().contains(resource)) { 372 if( een != null /*&& een.getPp() != null*/ ){ 373 accStats.meanAirFlow.add(airFlow.meanValue); 374 } 375 376 } else if( een != null && een.getAirFlowProfile() != null ){ 377 ComputingResource parent = resource.getParent(); 378 een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 379 boolean top = true; 380 while(parent != null){ 381 if(een != null && een.getAirFlowProfile() != null) { 382 top = false; 383 break; 384 } 385 parent = parent.getParent(); 386 } 387 if(top == true){ 388 accStats.meanAirFlow.add(airFlow.meanValue); 389 } 370 390 } 371 372 if(loadCategoryStats.containsKey(resType+"#"+compNode.getCategory().getName())){ 373 GSSAccumulator acc = loadCategoryStats.get(resType+"#"+compNode.getCategory().getName()); 374 acc.add(resourceUsage.meanUsage); 375 loadCategoryStats.put(resType+"#"+compNode.getCategory().getName(), acc); 376 } else{ 377 GSSAccumulator acc = new GSSAccumulator(); 378 acc.add(resourceUsage.meanUsage); 379 loadCategoryStats.put(resType+"#"+compNode.getCategory().getName(), acc); 391 if (airFlowStatsFile != null) { 392 Object txt = airFlow.serialize(serializer); 393 airFlowStatsFile.println(txt); 380 394 } 381 } else if(resType == ResourceType.Processor){ 382 Processor proc = (Processor)resource; 383 if(energyCategoryStats.containsKey(resType+"#"+proc.getComputingNode().getCategory().getName())){ 384 GSSAccumulator acc = energyCategoryStats.get(resType+"#"+proc.getComputingNode().getCategory().getName()); 385 acc.add(energyUsage.meanUsage); 386 energyCategoryStats.put(resType+"#"+proc.getComputingNode().getCategory().getName(), acc); 387 } else{ 388 GSSAccumulator acc = new GSSAccumulator(); 389 acc.add(energyUsage.meanUsage); 390 energyCategoryStats.put(resType+"#"+proc.getComputingNode().getCategory().getName(), acc); 395 } 396 if(type_stats.get(resourceName).contains(Stats.chartAirFlow)){ 397 398 if (configuration.creatediagrams_airflow) { 399 createResourceAirFlowGanttDiagram(airFlow); 391 400 } 392 393 if(loadCategoryStats.containsKey(resType+"#"+proc.getComputingNode().getCategory().getName())){394 GSSAccumulator acc = loadCategoryStats.get(resType+"#"+proc.getComputingNode().getCategory().getName());395 acc.add(resourceUsage.meanUsage);396 loadCategoryStats.put(resType+"#"+proc.getComputingNode().getCategory().getName(), acc);397 } else{398 GSSAccumulator acc = new GSSAccumulator();399 acc.add(resourceUsage.meanUsage);400 loadCategoryStats.put(resType+"#"+proc.getComputingNode().getCategory().getName(), acc);401 }402 }*/403 }404 405 if(energyCategoryStats.size() > 0)406 {407 energyStatsFile.println("\n=========BY CATEGORY===========");408 for(String key: energyCategoryStats.keySet()){409 GSSAccumulator acc = energyCategoryStats.get(key);410 energyStatsFile.println(key + "- mean: " + acc.getMean()+ " sum: " +acc.getMean() * (endSimulationTime-startSimulationTime) / (3600 * MILLI_SEC) * acc.getCount());411 401 } 412 energyStatsFile.println("\n\n");413 }414 415 if(loadCategoryStats.size() > 0)416 {417 resourceLoadStatsFile.println("\n=========BY CATEGORY===========");418 for(String key: loadCategoryStats.keySet()){419 GSSAccumulator acc = loadCategoryStats.get(key);420 resourceLoadStatsFile.println(key + "- mean: " + acc.getMean());421 }422 resourceLoadStatsFile.println("\n\n");423 402 } 424 403 } … … 427 406 saveResourceGanttDiagrams(); 428 407 createAccumulatedResourceSimulationStatistic(); 408 if (airFlowStatsFile != null) { 409 airFlowStatsFile.close(); 410 } 429 411 if (energyStatsFile != null) { 430 412 energyStatsFile.close(); … … 472 454 } 473 455 } 456 474 457 private Map<String, List<ResStat>> gatherPEStats( ExecutablesList executables) { 475 476 458 477 459 Map<String, List<ResStat>> basicResStats = new TreeMap<String, List<ResStat>>(new MapPEIdComparator()); 478 //Map<Integer, Map<String, Object>> history 479 460 480 461 for (ExecTask execTask:executables) { 481 462 Executable exec = (Executable) execTask; … … 485 466 ResourceUnit resUnit = res.get(StandardResourceUnitName.PE); 486 467 //ProcessingElements pes = (ProcessingElements) resUnit ; 487 if(resUnit instanceof ProcessingElements 468 if(resUnit instanceof ProcessingElements){ 488 469 ProcessingElements pes = (ProcessingElements) resUnit; 489 470 for(ComputingResource pe: pes){ … … 491 472 long startDate = Double.valueOf(exec.getExecStartTime()).longValue() * MILLI_SEC; 492 473 long endDate = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC; 493 494 474 495 475 String uniqueTaskID = execTask.getJobId() + "_" + execTask.getId(); … … 525 505 private ResourceUsageStats gatherResourceLoadStats(ComputingResource resource, Map<String,List<ResStat>> basicStats) { 526 506 ResourceUsageStats usageStats = new ResourceUsageStats(resource.getName(), resource.getType(), "resourceLoadStats"); 507 int cnt =0; 527 508 for(String resName: basicStats.keySet()){ 528 509 try { 529 510 if(resource.getDescendantByName(resName) != null || resource.getName().compareTo(resName) == 0){ 511 cnt++; 530 512 createResourceLoadData(usageStats, basicStats.get(resName)); 531 513 } … … 535 517 } 536 518 } 519 for(Long key: usageStats.getUsage().keySet()){ 520 Double value = usageStats.getUsage().get(key)/cnt; 521 usageStats.getUsage().put(key, value); 522 } 523 537 524 return usageStats; 538 525 } 539 526 540 private TreeMap<Long, Integer> createResourceLoadData(ResourceUsageStats usageStats, List<ResStat> resStats) {541 542 TreeMap<Long, Integer> ganttData = (TreeMap)usageStats.getUsage();527 private TreeMap<Long, Double> createResourceLoadData(ResourceUsageStats usageStats, List<ResStat> resStats) { 528 529 TreeMap<Long, Double> ganttData = (TreeMap<Long, Double>)usageStats.getUsage(); 543 530 for (ResStat resStat : resStats) { 544 531 … … 546 533 long end_time = resStat.getEndDate(); 547 534 if (end_time > start_time) { 548 Integerend = ganttData.get(end_time);535 Double end = ganttData.get(end_time); 549 536 if (end == null) { 550 ganttData.put(end_time, 0 );537 ganttData.put(end_time, 0.0); 551 538 Long left = getLeftKey(ganttData, end_time); 552 539 if (left != null) { 553 IntegerleftValue = ganttData.get(left);540 Double leftValue = ganttData.get(left); 554 541 ganttData.put(end_time, leftValue); 555 542 } 556 543 } 557 544 558 Integerstart = ganttData.get(start_time);545 Double start = ganttData.get(start_time); 559 546 if (start == null) { 560 ganttData.put(start_time, 0 );547 ganttData.put(start_time, 0.0); 561 548 Long left = getLeftKey(ganttData, start_time); 562 549 if (left != null) { 563 IntegerleftValue = ganttData.get(left);550 Double leftValue = ganttData.get(left); 564 551 ganttData.put(start_time, leftValue); 565 552 } 566 553 } 567 554 568 SortedMap<Long, Integer> sm = ganttData.subMap(start_time,555 SortedMap<Long, Double> sm = ganttData.subMap(start_time, 569 556 end_time); 570 557 for (Long key : sm.keySet()) { 571 IntegerkeyVal = ganttData.get(key);558 Double keyVal = ganttData.get(key); 572 559 ganttData.put(key, keyVal + 1); 573 560 } 574 561 } 575 562 } 563 576 564 return ganttData; 577 565 } 578 566 579 private Long getLeftKey(TreeMap<Long, Integer> ganttData, Long toKey) {580 581 SortedMap<Long, Integer> sm = ganttData.headMap(toKey);567 private Long getLeftKey(TreeMap<Long, Double> ganttData, Long toKey) { 568 569 SortedMap<Long, Double> sm = ganttData.headMap(toKey); 582 570 if (sm.isEmpty()) { 583 571 return null; … … 621 609 } 622 610 623 private void createResourceEnergyGanttDiagram(ResourceEnergyStats energyUsage) { 624 625 XYDataset dataset = createResourceEnergyGanttDataSet(energyUsage, 611 612 private ResourceAirFlowStats gatherResourceAirFlowStats(ComputingResource resource) { 613 614 ResourceAirFlowStats resAirFlow = new ResourceAirFlowStats(resource.getName(), resource.getType(), "resourceAirFlowStats"); 615 Map<Long, Double> airFlow = resAirFlow.getAirFlow(); 616 617 ExtensionList extensionList = resource.getExtensionList(); 618 if(extensionList != null){ 619 for (Extension extension : extensionList) { 620 if (extension.getType() == ExtensionType.ENERGY_EXTENSION) { 621 EnergyExtension ee = (EnergyExtension)extension; 622 if(ee.getAirFlowProfile() == null) 623 break; 624 List<AirFlowValue> airFlowHistory = ee.getAirFlowProfile().getAirThroughputHistory(); 625 if(airFlowHistory.size() == 0) 626 break; 627 long lastTime = DateTimeUtilsExt.getOffsetTime().getTimeInMillis(); 628 long endSimulationTime = DateTimeUtilsExt.currentTimeMillis(); 629 double lastAirFlow = 0; 630 airFlowHistory.add(new AirFlowValue(endSimulationTime, ee.getAirFlowProfile().getAirThroughputHistory().get(ee.getAirFlowProfile().getAirThroughputHistory().size()-1).getValue())); 631 for(AirFlowValue af:airFlowHistory){ 632 airFlow.put(af.getTimestamp(), af.getValue()); 633 634 lastAirFlow = af.getValue(); 635 lastTime = af.getTimestamp(); 636 } 637 } 638 } 639 } 640 return resAirFlow; 641 } 642 643 private void createResourceEnergyGanttDiagram(ResourceEnergyStats powerUsage) { 644 645 XYDataset dataset = createResourceEnergyGanttDataSet(powerUsage, 626 646 startSimulationTime, endSimulationTime); 627 647 628 List<XYDataset> energyDiagram = resource EnergyDiagrams.get(energyUsage.getResourceType());648 List<XYDataset> energyDiagram = resourcePowerUsageDiagrams.get(powerUsage.getResourceType()); 629 649 if(energyDiagram == null){ 630 650 energyDiagram = new ArrayList<XYDataset>(); 631 651 energyDiagram.add(dataset); 632 resource EnergyDiagrams.put(energyUsage.getResourceType(), energyDiagram);652 resourcePowerUsageDiagrams.put(powerUsage.getResourceType(), energyDiagram); 633 653 } else { 634 654 energyDiagram.add(dataset); … … 637 657 } 638 658 659 private void createResourceAirFlowGanttDiagram(ResourceAirFlowStats airFlow) { 660 661 XYDataset dataset = createResourceAirFlowGanttDataSet(airFlow, 662 startSimulationTime, endSimulationTime); 663 664 List<XYDataset> airFlowDiagram = resourceAirFlowDiagrams.get(airFlow.getResourceType()); 665 if(airFlowDiagram == null){ 666 airFlowDiagram = new ArrayList<XYDataset>(); 667 airFlowDiagram.add(dataset); 668 resourceAirFlowDiagrams.put(airFlow.getResourceType(), airFlowDiagram); 669 } else { 670 airFlowDiagram.add(dataset); 671 } 672 673 } 674 639 675 private XYDataset createResourceEnergyGanttDataSet( 640 676 ResourceEnergyStats energyUsage, long start, long end) { … … 665 701 } 666 702 703 private XYDataset createResourceAirFlowGanttDataSet( 704 ResourceAirFlowStats airFlowStats, long start, long end) { 705 706 TreeMap<Long, Double> ganttdata = createResourceAirFlowGanttData(airFlowStats); 707 XYSeriesCollection dataset = new XYSeriesCollection(); 708 XYSeries data = new XYSeries(airFlowStats.getResourceName(), false, true); 709 //data.add(start, 0); 710 for (Long key : ganttdata.keySet()) { 711 Double val = ganttdata.get(key); 712 data.add(key, val); 713 } 714 data.add(end, 0); 715 dataset.addSeries(data); 716 return dataset; 717 } 718 719 private TreeMap<Long, Double> createResourceAirFlowGanttData( 720 ResourceAirFlowStats airFlowStats) { 721 722 Map<Long, Double> airFlow = airFlowStats.getAirFlow(); 723 TreeMap<Long, Double> ganttData = new TreeMap<Long, Double>(); 724 for (Long afKey : airFlow.keySet()) { 725 ganttData.put(afKey, airFlow.get(afKey)); 726 } 727 return ganttData; 728 } 667 729 668 730 private boolean saveResourceGanttDiagrams() { … … 670 732 JFreeChart peDiagram = null; 671 733 JFreeChart resourceEnergyDiagram = null; 734 JFreeChart resourceAirFlowDiagram = null; 672 735 if (!generateDiagrams) 673 736 return false; … … 701 764 } 702 765 if (configuration.creatediagrams_energyusage) { 703 for(ResourceType resType: resource EnergyDiagrams.keySet()){766 for(ResourceType resType: resourcePowerUsageDiagrams.keySet()){ 704 767 resourceEnergyDiagram = getResourcesEnergyDiagram(resType, chartName, 705 768 subtitle, simulationTime); … … 708 771 } 709 772 } 773 774 775 if (configuration.creatediagrams_airflow) { 776 for(ResourceType resType: resourceAirFlowDiagrams.keySet()){ 777 resourceAirFlowDiagram = getResourcesAirFlowDiagram(resType, chartName, 778 subtitle, simulationTime); 779 if (!saveXYPlotChart(resourceAirFlowDiagram, fileName + "AirThroughput - "+resType)) 780 return false; 781 } 782 } 710 783 return true; 711 784 } … … 713 786 private JFreeChart getResourcesLoadDiagram(ResourceType resType, String chartName, Title subtitle, 714 787 String simulationTime) { 715 String cpu = " CPU";788 String cpu = "UTILIZATION [%]"; 716 789 boolean urls = false; 717 790 boolean tooltip = true; … … 750 823 DateAxis xAxis = new DateAxis(simulationTime); 751 824 752 List<XYDataset> energyDiagram = resource EnergyDiagrams.get(resType);825 List<XYDataset> energyDiagram = resourcePowerUsageDiagrams.get(resType); 753 826 for (XYDataset dataset : energyDiagram) { 754 827 … … 759 832 XYPlot tPlot = tChart.getXYPlot(); 760 833 NumberAxis yAxis = new NumberAxis(energy); 834 yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 835 tPlot.setRangeAxis(yAxis); 836 XYStepAreaRenderer rend = (XYStepAreaRenderer) tPlot.getRenderer(); 837 rend.setShapesVisible(false); 838 cPlot.add(tPlot); 839 } 840 cPlot.setDomainAxis(xAxis); 841 cPlot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT); 842 JFreeChart chart = new JFreeChart(chartName, cPlot); 843 chart.addSubtitle(subtitle); 844 return chart; 845 } 846 847 private JFreeChart getResourcesAirFlowDiagram(ResourceType resType, String chartName, 848 Title subtitle, String simulationTime) { 849 String airFlow = "AIR FLOW [m^3/min]"; 850 boolean urls = false; 851 boolean tooltip = true; 852 boolean legend = true; 853 CombinedDomainXYPlot cPlot = new CombinedDomainXYPlot(); 854 DateAxis xAxis = new DateAxis(simulationTime); 855 856 List<XYDataset> airFlowDiagram = resourceAirFlowDiagrams.get(resType); 857 for (XYDataset dataset : airFlowDiagram) { 858 859 JFreeChart tChart = ChartFactory.createXYStepAreaChart("", "", 860 null, dataset, PlotOrientation.VERTICAL, legend, tooltip, 861 urls); 862 863 XYPlot tPlot = tChart.getXYPlot(); 864 NumberAxis yAxis = new NumberAxis(airFlow); 761 865 yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 762 866 tPlot.setRangeAxis(yAxis); … … 870 974 XYSeriesCollection dataset = new XYSeriesCollection(); 871 975 XYSeries data = new XYSeries(resStats.resourceName, false, true); 872 Map<Long, Integer> usage = resStats.getUsage();976 Map<Long, Double> usage = resStats.getUsage(); 873 977 874 978 for (Long key : usage.keySet()) { 875 Integerval = usage.get(key);876 double newv = 100*val/basicResStats.size();877 int newinv = (int)newv;878 data.add(key, new Integer(newinv));979 Double val = usage.get(key); 980 double newv = 100 * val; 981 //System.out.println(newv+":"+val+";"+basicResStats.size()); 982 data.add(key, new Double(newv)); 879 983 } 880 984 dataset.addSeries(data); … … 950 1054 } 951 1055 1056 private double calculateAirFlowLoad(ResourceAirFlowStats resAirFlowStats ){ 1057 double meanAirFlow = 0; 1058 long time = 0; 1059 double usage = 0; 1060 Map<Long, Double> airFlow = resAirFlowStats.getAirFlow(); 1061 for (Long key : airFlow.keySet()) { 1062 1063 if (time != 0) { 1064 meanAirFlow += (usage * (key - time)) 1065 / (endSimulationTime - startSimulationTime); 1066 1067 time = key; 1068 } else { 1069 time = key; 1070 } 1071 usage = (double) airFlow.get(key); 1072 } 1073 return meanAirFlow; 1074 } 1075 1076 952 1077 /*private void createPEGanttDiagram(String peName, 953 1078 String uniqueTaskID, Map<String, Object> historyItem) { … … 1006 1131 Job job = (Job) jobs.get(i); 1007 1132 1008 //List<TaskInterface> execList = JobRegistry.getInstance("COMPUTING_GRID_0#BROKER").getAllSubmittedTasks();1009 1133 List<Executable> execList = jr.getExecutableTasks().getJobExecutables(job.getId()); 1010 1134 List<TaskStats> taskStatsList = new ArrayList<TaskStats>(); … … 1346 1470 statsData.put(RESOURCES_RESERVATION_LOAD, accStats.meanEnergyUsage); 1347 1471 statsData.put(RESOURCES_QUEUE_LENGTH, accStats.meanQueueLength); 1348 1349 1472 } 1350 1473 … … 1417 1540 chartLoad, 1418 1541 textEnergy, 1419 chartEnergy; 1542 chartEnergy, 1543 textAirFlow, 1544 chartAirFlow; 1420 1545 } -
DCWoRMS/trunk/src/simulator/stats/implementation/GSSAccumulatorsStats.java
r477 r495 10 10 public GSSAccumulator meanQueueLength; 11 11 public GSSAccumulator meanEnergyUsage; 12 public GSSAccumulator meanAirFlow; 12 13 13 14 public GSSAccumulator meanTaskStartTime; … … 29 30 meanReservationLoad = new GSSAccumulator(); 30 31 meanQueueLength = new GSSAccumulator(); 31 meanEnergyUsage = new GSSAccumulator(); 32 meanEnergyUsage = new GSSAccumulator(); 33 meanAirFlow = new GSSAccumulator(); 32 34 33 35 meanTaskStartTime = new GSSAccumulator(); -
DCWoRMS/trunk/src/simulator/stats/implementation/ResourceUsageStats.java
r477 r495 15 15 public class ResourceUsageStats implements StatsInterface { 16 16 17 protected Map<Long, Integer> usage;17 protected Map<Long, Double> usage; 18 18 protected String resourceName; 19 19 protected String usageType; … … 31 31 this.resourceType = resourceType; 32 32 this.usageType = usageType; 33 this.usage = new TreeMap<Long, Integer>();33 this.usage = new TreeMap<Long, Double>(); 34 34 this.meanUsage = 0; 35 35 } … … 51 51 } 52 52 53 public Map<Long, Integer> getUsage() {53 public Map<Long, Double> getUsage() { 54 54 return this.usage; 55 55 } -
DCWoRMS/trunk/src/simulator/stats/implementation/out/StatsSerializer.java
r477 r495 4 4 import simulator.stats.implementation.GSSAccumulatorsStats; 5 5 import simulator.stats.implementation.JobStats; 6 import simulator.stats.implementation.ResourceAirFlowStats; 6 7 import simulator.stats.implementation.ResourceEnergyStats; 7 8 import simulator.stats.implementation.ResourceStats; … … 28 29 public Object visit(ResourceEnergyStats arg); 29 30 31 public Object visit(ResourceAirFlowStats arg); 30 32 31 33 public Object visit(GSSAccumulatorsStats arg); -
DCWoRMS/trunk/src/simulator/stats/implementation/out/StringSerializer.java
r477 r495 11 11 import simulator.stats.implementation.GSSAccumulatorsStats; 12 12 import simulator.stats.implementation.JobStats; 13 import simulator.stats.implementation.ResourceAirFlowStats; 13 14 import simulator.stats.implementation.ResourceEnergyStats; 14 15 import simulator.stats.implementation.ResourceStats; … … 258 259 259 260 public Object visit(ResourceUsageStats resourceUsageStats) { 260 Map<Long, Integer> resourceUsage = resourceUsageStats.getUsage();261 Map<Long, Double> resourceUsage = resourceUsageStats.getUsage(); 261 262 262 263 int mapSize = resourceUsage.size(); … … 297 298 buffer.append(resourceUsageStats.getResourceName()); 298 299 buffer.append(fieldSeparator); 299 Integervalue = resourceUsage.get(timestamp);300 Double value = resourceUsage.get(timestamp); 300 301 buffer.append(timestamp); 301 302 buffer.append(fieldSeparator); … … 371 372 } 372 373 374 public Object visit(ResourceAirFlowStats resourceAirFlowStats) { 375 Map<Long, Double> resourceAirFlow = resourceAirFlowStats.getAirFlow(); 376 377 int mapSize = resourceAirFlow.size(); 378 /* 379 * FIXME: 380 * Integer.MAX_VALUE = 2147483647. We assume, that each line contains 381 * max 30 signs - this gives max 71582788 lines. If resourceUsage map 382 * contains more elements then we have a problem, because content of 383 * resourceUsage map will not fit in the buffer. 384 * This will need further attention in the future. 385 */ 386 int maxSize = (Integer.MAX_VALUE / 30 ) - 1; 387 if(mapSize >= maxSize){ 388 log.error("Resource usage data is to long to fit in the buffer."); 389 return null; 390 } 391 392 int size = 30 * resourceAirFlow.size(); 393 394 StringBuffer buffer = null; 395 396 if(printedHeaders.add(resourceAirFlowStats.getUsageType())) { 397 buffer = new StringBuffer(size + 42); 398 String[] headers = resourceAirFlowStats.getHeaders(); 399 for(int i = 0; i < headers.length; i++) 400 { 401 buffer.append(headers[i]); 402 buffer.append(fieldSeparator); 403 } 404 buffer.append(System.getProperty("line.separator")); 405 } else { 406 buffer = new StringBuffer(size); 407 } 408 409 410 for (Long timestamp : resourceAirFlow.keySet()) { 411 412 buffer.append(resourceAirFlowStats.getResourceName()); 413 buffer.append(fieldSeparator); 414 Double value = resourceAirFlow.get(timestamp); 415 buffer.append(timestamp); 416 buffer.append(fieldSeparator); 417 buffer.append(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT 418 .format(value)); 419 buffer.append(fieldSeparator); 420 buffer.append(System.getProperty("line.separator")); 421 422 } 423 424 if(resourceAirFlow.size() > 0) { 425 buffer.append("mean: "+resourceAirFlowStats.getMeanUsage() + " sum: " +resourceAirFlowStats.getSumUsage()); 426 buffer.append(System.getProperty("line.separator")); 427 } 428 429 return buffer.toString(); 430 } 431 373 432 public Object visit(GSSAccumulatorsStats accStats) { 374 433
Note: See TracChangeset
for help on using the changeset viewer.