Changeset 1207 for DCWoRMS/branches/coolemall/src/simulator
- Timestamp:
- 11/26/13 11:56:07 (11 years ago)
- Location:
- DCWoRMS/branches/coolemall/src/simulator
- Files:
-
- 5 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/branches/coolemall/src/simulator/ConfigurationOptions.java
r802 r1207 52 52 public static final String READ_SCENARIO_INPUT_FOLDER = READ_SCENARIO_MODIFIER 53 53 + ".inputfolder"; 54 54 /** The input folder with application profiles */ 55 public static final String READ_SCENARIO_APPLCIATION_PROFILES = READ_SCENARIO_MODIFIER + ".applicationProfiles"; 55 56 /** The name of the workload file */ 56 57 public static final String READ_SCENARIO_WORKLOAD_FILE = READ_SCENARIO_MODIFIER … … 79 80 public static final String JOBS_STATISTICS = CREATESTATISTICS + ".jobs"; 80 81 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 85 90 /** 86 91 * The main output folders base name … … 101 106 * Suffix for read scenario output folder 102 107 */ 103 public String statsOutputSubfolderNameRe rad = null;108 public String statsOutputSubfolderNameRead = null; 104 109 105 110 /* =============================================================================================== */ … … 137 142 */ 138 143 public String inputFolder = null; 144 145 public String appProfilesFolder = null; 139 146 140 147 public String inputTar = null; … … 184 191 public String [] resForUtilizationChart; 185 192 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 ; 188 200 /** 189 201 * An empty constructor. … … 255 267 256 268 try { 269 co.appProfilesFolder = getSeparatorTerminatedPath(bundle 270 .getString(READ_SCENARIO_APPLCIATION_PROFILES)); 271 } catch (MissingResourceException e) { 272 co.appProfilesFolder = null; 273 } 274 275 try { 257 276 co.inputWorkloadFileName = bundle 258 277 .getString(READ_SCENARIO_WORKLOAD_FILE); … … 346 365 try { 347 366 co.statsOutputSubfolderNameCreate = bundle.getString(STATS_OUTPUT_SUBFOLDER_NAME); 348 co.statsOutputSubfolderNameRe rad = co.statsOutputSubfolderNameCreate;367 co.statsOutputSubfolderNameRead = co.statsOutputSubfolderNameCreate; 349 368 } catch(MissingResourceException e){ 350 369 co.statsOutputSubfolderNameCreate = "stats_create"; 351 co.statsOutputSubfolderNameRe rad = "stats_read";370 co.statsOutputSubfolderNameRead = "stats_read"; 352 371 } 353 372 … … 370 389 co.numberOfSimulations = 1; 371 390 } 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 379 428 return co; 380 429 } -
DCWoRMS/branches/coolemall/src/simulator/DCWormsUsers.java
r1160 r1207 22 22 import org.apache.commons.logging.LogFactory; 23 23 import 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;27 24 28 25 import qcg.shared.constants.BrokerConstants; … … 244 241 245 242 } 246 System.out.println("finished sending jobs");247 243 } 248 244 -
DCWoRMS/branches/coolemall/src/simulator/DataCenterWorkloadSimulator.java
r1142 r1207 14 14 import javax.swing.filechooser.FileFilter; 15 15 16 import org.apache.commons.io.FilenameUtils; 16 17 import org.apache.commons.logging.Log; 17 18 import org.apache.commons.logging.LogFactory; … … 21 22 22 23 import schedframe.Initializable; 23 import schedframe. ResourceController;24 import schedframe.SimulatedEnvironment; 24 25 import simulator.reader.ResourceReader; 25 26 import simulator.stats.AccumulatedStatistics; … … 51 52 * The name of the simulator application 52 53 */ 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"; 54 60 55 61 /** … … 183 189 } 184 190 185 if (log.isInfoEnabled()) 191 if (log.isInfoEnabled()){ 186 192 log.info("Done :: " + SIMULATOR_NAME + " has finished " 187 193 + noOfSimulations + " simulation runs ::"); 194 log.info("Simulation finished with status: 0"); 195 } 188 196 189 197 System.out.flush(); … … 259 267 260 268 ResourceReader resourceReader = new ResourceReader( 261 options );262 ResourceControllerrc = resourceReader.read();269 options.resdescFileName); 270 SimulatedEnvironment rc = resourceReader.read(); 263 271 eventManager = new EventManager("eventManager", rc); 264 272 … … 268 276 rc.setInitList(null); 269 277 270 DCWormsUsers wl= new DCWormsUsers("Users",278 DCWormsUsers users = new DCWormsUsers("Users", 271 279 rc.getScheduler().get_name(), workload); 272 280 281 System.out.println("Starting simulation..."); 282 273 283 GridSimWrapper.startSimulation(); 274 284 long stopSimulation = System.currentTimeMillis(); 275 285 286 System.out.println("Simulation finished"); 287 276 288 DCWormsStatistics stats = new DCWormsStatistics(simulationIdentifier, 277 options, wl, statsOutputPath, rc);289 options, users, statsOutputPath, rc); 278 290 accumulatedStatistics.add(stats); 279 291 if (log.isInfoEnabled()) … … 301 313 String wlFileName = options.inputWorkloadFileName; 302 314 315 String appProfilesFolder = options.appProfilesFolder; 303 316 if (options.inputFolder != null) { 304 317 File f = null; … … 318 331 swfReader = AbstractWAReader.getInstace(wlFileName); 319 332 320 WorkloadLoader workload = new WorkloadLoader(xmlJobReader, swfReader );333 WorkloadLoader workload = new WorkloadLoader(xmlJobReader, swfReader, appProfilesFolder); 321 334 workload.load(); 322 335 … … 346 359 prefix = options.inputFolder; 347 360 } else if (options.inputWorkloadFileName != null) { 348 prefix = new File(options.inputWorkloadFileName).getParent();361 prefix = FilenameUtils.getFullPath(new File(options.inputWorkloadFileName).getAbsolutePath()); 349 362 } else { 350 363 prefix = System.getProperty("user.dir"); 351 364 } 352 statsOutputPath = prefix + File.separator 353 + options.statsOutputSubfolderNameRerad; 365 //statsOutputPath = prefix + File.separator 366 // + options.statsOutputSubfolderNameRead; 367 statsOutputPath = options.statsOutputSubfolderNameRead; 354 368 } 355 369 statsOutputPath += File.separator; -
DCWoRMS/branches/coolemall/src/simulator/reader/EnvironmentWrapper.java
r477 r1207 18 18 public class EnvironmentWrapper { 19 19 20 Environment environment;20 private Environment environment; 21 21 22 22 public void wrap(Environment environment) { … … 53 53 public ComputingResource[] getComputingResources() throws UnknownParameter{ 54 54 55 ArrayList<ComputingResource>tab = null;56 57 55 if(environment == null) 58 56 throw new UnknownParameter("Environment parameters are not defined."); … … 61 59 return null; 62 60 63 tab= new ArrayList<ComputingResource>();61 ArrayList<ComputingResource> computingResources = new ArrayList<ComputingResource>(); 64 62 65 63 for(int i = 0; i < resources.getComputingResourceCount(); i++){ 66 64 ComputingResource compRes = resources.getComputingResource(i); 67 tab.add(compRes);65 computingResources.add(compRes); 68 66 } 69 if( tab.size() == 0)67 if(computingResources.size() == 0) 70 68 return null; 71 69 else 72 return tab.toArray(new ComputingResource[0]);70 return computingResources.toArray(new ComputingResource[0]); 73 71 } 74 72 -
DCWoRMS/branches/coolemall/src/simulator/reader/ResourceReader.java
r1042 r1207 1 1 package simulator.reader; 2 3 import gridsim.ResourceCalendar;4 2 5 3 import java.io.File; … … 19 17 import java.util.Set; 20 18 19 import org.apache.commons.io.FilenameUtils; 21 20 import org.exolab.castor.xml.MarshalException; 22 21 import org.exolab.castor.xml.ValidationException; … … 26 25 import schedframe.Parameter; 27 26 import schedframe.Parameters; 28 import schedframe. ResourceController;27 import schedframe.SimulatedEnvironment; 29 28 import schedframe.exceptions.ResourceException; 29 import schedframe.resources.CoolEmAllResourceFactory; 30 30 import schedframe.resources.Resource; 31 31 import schedframe.resources.StandardResourceType; 32 32 import schedframe.resources.computing.ComputingResource; 33 33 import schedframe.resources.computing.ResourceFactory; 34 import schedframe.resources.computing. description.AbstractResourceDescription;34 import schedframe.resources.computing.StandardResourceFactory; 35 35 import schedframe.resources.computing.description.ComputingResourceDescription; 36 import schedframe.resources.computing.description.ResourceDescription; 36 37 import schedframe.resources.units.ResourceUnit; 37 38 import schedframe.resources.units.ResourceUnitName; … … 45 46 import schemas.ManagedComputingResources; 46 47 import schemas.StringValueWithUnit; 47 import simulator. ConfigurationOptions;48 import simulator.DataCenterWorkloadSimulator; 48 49 import simulator.utils.InstanceFactory; 50 import test.DEBBTranslator.src.PLMXMLTranslator; 49 51 50 52 public class ResourceReader { 51 53 52 54 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 58 58 private ExecutionTimeEstimationPlugin execTimeEstimationPlugin; 59 private String globalSchedulingPluginName;60 59 61 60 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, 72 72 UnknownParameter { 73 73 74 74 File file = new File(resDescFileName); 75 76 Environment env ;75 76 Environment env = null; 77 77 try{ 78 78 env = Environment.unmarshal(new FileReader(file)); 79 79 80 } 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 } 84 99 System.out.println("started creating environment description"); 85 100 List<ComputingResourceDescription> mainCompResDescList = createEnvironmentDescription(env); … … 94 109 System.out.println("finished creating schedulers"); 95 110 96 ResourceController rc = new ResourceController(mainScheduler, computingResources);111 SimulatedEnvironment simEnv = new SimulatedEnvironment(mainScheduler, computingResources); 97 112 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; 101 116 } 102 117 … … 181 196 182 197 for(ComputingResourceDescription mainExecResDes : mainCompResDesList){ 183 ComputingResource mainResource = ResourceFactory.createResource(mainExecResDes);198 ComputingResource mainResource = resFactory.createComputingResource(mainExecResDes); 184 199 toExamine.push(mainExecResDes); 185 200 resStructure.push(mainResource); … … 192 207 toInit.add(parentResource); 193 208 compResLayers.add(parentResource.getType().getName()); 194 List< AbstractResourceDescription> childrenResDesc = parentResDesc.getChildren();209 List<ResourceDescription> childrenResDesc = parentResDesc.getChildren(); 195 210 if (childrenResDesc == null){ 196 211 continue; … … 200 215 ComputingResourceDescription compResDesc = (ComputingResourceDescription) childrenResDesc.get(i); 201 216 toExamine.push(compResDesc); 202 ComputingResource resource = ResourceFactory.createResource(compResDesc);217 ComputingResource resource = resFactory.createComputingResource(compResDesc); 203 218 parentResource.addChild(resource); 204 219 resStructure.push(resource); … … 254 269 } 255 270 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"); 269 272 } 270 273 return mainScheduler; … … 332 335 //TODO - refactor (create scheduler in 1 line) 333 336 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); 335 338 } 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); 337 340 } 338 341 return scheduler; … … 374 377 ComputingResource computingResource; 375 378 try { 376 if( resourceName.equals(mainCompRes.getName()))379 if(mainCompRes.getFullName().contains(resourceName)) 377 380 computingResource = mainCompRes; 378 381 else … … 421 424 return resourceUnits; 422 425 } 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 441 427 442 428 class ResourceTypeComparator implements Comparator<Initializable>{ -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/DCWormsStatistics.java
r1199 r1207 7 7 import java.io.IOException; 8 8 import java.io.PrintStream; 9 import java.text.DecimalFormat; 9 10 import java.text.NumberFormat; 10 11 import java.util.ArrayList; … … 14 15 import java.util.Date; 15 16 import java.util.HashMap; 17 import java.util.HashSet; 16 18 import java.util.List; 17 19 import java.util.Map; 20 import java.util.Set; 18 21 import java.util.SortedMap; 19 22 import java.util.TreeMap; … … 54 57 55 58 import schedframe.ExecutablesList; 56 import schedframe. ResourceController;59 import schedframe.SimulatedEnvironment; 57 60 import schedframe.exceptions.ResourceException; 58 61 import schedframe.resources.ResourceType; … … 66 69 import schedframe.resources.computing.profiles.energy.power.PowerUsage; 67 70 import schedframe.resources.computing.profiles.energy.thermal.TemperatureValue; 68 import schedframe.resources.units.PEUnit; 71 import schedframe.resources.devices.Device; 72 import schedframe.resources.devices.PhysicalResource; 69 73 import schedframe.resources.units.ProcessingElements; 70 74 import schedframe.resources.units.ResourceUnit; … … 82 86 import simulator.GenericUser; 83 87 import simulator.stats.GSSAccumulator; 88 import simulator.stats.MetricsCalculator; 84 89 import simulator.stats.SimulationStatistics; 85 90 import simulator.stats.implementation.out.AbstractStringSerializer; 86 91 import simulator.stats.implementation.out.CoolEmAllStringSerializer; 92 import simulator.stats.implementation.out.StringSerializer; 87 93 import csiro.mit.utils.jfreechart.timetablechart.TimetableChartFactory; 88 94 import csiro.mit.utils.jfreechart.timetablechart.data.Timetable; … … 93 99 import dcworms.schedframe.scheduling.Executable; 94 100 import eduni.simjava.Sim_stat; 101 import example.energy.coolemall.CoolEmAllTestbedMeasurements; 95 102 96 103 public class DCWormsStatistics implements SimulationStatistics { … … 111 118 protected static final String AIRFLOW_STATISTICS_OUTPUT_FILE_NAME = "AirThroughput.txt"; 112 119 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 114 126 protected static final String DIAGRAMS_FILE_NAME_PREFIX = "Chart_"; 115 127 protected static final String STATS_FILE_NAME_PREFIX = "Stats_"; … … 127 139 128 140 protected GenericUser users; 129 protected ResourceControllerresourceController;141 protected SimulatedEnvironment resourceController; 130 142 protected boolean generateDiagrams = true; 131 143 protected AbstractStringSerializer serializer; … … 154 166 protected TaskSeriesCollection ganttDiagramTaskSeriesCollection; 155 167 protected TaskSeriesCollection ganttDiagramWaitingTimeSeriesCollection; 156 protected Map<String, List<String>> task_processorsMap;168 protected Map<String, Set<ComputingResource>> task_processorsMap; 157 169 158 170 protected JobRegistry jr; 159 171 protected MetricsCalculator metCalc; 160 172 161 173 public DCWormsStatistics(String simulationIdentifier, ConfigurationOptions co, GenericUser users, 162 String outputFolderName, ResourceControllerresourceController) {174 String outputFolderName, SimulatedEnvironment resourceController) { 163 175 this.simulationIdentifier = simulationIdentifier; 164 176 this.configuration = co; … … 167 179 this.outputFolderName = outputFolderName; 168 180 169 this.serializer = new CoolEmAllStringSerializer(); 181 this.serializer = new StringSerializer(); 182 183 if(DataCenterWorkloadSimulator.MODE.equals("CoolEmAll")){ 184 this.serializer = new CoolEmAllStringSerializer(); 185 } 170 186 this.serializer.setDefaultNumberFormat(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT); 171 187 … … 173 189 this.jr = new JobRegistryImpl(""); 174 190 init(); 191 metCalc = new MetricsCalculator(); 175 192 } 176 193 … … 183 200 this.endSimulationTime = DateTimeUtilsExt.currentTimeMillis(); 184 201 202 metCalc.setStartTime(startSimulationTime); 203 metCalc.setEndTime(endSimulationTime); 204 185 205 long s = 0; 186 206 long e = 0; … … 211 231 212 232 private void init() { 213 task_processorsMap = new HashMap<String, List<String>>();233 task_processorsMap = new HashMap<String, Set<ComputingResource>>(); 214 234 accStats = new GSSAccumulatorsStats(); 215 235 statsData = new HashMap<String, GSSAccumulator>(); … … 229 249 if (simulationStatsFile != null) { 230 250 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 231 268 simulationStatsFile.println(txt); 232 269 } … … 238 275 239 276 /************* RESOURCE STATISTICS SECTION **************/ 240 p rivatevoid gatherResourceStatistics() {277 public void gatherResourceStatistics() { 241 278 242 279 HashMap<String, List<Stats>> type_stats = new HashMap<String, List<Stats>>(); 243 280 244 for(String resource Name: resourceController.getComputingResourceLayers()){281 for(String resourceTypeName: resourceController.getComputingResourceLayers()){ 245 282 List<Stats> cStats = new ArrayList<Stats>(); 246 283 cStats.add(Stats.textLoad); 247 if(ArrayUtils.contains(configuration.resForUtilizationChart, resource Name))284 if(ArrayUtils.contains(configuration.resForUtilizationChart, resourceTypeName)) 248 285 cStats.add(Stats.chartLoad); 249 286 cStats.add(Stats.textEnergy); 250 if(ArrayUtils.contains(configuration.resForEnergyChart, resource Name))287 if(ArrayUtils.contains(configuration.resForEnergyChart, resourceTypeName)) 251 288 cStats.add(Stats.chartEnergy); 252 289 cStats.add(Stats.textAirFlow); 253 if(ArrayUtils.contains(configuration.resForAirFlowChart, resource Name))290 if(ArrayUtils.contains(configuration.resForAirFlowChart, resourceTypeName)) 254 291 cStats.add(Stats.chartAirFlow); 255 292 cStats.add(Stats.textTemperature); 256 if(ArrayUtils.contains(configuration.resForTemperatureChart, resource Name))293 if(ArrayUtils.contains(configuration.resForTemperatureChart, resourceTypeName)) 257 294 cStats.add(Stats.chartTemperature); 258 type_stats.put(resourceName, cStats); 295 type_stats.put(resourceTypeName, cStats); 296 259 297 } 260 298 … … 269 307 ganttDiagramTimetable = new Timetable(new FixedMillisecond( 270 308 startSimulationTime), new FixedMillisecond(endSimulationTime)); 309 271 310 272 311 PrintStream resourceLoadStatsFile = null; … … 310 349 } 311 350 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 312 391 basicResStats = gatherPEStats(jr.getTasks()); 313 392 peStatsPostProcessing(basicResStats); … … 318 397 } 319 398 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>(); 324 405 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){ 332 414 ResourceUsageStats resourceUsage = null; 333 415 ResourcePowerStats energyUsage = null; 334 416 ResourceAirFlowStats airFlow = null; 335 417 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); 338 421 resourceUsage.setMeanValue(calculateMeanValue(resourceUsage)); 339 422 if (resourceLoadStatsFile != null) { … … 341 424 resourceLoadStatsFile.print(txt); 342 425 } 343 } 344 if(type_stats.get(resourceName).contains(Stats.chartLoad)){ 426 427 } 428 if(type_stats.get(resourceTypeName).contains(Stats.chartLoad)){ 345 429 if (configuration.creatediagrams_resutilization) { 346 430 createResourceLoadDiagram(resourceUsage); 347 431 } 348 432 } 349 if(type_stats.get(resource Name).contains(Stats.textEnergy)){350 energyUsage = gatherResourcePowerConsumptionStats( resource);433 if(type_stats.get(resourceTypeName).contains(Stats.textEnergy)){ 434 energyUsage = gatherResourcePowerConsumptionStats(compResource); 351 435 energyUsage.setMeanValue(calculateMeanValue(energyUsage)); 352 436 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)) { 356 481 if( een != null && een.getPowerProfile() != null && een.getPowerProfile().getEnergyEstimationPlugin() != null){ 357 482 accStats.meanEnergyUsage.add(energyUsage.getSumValue()); … … 359 484 360 485 } else if( een != null && een.getPowerProfile() != null && een.getPowerProfile().getEnergyEstimationPlugin() != null){ 361 ComputingResource parent = resource.getParent();486 ComputingResource parent = compResource.getParent(); 362 487 boolean top = true; 363 488 while(parent != null){ … … 377 502 energyStatsFile.print(txt); 378 503 } 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)){ 382 525 if (configuration.creatediagrams_respowerusage) { 383 526 createResourceEnergyDiagramData(energyUsage); … … 385 528 } 386 529 387 if(type_stats.get(resource Name).contains(Stats.textAirFlow)){388 airFlow = gatherResourceAirFlowStats( resource);530 if(type_stats.get(resourceTypeName).contains(Stats.textAirFlow)){ 531 airFlow = gatherResourceAirFlowStats(compResource); 389 532 airFlow.setMeanValue(calculateMeanValue(airFlow)); 390 533 airFlow.setSumValue(airFlow.getMeanValue() * (endSimulationTime - startSimulationTime) / (60 * MILLI_SEC)); 391 534 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)) { 394 537 if( een != null && een.getAirFlowProfile() != null && een.getPowerProfile().getEnergyEstimationPlugin() != null){ 395 538 accStats.meanAirFlow.add(airFlow.getMeanValue()); … … 397 540 398 541 } else if( een != null && een.getAirFlowProfile() != null ){ 399 ComputingResource parent = resource.getParent();542 ComputingResource parent = compResource.getParent(); 400 543 een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 401 544 boolean top = true; … … 415 558 airFlowStatsFile.print(txt); 416 559 } 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)){ 419 579 420 580 if (configuration.creatediagrams_resairflow) { … … 423 583 } 424 584 425 if(type_stats.get(resource Name).contains(Stats.textTemperature)){426 temperature = gatherResourceTemperatureStats( resource);585 if(type_stats.get(resourceTypeName).contains(Stats.textTemperature)){ 586 temperature = gatherResourceTemperatureStats(compResource); 427 587 temperature.setMeanValue(calculateMeanValue(temperature)); 428 588 temperature.setSumValue(temperature.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 429 589 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)) { 432 592 if( een != null && een.getThermalProfile() != null && een.getPowerProfile().getEnergyEstimationPlugin() != null){ 433 593 accStats.meanTemperature.add(temperature.getMeanValue()); … … 435 595 436 596 } else if( een != null && een.getThermalProfile() != null ){ 437 ComputingResource parent = resource.getParent();597 ComputingResource parent = compResource.getParent(); 438 598 een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 439 599 boolean top = true; … … 453 613 temperatureStatsFile.print(txt); 454 614 } 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)){ 458 634 if (configuration.creatediagrams_restemperature) { 459 635 createResourceTemperatureDiagramData(temperature); 460 636 } 461 637 } 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 462 657 } 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 } 466 678 saveResourceUsageDiagrams(); 467 679 createAccumulatedResourceSimulationStatistic(); … … 479 691 resourceLoadStatsFile.close(); 480 692 } 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 481 709 } 482 710 … … 500 728 } 501 729 for(ComputingResource resource: resources){ 502 if(!basicResStats.containsKey(resource.get Name())){503 basicResStats.put(resource.get Name(), new ArrayList<ResStat>());730 if(!basicResStats.containsKey(resource.getFullName())){ 731 basicResStats.put(resource.getFullName(), new ArrayList<ResStat>()); 504 732 } 505 733 } … … 509 737 510 738 Map<String, List<ResStat>> basicResStats = new TreeMap<String, List<ResStat>>(new MapPEIdComparator()); 511 512 739 for (ExecTask execTask:executables) { 513 740 Executable exec = (Executable) execTask; … … 522 749 ProcessingElements pes = (ProcessingElements) resUnit; 523 750 for(ComputingResource pe: pes){ 524 String peName = pe.get Name();751 String peName = pe.getFullName(); 525 752 long startDate = Double.valueOf(exec.getExecStartTime()).longValue() * MILLI_SEC; 526 753 long endDate = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC; … … 541 768 String uniqueTaskID = getUniqueTaskId(execTask); 542 769 543 List<String> peNames = task_processorsMap.get(uniqueTaskID);770 Set<ComputingResource> peNames = task_processorsMap.get(uniqueTaskID); 544 771 if (peNames == null) { 545 peNames = new ArrayList<String>();546 peNames.add(pe Name);772 peNames = new HashSet<ComputingResource>(); 773 peNames.add(pe); 547 774 task_processorsMap.put(uniqueTaskID, peNames); 548 775 } 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 551 795 } 552 } else if (resUnit instanceof PEUnit){ 553 PEUnit peUnit = (PEUnit) resUnit; 554 } 555 796 } 556 797 } 557 798 return basicResStats; … … 571 812 } 572 813 814 573 815 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); 575 821 int cnt = 0; 576 822 for(String resName: basicStats.keySet()){ 577 823 try { 578 if(resource.getDescendantByName(resName) != null || resource.get Name().compareTo(resName) == 0){824 if(resource.getDescendantByName(resName) != null || resource.getFullName().compareTo(resName) == 0){ 579 825 createResourceLoadData(usageStats, basicStats.get(resName)); 580 826 cnt++; … … 591 837 592 838 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; 593 864 } 594 865 … … 629 900 } 630 901 } 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); 632 906 return ganttData; 633 907 } … … 643 917 644 918 645 private ResourcePowerStats gatherResourcePowerConsumptionStats( ComputingResource resource) {919 private ResourcePowerStats gatherResourcePowerConsumptionStats(PhysicalResource resource) { 646 920 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); 648 927 Map<Long, Double> usage = resEnergyUsage.getHistory(); 649 928 … … 665 944 usage.put(pu.getTimestamp(), pu.getValue()); 666 945 667 /// System.out.println(resource.getName() + ":"+new DateTime(pu.getTimestamp())+";"+pu.getValue());668 946 power = power + (pu.getTimestamp() - lastTime) * lastPower/ (3600 * MILLI_SEC); 669 947 lastPower = pu.getValue(); … … 673 951 } 674 952 } 675 //System.out.println(power);676 953 return resEnergyUsage; 677 954 } 678 955 679 956 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); 683 964 Map<Long, Double> airFlow = resAirFlow.getHistory(); 684 965 … … 704 985 } 705 986 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); 709 994 Map<Long, Double> temperature = resTemperature.getHistory(); 710 995 … … 1065 1350 1066 1351 try { 1067 if(resource.getDescendantByName(resName) != null || resource.get Name().compareTo(resName) == 0){1352 if(resource.getDescendantByName(resName) != null || resource.getFullName().compareTo(resName) == 0){ 1068 1353 Double load = peLoad.get(resName); 1069 1354 sum += load; … … 1102 1387 1103 1388 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 } 1107 1400 1108 1401 … … 1221 1514 TaskStats taskStats = new TaskStats(task, startSimulationTime); 1222 1515 String uniqueTaskID = getUniqueTaskId(task); 1223 taskStats.setProcessors Name(task_processorsMap.get(uniqueTaskID));1516 taskStats.setProcessors(task_processorsMap.get(uniqueTaskID)); 1224 1517 return taskStats; 1225 1518 } … … 1484 1777 1485 1778 public int compare(String o1, String o2) { 1486 Integer o1int ;1487 Integer o2int ;1779 Integer o1int = 0; 1780 Integer o2int = 0; 1488 1781 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) 1497 1799 return o1int.compareTo(o2int); 1800 else 1801 return o1string.compareTo(o2string); 1498 1802 } 1499 1803 } … … 1573 1877 chartAirFlow, 1574 1878 textTemperature, 1575 chartTemperature; 1879 chartTemperature, 1880 textUsefulWorl; 1576 1881 } -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceAirFlowStats.java
r496 r1207 12 12 public ResourceAirFlowStats (String resourceName, ResourceType resourceType, String usageType) { 13 13 super(resourceName, resourceType, usageType); 14 if(usageType == null){ 15 this.usageType = "airflow_volume"; 16 } 14 17 } 15 18 -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourcePowerStats.java
r496 r1207 12 12 public ResourcePowerStats (String resourceName, ResourceType resourceType, String usageType) { 13 13 super(resourceName, resourceType, usageType); 14 if(usageType == null){ 15 this.usageType = "power"; 16 } 14 17 } 15 18 -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceStats.java
r477 r1207 22 22 23 23 public ResourceStats(ComputingResource compResource) { 24 this.resourceName = compResource.get Name();24 this.resourceName = compResource.getFullName(); 25 25 init(); 26 26 -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceTemperatureStats.java
r806 r1207 12 12 public ResourceTemperatureStats (String resourceName, ResourceType resourceType, String usageType) { 13 13 super(resourceName, resourceType, usageType); 14 if(usageType == null){ 15 this.usageType = "temperature"; 16 } 14 17 } 15 18 -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceUsageStats.java
r496 r1207 10 10 public ResourceUsageStats(String resourceName, ResourceType resourceType, String usageType) { 11 11 super(resourceName, resourceType, usageType); 12 if(usageType == null){ 13 this.usageType = "cpu_load"; 14 } 12 15 } 13 16 -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/TaskStats.java
r1199 r1207 2 2 3 3 4 import java.util.List; 5 4 import java.util.HashSet; 5 import java.util.Iterator; 6 import java.util.Set; 7 8 9 import schedframe.resources.computing.ComputingNode; 10 import schedframe.resources.computing.ComputingResource; 11 import schedframe.resources.computing.Core; 12 import schedframe.resources.computing.Processor; 13 import simulator.stats.implementation.out.StatsSerializer; 6 14 import dcworms.schedframe.scheduling.Executable; 7 8 import simulator.stats.implementation.out.StatsSerializer;9 15 10 16 /** … … 14 20 */ 15 21 public class TaskStats implements StatsInterface { 16 protected List<String> processorsName;22 protected Set<ComputingResource> processingElements; 17 23 protected double reservationStartDate; 18 24 protected double reservationFinishDate; … … 26 32 "ExecutionTime", "ReadyTime", "StartTime", "FlowTime", 27 33 "WaitingTime", "GQ_WaitingTime", "Lateness", "Tardiness", 28 "ReservStartDate", "ReservFinishDate", " ProcessorName", "Energy"};34 "ReservStartDate", "ReservFinishDate", "HostNames", "ProcessorName", "Energy", "AppName",}; 29 35 30 36 public TaskStats(Executable task, long startSimulationTime) { … … 147 153 } 148 154 149 public void setProcessors Name(List<String> value) {150 this.process orsName= value;155 public void setProcessors(Set<ComputingResource> value) { 156 this.processingElements = value; 151 157 } 152 158 … … 159 165 } 160 166 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 165 198 public double getReservationStartDate() { 166 199 return reservationStartDate; … … 170 203 return reservationFinishDate; 171 204 } 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 } 172 216 173 217 public String[] getHeaders() { -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/CoolEmAllStringSerializer.java
r1140 r1207 1 1 package simulator.stats.implementation.out; 2 2 3 import java.text.DecimalFormat; 3 4 import java.util.Map; 4 5 … … 7 8 8 9 import schedframe.resources.CoolEmAllResourceType; 10 import schedframe.resources.ResourceHistoryChanges; 9 11 import schedframe.resources.StandardResourceType; 12 import simulator.stats.implementation.MetricsStats; 10 13 import simulator.stats.implementation.ResourceAirFlowStats; 14 import simulator.stats.implementation.ResourceAvailabilityStats; 15 import simulator.stats.implementation.ResourceHistoryStats; 11 16 import simulator.stats.implementation.ResourcePowerStats; 12 17 import simulator.stats.implementation.ResourceTemperatureStats; 13 18 import simulator.stats.implementation.ResourceUsageStats; 19 import simulator.stats.implementation.ResourceUsefulWorkStats; 14 20 15 21 public class CoolEmAllStringSerializer extends StringSerializer { … … 19 25 public Object visit(ResourceUsageStats resourceUsageStats) { 20 26 Map<Long, Double> resourceUsage = resourceUsageStats.getHistory(); 21 String cpuMetricName = "CPU_Load"; 27 //String metricName = "cpu_load"; 28 String metricName = resourceUsageStats.getUsageType(); 22 29 int mapSize = resourceUsage.size(); 23 30 /* … … 45 52 } 46 53 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())){ 48 55 for (Long timestamp : resourceUsage.keySet()) { 49 56 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()); 53 62 buffer.append(fieldSeparator); 54 63 Double value = resourceUsage.get(timestamp); … … 73 82 public Object visit(ResourcePowerStats resourceEnergyStats) { 74 83 Map<Long, Double> resourceEnergy = resourceEnergyStats.getHistory(); 75 String nodeMetricName = "RECS_Power"; 84 //String nodeMetricName = "power"; 85 String metricName = resourceEnergyStats.getUsageType(); 76 86 int mapSize = resourceEnergy.size(); 77 87 /* … … 98 108 buffer = new StringBuffer(size); 99 109 } 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 102 114 for (Long timestamp : resourceEnergy.keySet()) { 103 115 104 buffer.append( nodeMetricName);116 buffer.append(metricName); 105 117 buffer.append(fieldSeparator); 106 118 if(resourceEnergyStats.getResourceName().startsWith("/")) … … 117 129 buffer.append(System.getProperty("line.separator")); 118 130 } 119 }131 // } 120 132 121 133 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); … … 129 141 public Object visit(ResourceAirFlowStats resourceAirFlowStats) { 130 142 Map<Long, Double> resourceAirFlow = resourceAirFlowStats.getHistory(); 131 String nodeMetricName = "RECS_Airflow"; 143 //String nodeMetricName = "airflow_volume"; 144 String metricName = resourceAirFlowStats.getUsageType(); 132 145 int mapSize = resourceAirFlow.size(); 133 146 /* … … 154 167 buffer = new StringBuffer(size); 155 168 } 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())){ 158 171 for (Long timestamp : resourceAirFlow.keySet()) { 159 160 buffer.append(nodeMetricName); 172 buffer.append(metricName); 161 173 buffer.append(fieldSeparator); 162 174 if(resourceAirFlowStats.getResourceName().startsWith("/")) … … 185 197 public Object visit(ResourceTemperatureStats resourceTemperatureStats) { 186 198 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 189 204 int mapSize = resourceTemperature.size(); 190 205 /* … … 212 227 } 213 228 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; 217 231 if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Node)){ 218 232 metricName = nodeMetricName; 219 233 } else if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.Processor) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Processor)){ 220 234 metricName = cpuMetricName; 221 } 235 }*/ 222 236 for (Long timestamp : resourceTemperature.keySet()) { 223 237 224 238 buffer.append(metricName); 225 239 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()); 227 243 buffer.append(fieldSeparator); 228 244 Double value = resourceTemperature.get(timestamp); … … 245 261 } 246 262 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 } 248 400 } -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/StatsSerializer.java
r805 r1207 4 4 import simulator.stats.implementation.GSSAccumulatorsStats; 5 5 import simulator.stats.implementation.JobStats; 6 import simulator.stats.implementation.MetricsStats; 6 7 import simulator.stats.implementation.ResourceAirFlowStats; 8 import simulator.stats.implementation.ResourceAvailabilityStats; 9 import simulator.stats.implementation.ResourceHistoryStats; 7 10 import simulator.stats.implementation.ResourcePowerStats; 8 11 import simulator.stats.implementation.ResourceStats; 9 12 import simulator.stats.implementation.ResourceTemperatureStats; 10 13 import simulator.stats.implementation.ResourceUsageStats; 14 import simulator.stats.implementation.ResourceUsefulWorkStats; 11 15 import simulator.stats.implementation.TaskStats; 12 16 … … 34 38 public Object visit(ResourceTemperatureStats arg); 35 39 40 public Object visit(ResourceUsefulWorkStats arg); 41 36 42 public Object visit(GSSAccumulatorsStats arg); 37 43 44 public Object visit(MetricsStats arg); 45 46 public Object visit(ResourceHistoryStats arg); 47 48 public Object visit(ResourceAvailabilityStats resourceAvailabilityStats); 49 38 50 } -
DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/StringSerializer.java
r1192 r1207 11 11 import simulator.stats.implementation.GSSAccumulatorsStats; 12 12 import simulator.stats.implementation.JobStats; 13 import simulator.stats.implementation.MetricsStats; 13 14 import simulator.stats.implementation.ResourceAirFlowStats; 15 import simulator.stats.implementation.ResourceAvailabilityStats; 16 import simulator.stats.implementation.ResourceHistoryStats; 14 17 import simulator.stats.implementation.ResourcePowerStats; 15 18 import simulator.stats.implementation.ResourceStats; 16 19 import simulator.stats.implementation.ResourceTemperatureStats; 17 20 import simulator.stats.implementation.ResourceUsageStats; 21 import simulator.stats.implementation.ResourceUsefulWorkStats; 18 22 import simulator.stats.implementation.TaskStats; 19 23 … … 48 52 buffer.append(fieldSeparator); 49 53 } 50 51 54 } 52 55 … … 108 111 .longValue()); 109 112 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()); 111 120 buffer.append(fieldSeparator); 112 121 } … … 311 320 } 312 321 313 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator"));314 if(lastIdx != -1)315 buffer.deleteCharAt(lastIdx);316 317 322 if(resourceUsage.size() > 0){ 318 323 buffer.append("mean: " + resourceUsageStats.getMeanValue()); … … 373 378 374 379 } 375 376 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 377 if(lastIdx != -1) 378 buffer.deleteCharAt(lastIdx); 379 380 380 381 if(resourceEnergy.size() > 0) { 381 382 buffer.append("mean: "+resourceEnergyStats.getMeanValue() + " sum: " +resourceEnergyStats.getSumValue()); … … 437 438 438 439 } 439 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 440 if(lastIdx != -1) 441 buffer.deleteCharAt(lastIdx); 442 440 443 441 if(resourceAirFlow.size() > 0) { 444 442 buffer.append("mean: "+resourceAirFlowStats.getMeanValue()); … … 500 498 501 499 } 502 503 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 504 if(lastIdx != -1) 505 buffer.deleteCharAt(lastIdx); 506 500 507 501 if(resourceTemperature.size() > 0) { 508 502 buffer.append("mean: "+resourceTemperatureStats.getMeanValue()); … … 573 567 } 574 568 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 575 590 } -
DCWoRMS/branches/coolemall/src/simulator/utils/XsltTransformations.java
r1131 r1207 19 19 import javax.xml.xpath.XPathExpressionException; 20 20 21 import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription; 21 22 import dcworms.schedframe.scheduling.utils.JobDescription; 22 23 import dcworms.schedframe.scheduling.utils.TaskDescription; … … 35 36 String value = 36 37 //"org.apache.xalan.xsltc.trax.TransformerFactoryImpl"; 37 "org.apache.xalan.processor.TransformerFactoryImpl"; 38 //"org.apache.xalan.processor.TransformerFactoryImpl"; 39 "net.sf.saxon.TransformerFactoryImpl"; 38 40 Properties props = System.getProperties(); 39 41 props.put(key, value); … … 191 193 } 192 194 195 public ApplicationProfileDescription getApplicationProfileDescription(String xmlJob){ 196 ApplicationProfileDescription appProfDesc = new ApplicationProfileDescription(xmlJob); 197 return appProfDesc; 198 } 199 193 200 public String extractJobId(String job){ 194 201 Transformer t = null; -
DCWoRMS/branches/coolemall/src/simulator/workload/WorkloadLoader.java
r1170 r1207 17 17 import javax.xml.xpath.XPathExpressionException; 18 18 19 import org.apache.commons.io.FilenameUtils; 19 20 import org.apache.commons.logging.Log; 20 21 import org.apache.commons.logging.LogFactory; … … 32 33 import simulator.workload.reader.archive.swf.SWFFields; 33 34 import simulator.workload.reader.xmlJob.XMLJobReader; 35 import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription; 34 36 import dcworms.schedframe.scheduling.utils.JobDescription; 35 37 import dcworms.schedframe.scheduling.utils.TaskDescription; … … 56 58 57 59 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){ 61 65 if(swfReader == null){ 62 66 throw new RuntimeException("Swf reader is required to build proper tasks."); … … 67 71 this.generatedTasksCnt = 0; 68 72 this.jobsMap = new TreeMap<String, JobDescription>(); 69 this.applicationProfilesMap = new TreeMap<String, JobDescription>(); 73 this.appProfilesFolder = appProfilesFolder; 74 this.applicationProfiles = new TreeMap<String, ApplicationProfileDescription>(); 70 75 try { 71 76 this.xsltTransformation = new XsltTransformations(); … … 187 192 188 193 // 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 192 204 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); 198 210 } 199 211 } else { // use swf job reader. Job created by this reader does not require xslt transformation 200 212 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){ 215 214 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); 240 220 } 241 221 } … … 302 282 } 303 283 304 public String loadApplicationProfile(String fileName) throws IOException{284 public String loadApplicationProfile(String pathToAppProfile) throws IOException{ 305 285 306 286 BufferedReader reader = null; 307 287 StringBuffer buffer = new StringBuffer(); 308 288 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 )); 311 300 String line = null; 312 301 -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/AbstractWAParser.java
r1144 r1207 33 33 protected HashMap<String, String> reverseIdMapping; // key - xmlJobId_xmlTaskId, value - swf job id 34 34 protected HashMap<String, Long> jobIndex; 35 protected HashMap<String, String> app Mapping;35 protected HashMap<String, String> appProfilesLocation; 36 36 protected String fields[]; 37 37 protected int fieldsNo; … … 46 46 this.reverseIdMapping = new HashMap<String, String>(); 47 47 this.jobIndex = new HashMap<String, Long>(); 48 this.app Mapping= new HashMap<String, String>();48 this.appProfilesLocation = new HashMap<String, String>(); 49 49 this.headerLoaded = false; 50 50 this.buildIndex = true; 51 51 this.fieldsNo = 18; 52 52 53 } 53 54 … … 152 153 String appId = valueData[0]; 153 154 String pathToAppProfile = valueData[1]; 154 app Mapping.put(appId, pathToAppProfile);155 appProfilesLocation.put(appId, pathToAppProfile); 155 156 continue; 156 157 } … … 296 297 297 298 298 public Map<String, String> getApp Mapping() {299 return app Mapping;299 public Map<String, String> getAppProfilesLocation() { 300 return appProfilesLocation; 300 301 } 301 302 -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/QcgWAJobReader.java
r1163 r1207 15 15 16 16 import simulator.workload.reader.archive.swf.SWFFields; 17 18 import org.qcg.broker.schemas.jobdesc.FileType; 17 19 import org.qcg.broker.schemas.jobdesc.ResourceConsumptionProfileType; 18 20 import org.qcg.broker.schemas.jobdesc.Task; 19 21 import org.qcg.broker.schemas.jobdesc.Workflow; 20 22 21 import dcworms.schedframe.scheduling.utils. JobDescription;23 import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription; 22 24 23 25 /** … … 116 118 } 117 119 118 public String mergeSwfAnd XmlProfile(Map<String, JobDescription> applicationProfilesMap, String swfJobDesc) throws IOException{120 public String mergeSwfAndAppProfile(Map<String, ApplicationProfileDescription> applicationProfiles, String swfJobDesc) throws IOException{ 119 121 120 122 StringReader reader = new StringReader(swfJobDesc); … … 132 134 for(int i = 0; i < job.getTaskCount(); i++){ 133 135 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); 142 145 } 143 146 } -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/WAParser.java
r1144 r1207 45 45 public int getType(); 46 46 47 public Map<String, String> getApp Mapping();47 public Map<String, String> getAppProfilesLocation(); 48 48 } -
DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/swf/QcgSWFJobReader.java
r1202 r1207 221 221 222 222 case SWFFields.DATA_EXECUTABLE_NUMBER: 223 String pathToAppProfile = waParser.getApp Mapping().get(String.valueOf(value));223 String pathToAppProfile = waParser.getAppProfilesLocation().get(String.valueOf(value)); 224 224 String appName = null; 225 225 if(pathToAppProfile == null){
Note: See TracChangeset
for help on using the changeset viewer.