Ignore:
Timestamp:
10/10/12 12:12:06 (13 years ago)
Author:
wojtekp
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java

    r494 r495  
    6262import schedframe.resources.computing.extensions.ExtensionType; 
    6363import schedframe.resources.computing.profiles.energy.EnergyExtension; 
     64import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue; 
    6465import schedframe.resources.computing.profiles.energy.power.PowerUsage; 
    6566import schedframe.resources.units.PEUnit; 
     
    8182import simulator.stats.SimulationStatistics; 
    8283import simulator.stats.implementation.out.AbstractStringSerializer; 
    83 import simulator.stats.implementation.out.FormatedStringSerializer; 
    8484import simulator.stats.implementation.out.StringSerializer; 
    8585import csiro.mit.utils.jfreechart.timetablechart.TimetableChartFactory; 
     
    9898        protected static float ALPHA = 0.5f; 
    9999        protected static int GANTT_WIDTH = 1200; 
    100  
    101         //protected static final int BITS = 8; 
     100         
    102101        protected static final int MILLI_SEC = 1000; 
    103102 
     
    106105 
    107106        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"; 
    110110 
    111111        protected static final String DIAGRAMS_FILE_NAME_PREFIX = "Chart_"; 
     
    123123        protected Map<String, GSSAccumulator> statsData; 
    124124         
    125         private GenericUser users; 
     125        protected GenericUser users; 
    126126        protected ResourceController resourceController; 
    127127        protected boolean generateDiagrams = true; 
     
    132132        //RESOURCES 
    133133        protected Timetable ganttDiagramPeTimetable; 
    134         protected Map<ResourceType, List<XYDataset>> resourceEnergyDiagrams; 
     134        protected Map<ResourceType, List<XYDataset>> resourcePowerUsageDiagrams; 
     135        protected Map<ResourceType, List<XYDataset>> resourceAirFlowDiagrams; 
    135136        protected Map<ResourceType, List<XYDataset>> resourceLoadDiagrams; 
    136137        protected Map<String,List<ResStat>> basicResStats; 
     
    161162                this.outputFolderName = outputFolderName; 
    162163 
    163  
    164164                this.serializer = new StringSerializer(); 
    165  
    166165                this.serializer.setDefaultNumberFormat(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT); 
    167166 
    168167                this.resourceController = resourceController; 
    169                 jr = new JobRegistryImpl(""); 
     168                this.jr = new JobRegistryImpl(""); 
    170169                init(); 
    171170        } 
     
    174173 
    175174                this.startSimulationTime = DateTimeUtilsExt.getOffsetTime().getTimeInMillis(); 
    176  
    177175                this.endSimulationTime = DateTimeUtilsExt.currentTimeMillis(); 
    178176 
     
    235233        private void gatherResourceStatistics() { 
    236234                 
    237                  
    238                 //TEMPORARY CONFIGURATION SECTION 
    239                  
    240235                HashMap<String, List<Stats>> type_stats = new HashMap<String, List<Stats>>(); 
    241236                 
     
    248243                        if(ArrayUtils.contains(configuration.resForEnergyChart, resourceName)) 
    249244                                cStats.add(Stats.chartEnergy); 
     245                        cStats.add(Stats.textAirFlow); 
     246                        if(ArrayUtils.contains(configuration.resForAirFlowChart, resourceName)) 
     247                                cStats.add(Stats.chartAirFlow); 
    250248                        type_stats.put(resourceName, cStats); 
    251249                }                
    252250                 
    253251                peGanttMap = new HashMap<String, TimetableEventSource>(); 
    254                 taskGanttMap = new HashMap<String, TimetableEventGroup>(); 
    255                  
     252                taskGanttMap = new HashMap<String, TimetableEventGroup>();               
    256253                 
    257254                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>>(); 
    259257                 
    260258                ganttDiagramPeTimetable = new Timetable(new FixedMillisecond( 
     
    265263                        File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 
    266264                                        + simulationIdentifier + "_" 
    267                                         + RESOURCEUSAGE_STATISTICS_OUTPUT_FILE_NAME); 
     265                                        + RESOURCEUTILIZATION_STATISTICS_OUTPUT_FILE_NAME); 
    268266                        resourceLoadStatsFile = new PrintStream(new FileOutputStream(file)); 
    269267                } catch (IOException e) { 
     
    280278                        energyStatsFile = null; 
    281279                } 
    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 
    283291                basicResStats = gatherPEStats(jr.getExecutableTasks()); 
    284292                peStatsPostProcessing(basicResStats); 
     
    291299                for(String resourceName: resourceController.getComputingResourceLayers()){ 
    292300                        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                 
    303309                        if(type_stats.containsKey(resourceName)){ 
    304                                 Map<String, GSSAccumulator> energyCategoryStats = new TreeMap<String, GSSAccumulator>(); 
    305                                 Map<String, GSSAccumulator> loadCategoryStats = new TreeMap<String, GSSAccumulator>(); 
    306310                                for(ComputingResource resource: resources){ 
    307311                                        ResourceUsageStats resourceUsage = null; 
    308312                                        ResourceEnergyStats energyUsage = null; 
     313                                        ResourceAirFlowStats airFlow = null; 
    309314                                        if(type_stats.get(resourceName).contains(Stats.textLoad)){ 
    310315                                                resourceUsage = gatherResourceLoadStats(resource, basicResStats); 
     
    358363                                        } 
    359364                                         
    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                                                        } 
    370390                                                } 
    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); 
    380394                                                } 
    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); 
    391400                                                } 
    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()); 
    411401                                        } 
    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"); 
    423402                                } 
    424403                        } 
     
    427406                saveResourceGanttDiagrams(); 
    428407                createAccumulatedResourceSimulationStatistic(); 
     408                if (airFlowStatsFile != null) { 
     409                        airFlowStatsFile.close(); 
     410                } 
    429411                if (energyStatsFile != null) { 
    430412                        energyStatsFile.close(); 
     
    472454                } 
    473455        } 
     456         
    474457        private Map<String, List<ResStat>> gatherPEStats( ExecutablesList executables) { 
    475  
    476458                 
    477459                Map<String, List<ResStat>> basicResStats = new TreeMap<String, List<ResStat>>(new MapPEIdComparator()); 
    478                 //Map<Integer, Map<String, Object>> history 
    479                  
     460 
    480461                for (ExecTask execTask:executables) { 
    481462                        Executable exec = (Executable) execTask; 
     
    485466                        ResourceUnit resUnit = res.get(StandardResourceUnitName.PE); 
    486467                        //ProcessingElements pes = (ProcessingElements) resUnit ; 
    487                         if(resUnit instanceof ProcessingElements ){ 
     468                        if(resUnit instanceof ProcessingElements){ 
    488469                                ProcessingElements pes = (ProcessingElements) resUnit; 
    489470                                for(ComputingResource pe: pes){ 
     
    491472                                        long startDate = Double.valueOf(exec.getExecStartTime()).longValue() * MILLI_SEC; 
    492473                                        long endDate = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC; 
    493  
    494474 
    495475                                        String uniqueTaskID = execTask.getJobId() + "_" + execTask.getId(); 
     
    525505        private ResourceUsageStats gatherResourceLoadStats(ComputingResource resource, Map<String,List<ResStat>> basicStats) { 
    526506                ResourceUsageStats usageStats = new ResourceUsageStats(resource.getName(), resource.getType(), "resourceLoadStats"); 
     507                int cnt =0; 
    527508                for(String resName: basicStats.keySet()){ 
    528509                        try { 
    529510                                if(resource.getDescendantByName(resName) != null || resource.getName().compareTo(resName) == 0){ 
     511                                        cnt++; 
    530512                                        createResourceLoadData(usageStats, basicStats.get(resName)); 
    531513                                } 
     
    535517                        } 
    536518                } 
     519                for(Long key: usageStats.getUsage().keySet()){ 
     520                        Double value = usageStats.getUsage().get(key)/cnt; 
     521                        usageStats.getUsage().put(key, value); 
     522                } 
     523 
    537524                return usageStats; 
    538525        } 
    539526         
    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(); 
    543530                for (ResStat resStat : resStats) { 
    544531                         
     
    546533                        long end_time = resStat.getEndDate(); 
    547534                        if (end_time > start_time) { 
    548                                 Integer end = ganttData.get(end_time); 
     535                                Double end = ganttData.get(end_time); 
    549536                                if (end == null) { 
    550                                         ganttData.put(end_time, 0); 
     537                                        ganttData.put(end_time, 0.0); 
    551538                                        Long left = getLeftKey(ganttData, end_time); 
    552539                                        if (left != null) { 
    553                                                 Integer leftValue = ganttData.get(left); 
     540                                                Double leftValue = ganttData.get(left); 
    554541                                                ganttData.put(end_time, leftValue); 
    555542                                        } 
    556543                                } 
    557544 
    558                                 Integer start = ganttData.get(start_time); 
     545                                Double start = ganttData.get(start_time); 
    559546                                if (start == null) { 
    560                                         ganttData.put(start_time, 0); 
     547                                        ganttData.put(start_time, 0.0); 
    561548                                        Long left = getLeftKey(ganttData, start_time); 
    562549                                        if (left != null) { 
    563                                                 Integer leftValue = ganttData.get(left); 
     550                                                Double leftValue = ganttData.get(left); 
    564551                                                ganttData.put(start_time, leftValue); 
    565552                                        } 
    566553                                } 
    567554 
    568                                 SortedMap<Long, Integer> sm = ganttData.subMap(start_time, 
     555                                SortedMap<Long, Double> sm = ganttData.subMap(start_time, 
    569556                                                end_time); 
    570557                                for (Long key : sm.keySet()) { 
    571                                         Integer keyVal = ganttData.get(key); 
     558                                        Double keyVal = ganttData.get(key); 
    572559                                        ganttData.put(key, keyVal + 1); 
    573560                                } 
    574561                        } 
    575562                } 
     563 
    576564                return ganttData; 
    577565        } 
    578566 
    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); 
    582570                if (sm.isEmpty()) { 
    583571                        return null; 
     
    621609        } 
    622610         
    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, 
    626646                                startSimulationTime, endSimulationTime); 
    627647                 
    628                 List<XYDataset> energyDiagram = resourceEnergyDiagrams.get(energyUsage.getResourceType()); 
     648                List<XYDataset> energyDiagram = resourcePowerUsageDiagrams.get(powerUsage.getResourceType()); 
    629649                if(energyDiagram == null){ 
    630650                        energyDiagram = new ArrayList<XYDataset>(); 
    631651                        energyDiagram.add(dataset); 
    632                         resourceEnergyDiagrams.put(energyUsage.getResourceType(), energyDiagram); 
     652                        resourcePowerUsageDiagrams.put(powerUsage.getResourceType(), energyDiagram); 
    633653                } else { 
    634654                        energyDiagram.add(dataset); 
     
    637657        } 
    638658 
     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         
    639675        private XYDataset createResourceEnergyGanttDataSet( 
    640676                        ResourceEnergyStats energyUsage, long start, long end) { 
     
    665701        } 
    666702 
     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        } 
    667729 
    668730        private boolean saveResourceGanttDiagrams() { 
     
    670732                JFreeChart peDiagram = null; 
    671733                JFreeChart resourceEnergyDiagram = null; 
     734                JFreeChart resourceAirFlowDiagram = null; 
    672735                if (!generateDiagrams) 
    673736                        return false; 
     
    701764                } 
    702765                if (configuration.creatediagrams_energyusage) { 
    703                         for(ResourceType resType: resourceEnergyDiagrams.keySet()){ 
     766                        for(ResourceType resType: resourcePowerUsageDiagrams.keySet()){ 
    704767                                resourceEnergyDiagram = getResourcesEnergyDiagram(resType, chartName, 
    705768                                                subtitle, simulationTime); 
     
    708771                        } 
    709772                } 
     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                } 
    710783                return true; 
    711784        } 
     
    713786        private JFreeChart getResourcesLoadDiagram(ResourceType resType, String chartName, Title subtitle, 
    714787                        String simulationTime) { 
    715                 String cpu = "CPU"; 
     788                String cpu = "UTILIZATION [%]"; 
    716789                boolean urls = false; 
    717790                boolean tooltip = true; 
     
    750823                DateAxis xAxis = new DateAxis(simulationTime); 
    751824 
    752                 List<XYDataset> energyDiagram = resourceEnergyDiagrams.get(resType); 
     825                List<XYDataset> energyDiagram = resourcePowerUsageDiagrams.get(resType); 
    753826                for (XYDataset dataset : energyDiagram) { 
    754827 
     
    759832                        XYPlot tPlot = tChart.getXYPlot(); 
    760833                        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); 
    761865                        yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 
    762866                        tPlot.setRangeAxis(yAxis); 
     
    870974                XYSeriesCollection dataset = new XYSeriesCollection(); 
    871975                XYSeries data = new XYSeries(resStats.resourceName, false, true); 
    872                 Map<Long, Integer> usage = resStats.getUsage(); 
     976                Map<Long, Double> usage = resStats.getUsage(); 
    873977                 
    874978                for (Long key : usage.keySet()) { 
    875                         Integer val = 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)); 
    879983                } 
    880984                dataset.addSeries(data); 
     
    9501054        } 
    9511055         
     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         
    9521077        /*private void createPEGanttDiagram(String peName, 
    9531078                        String uniqueTaskID, Map<String, Object> historyItem) { 
     
    10061131                        Job job = (Job) jobs.get(i); 
    10071132 
    1008                         //List<TaskInterface> execList = JobRegistry.getInstance("COMPUTING_GRID_0#BROKER").getAllSubmittedTasks(); 
    10091133                        List<Executable> execList = jr.getExecutableTasks().getJobExecutables(job.getId()); 
    10101134                        List<TaskStats> taskStatsList = new ArrayList<TaskStats>(); 
     
    13461470                statsData.put(RESOURCES_RESERVATION_LOAD, accStats.meanEnergyUsage); 
    13471471                statsData.put(RESOURCES_QUEUE_LENGTH, accStats.meanQueueLength); 
    1348  
    13491472        } 
    13501473 
     
    14171540        chartLoad, 
    14181541        textEnergy, 
    1419         chartEnergy; 
     1542        chartEnergy, 
     1543        textAirFlow, 
     1544        chartAirFlow; 
    14201545} 
Note: See TracChangeset for help on using the changeset viewer.