- Timestamp:
- 10/08/12 10:23:45 (13 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java
r477 r481 49 49 import org.jfree.data.xy.XYSeriesCollection; 50 50 import org.jfree.ui.TextAnchor; 51 import org.joda.time.DateTime;52 51 import org.joda.time.DateTimeUtilsExt; 53 52 53 import schedframe.ExecutablesList; 54 54 import schedframe.ResourceController; 55 55 import schedframe.exceptions.ResourceException; … … 69 69 import schedframe.scheduling.ResourceHistoryItem; 70 70 import schedframe.scheduling.Scheduler; 71 import schedframe.scheduling.manager.tasks.JobRegistry; 71 72 import schedframe.scheduling.manager.tasks.JobRegistryImpl; 72 73 import schedframe.scheduling.tasks.Job; 73 74 import schedframe.scheduling.tasks.JobInterface; 74 75 import simulator.ConfigurationOptions; 76 import simulator.DCWormsConstants; 75 77 import simulator.DataCenterWorkloadSimulator; 76 78 import simulator.GenericUser; 77 import simulator.WormsConstants;78 79 import simulator.stats.GSSAccumulator; 79 80 import simulator.stats.SimulationStatistics; … … 90 91 import gssim.schedframe.scheduling.Executable; 91 92 92 public class WormsStatistics implements SimulationStatistics {93 94 private Log log = LogFactory.getLog( WormsStatistics.class);93 public class DCWormsStatistics implements SimulationStatistics { 94 95 private Log log = LogFactory.getLog(DCWormsStatistics.class); 95 96 96 97 protected static float ALPHA = 0.5f; … … 98 99 99 100 //protected static final int BITS = 8; 100 //protected static final int MILLI_SEC = 1000;101 protected static final int MILLI_SEC = 1000; 101 102 102 103 protected static final String RAW_TASKS_STATISTICS_OUTPUT_FILE_NAME = "Tasks.txt"; … … 117 118 protected String simulationIdentifier; 118 119 protected ConfigurationOptions configuration; 119 120 120 121 121 protected GSSAccumulatorsStats accStats; … … 129 129 protected long endSimulationTime; 130 130 131 132 131 //RESOURCES 133 132 protected Timetable ganttDiagramPeTimetable; … … 140 139 protected Map<String, TimetableEventGroup> taskGanttMap; 141 140 142 143 141 //TASKS 144 142 protected int numOfdelayedTasks = 0; … … 151 149 protected HashMap<String, List<String>> task_processorsMap; 152 150 153 154 151 protected JobRegistryImpl jr; 155 152 156 153 157 public WormsStatistics(String simulationIdentifier, ConfigurationOptions co, GenericUser users,154 public DCWormsStatistics(String simulationIdentifier, ConfigurationOptions co, GenericUser users, 158 155 String outputFolderName, ResourceController resourceController) { 159 156 this.simulationIdentifier = simulationIdentifier; … … 188 185 gatherResourceStatistics(); 189 186 e = System.currentTimeMillis(); 190 log.info("time in sec: " + ((e - s) / 1000));187 log.info("time in sec: " + ((e - s) / MILLI_SEC)); 191 188 192 189 log.info("gatherTaskStatistics"); … … 194 191 gatherTaskStatistics(); 195 192 e = System.currentTimeMillis(); 196 log.info("time in sec: " + ((e - s) / 1000));193 log.info("time in sec: " + ((e - s) / MILLI_SEC)); 197 194 198 195 log.info("saveSimulationStatistics"); … … 200 197 saveSimulationStatistics(); 201 198 e = System.currentTimeMillis(); 202 log.info("time in sec: " + ((e - s) / 1000));199 log.info("time in sec: " + ((e - s) / MILLI_SEC)); 203 200 } 204 201 … … 299 296 energyStatsFile = null; 300 297 } 301 302 basicResStats = gatherPEStats( JobRegistryImpl.getAllocationHistory());298 JobRegistry jr = new JobRegistryImpl("stats"); 299 basicResStats = gatherPEStats(jr.getExecutableTasks()); 303 300 peStatsPostProcessing(basicResStats); 304 301 basicResLoad = calculatePELoad( basicResStats); … … 342 339 energyUsage = gatherResourceEnergyStats(resource); 343 340 energyUsage.setMeanUsage(calculateEnergyLoad(energyUsage)); 344 energyUsage.setSumUsage(energyUsage.getMeanUsage() * (endSimulationTime - startSimulationTime) / (3600 * 1000));341 energyUsage.setSumUsage(energyUsage.getMeanUsage() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 345 342 346 343 EnergyExtension een = (EnergyExtension )(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); … … 428 425 for(String key: energyCategoryStats.keySet()){ 429 426 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()); 431 428 } 432 429 energyStatsFile.println("\n\n"); … … 462 459 String measure = (String) info[0]; 463 460 if (measure 464 .startsWith( WormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME)) {461 .startsWith(DCWormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME)) { 465 462 return stats.average(measure); 466 463 } … … 492 489 } 493 490 } 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 496 494 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(); 502 501 Map<ResourceUnitName, ResourceUnit> res = resHistItemList.get(resHistItemList.size() - 1).getResourceUnits(); 503 502 ResourceUnit resUnit = res.get(StandardResourceUnitName.PE); … … 507 506 for(ComputingResource pe: pes){ 508 507 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 513 512 String uniqueTaskID = execTask.getJobId() + "_" + execTask.getId(); 514 513 … … 535 534 } else if (resUnit instanceof PEUnit){ 536 535 PEUnit peUnit = (PEUnit) resUnit ; 537 538 536 } 539 537 … … 629 627 630 628 /// 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); 632 630 lastPower = pu.getValue(); 633 631 lastTime = pu.getTimestamp(); … … 1026 1024 1027 1025 //List<TaskInterface> execList = JobRegistry.getInstance("COMPUTING_GRID_0#BROKER").getAllSubmittedTasks(); 1028 List<Executable> execList = jr.get JobExecutables(job.getId());1026 List<Executable> execList = jr.getExecutableTasks().getJobExecutables(job.getId()); 1029 1027 List<TaskStats> taskStatsList = new ArrayList<TaskStats>(); 1030 1028 … … 1143 1141 String uniqueTaskID = task.getJobId() + "_" + task.getId(); 1144 1142 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; 1150 1147 1151 1148 TaskSeries taskRes = ganttDiagramTaskSeriesCollection.getSeries(resID); … … 1165 1162 String uniqueTaskID = task.getJobId() + "_" + task.getId(); 1166 1163 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; 1172 1168 1173 1169 TaskSeries waitRes = ganttDiagramWaitingTimeSeriesCollection.getSeries(resID); … … 1177 1173 } 1178 1174 1179 long sub = Double.valueOf(task.getSubmissionTime()).longValue() * 1000;1175 long sub = Double.valueOf(task.getSubmissionTime()).longValue() * MILLI_SEC; 1180 1176 org.jfree.data.gantt.Task wait_exec = new org.jfree.data.gantt.Task(uniqueTaskID, new Date(sub), new Date( 1181 1177 execEndTime));
Note: See TracChangeset
for help on using the changeset viewer.