Ignore:
Timestamp:
10/08/12 10:23:45 (13 years ago)
Author:
wojtekp
Message:
 
File:
1 moved

Legend:

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

    r477 r481  
    4949import org.jfree.data.xy.XYSeriesCollection; 
    5050import org.jfree.ui.TextAnchor; 
    51 import org.joda.time.DateTime; 
    5251import org.joda.time.DateTimeUtilsExt; 
    5352 
     53import schedframe.ExecutablesList; 
    5454import schedframe.ResourceController; 
    5555import schedframe.exceptions.ResourceException; 
     
    6969import schedframe.scheduling.ResourceHistoryItem; 
    7070import schedframe.scheduling.Scheduler; 
     71import schedframe.scheduling.manager.tasks.JobRegistry; 
    7172import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    7273import schedframe.scheduling.tasks.Job; 
    7374import schedframe.scheduling.tasks.JobInterface; 
    7475import simulator.ConfigurationOptions; 
     76import simulator.DCWormsConstants; 
    7577import simulator.DataCenterWorkloadSimulator; 
    7678import simulator.GenericUser; 
    77 import simulator.WormsConstants; 
    7879import simulator.stats.GSSAccumulator; 
    7980import simulator.stats.SimulationStatistics; 
     
    9091import gssim.schedframe.scheduling.Executable; 
    9192 
    92 public class WormsStatistics implements SimulationStatistics { 
    93  
    94         private Log log = LogFactory.getLog(WormsStatistics.class); 
     93public class DCWormsStatistics implements SimulationStatistics { 
     94 
     95        private Log log = LogFactory.getLog(DCWormsStatistics.class); 
    9596 
    9697        protected static float ALPHA = 0.5f; 
     
    9899 
    99100        //protected static final int BITS = 8; 
    100         //protected static final int MILLI_SEC = 1000; 
     101        protected static final int MILLI_SEC = 1000; 
    101102 
    102103        protected static final String RAW_TASKS_STATISTICS_OUTPUT_FILE_NAME = "Tasks.txt"; 
     
    117118        protected String simulationIdentifier; 
    118119        protected ConfigurationOptions configuration; 
    119  
    120120 
    121121        protected GSSAccumulatorsStats accStats; 
     
    129129        protected long endSimulationTime; 
    130130         
    131          
    132131        //RESOURCES 
    133132        protected Timetable ganttDiagramPeTimetable; 
     
    140139        protected Map<String, TimetableEventGroup> taskGanttMap; 
    141140         
    142          
    143141        //TASKS 
    144142        protected int numOfdelayedTasks = 0; 
     
    151149        protected HashMap<String, List<String>> task_processorsMap; 
    152150 
    153  
    154151        protected JobRegistryImpl jr; 
    155152 
    156153         
    157         public WormsStatistics(String simulationIdentifier, ConfigurationOptions co, GenericUser users, 
     154        public DCWormsStatistics(String simulationIdentifier, ConfigurationOptions co, GenericUser users, 
    158155                        String outputFolderName, ResourceController resourceController) { 
    159156                this.simulationIdentifier = simulationIdentifier; 
     
    188185                gatherResourceStatistics(); 
    189186                e = System.currentTimeMillis(); 
    190                 log.info("time in sec: " + ((e - s) / 1000)); 
     187                log.info("time in sec: " + ((e - s) / MILLI_SEC)); 
    191188                 
    192189                log.info("gatherTaskStatistics"); 
     
    194191                gatherTaskStatistics(); 
    195192                e = System.currentTimeMillis(); 
    196                 log.info("time in sec: " + ((e - s) / 1000)); 
     193                log.info("time in sec: " + ((e - s) / MILLI_SEC)); 
    197194 
    198195                log.info("saveSimulationStatistics"); 
     
    200197                saveSimulationStatistics(); 
    201198                e = System.currentTimeMillis(); 
    202                 log.info("time in sec: " + ((e - s) / 1000)); 
     199                log.info("time in sec: " + ((e - s) / MILLI_SEC)); 
    203200        } 
    204201 
     
    299296                        energyStatsFile = null; 
    300297                } 
    301                  
    302                 basicResStats = gatherPEStats(JobRegistryImpl.getAllocationHistory()); 
     298                JobRegistry jr = new JobRegistryImpl("stats"); 
     299                basicResStats = gatherPEStats(jr.getExecutableTasks()); 
    303300                peStatsPostProcessing(basicResStats); 
    304301                basicResLoad = calculatePELoad( basicResStats); 
     
    342339                                                energyUsage = gatherResourceEnergyStats(resource); 
    343340                                                energyUsage.setMeanUsage(calculateEnergyLoad(energyUsage)); 
    344                                                 energyUsage.setSumUsage(energyUsage.getMeanUsage() * (endSimulationTime - startSimulationTime) / (3600 * 1000)); 
     341                                                energyUsage.setSumUsage(energyUsage.getMeanUsage() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 
    345342                                                 
    346343                                                EnergyExtension een = (EnergyExtension )(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
     
    428425                                        for(String key: energyCategoryStats.keySet()){ 
    429426                                                GSSAccumulator acc = energyCategoryStats.get(key); 
    430                                                 energyStatsFile.println(key + "- mean: "  + acc.getMean()+ " sum: " +acc.getMean() * (endSimulationTime-startSimulationTime) / (3600 * 1000) * acc.getCount()); 
     427                                                energyStatsFile.println(key + "- mean: "  + acc.getMean()+ " sum: " +acc.getMean() * (endSimulationTime-startSimulationTime) / (3600 * MILLI_SEC) * acc.getCount()); 
    431428                                        } 
    432429                                        energyStatsFile.println("\n\n"); 
     
    462459                        String measure = (String) info[0]; 
    463460                        if (measure 
    464                                         .startsWith(WormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME)) { 
     461                                        .startsWith(DCWormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME)) { 
    465462                                return stats.average(measure); 
    466463                        } 
     
    492489                } 
    493490        } 
    494         private Map<String, List<ResStat>> gatherPEStats(Map<Integer, Map<String, Object>> history) { 
    495  
     491        private Map<String, List<ResStat>> gatherPEStats( ExecutablesList executables) { 
     492 
     493                 
    496494                Map<String, List<ResStat>> basicResStats = new TreeMap<String, List<ResStat>>(new MapPEIdComparator()); 
    497                  
    498                 for (Integer executableId : history.keySet()) { 
    499  
    500                         Map<String, Object> historyItem = (Map<String, Object>) history.get(executableId); 
    501                         List<ResourceHistoryItem> resHistItemList = (List<ResourceHistoryItem>) historyItem.get(WormsConstants.RESOURCES); 
     495                //Map<Integer, Map<String, Object>> history 
     496                 
     497                for (ExecTask execTask:executables) { 
     498                        Executable exec = (Executable) execTask; 
     499 
     500                        List<ResourceHistoryItem> resHistItemList = exec.getUsedResources(); 
    502501                        Map<ResourceUnitName, ResourceUnit> res = resHistItemList.get(resHistItemList.size() - 1).getResourceUnits(); 
    503502                        ResourceUnit resUnit = res.get(StandardResourceUnitName.PE); 
     
    507506                                for(ComputingResource pe: pes){ 
    508507                                        String peName = pe.getName(); 
    509                                         long startDate = ((DateTime) historyItem.get(WormsConstants.START_TIME)).getMillis(); 
    510                                         long endDate = ((DateTime) historyItem.get(WormsConstants.END_TIME)).getMillis(); 
    511                                         JobRegistryImpl jr = new JobRegistryImpl("stats"); 
    512                                         ExecTask execTask = jr.getTaskExecutable(executableId); 
     508                                        long startDate = Double.valueOf(exec.getExecStartTime()).longValue() * MILLI_SEC; 
     509                                        long endDate = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC; 
     510 
     511 
    513512                                        String uniqueTaskID = execTask.getJobId() + "_" + execTask.getId(); 
    514513                                         
     
    535534                        } else if (resUnit instanceof PEUnit){ 
    536535                                PEUnit peUnit = (PEUnit) resUnit ; 
    537                          
    538536                        } 
    539537 
     
    629627                                                 
    630628                                        ///     System.out.println(resource.getName() + ":"+new DateTime(pu.getTimestamp())+";"+pu.getValue()); 
    631                                                 power = power + (pu.getTimestamp() - lastTime) * lastPower/ (3600 * 1000); 
     629                                                power = power + (pu.getTimestamp() - lastTime) * lastPower/ (3600 * MILLI_SEC); 
    632630                                                lastPower = pu.getValue(); 
    633631                                                lastTime = pu.getTimestamp(); 
     
    10261024 
    10271025                        //List<TaskInterface> execList = JobRegistry.getInstance("COMPUTING_GRID_0#BROKER").getAllSubmittedTasks(); 
    1028                         List<Executable> execList = jr.getJobExecutables(job.getId()); 
     1026                        List<Executable> execList = jr.getExecutableTasks().getJobExecutables(job.getId()); 
    10291027                        List<TaskStats> taskStatsList = new ArrayList<TaskStats>(); 
    10301028 
     
    11431141                String uniqueTaskID = task.getJobId() + "_" + task.getId(); 
    11441142 
    1145                 String resIDlist[] = task.getAllResourceName(); 
    1146                 String resID = resIDlist[resIDlist.length - 1]; 
    1147  
    1148                 long execStartTime = Double.valueOf(task.getExecStartTime()).longValue() * 1000; 
    1149                 long execEndTime = Double.valueOf(task.getFinishTime()).longValue() * 1000; 
     1143                String resID = task.getSchedulerName(); 
     1144 
     1145                long execStartTime = Double.valueOf(task.getExecStartTime()).longValue() * MILLI_SEC; 
     1146                long execEndTime = Double.valueOf(task.getFinishTime()).longValue() * MILLI_SEC; 
    11501147 
    11511148                TaskSeries taskRes = ganttDiagramTaskSeriesCollection.getSeries(resID); 
     
    11651162                String uniqueTaskID = task.getJobId() + "_" + task.getId(); 
    11661163 
    1167                 String resIDlist[] = task.getAllResourceName(); 
    1168                 String resID = resIDlist[resIDlist.length - 1]; 
    1169  
    1170                 long execStartTime = Double.valueOf(task.getExecStartTime()).longValue() * 1000; 
    1171                 long execEndTime = Double.valueOf(task.getFinishTime()).longValue() * 1000; 
     1164                String resID = task.getSchedulerName(); 
     1165 
     1166                long execStartTime = Double.valueOf(task.getExecStartTime()).longValue() * MILLI_SEC; 
     1167                long execEndTime = Double.valueOf(task.getFinishTime()).longValue() * MILLI_SEC; 
    11721168 
    11731169                TaskSeries waitRes = ganttDiagramWaitingTimeSeriesCollection.getSeries(resID); 
     
    11771173                } 
    11781174 
    1179                 long sub = Double.valueOf(task.getSubmissionTime()).longValue() * 1000; 
     1175                long sub = Double.valueOf(task.getSubmissionTime()).longValue() * MILLI_SEC; 
    11801176                org.jfree.data.gantt.Task wait_exec = new org.jfree.data.gantt.Task(uniqueTaskID, new Date(sub), new Date( 
    11811177                                execEndTime)); 
Note: See TracChangeset for help on using the changeset viewer.