Ignore:
Timestamp:
11/26/13 11:56:07 (11 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/branches/coolemall/src/simulator
Files:
5 added
21 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/simulator/ConfigurationOptions.java

    r802 r1207  
    5252        public static final String READ_SCENARIO_INPUT_FOLDER = READ_SCENARIO_MODIFIER 
    5353                        + ".inputfolder"; 
    54          
     54        /** The input folder with application profiles */ 
     55        public static final String READ_SCENARIO_APPLCIATION_PROFILES = READ_SCENARIO_MODIFIER + ".applicationProfiles"; 
    5556        /** The name of the workload file */ 
    5657        public static final String READ_SCENARIO_WORKLOAD_FILE = READ_SCENARIO_MODIFIER 
     
    7980        public static final String JOBS_STATISTICS = CREATESTATISTICS + ".jobs"; 
    8081        public static final String SIMULATION_STATISTICS = CREATESTATISTICS + ".simulation"; 
    81          
    82         public static final String COOLEMALL = "coolemall"; 
    83         public static final String COOLEMALL_RESOURCE = COOLEMALL + ".resdesc"; 
    84  
     82 
     83        public static final String PRESSURE_DROP = "pressuredrop"; 
     84        public static final String OUTLET_ROOM_AIR_TEMPERATURE = "outletroomairtemperature"; 
     85        public static final String INLET_ROOM_AIR_TEMPERATURE = "inletroomairtemperature"; 
     86        public static final String AMBIENT_AIR_TEMPERATURE = "ambientairtemperature"; 
     87        public static final String AIR_FLOW_VOLUME = "airflowvolume"; 
     88        public static final String ALPHA = "alpha"; 
     89         
    8590        /** 
    8691         * The main output folders base name 
     
    101106         * Suffix for read scenario output folder 
    102107         */ 
    103         public String statsOutputSubfolderNameRerad = null; 
     108        public String statsOutputSubfolderNameRead = null; 
    104109         
    105110        /* =============================================================================================== */ 
     
    137142         */ 
    138143        public String inputFolder = null; 
     144         
     145        public String appProfilesFolder = null; 
    139146         
    140147        public String inputTar = null; 
     
    184191        public String [] resForUtilizationChart; 
    185192         
    186         public String coolEmAllResdescFileName = null; 
    187  
     193        public static double pressureDrop; 
     194        public static double outletRoomAirTempeature; 
     195        public static double inletRoomAirTempeature; 
     196        public static double ambientAirTempeature; 
     197        public static double airFlowVolume; 
     198        public static double alpha 
     199        ; 
    188200        /** 
    189201         * An empty constructor. 
     
    255267                         
    256268                        try { 
     269                                co.appProfilesFolder  = getSeparatorTerminatedPath(bundle 
     270                                        .getString(READ_SCENARIO_APPLCIATION_PROFILES)); 
     271                        } catch (MissingResourceException e) { 
     272                                co.appProfilesFolder  = null; 
     273                        } 
     274                         
     275                        try { 
    257276                                co.inputWorkloadFileName = bundle 
    258277                                                .getString(READ_SCENARIO_WORKLOAD_FILE); 
     
    346365                try { 
    347366                        co.statsOutputSubfolderNameCreate = bundle.getString(STATS_OUTPUT_SUBFOLDER_NAME); 
    348                         co.statsOutputSubfolderNameRerad = co.statsOutputSubfolderNameCreate; 
     367                        co.statsOutputSubfolderNameRead = co.statsOutputSubfolderNameCreate; 
    349368                } catch(MissingResourceException e){ 
    350369                        co.statsOutputSubfolderNameCreate = "stats_create"; 
    351                         co.statsOutputSubfolderNameRerad = "stats_read"; 
     370                        co.statsOutputSubfolderNameRead = "stats_read"; 
    352371                } 
    353372 
     
    370389                        co.numberOfSimulations = 1; 
    371390                } 
    372                  
    373                 try { 
    374                         co.coolEmAllResdescFileName = bundle.getString(COOLEMALL_RESOURCE); 
    375                         System.setProperty("coolemall.resdesc", co.coolEmAllResdescFileName); 
    376                 } catch(MissingResourceException e){ 
    377                         co.coolEmAllResdescFileName = null; 
    378                 } 
     391 
     392                try { 
     393                        ConfigurationOptions.pressureDrop = Double.valueOf(bundle.getString(PRESSURE_DROP)).doubleValue(); 
     394                } catch(MissingResourceException e){ 
     395                        ConfigurationOptions.pressureDrop = 175.337; 
     396                } 
     397                 
     398                try { 
     399                        ConfigurationOptions.outletRoomAirTempeature = Double.valueOf(bundle.getString(OUTLET_ROOM_AIR_TEMPERATURE)).doubleValue(); 
     400                } catch(MissingResourceException e){ 
     401                        ConfigurationOptions.outletRoomAirTempeature = 23; 
     402                } 
     403                 
     404                try { 
     405                        ConfigurationOptions.inletRoomAirTempeature = Double.valueOf(bundle.getString(INLET_ROOM_AIR_TEMPERATURE)).doubleValue(); 
     406                } catch(MissingResourceException e){ 
     407                        ConfigurationOptions.inletRoomAirTempeature = 17; 
     408                } 
     409                 
     410                try { 
     411                        ConfigurationOptions.ambientAirTempeature = Double.valueOf(bundle.getString(AMBIENT_AIR_TEMPERATURE)).doubleValue(); 
     412                } catch(MissingResourceException e){ 
     413                        ConfigurationOptions.ambientAirTempeature = 17; 
     414                } 
     415                 
     416                try { 
     417                        ConfigurationOptions.airFlowVolume = Double.valueOf(bundle.getString(AIR_FLOW_VOLUME)).doubleValue(); 
     418                } catch(MissingResourceException e){ 
     419                        ConfigurationOptions.airFlowVolume = 0.304; 
     420                } 
     421                 
     422                try { 
     423                        ConfigurationOptions.alpha = Double.valueOf(bundle.getString(ALPHA)).doubleValue(); 
     424                } catch(MissingResourceException e){ 
     425                        ConfigurationOptions.alpha = 0.02; 
     426                } 
     427                 
    379428                return co; 
    380429        } 
  • DCWoRMS/branches/coolemall/src/simulator/DCWormsUsers.java

    r1160 r1207  
    2222import org.apache.commons.logging.LogFactory; 
    2323import org.joda.time.DateTime; 
    24 import org.qcg.broker.schemas.jobdesc.ParentType; 
    25 import org.qcg.broker.schemas.jobdesc.Workflow; 
    26 import org.qcg.broker.schemas.jobdesc.types.TaskStatesName; 
    2724 
    2825import qcg.shared.constants.BrokerConstants; 
     
    244241                         
    245242                } 
    246                 System.out.println("finished sending jobs"); 
    247243        } 
    248244         
  • DCWoRMS/branches/coolemall/src/simulator/DataCenterWorkloadSimulator.java

    r1142 r1207  
    1414import javax.swing.filechooser.FileFilter; 
    1515 
     16import org.apache.commons.io.FilenameUtils; 
    1617import org.apache.commons.logging.Log; 
    1718import org.apache.commons.logging.LogFactory; 
     
    2122 
    2223import schedframe.Initializable; 
    23 import schedframe.ResourceController; 
     24import schedframe.SimulatedEnvironment; 
    2425import simulator.reader.ResourceReader; 
    2526import simulator.stats.AccumulatedStatistics; 
     
    5152         * The name of the simulator application 
    5253         */ 
    53         public static final String SIMULATOR_NAME = "Data Center Workload Simulator"; 
     54        public static final String SIMULATOR_NAME = "Data Center Workload and Resource Management Simulator"; 
     55         
     56        /** 
     57         * The simulation mode 
     58         */ 
     59        public static String MODE = "Standard"; 
    5460 
    5561        /** 
     
    183189                } 
    184190 
    185                 if (log.isInfoEnabled()) 
     191                if (log.isInfoEnabled()){ 
    186192                        log.info("Done :: " + SIMULATOR_NAME + " has finished " 
    187193                                        + noOfSimulations + " simulation runs ::"); 
     194                        log.info("Simulation finished with status: 0"); 
     195                } 
    188196 
    189197                System.out.flush(); 
     
    259267 
    260268                ResourceReader resourceReader = new ResourceReader( 
    261                                 options); 
    262                 ResourceController rc = resourceReader.read(); 
     269                                options.resdescFileName); 
     270                SimulatedEnvironment rc = resourceReader.read(); 
    263271                eventManager = new EventManager("eventManager", rc); 
    264272                 
     
    268276                rc.setInitList(null); 
    269277                 
    270                 DCWormsUsers wl = new DCWormsUsers("Users", 
     278                DCWormsUsers users = new DCWormsUsers("Users", 
    271279                                rc.getScheduler().get_name(), workload); 
    272280                 
     281                System.out.println("Starting simulation..."); 
     282 
    273283                GridSimWrapper.startSimulation(); 
    274284                long stopSimulation = System.currentTimeMillis(); 
    275285 
     286                System.out.println("Simulation finished"); 
     287 
    276288                DCWormsStatistics stats = new DCWormsStatistics(simulationIdentifier, 
    277                                 options, wl, statsOutputPath, rc); 
     289                                options, users, statsOutputPath, rc); 
    278290                accumulatedStatistics.add(stats); 
    279291                if (log.isInfoEnabled()) 
     
    301313                String wlFileName = options.inputWorkloadFileName; 
    302314 
     315                String appProfilesFolder = options.appProfilesFolder; 
    303316                if (options.inputFolder != null) { 
    304317                        File f = null; 
     
    318331                swfReader = AbstractWAReader.getInstace(wlFileName); 
    319332 
    320                 WorkloadLoader workload = new WorkloadLoader(xmlJobReader, swfReader); 
     333                WorkloadLoader workload = new WorkloadLoader(xmlJobReader, swfReader, appProfilesFolder); 
    321334                workload.load(); 
    322335 
     
    346359                                prefix = options.inputFolder; 
    347360                        } else if (options.inputWorkloadFileName != null) { 
    348                                 prefix = new File(options.inputWorkloadFileName).getParent(); 
     361                                prefix = FilenameUtils.getFullPath(new File(options.inputWorkloadFileName).getAbsolutePath()); 
    349362                        } else { 
    350363                                prefix = System.getProperty("user.dir"); 
    351364                        } 
    352                         statsOutputPath = prefix + File.separator 
    353                                         + options.statsOutputSubfolderNameRerad; 
     365                        //statsOutputPath = prefix + File.separator 
     366                        //              + options.statsOutputSubfolderNameRead; 
     367                        statsOutputPath = options.statsOutputSubfolderNameRead; 
    354368                } 
    355369                statsOutputPath += File.separator; 
  • DCWoRMS/branches/coolemall/src/simulator/reader/EnvironmentWrapper.java

    r477 r1207  
    1818public class EnvironmentWrapper { 
    1919 
    20         Environment environment; 
     20        private Environment environment; 
    2121 
    2222        public void wrap(Environment environment) { 
     
    5353        public ComputingResource[] getComputingResources() throws UnknownParameter{ 
    5454                 
    55                 ArrayList<ComputingResource>tab = null; 
    56                  
    5755                if(environment == null) 
    5856                        throw new UnknownParameter("Environment parameters are not defined."); 
     
    6159                        return null; 
    6260                 
    63                 tab = new ArrayList<ComputingResource>(); 
     61                ArrayList<ComputingResource> computingResources = new ArrayList<ComputingResource>(); 
    6462                  
    6563                for(int i = 0; i < resources.getComputingResourceCount(); i++){ 
    6664                        ComputingResource compRes = resources.getComputingResource(i); 
    67                         tab.add(compRes); 
     65                        computingResources.add(compRes); 
    6866                } 
    69                 if(tab.size() == 0) 
     67                if(computingResources.size() == 0) 
    7068                        return null; 
    7169                else 
    72                         return tab.toArray(new ComputingResource[0]); 
     70                        return computingResources.toArray(new ComputingResource[0]); 
    7371        } 
    7472         
  • DCWoRMS/branches/coolemall/src/simulator/reader/ResourceReader.java

    r1042 r1207  
    11package simulator.reader; 
    2  
    3 import gridsim.ResourceCalendar; 
    42 
    53import java.io.File; 
     
    1917import java.util.Set; 
    2018 
     19import org.apache.commons.io.FilenameUtils; 
    2120import org.exolab.castor.xml.MarshalException; 
    2221import org.exolab.castor.xml.ValidationException; 
     
    2625import schedframe.Parameter; 
    2726import schedframe.Parameters; 
    28 import schedframe.ResourceController; 
     27import schedframe.SimulatedEnvironment; 
    2928import schedframe.exceptions.ResourceException; 
     29import schedframe.resources.CoolEmAllResourceFactory; 
    3030import schedframe.resources.Resource; 
    3131import schedframe.resources.StandardResourceType; 
    3232import schedframe.resources.computing.ComputingResource; 
    3333import schedframe.resources.computing.ResourceFactory; 
    34 import schedframe.resources.computing.description.AbstractResourceDescription; 
     34import schedframe.resources.computing.StandardResourceFactory; 
    3535import schedframe.resources.computing.description.ComputingResourceDescription; 
     36import schedframe.resources.computing.description.ResourceDescription; 
    3637import schedframe.resources.units.ResourceUnit; 
    3738import schedframe.resources.units.ResourceUnitName; 
     
    4546import schemas.ManagedComputingResources; 
    4647import schemas.StringValueWithUnit; 
    47 import simulator.ConfigurationOptions; 
     48import simulator.DataCenterWorkloadSimulator; 
    4849import simulator.utils.InstanceFactory; 
     50import test.DEBBTranslator.src.PLMXMLTranslator; 
    4951 
    5052public class ResourceReader { 
    5153         
    5254        private static String COOLEMALL_RESDESC_PREFIX = "DCWORMS"; 
    53         protected String resDescFileName; 
    54  
    55         protected ResourceCalendar resourceCalendar; 
    56         protected List<Initializable> toInit = new ArrayList<Initializable>(); 
    57          
     55        private String resDescFileName; 
     56        private ResourceFactory resFactory; 
     57                 
    5858        private ExecutionTimeEstimationPlugin execTimeEstimationPlugin; 
    59         private String globalSchedulingPluginName; 
    6059         
    6160        private Set<String> compResLayers; 
    62          
    63         public ResourceReader(ConfigurationOptions options) throws IOException { 
    64  
    65                 resDescFileName = options.resdescFileName; 
    66                 globalSchedulingPluginName = "example.globalplugin.GridFCFSRoundRobinPlugin"; 
    67                 prepareCalendar(); 
    68                 compResLayers = new LinkedHashSet<String>(); 
    69         } 
    70  
    71         public ResourceController read() throws MarshalException, ValidationException, FileNotFoundException, Exception, 
     61        private List<Initializable> toInit; 
     62         
     63        public ResourceReader(String resdescFileName) throws IOException { 
     64 
     65                this.resDescFileName = resdescFileName; 
     66                this.resFactory = new StandardResourceFactory(); 
     67                this.compResLayers = new LinkedHashSet<String>(); 
     68                this.toInit = new ArrayList<Initializable>(); 
     69        } 
     70 
     71        public SimulatedEnvironment read() throws MarshalException, ValidationException, FileNotFoundException, Exception, 
    7272                        UnknownParameter { 
    7373 
    7474                File file = new File(resDescFileName); 
    75                  
    76                 Environment env; 
     75 
     76                Environment env = null; 
    7777                try{ 
    7878                        env = Environment.unmarshal(new FileReader(file)); 
     79                         
    7980                } catch (Exception e){   
    80                         File dcwormsFile = new File(file.getParent() + "/" + COOLEMALL_RESDESC_PREFIX + "_" + file.getName()); 
    81                         env = Environment.unmarshal(new FileReader(dcwormsFile)); 
    82                 } 
    83                  
     81                        //e.printStackTrace(); 
     82                        try{ 
     83                                File dcwormsFile = new File(FilenameUtils.getFullPath(file.getAbsolutePath()) + COOLEMALL_RESDESC_PREFIX + "_" + file.getName()); 
     84                                env = Environment.unmarshal(new FileReader(dcwormsFile)); 
     85                        } catch (Exception e2){ 
     86                                PLMXMLTranslator plmxmlTranslator = new PLMXMLTranslator(); 
     87                                String trasnlatedFileName = plmxmlTranslator.translate(new String[]{file.getAbsolutePath()}); 
     88                                File dcwormsFile = new File(trasnlatedFileName);                         
     89                                //File dcwormsFile = new File(FilenameUtils.getFullPath(file.getAbsolutePath()) + COOLEMALL_RESDESC_PREFIX + "_" + file.getName()); 
     90 
     91                                env = Environment.unmarshal(new FileReader(dcwormsFile)); 
     92                        } 
     93                } 
     94                 
     95                if(env.getResources().getMode().equals("CoolEmAll")){ 
     96                        DataCenterWorkloadSimulator.MODE = "CoolEmAll"; 
     97                        resFactory = new CoolEmAllResourceFactory(); 
     98                } 
    8499                System.out.println("started creating environment description"); 
    85100                List<ComputingResourceDescription> mainCompResDescList = createEnvironmentDescription(env); 
     
    94109                System.out.println("finished creating schedulers"); 
    95110 
    96                 ResourceController rc = new ResourceController(mainScheduler, computingResources); 
     111                SimulatedEnvironment simEnv = new SimulatedEnvironment(mainScheduler, computingResources); 
    97112                Collections.sort(toInit, new ResourceTypeComparator(new ArrayList<String>(compResLayers))); 
    98                 rc.setInitList(toInit); 
    99                 rc.setCompResLayers(compResLayers); 
    100                 return rc; 
     113                simEnv.setInitList(toInit); 
     114                simEnv.setCompResLayers(compResLayers); 
     115                return simEnv; 
    101116        } 
    102117 
     
    181196                 
    182197                for(ComputingResourceDescription mainExecResDes : mainCompResDesList){ 
    183                         ComputingResource mainResource = ResourceFactory.createResource(mainExecResDes); 
     198                        ComputingResource mainResource = resFactory.createComputingResource(mainExecResDes); 
    184199                        toExamine.push(mainExecResDes); 
    185200                        resStructure.push(mainResource); 
     
    192207                        toInit.add(parentResource); 
    193208                        compResLayers.add(parentResource.getType().getName()); 
    194                         List<AbstractResourceDescription> childrenResDesc = parentResDesc.getChildren(); 
     209                        List<ResourceDescription> childrenResDesc = parentResDesc.getChildren(); 
    195210                        if (childrenResDesc == null){ 
    196211                                continue; 
     
    200215                                ComputingResourceDescription compResDesc = (ComputingResourceDescription) childrenResDesc.get(i); 
    201216                                toExamine.push(compResDesc); 
    202                                 ComputingResource resource = ResourceFactory.createResource(compResDesc); 
     217                                ComputingResource resource = resFactory.createComputingResource(compResDesc); 
    203218                                parentResource.addChild(resource); 
    204219                                resStructure.push(resource); 
     
    254269                } 
    255270                else{ 
    256                         SchedulingPlugin schedulingPlugin = (SchedulingPlugin) InstanceFactory.createInstance(globalSchedulingPluginName, 
    257                                         SchedulingPlugin.class); 
    258                         TaskQueueList queues = new TaskQueueList(1); 
    259                         TaskQueue queue = new TaskQueue(false); 
    260                         queues.add(queue); 
    261                         ManagedResources managedResources = new ManagedResources(mainCompResourceList, new HashMap<ResourceUnitName, List<ResourceUnit>>()); 
    262                         mainScheduler = ResourceFactory.createScheduler(StandardResourceType.GS, "grid", schedulingPlugin , execTimeEstimationPlugin,  queues, managedResources); 
    263  
    264                         for(Scheduler lr: mainSchedulers){ 
    265                                 mainScheduler.addChild(lr); 
    266                         } 
    267                         //necessary if children list isn't initialized in Scheduler 
    268                         //mainScheduler.init(); 
     271                        throw new Exception("Worng schedule definition"); 
    269272                } 
    270273                return mainScheduler; 
     
    332335                //TODO - refactor (create scheduler in 1 line) 
    333336                if(schedulerDef.getClazz().equals("GridBroker")){ 
    334                         scheduler = ResourceFactory.createScheduler(StandardResourceType.GS, "grid", schedulingPlugin, execTimeEstimationPlugin, queues, managedResources); 
     337                        scheduler = resFactory.createScheduler(StandardResourceType.GS, "grid", schedulingPlugin, execTimeEstimationPlugin, queues, managedResources); 
    335338                } else { 
    336                         scheduler = ResourceFactory.createScheduler(StandardResourceType.LS, schedulerDef.getName(), schedulingPlugin, execTimeEstimationPlugin,  queues, managedResources); 
     339                        scheduler = resFactory.createScheduler(StandardResourceType.LS, schedulerDef.getName(), schedulingPlugin, execTimeEstimationPlugin,  queues, managedResources); 
    337340                } 
    338341                return scheduler; 
     
    374377                                ComputingResource computingResource; 
    375378                                try { 
    376                                         if(resourceName.equals(mainCompRes.getName())) 
     379                                        if(mainCompRes.getFullName().contains(resourceName)) 
    377380                                                computingResource = mainCompRes; 
    378381                                        else 
     
    421424                return resourceUnits; 
    422425        } 
    423          
    424         private void prepareCalendar() { 
    425                 long seed = 11L * 13L * 17L * 19L * 23L + 1L; 
    426                 double timeZone = 0.0; 
    427                 double peakLoad = 0.0; // the resource load during peak hour 
    428                 double offPeakLoad = 0.0; // the resource load during off-peak hr 
    429                 double holidayLoad = 0.0; // the resource load during holiday 
    430  
    431                 // incorporates weekends so the grid resource is on 7 days a week 
    432                 LinkedList<Integer> Weekends = new LinkedList<Integer>(); 
    433                 Weekends.add(java.util.Calendar.SATURDAY); 
    434                 Weekends.add(java.util.Calendar.SUNDAY); 
    435  
    436                 // incorporates holidays. However, no holidays are set in this example 
    437                 LinkedList<Integer> Holidays = new LinkedList<Integer>(); 
    438                 resourceCalendar = new ResourceCalendar(timeZone, peakLoad, offPeakLoad, holidayLoad, Weekends, Holidays, 
    439                                 seed); 
    440         } 
     426 
    441427         
    442428        class ResourceTypeComparator implements Comparator<Initializable>{ 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/DCWormsStatistics.java

    r1199 r1207  
    77import java.io.IOException; 
    88import java.io.PrintStream; 
     9import java.text.DecimalFormat; 
    910import java.text.NumberFormat; 
    1011import java.util.ArrayList; 
     
    1415import java.util.Date; 
    1516import java.util.HashMap; 
     17import java.util.HashSet; 
    1618import java.util.List; 
    1719import java.util.Map; 
     20import java.util.Set; 
    1821import java.util.SortedMap; 
    1922import java.util.TreeMap; 
     
    5457 
    5558import schedframe.ExecutablesList; 
    56 import schedframe.ResourceController; 
     59import schedframe.SimulatedEnvironment; 
    5760import schedframe.exceptions.ResourceException; 
    5861import schedframe.resources.ResourceType; 
     
    6669import schedframe.resources.computing.profiles.energy.power.PowerUsage; 
    6770import schedframe.resources.computing.profiles.energy.thermal.TemperatureValue; 
    68 import schedframe.resources.units.PEUnit; 
     71import schedframe.resources.devices.Device; 
     72import schedframe.resources.devices.PhysicalResource; 
    6973import schedframe.resources.units.ProcessingElements; 
    7074import schedframe.resources.units.ResourceUnit; 
     
    8286import simulator.GenericUser; 
    8387import simulator.stats.GSSAccumulator; 
     88import simulator.stats.MetricsCalculator; 
    8489import simulator.stats.SimulationStatistics; 
    8590import simulator.stats.implementation.out.AbstractStringSerializer; 
    8691import simulator.stats.implementation.out.CoolEmAllStringSerializer; 
     92import simulator.stats.implementation.out.StringSerializer; 
    8793import csiro.mit.utils.jfreechart.timetablechart.TimetableChartFactory; 
    8894import csiro.mit.utils.jfreechart.timetablechart.data.Timetable; 
     
    9399import dcworms.schedframe.scheduling.Executable; 
    94100import eduni.simjava.Sim_stat; 
     101import example.energy.coolemall.CoolEmAllTestbedMeasurements; 
    95102 
    96103public class DCWormsStatistics implements SimulationStatistics { 
     
    111118        protected static final String AIRFLOW_STATISTICS_OUTPUT_FILE_NAME = "AirThroughput.txt"; 
    112119        protected static final String TEMPERATURE_STATISTICS_OUTPUT_FILE_NAME = "Temperature.txt"; 
    113  
     120        protected static final String USEFUL_WORK_STATISTICS_OUTPUT_FILE_NAME = "UsefulWork.txt"; 
     121        protected static final String DEVICE_STATISTICS_OUTPUT_FILE_NAME = "Devices.txt"; 
     122        protected static final String NODES_AVAILABILITY_STATISTICS_OUTPUT_FILE_NAME = "NodesAvailability.txt"; 
     123        protected static final String METRICS_STATISTICS_OUTPUT_FILE_NAME = "Metrics.txt"; 
     124        protected static final String RESOURCE_HISTORY_OUTPUT_FILE_NAME = "ResourceHistyory.txt"; 
     125         
    114126        protected static final String DIAGRAMS_FILE_NAME_PREFIX = "Chart_"; 
    115127        protected static final String STATS_FILE_NAME_PREFIX = "Stats_"; 
     
    127139         
    128140        protected GenericUser users; 
    129         protected ResourceController resourceController; 
     141        protected SimulatedEnvironment resourceController; 
    130142        protected boolean generateDiagrams = true; 
    131143        protected AbstractStringSerializer serializer; 
     
    154166        protected TaskSeriesCollection ganttDiagramTaskSeriesCollection; 
    155167        protected TaskSeriesCollection ganttDiagramWaitingTimeSeriesCollection; 
    156         protected Map<String, List<String>> task_processorsMap; 
     168        protected Map<String, Set<ComputingResource>> task_processorsMap; 
    157169 
    158170        protected JobRegistry jr; 
    159  
     171        protected MetricsCalculator metCalc; 
    160172         
    161173        public DCWormsStatistics(String simulationIdentifier, ConfigurationOptions co, GenericUser users, 
    162                         String outputFolderName, ResourceController resourceController) { 
     174                        String outputFolderName, SimulatedEnvironment resourceController) { 
    163175                this.simulationIdentifier = simulationIdentifier; 
    164176                this.configuration = co; 
     
    167179                this.outputFolderName = outputFolderName; 
    168180 
    169                 this.serializer = new CoolEmAllStringSerializer(); 
     181                this.serializer = new StringSerializer(); 
     182                 
     183                if(DataCenterWorkloadSimulator.MODE.equals("CoolEmAll")){ 
     184                        this.serializer = new CoolEmAllStringSerializer();       
     185                } 
    170186                this.serializer.setDefaultNumberFormat(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT); 
    171187 
     
    173189                this.jr = new JobRegistryImpl(""); 
    174190                init(); 
     191                metCalc = new MetricsCalculator(); 
    175192        } 
    176193 
     
    183200                this.endSimulationTime = DateTimeUtilsExt.currentTimeMillis(); 
    184201 
     202                metCalc.setStartTime(startSimulationTime); 
     203                metCalc.setEndTime(endSimulationTime); 
     204                 
    185205                long s = 0; 
    186206                long e = 0; 
     
    211231 
    212232        private void init() { 
    213                 task_processorsMap = new HashMap<String, List<String>>(); 
     233                task_processorsMap = new HashMap<String, Set<ComputingResource>>(); 
    214234                accStats = new GSSAccumulatorsStats(); 
    215235                statsData = new HashMap<String, GSSAccumulator>(); 
     
    229249                if (simulationStatsFile != null) { 
    230250                        Object txt = accStats.serialize(this.serializer); 
     251                         
     252                        DecimalFormat df = new DecimalFormat(); 
     253                        df.setMaximumFractionDigits(3); 
     254                        df.setGroupingUsed(false); 
     255                         
     256                        /*log.info("#STATS " + "Performance statistics"); 
     257                        log.info("#STATS " + "Makespan: " + accStats.makespan.getMean() + " [s]"); 
     258                        log.info("#STATS " + "Task completion time - " + "min: " + accStats.meanTaskCompletionTime.getMin() + "; max: " + accStats.meanTaskCompletionTime.getMax() + " [s]"); 
     259                        log.info("#STATS " + "Mean task execution time: " + accStats.meanTaskExecutionTime.getMean() + " [s]"); 
     260                        log.info("#STATS " + "System load: " + accStats.meanTotalLoad.getMean() * 100 + " [%]");*/ 
     261                         
     262                        System.out.println("#STATS " + "===== Performance statistics ====="); 
     263                        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]"); 
     265                        System.out.println("#STATS " + "Mean task execution time: " + df.format(accStats.meanTaskExecutionTime.getMean()) + " [s]"); 
     266                        System.out.println("#STATS " + "System load: " + df.format(accStats.meanTotalLoad.getMean() * 100) + " [%]"); 
     267                         
    231268                        simulationStatsFile.println(txt); 
    232269                } 
     
    238275 
    239276        /************* RESOURCE STATISTICS SECTION **************/ 
    240         private void gatherResourceStatistics() { 
     277        public void gatherResourceStatistics() { 
    241278                 
    242279                HashMap<String, List<Stats>> type_stats = new HashMap<String, List<Stats>>(); 
    243280                 
    244                 for(String resourceName: resourceController.getComputingResourceLayers()){ 
     281                for(String resourceTypeName: resourceController.getComputingResourceLayers()){ 
    245282                        List<Stats> cStats = new ArrayList<Stats>(); 
    246283                        cStats.add(Stats.textLoad); 
    247                         if(ArrayUtils.contains(configuration.resForUtilizationChart, resourceName)) 
     284                        if(ArrayUtils.contains(configuration.resForUtilizationChart, resourceTypeName)) 
    248285                                cStats.add(Stats.chartLoad); 
    249286                        cStats.add(Stats.textEnergy); 
    250                         if(ArrayUtils.contains(configuration.resForEnergyChart, resourceName)) 
     287                        if(ArrayUtils.contains(configuration.resForEnergyChart, resourceTypeName)) 
    251288                                cStats.add(Stats.chartEnergy); 
    252289                        cStats.add(Stats.textAirFlow); 
    253                         if(ArrayUtils.contains(configuration.resForAirFlowChart, resourceName)) 
     290                        if(ArrayUtils.contains(configuration.resForAirFlowChart, resourceTypeName)) 
    254291                                cStats.add(Stats.chartAirFlow); 
    255292                        cStats.add(Stats.textTemperature); 
    256                         if(ArrayUtils.contains(configuration.resForTemperatureChart, resourceName)) 
     293                        if(ArrayUtils.contains(configuration.resForTemperatureChart, resourceTypeName)) 
    257294                                cStats.add(Stats.chartTemperature); 
    258                         type_stats.put(resourceName, cStats); 
     295                        type_stats.put(resourceTypeName, cStats); 
     296 
    259297                }                
    260298                 
     
    269307                ganttDiagramTimetable = new Timetable(new FixedMillisecond( 
    270308                                startSimulationTime), new FixedMillisecond(endSimulationTime)); 
     309                 
    271310                 
    272311                PrintStream resourceLoadStatsFile = null; 
     
    310349                } 
    311350 
     351                PrintStream deviceStatsFile = null; 
     352                try { 
     353                        File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 
     354                                        + simulationIdentifier + "_" 
     355                                        + DEVICE_STATISTICS_OUTPUT_FILE_NAME); 
     356                        deviceStatsFile = new PrintStream(new FileOutputStream(file)); 
     357                } catch (IOException e) { 
     358                        deviceStatsFile = null; 
     359                } 
     360                 
     361                PrintStream nodesAvailabilityStatsFile = null; 
     362                try { 
     363                        File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 
     364                                        + simulationIdentifier + "_" 
     365                                        + NODES_AVAILABILITY_STATISTICS_OUTPUT_FILE_NAME); 
     366                        nodesAvailabilityStatsFile = new PrintStream(new FileOutputStream(file)); 
     367                } catch (IOException e) { 
     368                        nodesAvailabilityStatsFile = null; 
     369                } 
     370                 
     371                PrintStream metricsStatsFile = null; 
     372                try { 
     373                        File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 
     374                                        + simulationIdentifier + "_" 
     375                                        + METRICS_STATISTICS_OUTPUT_FILE_NAME); 
     376                        metricsStatsFile = new PrintStream(new FileOutputStream(file)); 
     377                } catch (IOException e) { 
     378                        metricsStatsFile = null; 
     379                } 
     380                 
     381                PrintStream usefulWorkStatsFile = null; 
     382                try { 
     383                        File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 
     384                                        + simulationIdentifier + "_" 
     385                                        + USEFUL_WORK_STATISTICS_OUTPUT_FILE_NAME); 
     386                        usefulWorkStatsFile = new PrintStream(new FileOutputStream(file)); 
     387                } catch (IOException e) { 
     388                        usefulWorkStatsFile = null; 
     389                } 
     390                 
    312391                basicResStats = gatherPEStats(jr.getTasks()); 
    313392                peStatsPostProcessing(basicResStats); 
     
    318397                } 
    319398                 
    320                 for(String resourceName: resourceController.getComputingResourceLayers()){ 
    321                         List<ComputingResource> resources = null; 
    322  
    323                         resources = new ArrayList<ComputingResource>(); 
     399                List<ComputingResource> compResources = null; 
     400                for(String resourceTypeName: resourceController.getComputingResourceLayers()){ 
     401                        GSSAccumulator resourceEnergyAccumulator = new GSSAccumulator(); 
     402                        GSSAccumulator maxResourceEnergyAccumulator = new GSSAccumulator(); 
     403                        GSSAccumulator calculationsEnergyAccumulator = new GSSAccumulator(); 
     404                        compResources = new ArrayList<ComputingResource>(); 
    324405                        for(ComputingResource compRes: resourceController.getComputingResources() ){ 
    325                                 resources.addAll(compRes.getDescendantsByType(new UserResourceType(resourceName))); 
    326                         } 
    327                         if(resourceController.getComputingResources().get(0).getType().getName().equals(resourceName)) 
    328                                 resources.addAll(resourceController.getComputingResources()); 
    329                  
    330                         if(type_stats.containsKey(resourceName)){ 
    331                                 for(ComputingResource resource: resources){ 
     406                                compResources.addAll(compRes.getDescendantsByType(new UserResourceType(resourceTypeName))); 
     407                        } 
     408                        if(resourceController.getComputingResources().get(0).getType().getName().equals(resourceTypeName)) 
     409                                compResources.addAll(resourceController.getComputingResources()); 
     410                        if(type_stats.containsKey(resourceTypeName)){ 
     411                 
     412                                 
     413                                for(ComputingResource compResource: compResources){ 
    332414                                        ResourceUsageStats resourceUsage = null; 
    333415                                        ResourcePowerStats energyUsage = null; 
    334416                                        ResourceAirFlowStats airFlow = null; 
    335417                                        ResourceTemperatureStats temperature = null; 
    336                                         if(type_stats.get(resourceName).contains(Stats.textLoad)){ 
    337                                                 resourceUsage = gatherResourceLoadStats(resource, basicResStats); 
     418                                        ResourceUsefulWorkStats usefulWork = null; 
     419                                        if(type_stats.get(resourceTypeName).contains(Stats.textLoad)){ 
     420                                                resourceUsage = gatherResourceLoadStats(compResource, basicResStats); 
    338421                                                resourceUsage.setMeanValue(calculateMeanValue(resourceUsage)); 
    339422                                                if (resourceLoadStatsFile != null) { 
     
    341424                                                        resourceLoadStatsFile.print(txt); 
    342425                                                } 
    343                                         } 
    344                                         if(type_stats.get(resourceName).contains(Stats.chartLoad)){ 
     426 
     427                                        } 
     428                                        if(type_stats.get(resourceTypeName).contains(Stats.chartLoad)){ 
    345429                                                if (configuration.creatediagrams_resutilization) { 
    346430                                                        createResourceLoadDiagram(resourceUsage); 
    347431                                                } 
    348432                                        } 
    349                                         if(type_stats.get(resourceName).contains(Stats.textEnergy)){ 
    350                                                 energyUsage = gatherResourcePowerConsumptionStats(resource); 
     433                                        if(type_stats.get(resourceTypeName).contains(Stats.textEnergy)){ 
     434                                                energyUsage = gatherResourcePowerConsumptionStats(compResource); 
    351435                                                energyUsage.setMeanValue(calculateMeanValue(energyUsage)); 
    352436                                                energyUsage.setSumValue(energyUsage.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 
    353                                                  
    354                                                 EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
    355                                                 if(resourceController.getComputingResources().contains(resource)) { 
     437                                                resourceEnergyAccumulator.add(energyUsage.getSumValue()); 
     438                                                maxResourceEnergyAccumulator.add(calculateMaxValue(energyUsage)); 
     439                                                double calulcationsEnergy = 0; 
     440                                                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                                                        boolean doCalc = false; 
     455                                                        long prevTimestamp = 0; 
     456                                                        for(Long key: energyUsage.getHistory().keySet()){ 
     457                                                                if(doCalc){ 
     458                                                                        double load = 0; 
     459                                                                        if(resourceUsage.getHistory().get(prevTimestamp)!= null){ 
     460                                                                                load = resourceUsage.getHistory().get(prevTimestamp); 
     461                                                                        } 
     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                                                                } 
     470                                                        } 
     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); 
     476                                                } catch (Exception e) { 
     477                                                        e.printStackTrace(); 
     478                                                } 
     479                                                EnergyExtension een = (EnergyExtension)(compResource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
     480                                                if(resourceController.getComputingResources().contains(compResource)) { 
    356481                                                        if( een != null && een.getPowerProfile() != null &&  een.getPowerProfile().getEnergyEstimationPlugin() != null){ 
    357482                                                                accStats.meanEnergyUsage.add(energyUsage.getSumValue()); 
     
    359484 
    360485                                                } else if( een != null && een.getPowerProfile() != null &&  een.getPowerProfile().getEnergyEstimationPlugin() != null){ 
    361                                                         ComputingResource parent = resource.getParent(); 
     486                                                        ComputingResource parent = compResource.getParent(); 
    362487                                                        boolean top = true; 
    363488                                                        while(parent != null){ 
     
    377502                                                        energyStatsFile.print(txt); 
    378503                                                } 
    379                                         } 
    380                                         if(type_stats.get(resourceName).contains(Stats.chartEnergy)){ 
    381  
     504                                                 
     505                                                for(Device device: compResource.getResourceCharacteristic().getDevices()){ 
     506                                                        GSSAccumulator devAccumulator = new GSSAccumulator(); 
     507                                                        ResourcePowerStats deviceEnergyUsage = gatherResourcePowerConsumptionStats(device); 
     508                                                        deviceEnergyUsage.setMeanValue(calculateMeanValue(deviceEnergyUsage)); 
     509                                                        deviceEnergyUsage.setSumValue(deviceEnergyUsage.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 
     510                                                        devAccumulator.add(deviceEnergyUsage.getSumValue()); 
     511                                                        metCalc.addMetricsData(device.getType().getName(), devAccumulator); 
     512                                                        if (deviceStatsFile != null) { 
     513                                                                Object txt = deviceEnergyUsage.serialize(serializer); 
     514                                                                deviceStatsFile.print(txt); 
     515                                                        } 
     516                                                         
     517                                                        if(ArrayUtils.contains(configuration.resForEnergyChart, device.getType().getName())){ 
     518                                                                if (configuration.creatediagrams_respowerusage) { 
     519                                                                        createResourceEnergyDiagramData(deviceEnergyUsage); 
     520                                                                } 
     521                                                        } 
     522                                                } 
     523                                        } 
     524                                        if(type_stats.get(resourceTypeName).contains(Stats.chartEnergy)){ 
    382525                                                if (configuration.creatediagrams_respowerusage) { 
    383526                                                        createResourceEnergyDiagramData(energyUsage); 
     
    385528                                        } 
    386529                                         
    387                                         if(type_stats.get(resourceName).contains(Stats.textAirFlow)){ 
    388                                                 airFlow = gatherResourceAirFlowStats(resource); 
     530                                        if(type_stats.get(resourceTypeName).contains(Stats.textAirFlow)){ 
     531                                                airFlow = gatherResourceAirFlowStats(compResource); 
    389532                                                airFlow.setMeanValue(calculateMeanValue(airFlow)); 
    390533                                                airFlow.setSumValue(airFlow.getMeanValue() * (endSimulationTime - startSimulationTime) / (60 * MILLI_SEC)); 
    391534                                                 
    392                                                 EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
    393                                                 if(resourceController.getComputingResources().contains(resource)) { 
     535                                                EnergyExtension een = (EnergyExtension)(compResource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
     536                                                if(resourceController.getComputingResources().contains(compResource)) { 
    394537                                                        if( een != null && een.getAirFlowProfile() != null &&  een.getPowerProfile().getEnergyEstimationPlugin() != null){ 
    395538                                                                accStats.meanAirFlow.add(airFlow.getMeanValue()); 
     
    397540 
    398541                                                } else if( een != null && een.getAirFlowProfile() != null ){ 
    399                                                         ComputingResource parent = resource.getParent(); 
     542                                                        ComputingResource parent = compResource.getParent(); 
    400543                                                        een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
    401544                                                        boolean top = true; 
     
    415558                                                        airFlowStatsFile.print(txt); 
    416559                                                } 
    417                                         } 
    418                                         if(type_stats.get(resourceName).contains(Stats.chartAirFlow)){ 
     560                                                 
     561                                                for(Device device: compResource.getResourceCharacteristic().getDevices()){ 
     562                                                        ResourceAirFlowStats deviceAirFlow = gatherResourceAirFlowStats(device); 
     563                                                        deviceAirFlow.setMeanValue(calculateMeanValue(deviceAirFlow)); 
     564                                                        deviceAirFlow.setSumValue(deviceAirFlow.getMeanValue() * (endSimulationTime - startSimulationTime) / (60 * MILLI_SEC)); 
     565                                                         
     566                                                        if (deviceStatsFile != null) { 
     567                                                                Object txt = deviceAirFlow.serialize(serializer); 
     568                                                                deviceStatsFile.print(txt); 
     569                                                        } 
     570                                                         
     571                                                        if(ArrayUtils.contains(configuration.resForAirFlowChart, device.getType().getName())){ 
     572                                                                if (configuration.creatediagrams_resairflow) { 
     573                                                                        createResourceAirFlowDiagramData(deviceAirFlow); 
     574                                                                } 
     575                                                        } 
     576                                                } 
     577                                        } 
     578                                        if(type_stats.get(resourceTypeName).contains(Stats.chartAirFlow)){ 
    419579 
    420580                                                if (configuration.creatediagrams_resairflow) { 
     
    423583                                        } 
    424584                                         
    425                                         if(type_stats.get(resourceName).contains(Stats.textTemperature)){ 
    426                                                 temperature = gatherResourceTemperatureStats(resource); 
     585                                        if(type_stats.get(resourceTypeName).contains(Stats.textTemperature)){ 
     586                                                temperature = gatherResourceTemperatureStats(compResource); 
    427587                                                temperature.setMeanValue(calculateMeanValue(temperature)); 
    428588                                                temperature.setSumValue(temperature.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 
    429589                                                 
    430                                                 EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
    431                                                 if(resourceController.getComputingResources().contains(resource)) { 
     590                                                EnergyExtension een = (EnergyExtension)(compResource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
     591                                                if(resourceController.getComputingResources().contains(compResource)) { 
    432592                                                        if( een != null  && een.getThermalProfile() != null &&  een.getPowerProfile().getEnergyEstimationPlugin() != null){ 
    433593                                                                accStats.meanTemperature.add(temperature.getMeanValue()); 
     
    435595 
    436596                                                } else if( een != null && een.getThermalProfile() != null ){ 
    437                                                         ComputingResource parent = resource.getParent(); 
     597                                                        ComputingResource parent = compResource.getParent(); 
    438598                                                        een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
    439599                                                        boolean top = true; 
     
    453613                                                        temperatureStatsFile.print(txt); 
    454614                                                } 
    455                                         } 
    456                                         if(type_stats.get(resourceName).contains(Stats.chartTemperature)){ 
    457  
     615                                                 
     616                                                for(Device device: compResource.getResourceCharacteristic().getDevices()){ 
     617                                                        ResourceTemperatureStats deviceTemperature = gatherResourceTemperatureStats(device); 
     618                                                        deviceTemperature.setMeanValue(calculateMeanValue(deviceTemperature)); 
     619                                                        deviceTemperature.setSumValue(deviceTemperature.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 
     620                                                         
     621                                                        if (deviceStatsFile != null) { 
     622                                                                Object txt = deviceTemperature.serialize(serializer); 
     623                                                                deviceStatsFile.print(txt); 
     624                                                        } 
     625                                                         
     626                                                        if(ArrayUtils.contains(configuration.resForTemperatureChart, device.getType().getName())){ 
     627                                                                if (configuration.creatediagrams_restemperature) { 
     628                                                                        createResourceTemperatureDiagramData(deviceTemperature); 
     629                                                                } 
     630                                                        } 
     631                                                }                                                
     632                                        } 
     633                                        if(type_stats.get(resourceTypeName).contains(Stats.chartTemperature)){ 
    458634                                                if (configuration.creatediagrams_restemperature) { 
    459635                                                        createResourceTemperatureDiagramData(temperature); 
    460636                                                } 
    461637                                        } 
     638                                         
     639                                        if(type_stats.get(resourceTypeName).contains(Stats.textLoad)){ 
     640                                                usefulWork = gatherResourceUsefulWorkStats(compResource); 
     641                                                if (usefulWorkStatsFile != null) { 
     642                                                        Object txt = usefulWork.serialize(serializer); 
     643                                                        usefulWorkStatsFile.print(txt); 
     644                                                } 
     645                                        } 
     646                                         
     647                                         
     648                                        if (nodesAvailabilityStatsFile != null) { 
     649                                                ResourceAvailabilityStats ras = new ResourceAvailabilityStats(compResource.getFullName(), compResource.getType(), "availableNodes", compResource.getChildren().size(), endSimulationTime); 
     650                                                Object txt = ras.serialize(serializer); 
     651                                                nodesAvailabilityStatsFile.print(txt); 
     652                                                ras = gatherResourceAvailabilityStats(compResource); 
     653                                                txt = ras.serialize(serializer); 
     654                                                nodesAvailabilityStatsFile.print(txt); 
     655                                        } 
     656                                         
    462657                                } 
    463                         } 
    464                 } 
    465                  
     658                                metCalc.addMetricsData(resourceTypeName + "_CALC", calculationsEnergyAccumulator); 
     659                                metCalc.addMetricsData(resourceTypeName, resourceEnergyAccumulator); 
     660                                metCalc.addMetricsData(resourceTypeName + "_MAX", maxResourceEnergyAccumulator); 
     661                        } 
     662                } 
     663                 
     664                 
     665                if (metricsStatsFile != null) { 
     666                        //log.info("#STATS " + "Metrics"); 
     667                        System.out.println("#STATS " + "===== Metrics ====="); 
     668                        for(MetricsStats metric: metCalc.calulateMetrics(endSimulationTime)){ 
     669                                Object txt = metric.serialize(serializer); 
     670                                //log.info("#STATS " +  metric.getResourceName() + " " + metric.getMetricName() + ": " + metric.getValue()); 
     671                                DecimalFormat df = new DecimalFormat(); 
     672                                df.setMaximumFractionDigits(3); 
     673                                df.setGroupingUsed(false); 
     674                                System.out.println("#STATS " +  metric.getMetricName().replaceAll("_", " ") + ": " + df.format(metric.getValue()) + " [" + metric.getUnit() + "]"); 
     675                                metricsStatsFile.println(txt);   
     676                        } 
     677                } 
    466678                saveResourceUsageDiagrams(); 
    467679                createAccumulatedResourceSimulationStatistic(); 
     
    479691                        resourceLoadStatsFile.close(); 
    480692                } 
     693                 
     694                if (usefulWorkStatsFile != null) { 
     695                        usefulWorkStatsFile.close(); 
     696                } 
     697                if (deviceStatsFile != null) { 
     698                        deviceStatsFile.close(); 
     699                } 
     700                 
     701                if (nodesAvailabilityStatsFile != null) { 
     702                        nodesAvailabilityStatsFile.close(); 
     703                } 
     704                 
     705                if (metricsStatsFile != null) { 
     706                        metricsStatsFile.close(); 
     707                } 
     708 
    481709        } 
    482710 
     
    500728                } 
    501729                for(ComputingResource resource: resources){ 
    502                         if(!basicResStats.containsKey(resource.getName())){ 
    503                                 basicResStats.put(resource.getName(), new ArrayList<ResStat>()); 
     730                        if(!basicResStats.containsKey(resource.getFullName())){ 
     731                                basicResStats.put(resource.getFullName(), new ArrayList<ResStat>()); 
    504732                        } 
    505733                } 
     
    509737                 
    510738                Map<String, List<ResStat>> basicResStats = new TreeMap<String, List<ResStat>>(new MapPEIdComparator()); 
    511  
    512739                for (ExecTask execTask:executables) { 
    513740                        Executable exec = (Executable) execTask; 
     
    522749                                ProcessingElements pes = (ProcessingElements) resUnit; 
    523750                                for(ComputingResource pe: pes){ 
    524                                         String peName = pe.getName(); 
     751                                        String peName = pe.getFullName(); 
    525752                                        long startDate = Double.valueOf(exec.getExecStartTime()).longValue() * MILLI_SEC; 
    526753                                        long endDate = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC; 
     
    541768                                        String uniqueTaskID = getUniqueTaskId(execTask); 
    542769 
    543                                         List<String> peNames = task_processorsMap.get(uniqueTaskID); 
     770                                        Set<ComputingResource> peNames = task_processorsMap.get(uniqueTaskID); 
    544771                                        if (peNames == null) { 
    545                                                 peNames = new ArrayList<String>(); 
    546                                                 peNames.add(peName); 
     772                                                peNames = new HashSet<ComputingResource>(); 
     773                                                peNames.add(pe); 
    547774                                                task_processorsMap.put(uniqueTaskID, peNames); 
    548775                                        } else { 
    549                                                 peNames.add(peName); 
    550                                         } 
     776                                                peNames.add(pe); 
     777                                        } 
     778 
     779                                        try{ 
     780                                                double usefulWork = execTask.getResourceConsumptionProfile().getUsefulWork(); 
     781                                                //double usefulWork = gatherUsefulWorkStats(pe).getValue(); 
     782                                                GSSAccumulator uwAcc; 
     783                                                if(metCalc.getMetricsData().containsKey(pe.getFullName())){ 
     784                                                        uwAcc = metCalc.getMetricsData().get(pe.getFullName()).get(0); 
     785                                                        uwAcc.add(usefulWork); 
     786                                                } else { 
     787                                                        uwAcc = new GSSAccumulator(); 
     788                                                        uwAcc.add(usefulWork); 
     789                                                        metCalc.addMetricsData(pe.getFullName(), uwAcc); 
     790                                                } 
     791                                        }  catch (Exception e){ 
     792                                                 
     793                                        } 
     794                                         
    551795                                } 
    552                         } else if (resUnit instanceof PEUnit){ 
    553                                 PEUnit peUnit = (PEUnit) resUnit; 
    554                         } 
    555  
     796                        }  
    556797                } 
    557798                return basicResStats; 
     
    571812        } 
    572813         
     814         
    573815        private ResourceUsageStats gatherResourceLoadStats(ComputingResource resource, Map<String, List<ResStat>> basicStats) { 
    574                 ResourceUsageStats usageStats = new ResourceUsageStats(resource.getFullName(), resource.getType(), "resourceLoadStats"); 
     816                String usageType = null; 
     817                if(resource.getResourceCharacteristic().getParameters().get("load-sensor")!= null){ 
     818                        usageType = resource.getResourceCharacteristic().getParameters().get("load-sensor").get(0).getContent(); 
     819                } 
     820                ResourceUsageStats usageStats = new ResourceUsageStats(resource.getFullName(), resource.getType(), usageType); 
    575821                int cnt = 0; 
    576822                for(String resName: basicStats.keySet()){ 
    577823                        try { 
    578                                 if(resource.getDescendantByName(resName) != null || resource.getName().compareTo(resName) == 0){ 
     824                                if(resource.getDescendantByName(resName) != null || resource.getFullName().compareTo(resName) == 0){ 
    579825                                        createResourceLoadData(usageStats, basicStats.get(resName)); 
    580826                                        cnt++; 
     
    591837 
    592838                return usageStats; 
     839        } 
     840         
     841        private ResourceAvailabilityStats gatherResourceAvailabilityStats(ComputingResource resource) { 
     842                String usageType = new String ("usedNodes"); 
     843 
     844                int usedResources = 0; 
     845                for(ComputingResource compResource: resource.getChildren()){ 
     846                        double meanLoad = calculateMeanValue(gatherResourceLoadStats(compResource, basicResStats)); 
     847                        if(meanLoad > 0){ 
     848                                usedResources++; 
     849                        } 
     850                } 
     851                ResourceAvailabilityStats availabilityStats = new ResourceAvailabilityStats(resource.getFullName(), resource.getType(), usageType, usedResources, endSimulationTime); 
     852                return availabilityStats; 
     853        } 
     854         
     855        private ResourceUsefulWorkStats gatherResourceUsefulWorkStats(ComputingResource compResource) { 
     856                String usageType = "usefulWork"; 
     857                double usefulWork = 0; 
     858                JobRegistry jr = new JobRegistryImpl(compResource.getFullName()); 
     859                for(ExecTask task: jr.getFinishedTasks()){ 
     860                        usefulWork = usefulWork + task.getResourceConsumptionProfile().getUsefulWork(); 
     861                } 
     862                ResourceUsefulWorkStats usefulWorkStats = new ResourceUsefulWorkStats(compResource.getFullName(), compResource.getType(), usageType, usefulWork, endSimulationTime); 
     863                return usefulWorkStats; 
    593864        } 
    594865         
     
    629900                        } 
    630901                } 
    631  
     902                if(ganttData.get(startSimulationTime) == null) 
     903                        ganttData.put(startSimulationTime, 0.0); 
     904                if(ganttData.get(endSimulationTime) == null)     
     905                        ganttData.put(endSimulationTime, 0.0); 
    632906                return ganttData; 
    633907        } 
     
    643917         
    644918         
    645         private ResourcePowerStats gatherResourcePowerConsumptionStats(ComputingResource resource) { 
     919        private ResourcePowerStats gatherResourcePowerConsumptionStats(PhysicalResource resource) { 
    646920                double power = 0; 
    647                 ResourcePowerStats resEnergyUsage = new ResourcePowerStats(resource.getFullName(), resource.getType(), "resourcePowerConsumptionStats"); 
     921                 
     922                String usageType = null; 
     923                if(resource.getResourceCharacteristic().getParameters().get("power-sensor")!= null){ 
     924                        usageType = resource.getResourceCharacteristic().getParameters().get("power-sensor").get(0).getContent(); 
     925                } 
     926                ResourcePowerStats resEnergyUsage = new ResourcePowerStats(resource.getFullName(), resource.getType(), usageType); 
    648927                Map<Long, Double> usage = resEnergyUsage.getHistory(); 
    649928                 
     
    665944                                                usage.put(pu.getTimestamp(), pu.getValue()); 
    666945                                                 
    667                                         ///     System.out.println(resource.getName() + ":"+new DateTime(pu.getTimestamp())+";"+pu.getValue()); 
    668946                                                power = power + (pu.getTimestamp() - lastTime) * lastPower/ (3600 * MILLI_SEC); 
    669947                                                lastPower = pu.getValue(); 
     
    673951                        } 
    674952                } 
    675                 //System.out.println(power); 
    676953                return resEnergyUsage; 
    677954        } 
    678955         
    679956         
    680         private ResourceAirFlowStats gatherResourceAirFlowStats(ComputingResource resource) { 
    681  
    682                 ResourceAirFlowStats resAirFlow = new ResourceAirFlowStats(resource.getFullName(), resource.getType(), "resourceAirFlowStats"); 
     957        private ResourceAirFlowStats gatherResourceAirFlowStats(PhysicalResource resource) { 
     958 
     959                String usageType = null; 
     960                if(resource.getResourceCharacteristic().getParameters().get("airflow_volume-sensor")!= null){ 
     961                        usageType = resource.getResourceCharacteristic().getParameters().get("airflow_volume-sensor").get(0).getContent(); 
     962                } 
     963                ResourceAirFlowStats resAirFlow = new ResourceAirFlowStats(resource.getFullName(), resource.getType(), usageType); 
    683964                Map<Long, Double> airFlow = resAirFlow.getHistory(); 
    684965                 
     
    704985        } 
    705986         
    706         private ResourceTemperatureStats gatherResourceTemperatureStats(ComputingResource resource) { 
    707  
    708                 ResourceTemperatureStats resTemperature = new ResourceTemperatureStats(resource.getFullName(), resource.getType(), "resourceTemperatureStats"); 
     987        private ResourceTemperatureStats gatherResourceTemperatureStats(PhysicalResource resource) { 
     988 
     989                String usageType = null; 
     990                if(resource.getResourceCharacteristic().getParameters().get("temperature-sensor")!= null){ 
     991                        usageType = resource.getResourceCharacteristic().getParameters().get("temperature-sensor").get(0).getContent(); 
     992                } 
     993                ResourceTemperatureStats resTemperature = new ResourceTemperatureStats(resource.getFullName(), resource.getType(), usageType); 
    709994                Map<Long, Double> temperature = resTemperature.getHistory(); 
    710995                 
     
    10651350 
    10661351                        try { 
    1067                                 if(resource.getDescendantByName(resName) != null || resource.getName().compareTo(resName) == 0){ 
     1352                                if(resource.getDescendantByName(resName) != null || resource.getFullName().compareTo(resName) == 0){ 
    10681353                                        Double load = peLoad.get(resName); 
    10691354                                        sum += load; 
     
    11021387         
    11031388         
    1104  
    1105          
    1106          
     1389        private double calculateMaxValue(ResourceDynamicStats resDynamicStats ){ 
     1390                double maxValue = 0; 
     1391 
     1392                Map<Long, Double> history = resDynamicStats.getHistory(); 
     1393                for (Long key : history.keySet()) { 
     1394                        if(history.get(key) > maxValue){ 
     1395                                maxValue = history.get(key) ; 
     1396                        } 
     1397                } 
     1398                return maxValue; 
     1399        } 
    11071400         
    11081401         
     
    12211514                TaskStats taskStats = new TaskStats(task, startSimulationTime); 
    12221515                String uniqueTaskID = getUniqueTaskId(task); 
    1223                 taskStats.setProcessorsName(task_processorsMap.get(uniqueTaskID)); 
     1516                taskStats.setProcessors(task_processorsMap.get(uniqueTaskID)); 
    12241517                return taskStats; 
    12251518        } 
     
    14841777 
    14851778                public int compare(String o1, String o2)  { 
    1486                         Integer o1int; 
    1487                         Integer o2int; 
     1779                        Integer o1int = 0; 
     1780                        Integer o2int = 0; 
    14881781                        String o1string; 
    1489                         String o2string; 
    1490                         o1string = o1.substring(0, o1.indexOf("_")); 
    1491                         o2string = o2.substring(0, o2.indexOf("_")); 
    1492                         o1int = Integer.parseInt(o1.substring(o1.indexOf("_")+1)); 
    1493                         o2int = Integer.parseInt(o2.substring(o2.indexOf("_")+1)); 
    1494                         //if(o1string.compareTo(o2string) != 0) 
    1495                         //      return o1string.compareTo(o2string); 
    1496                         //else 
     1782                        String o2string = null; 
     1783 
     1784                        if(o1.contains("_")){ 
     1785                                o1string = o1.substring(0, o1.lastIndexOf("_")); 
     1786                                o1int = Integer.parseInt(o1.substring(o1.lastIndexOf("_")+1)); 
     1787                        } else { 
     1788                                o1string = o1; 
     1789                        } 
     1790                         
     1791                        if(o2.contains("_")){ 
     1792                                o2string = o2.substring(0, o2.lastIndexOf("_")); 
     1793                                o2int = Integer.parseInt(o2.substring(o2.lastIndexOf("_")+1)); 
     1794                        }else { 
     1795                                o2string = o2; 
     1796                        } 
     1797 
     1798                        if(o1int.compareTo(o2int) != 0) 
    14971799                                return o1int.compareTo(o2int); 
     1800                        else 
     1801                                return o1string.compareTo(o2string); 
    14981802                } 
    14991803        } 
     
    15731877        chartAirFlow, 
    15741878        textTemperature, 
    1575         chartTemperature; 
     1879        chartTemperature, 
     1880        textUsefulWorl; 
    15761881} 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceAirFlowStats.java

    r496 r1207  
    1212        public ResourceAirFlowStats (String resourceName, ResourceType resourceType, String usageType) { 
    1313                super(resourceName, resourceType, usageType); 
     14                if(usageType == null){ 
     15                        this.usageType = "airflow_volume"; 
     16                } 
    1417        } 
    1518 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourcePowerStats.java

    r496 r1207  
    1212        public ResourcePowerStats (String resourceName, ResourceType resourceType, String usageType) { 
    1313                super(resourceName, resourceType, usageType); 
     14                if(usageType == null){ 
     15                        this.usageType = "power"; 
     16                } 
    1417        } 
    1518 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceStats.java

    r477 r1207  
    2222 
    2323        public ResourceStats(ComputingResource compResource) { 
    24                 this.resourceName = compResource.getName(); 
     24                this.resourceName = compResource.getFullName(); 
    2525                init(); 
    2626 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceTemperatureStats.java

    r806 r1207  
    1212        public ResourceTemperatureStats (String resourceName, ResourceType resourceType, String usageType) { 
    1313                super(resourceName, resourceType, usageType); 
     14                if(usageType == null){ 
     15                        this.usageType = "temperature"; 
     16                } 
    1417        } 
    1518 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceUsageStats.java

    r496 r1207  
    1010        public ResourceUsageStats(String resourceName, ResourceType resourceType, String usageType) { 
    1111                super(resourceName, resourceType, usageType); 
     12                if(usageType == null){ 
     13                        this.usageType = "cpu_load"; 
     14                } 
    1215        } 
    1316 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/TaskStats.java

    r1199 r1207  
    22 
    33 
    4 import java.util.List; 
    5  
     4import java.util.HashSet; 
     5import java.util.Iterator; 
     6import java.util.Set; 
     7 
     8 
     9import schedframe.resources.computing.ComputingNode; 
     10import schedframe.resources.computing.ComputingResource; 
     11import schedframe.resources.computing.Core; 
     12import schedframe.resources.computing.Processor; 
     13import simulator.stats.implementation.out.StatsSerializer; 
    614import dcworms.schedframe.scheduling.Executable; 
    7  
    8 import simulator.stats.implementation.out.StatsSerializer; 
    915 
    1016/** 
     
    1420 */ 
    1521public class TaskStats implements StatsInterface { 
    16         protected List<String> processorsName; 
     22        protected Set<ComputingResource> processingElements; 
    1723        protected double reservationStartDate; 
    1824        protected double reservationFinishDate; 
     
    2632                        "ExecutionTime", "ReadyTime", "StartTime", "FlowTime", 
    2733                        "WaitingTime", "GQ_WaitingTime", "Lateness", "Tardiness", 
    28                         "ReservStartDate", "ReservFinishDate", "ProcessorName", "Energy"}; 
     34                        "ReservStartDate", "ReservFinishDate", "HostNames", "ProcessorName", "Energy", "AppName",}; 
    2935 
    3036        public TaskStats(Executable task, long startSimulationTime) { 
     
    147153        } 
    148154 
    149         public void setProcessorsName(List<String> value) { 
    150                 this.processorsName = value; 
     155        public void setProcessors(Set<ComputingResource> value) { 
     156                this.processingElements = value; 
    151157        } 
    152158 
     
    159165        } 
    160166 
    161         public List<String> getProcessorsName() { 
    162                 return processorsName; 
    163         } 
    164  
     167        public Set<String> getProcessingElementsName() { 
     168                Set<String> processingElementsNames = new HashSet<String>(); 
     169                Iterator<ComputingResource> it = processingElements.iterator(); 
     170                while(it.hasNext()) { 
     171                        ComputingResource compRes = it.next(); 
     172                        processingElementsNames.add(compRes.getFullName()); 
     173                } 
     174                return processingElementsNames; 
     175        } 
     176 
     177        public Set<String> getHostName() { 
     178                Set<String> hostNames = new HashSet<String>(); 
     179                Iterator<ComputingResource> it = processingElements.iterator(); 
     180                while(it.hasNext()) { 
     181                        ComputingResource compRes = it.next(); 
     182                        ComputingNode node = null; 
     183                        if(compRes instanceof Core){ 
     184                                Core core =(Core) compRes; 
     185                                node = (ComputingNode)core.getNode(); 
     186                        } else if(compRes instanceof Processor){ 
     187                                Processor proc = (Processor) compRes; 
     188                                node = (ComputingNode)proc.getNode(); 
     189                        } else if(compRes instanceof ComputingNode){ 
     190                                node = (ComputingNode)compRes; 
     191                        } 
     192                        if(node != null) 
     193                                hostNames.add(node.getFullName()); 
     194                } 
     195                return hostNames; 
     196        } 
     197         
    165198        public double getReservationStartDate() { 
    166199                return reservationStartDate; 
     
    170203                return reservationFinishDate; 
    171204        } 
     205         
     206        public String getExecName() { 
     207                String execName = null; 
     208                if(task.getDescription().getExecution() != null) { 
     209                        if(task.getDescription().getExecution().getStdin()!= null && task.getDescription().getExecution().getStdin().length > 0) 
     210                                execName = task.getDescription().getExecution().getStdin()[0].getName(); 
     211                        else if(task.getDescription().getExecution().getExecutable() != null && task.getDescription().getExecution().getExecutable().getApplication() != null) 
     212                                execName = task.getDescription().getExecution().getExecutable().getApplication().getName(); 
     213                } 
     214                return execName; 
     215        } 
    172216 
    173217        public String[] getHeaders() { 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/CoolEmAllStringSerializer.java

    r1140 r1207  
    11package simulator.stats.implementation.out; 
    22 
     3import java.text.DecimalFormat; 
    34import java.util.Map; 
    45 
     
    78 
    89import schedframe.resources.CoolEmAllResourceType; 
     10import schedframe.resources.ResourceHistoryChanges; 
    911import schedframe.resources.StandardResourceType; 
     12import simulator.stats.implementation.MetricsStats; 
    1013import simulator.stats.implementation.ResourceAirFlowStats; 
     14import simulator.stats.implementation.ResourceAvailabilityStats; 
     15import simulator.stats.implementation.ResourceHistoryStats; 
    1116import simulator.stats.implementation.ResourcePowerStats; 
    1217import simulator.stats.implementation.ResourceTemperatureStats; 
    1318import simulator.stats.implementation.ResourceUsageStats; 
     19import simulator.stats.implementation.ResourceUsefulWorkStats; 
    1420 
    1521public class CoolEmAllStringSerializer extends StringSerializer { 
     
    1925        public Object visit(ResourceUsageStats resourceUsageStats) { 
    2026                Map<Long, Double> resourceUsage = resourceUsageStats.getHistory(); 
    21                 String cpuMetricName = "CPU_Load"; 
     27                //String metricName = "cpu_load"; 
     28                String metricName = resourceUsageStats.getUsageType(); 
    2229                int mapSize = resourceUsage.size(); 
    2330                /* 
     
    4552                } 
    4653                 
    47                 if(resourceUsageStats.getResourceType().equals(StandardResourceType.Processor) || resourceUsageStats.getResourceType().equals(CoolEmAllResourceType.Processor)){ 
     54                if(!resourceUsageStats.getResourceType().getName().equals(StandardResourceType.Core.getName()) && !resourceUsageStats.getResourceType().getName().equals(CoolEmAllResourceType.Core.getName())){ 
    4855                        for (Long timestamp : resourceUsage.keySet()) { 
    4956                                 
    50                                 buffer.append(cpuMetricName); 
    51                                 buffer.append(fieldSeparator); 
    52                                 buffer.append(resourceUsageStats.getResourceName()); 
     57                                buffer.append(metricName); 
     58                                buffer.append(fieldSeparator); 
     59                                if(resourceUsageStats.getResourceName().startsWith("/")) 
     60                                        buffer.append(resourceUsageStats.getResourceName().substring(1)); 
     61                                else buffer.append(resourceUsageStats.getResourceName()); 
    5362                                buffer.append(fieldSeparator); 
    5463                                Double value = resourceUsage.get(timestamp); 
     
    7382        public Object visit(ResourcePowerStats resourceEnergyStats) { 
    7483                Map<Long, Double> resourceEnergy = resourceEnergyStats.getHistory(); 
    75                 String nodeMetricName = "RECS_Power"; 
     84                //String nodeMetricName = "power"; 
     85                String metricName = resourceEnergyStats.getUsageType(); 
    7686                int mapSize = resourceEnergy.size(); 
    7787                /* 
     
    98108                        buffer = new StringBuffer(size); 
    99109                } 
    100                  
    101                 if(resourceEnergyStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceEnergyStats.getResourceType().equals(CoolEmAllResourceType.Node)){ 
     110                //if(resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.ComputingNode.getName()) || resourceEnergyStats.getResourceType().getName().equals(CoolEmAllResourceType.Node.getName()) ||  
     111                                //resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.Inlet.getName())  || resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.Outlet.getName()) ||  
     112                //              resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.Heatsink.getName())){ 
     113                 
    102114                        for (Long timestamp : resourceEnergy.keySet()) { 
    103115                                 
    104                                 buffer.append(nodeMetricName); 
     116                                buffer.append(metricName); 
    105117                                buffer.append(fieldSeparator); 
    106118                                if(resourceEnergyStats.getResourceName().startsWith("/")) 
     
    117129                                buffer.append(System.getProperty("line.separator")); 
    118130                        } 
    119                 } 
     131        //      } 
    120132 
    121133                int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 
     
    129141        public Object visit(ResourceAirFlowStats resourceAirFlowStats) { 
    130142                Map<Long, Double> resourceAirFlow = resourceAirFlowStats.getHistory(); 
    131                 String nodeMetricName = "RECS_Airflow"; 
     143                //String nodeMetricName = "airflow_volume"; 
     144                String metricName = resourceAirFlowStats.getUsageType(); 
    132145                int mapSize = resourceAirFlow.size(); 
    133146                /* 
     
    154167                        buffer = new StringBuffer(size); 
    155168                } 
    156                  
    157                 if(resourceAirFlowStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceAirFlowStats.getResourceType().equals(CoolEmAllResourceType.Node)){ 
     169 
     170                if(resourceAirFlowStats.getResourceType().getName().equals(StandardResourceType.Inlet.getName()) || resourceAirFlowStats.getResourceType().getName().equals(StandardResourceType.Outlet.getName())){ 
    158171                        for (Long timestamp : resourceAirFlow.keySet()) { 
    159                                  
    160                                 buffer.append(nodeMetricName); 
     172                                buffer.append(metricName); 
    161173                                buffer.append(fieldSeparator); 
    162174                                if(resourceAirFlowStats.getResourceName().startsWith("/")) 
     
    185197        public Object visit(ResourceTemperatureStats resourceTemperatureStats) { 
    186198                Map<Long, Double> resourceTemperature = resourceTemperatureStats.getHistory(); 
    187                 String nodeMetricName = "RECS_Temperature"; 
    188                 String cpuMetricName = "CPU_Temp"; 
     199                //String nodeMetricName = "temperature"; 
     200                //String cpuMetricName = "temperature"; 
     201                 
     202                String metricName = resourceTemperatureStats.getUsageType(); 
     203 
    189204                int mapSize = resourceTemperature.size(); 
    190205                /* 
     
    212227                } 
    213228                 
    214                 if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Node) ||  
    215                                 resourceTemperatureStats.getResourceType().equals(StandardResourceType.Processor) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Processor)){ 
    216                         String metricName = null; 
     229                if(resourceTemperatureStats.getResourceType().getName().equals(StandardResourceType.Node.getName()) || resourceTemperatureStats.getResourceType().getName().equals(StandardResourceType.Processor.getName())){ 
     230                        /*String metricName = null; 
    217231                        if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Node)){ 
    218232                                metricName = nodeMetricName; 
    219233                        } else if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.Processor) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Processor)){ 
    220234                                metricName = cpuMetricName; 
    221                         } 
     235                        }*/ 
    222236                        for (Long timestamp : resourceTemperature.keySet()) { 
    223237                                 
    224238                                buffer.append(metricName); 
    225239                                buffer.append(fieldSeparator); 
    226                                 buffer.append(resourceTemperatureStats.getResourceName()); 
     240                                if(resourceTemperatureStats.getResourceName().startsWith("/")) 
     241                                        buffer.append(resourceTemperatureStats.getResourceName().substring(1)); 
     242                                else buffer.append(resourceTemperatureStats.getResourceName()); 
    227243                                buffer.append(fieldSeparator); 
    228244                                Double value = resourceTemperature.get(timestamp); 
     
    245261        } 
    246262 
    247  
     263        public Object visit(MetricsStats metricsStats) { 
     264                StringBuffer buffer = null; 
     265 
     266                if(printedHeaders.add("metrics")) { 
     267                        buffer = new StringBuffer(600); 
     268                        /*String[] headers = metricsStats.getHeaders(); 
     269                        for(int i = 0; i < headers.length; i++) 
     270                        { 
     271                                buffer.append(headers[i]); 
     272                                buffer.append(fieldSeparator); 
     273                        } 
     274                        buffer.append(System.getProperty("line.separator"));*/ 
     275                } else { 
     276                        buffer = new StringBuffer(300); 
     277                } 
     278                DecimalFormat df = new DecimalFormat(); 
     279                df.setMaximumFractionDigits(3); 
     280                df.setGroupingUsed(false); 
     281                 
     282                buffer.append(metricsStats.getMetricName()); 
     283                buffer.append(fieldSeparator); 
     284                buffer.append(metricsStats.getResourceName()); 
     285                buffer.append(fieldSeparator); 
     286                buffer.append(metricsStats.getTimestamp()); 
     287                buffer.append(fieldSeparator); 
     288                buffer.append(df.format(metricsStats.getValue())); 
     289                buffer.append(fieldSeparator); 
     290 
     291                return buffer.toString(); 
     292        } 
     293         
     294        public Object visit(ResourceHistoryStats arg) { 
     295                StringBuffer buffer = null; 
     296 
     297                if(printedHeaders.add("metrics")) { 
     298                        buffer = new StringBuffer(600); 
     299                        /*String[] headers = metricsStats.getHeaders(); 
     300                        for(int i = 0; i < headers.length; i++) 
     301                        { 
     302                                buffer.append(headers[i]); 
     303                                buffer.append(fieldSeparator); 
     304                        } 
     305                        buffer.append(System.getProperty("line.separator"));*/ 
     306                } else { 
     307                        buffer = new StringBuffer(300); 
     308                } 
     309                DecimalFormat df = new DecimalFormat(); 
     310                df.setMaximumFractionDigits(3); 
     311                df.setGroupingUsed(false); 
     312                 
     313                for(ResourceHistoryChanges rhc: arg.getResHistChanges()){ 
     314                        buffer.append(rhc.getTimestamp()); 
     315                        buffer.append(fieldSeparator); 
     316                        buffer.append(rhc.getResourceName()); 
     317                        buffer.append(fieldSeparator); 
     318                        buffer.append(rhc.getOperation()); 
     319                        buffer.append(fieldSeparator); 
     320                        buffer.append(rhc.getParamter()); 
     321                        buffer.append(fieldSeparator); 
     322                        buffer.append(System.getProperty("line.separator")); 
     323                } 
     324 
     325                return buffer.toString(); 
     326        } 
     327 
     328        public Object visit(ResourceUsefulWorkStats resourceUsefulWorkStats) { 
     329                         
     330                String metricName = resourceUsefulWorkStats.getUsageType(); 
     331                 
     332                StringBuffer buffer = null; 
     333 
     334                if(printedHeaders.add("metrics")) { 
     335                        buffer = new StringBuffer(600); 
     336                        /*String[] headers = metricsStats.getHeaders(); 
     337                        for(int i = 0; i < headers.length; i++) 
     338                        { 
     339                                buffer.append(headers[i]); 
     340                                buffer.append(fieldSeparator); 
     341                        } 
     342                        buffer.append(System.getProperty("line.separator"));*/ 
     343                } else { 
     344                        buffer = new StringBuffer(300); 
     345                } 
     346                DecimalFormat df = new DecimalFormat(); 
     347                df.setMaximumFractionDigits(3); 
     348                df.setGroupingUsed(false); 
     349                if(!resourceUsefulWorkStats.getResourceType().getName().equals(StandardResourceType.Core.getName()) && !resourceUsefulWorkStats.getResourceType().getName().equals(CoolEmAllResourceType.Core.getName())){ 
     350 
     351                        buffer.append(metricName); 
     352                        buffer.append(fieldSeparator); 
     353                        buffer.append(resourceUsefulWorkStats.getResourceName()); 
     354                        buffer.append(fieldSeparator); 
     355                        buffer.append(resourceUsefulWorkStats.getTimestamp()); 
     356                        buffer.append(fieldSeparator); 
     357                        buffer.append(df.format(resourceUsefulWorkStats.getValue())); 
     358                        buffer.append(fieldSeparator); 
     359                        buffer.append(System.getProperty("line.separator")); 
     360                } 
     361                return buffer.toString(); 
     362        } 
     363         
     364 
     365        public Object visit(ResourceAvailabilityStats resourceAvailabilityStats) { 
     366                 
     367                String metricName = resourceAvailabilityStats.getUsageType(); 
     368                 
     369                StringBuffer buffer = null; 
     370 
     371                if(printedHeaders.add("metrics")) { 
     372                        buffer = new StringBuffer(600); 
     373                        /*String[] headers = metricsStats.getHeaders(); 
     374                        for(int i = 0; i < headers.length; i++) 
     375                        { 
     376                                buffer.append(headers[i]); 
     377                                buffer.append(fieldSeparator); 
     378                        } 
     379                        buffer.append(System.getProperty("line.separator"));*/ 
     380                } else { 
     381                        buffer = new StringBuffer(300); 
     382                } 
     383                DecimalFormat df = new DecimalFormat(); 
     384                df.setMaximumFractionDigits(3); 
     385                df.setGroupingUsed(false); 
     386                if(resourceAvailabilityStats.getResourceType().getName().equals(CoolEmAllResourceType.NodeGroup.getName())){ 
     387 
     388                        buffer.append(metricName); 
     389                        buffer.append(fieldSeparator); 
     390                        buffer.append(resourceAvailabilityStats.getResourceName()); 
     391                        buffer.append(fieldSeparator); 
     392                        buffer.append(resourceAvailabilityStats.getTimestamp()); 
     393                        buffer.append(fieldSeparator); 
     394                        buffer.append(df.format(resourceAvailabilityStats.getValue())); 
     395                        buffer.append(fieldSeparator); 
     396                        buffer.append(System.getProperty("line.separator")); 
     397                } 
     398                return buffer.toString(); 
     399        } 
    248400} 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/StatsSerializer.java

    r805 r1207  
    44import simulator.stats.implementation.GSSAccumulatorsStats; 
    55import simulator.stats.implementation.JobStats; 
     6import simulator.stats.implementation.MetricsStats; 
    67import simulator.stats.implementation.ResourceAirFlowStats; 
     8import simulator.stats.implementation.ResourceAvailabilityStats; 
     9import simulator.stats.implementation.ResourceHistoryStats; 
    710import simulator.stats.implementation.ResourcePowerStats; 
    811import simulator.stats.implementation.ResourceStats; 
    912import simulator.stats.implementation.ResourceTemperatureStats; 
    1013import simulator.stats.implementation.ResourceUsageStats; 
     14import simulator.stats.implementation.ResourceUsefulWorkStats; 
    1115import simulator.stats.implementation.TaskStats; 
    1216 
     
    3438        public Object visit(ResourceTemperatureStats arg); 
    3539         
     40        public Object visit(ResourceUsefulWorkStats arg); 
     41         
    3642        public Object visit(GSSAccumulatorsStats arg); 
    3743         
     44        public Object visit(MetricsStats arg); 
     45         
     46        public Object visit(ResourceHistoryStats arg); 
     47 
     48        public Object visit(ResourceAvailabilityStats resourceAvailabilityStats); 
     49         
    3850} 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/StringSerializer.java

    r1192 r1207  
    1111import simulator.stats.implementation.GSSAccumulatorsStats; 
    1212import simulator.stats.implementation.JobStats; 
     13import simulator.stats.implementation.MetricsStats; 
    1314import simulator.stats.implementation.ResourceAirFlowStats; 
     15import simulator.stats.implementation.ResourceAvailabilityStats; 
     16import simulator.stats.implementation.ResourceHistoryStats; 
    1417import simulator.stats.implementation.ResourcePowerStats; 
    1518import simulator.stats.implementation.ResourceStats; 
    1619import simulator.stats.implementation.ResourceTemperatureStats; 
    1720import simulator.stats.implementation.ResourceUsageStats; 
     21import simulator.stats.implementation.ResourceUsefulWorkStats; 
    1822import simulator.stats.implementation.TaskStats; 
    1923 
     
    4852                                                buffer.append(fieldSeparator); 
    4953                                        } 
    50                                          
    5154                                } 
    5255 
     
    108111                                        .longValue()); 
    109112                        buffer.append(fieldSeparator); 
    110                         buffer.append(taskStats.getProcessorsName()); 
     113                        buffer.append(taskStats.getHostName()); 
     114                        buffer.append(fieldSeparator); 
     115                        buffer.append(taskStats.getProcessingElementsName()); 
     116                        buffer.append(fieldSeparator); 
     117                        buffer.append(0); 
     118                        buffer.append(fieldSeparator); 
     119                        buffer.append(taskStats.getExecName()); 
    111120                        buffer.append(fieldSeparator); 
    112121                } 
     
    311320                } 
    312321                 
    313                 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 
    314                 if(lastIdx != -1) 
    315                         buffer.deleteCharAt(lastIdx); 
    316                  
    317322                if(resourceUsage.size() > 0){ 
    318323                        buffer.append("mean: " + resourceUsageStats.getMeanValue()); 
     
    373378 
    374379                } 
    375                  
    376                 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 
    377                 if(lastIdx != -1) 
    378                         buffer.deleteCharAt(lastIdx); 
    379                  
     380 
    380381                if(resourceEnergy.size() > 0) { 
    381382                        buffer.append("mean: "+resourceEnergyStats.getMeanValue() + " sum: " +resourceEnergyStats.getSumValue()); 
     
    437438 
    438439                } 
    439                 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 
    440                 if(lastIdx != -1) 
    441                         buffer.deleteCharAt(lastIdx); 
    442                  
     440 
    443441                if(resourceAirFlow.size() > 0) { 
    444442                        buffer.append("mean: "+resourceAirFlowStats.getMeanValue()); 
     
    500498 
    501499                } 
    502                  
    503                 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 
    504                 if(lastIdx != -1) 
    505                         buffer.deleteCharAt(lastIdx); 
    506                  
     500 
    507501                if(resourceTemperature.size() > 0) { 
    508502                        buffer.append("mean: "+resourceTemperatureStats.getMeanValue()); 
     
    573567        } 
    574568 
     569        public Object visit(MetricsStats metricsStats) { 
     570                StringBuffer buffer = new StringBuffer(300); 
     571                return buffer.toString(); 
     572        } 
     573 
     574        public Object visit(ResourceHistoryStats arg) { 
     575                StringBuffer buffer = new StringBuffer(300); 
     576                return buffer.toString(); 
     577        } 
     578 
     579        public Object visit(ResourceUsefulWorkStats arg) { 
     580                StringBuffer buffer = new StringBuffer(300); 
     581                return buffer.toString(); 
     582        } 
     583 
     584        public Object visit(ResourceAvailabilityStats arg) { 
     585                StringBuffer buffer = new StringBuffer(300); 
     586                return buffer.toString(); 
     587        } 
     588 
     589 
    575590} 
  • DCWoRMS/branches/coolemall/src/simulator/utils/XsltTransformations.java

    r1131 r1207  
    1919import javax.xml.xpath.XPathExpressionException; 
    2020 
     21import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription; 
    2122import dcworms.schedframe.scheduling.utils.JobDescription; 
    2223import dcworms.schedframe.scheduling.utils.TaskDescription; 
     
    3536                String value =  
    3637                        //"org.apache.xalan.xsltc.trax.TransformerFactoryImpl"; 
    37                         "org.apache.xalan.processor.TransformerFactoryImpl"; 
     38                        //"org.apache.xalan.processor.TransformerFactoryImpl"; 
     39                        "net.sf.saxon.TransformerFactoryImpl"; 
    3840                Properties props = System.getProperties(); 
    3941                props.put(key, value); 
     
    191193        } 
    192194         
     195        public ApplicationProfileDescription getApplicationProfileDescription(String xmlJob){ 
     196                ApplicationProfileDescription appProfDesc = new  ApplicationProfileDescription(xmlJob); 
     197                return appProfDesc; 
     198        } 
     199         
    193200        public String extractJobId(String job){ 
    194201                Transformer t = null; 
  • DCWoRMS/branches/coolemall/src/simulator/workload/WorkloadLoader.java

    r1170 r1207  
    1717import javax.xml.xpath.XPathExpressionException; 
    1818 
     19import org.apache.commons.io.FilenameUtils; 
    1920import org.apache.commons.logging.Log; 
    2021import org.apache.commons.logging.LogFactory; 
     
    3233import simulator.workload.reader.archive.swf.SWFFields; 
    3334import simulator.workload.reader.xmlJob.XMLJobReader; 
     35import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription; 
    3436import dcworms.schedframe.scheduling.utils.JobDescription; 
    3537import dcworms.schedframe.scheduling.utils.TaskDescription; 
     
    5658         
    5759        protected Map<String, JobDescription> jobsMap; 
    58         protected Map<String, JobDescription> applicationProfilesMap; 
    59  
    60         public WorkloadLoader(XMLJobReader<org.qcg.broker.schemas.jobdesc.Job> xmlReader, WAReader<org.qcg.broker.schemas.jobdesc.Job> swfReader){ 
     60         
     61        protected String appProfilesFolder; 
     62        protected Map<String, ApplicationProfileDescription> applicationProfiles; 
     63 
     64        public WorkloadLoader(XMLJobReader<org.qcg.broker.schemas.jobdesc.Job> xmlReader, WAReader<org.qcg.broker.schemas.jobdesc.Job> swfReader, String appProfilesFolder){ 
    6165                if(swfReader == null){ 
    6266                        throw new RuntimeException("Swf reader is required to build proper tasks."); 
     
    6771                this.generatedTasksCnt = 0; 
    6872                this.jobsMap = new TreeMap<String, JobDescription>(); 
    69                 this.applicationProfilesMap = new TreeMap<String, JobDescription>(); 
     73                this.appProfilesFolder = appProfilesFolder; 
     74                this.applicationProfiles = new TreeMap<String, ApplicationProfileDescription>(); 
    7075                try { 
    7176                        this.xsltTransformation = new XsltTransformations(); 
     
    187192 
    188193                // determine which reader should be used 
    189                 String jobDesc = null; 
    190                 JobDescription job = null; 
    191                          
     194                String xmlJob = null; 
     195                JobDescription jobDesc = null; 
     196                         
     197                for(String key: waReader.getParser().getAppProfilesLocation().keySet()){ 
     198                        String xmlApp = loadApplicationProfile(waReader.getParser().getAppProfilesLocation().get(key)); 
     199                        xmlApp = this.xsltTransformation.extendJobDescription(xmlApp); 
     200                        ApplicationProfileDescription app = this.xsltTransformation.getApplicationProfileDescription(xmlApp); 
     201                        this.applicationProfiles.put(key, app); 
     202                } 
     203                 
    192204                if(this.xmlJobReader != null){ // use xml job reader. Xml job require xslt transformation 
    193                         while((jobDesc = this.xmlJobReader.readRaw()) != null){ 
    194                                 jobDesc = this.xsltTransformation.extendJobDescription(jobDesc); 
    195                                 job = createJobDescription(jobDesc, puSpeed); 
    196                                 if(job != null) 
    197                                         this.jobsMap.put(job.getJobId(), job); 
     205                        while((xmlJob = this.xmlJobReader.readRaw()) != null){ 
     206                                xmlJob = this.xsltTransformation.extendJobDescription(xmlJob); 
     207                                jobDesc = createJobDescription(xmlJob, puSpeed); 
     208                                if(jobDesc != null) 
     209                                        this.jobsMap.put(jobDesc.getJobId(), jobDesc); 
    198210                        } 
    199211                } else {                                                // use swf job reader. Job created by this reader does not require xslt transformation 
    200212                         
    201                         for(String key: waReader.getParser().getAppMapping().keySet()){ 
    202                                 jobDesc = loadApplicationProfile(waReader.getParser().getAppMapping().get(key)); 
    203                                 jobDesc = this.xsltTransformation.extendJobDescription(jobDesc); 
    204                                          
    205                                 try { 
    206                                         job = this.xsltTransformation.splitJobToTasks(jobDesc); 
    207                                 } catch (Exception e) { 
    208                                         throw new IOException(e.getMessage()); 
    209                                 } 
    210                                  
    211                                 this.applicationProfilesMap.put(key, job); 
    212                         } 
    213                          
    214                         while((jobDesc = this.waReader.readRaw()) != null){ 
     213                        while((xmlJob = this.waReader.readRaw()) != null){ 
    215214                                QcgWAJobReader qcgReader = (QcgWAJobReader)waReader; 
    216                                 if(!applicationProfilesMap.isEmpty()) 
    217                                         jobDesc = qcgReader.mergeSwfAndXmlProfile(applicationProfilesMap, jobDesc); 
    218                                 job = createJobDescription(jobDesc, puSpeed); 
    219                                 /*if(job!= null && !applicationProfilesMap.isEmpty()){ 
    220                                         for(int i = 0; i < job.getDescription().getTaskCount(); i++){ 
    221                                                 try { 
    222                                                         JobDescription xmlJobDescription = applicationProfilesMap.get(job.getDescription().getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent()); 
    223                                                         if(xmlJobDescription != null){ 
    224                                                                 for(int j = 0; j < xmlJobDescription.size(); j++){ 
    225                                                                         Task patternTask = xmlJobDescription.getDescription().getTask(j); 
    226                                                                         if(patternTask != null){ 
    227                                                                                 ResourceConsumptionProfileType rcp = patternTask.getExecution().getResourceConsumptionProfile(); 
    228                                                                                 job.getDescription().getTask(j).getExecution().setResourceConsumptionProfile(rcp); 
    229                                                                         } 
    230                                                                 } 
    231                                                         }        
    232                                                 } catch (Exception e){ 
    233                                                         continue; 
    234                                                 } 
    235                                         }                                        
    236                                 } 
    237                                 */ 
    238                                 if(job != null) 
    239                                         this.jobsMap.put(job.getJobId(), job); 
     215                                if(!applicationProfiles.isEmpty()) 
     216                                        xmlJob = qcgReader.mergeSwfAndAppProfile(applicationProfiles, xmlJob); 
     217                                jobDesc = createJobDescription(xmlJob, puSpeed); 
     218                                if(jobDesc != null) 
     219                                        this.jobsMap.put(jobDesc.getJobId(), jobDesc); 
    240220                        } 
    241221                } 
     
    302282        } 
    303283 
    304         public String loadApplicationProfile(String fileName) throws IOException{ 
     284        public String loadApplicationProfile(String pathToAppProfile) throws IOException{ 
    305285                 
    306286                BufferedReader reader = null; 
    307287                StringBuffer buffer = new StringBuffer(); 
    308288 
    309                 try { 
    310                         reader = new BufferedReader(new FileReader(fileName)); 
     289                String localPathToAppProfile; 
     290                 
     291                if(appProfilesFolder != null) { 
     292                        String folderName = FilenameUtils.getFullPath(appProfilesFolder); 
     293                        String fileName = FilenameUtils.getName(pathToAppProfile); 
     294                        localPathToAppProfile = folderName + fileName; 
     295                } else { 
     296                        localPathToAppProfile = pathToAppProfile; 
     297                } 
     298                try { 
     299                        reader = new BufferedReader(new FileReader(localPathToAppProfile )); 
    311300                        String line = null; 
    312301                         
  • DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/AbstractWAParser.java

    r1144 r1207  
    3333        protected HashMap<String, String> reverseIdMapping; // key - xmlJobId_xmlTaskId, value - swf job id 
    3434        protected HashMap<String, Long> jobIndex; 
    35         protected HashMap<String, String> appMapping; 
     35        protected HashMap<String, String> appProfilesLocation; 
    3636        protected String fields[]; 
    3737        protected int fieldsNo; 
     
    4646                this.reverseIdMapping = new HashMap<String, String>(); 
    4747                this.jobIndex = new HashMap<String, Long>(); 
    48                 this.appMapping = new HashMap<String, String>(); 
     48                this.appProfilesLocation = new HashMap<String, String>(); 
    4949                this.headerLoaded = false; 
    5050                this.buildIndex = true; 
    5151                this.fieldsNo = 18; 
     52                 
    5253        } 
    5354 
     
    152153                                String appId = valueData[0]; 
    153154                                String pathToAppProfile = valueData[1]; 
    154                                 appMapping.put(appId, pathToAppProfile); 
     155                                appProfilesLocation.put(appId, pathToAppProfile); 
    155156                                continue; 
    156157                        } 
     
    296297         
    297298         
    298         public Map<String, String> getAppMapping() { 
    299                 return appMapping; 
     299        public Map<String, String> getAppProfilesLocation() { 
     300                return appProfilesLocation; 
    300301        } 
    301302         
  • DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/QcgWAJobReader.java

    r1163 r1207  
    1515 
    1616import simulator.workload.reader.archive.swf.SWFFields; 
     17 
     18import org.qcg.broker.schemas.jobdesc.FileType; 
    1719import org.qcg.broker.schemas.jobdesc.ResourceConsumptionProfileType; 
    1820import org.qcg.broker.schemas.jobdesc.Task; 
    1921import org.qcg.broker.schemas.jobdesc.Workflow; 
    2022 
    21 import dcworms.schedframe.scheduling.utils.JobDescription; 
     23import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription; 
    2224 
    2325/** 
     
    116118        } 
    117119 
    118         public String mergeSwfAndXmlProfile(Map<String, JobDescription> applicationProfilesMap, String swfJobDesc) throws IOException{ 
     120        public String mergeSwfAndAppProfile(Map<String, ApplicationProfileDescription> applicationProfiles, String swfJobDesc) throws IOException{ 
    119121                 
    120122                StringReader reader = new StringReader(swfJobDesc); 
     
    132134                for(int i = 0; i < job.getTaskCount(); i++){ 
    133135                        try { 
    134                                 JobDescription xmlJobDescription = applicationProfilesMap.get(job.getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent()); 
    135                                 if(xmlJobDescription != null){ 
    136                                         for(int j = 0; j < xmlJobDescription.size(); j++){ 
    137                                                 Task patternTask = xmlJobDescription.getDescription().getTask(j); 
    138                                                 if(patternTask != null){ 
    139                                                         ResourceConsumptionProfileType rcp = patternTask.getExecution().getResourceConsumptionProfile(); 
    140                                                         job.getTask(j).getExecution().setResourceConsumptionProfile(rcp); 
    141                                                 } 
     136                                ApplicationProfileDescription appProfileDescription = applicationProfiles.get(job.getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent()); 
     137                                if(appProfileDescription != null){ 
     138                                        Task patternTask = appProfileDescription.getDescription(); 
     139                                        if(patternTask != null){ 
     140                                                ResourceConsumptionProfileType[] rcp = patternTask.getExecution().getResourceConsumptionProfile(); 
     141                                                job.getTask(i).getExecution().setResourceConsumptionProfile(rcp); 
     142                                                FileType script = new FileType(); 
     143                                                script.setName(patternTask.getId()); 
     144                                                job.getTask(i).getExecution().addStdin(script); 
    142145                                        } 
    143146                                }        
  • DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/WAParser.java

    r1144 r1207  
    4545        public int getType(); 
    4646         
    47         public Map<String, String> getAppMapping(); 
     47        public Map<String, String> getAppProfilesLocation(); 
    4848} 
  • DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/swf/QcgSWFJobReader.java

    r1202 r1207  
    221221                                         
    222222                                case SWFFields.DATA_EXECUTABLE_NUMBER: 
    223                                         String pathToAppProfile = waParser.getAppMapping().get(String.valueOf(value)); 
     223                                        String pathToAppProfile = waParser.getAppProfilesLocation().get(String.valueOf(value)); 
    224224                                        String appName = null; 
    225225                                        if(pathToAppProfile == null){ 
Note: See TracChangeset for help on using the changeset viewer.