- Timestamp:
- 10/10/12 12:12:06 (13 years ago)
- Location:
- DCWoRMS/trunk/src
- Files:
-
- 4 added
- 1 deleted
- 22 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/trunk/src/schedframe/resources/computing/ComputingNode.java
r477 r495 10 10 import schedframe.resources.computing.extensions.ExtensionType; 11 11 import schedframe.resources.computing.profiles.energy.EnergyExtension; 12 import schedframe.resources.computing.profiles.energy.power.Power ProfileFactory;12 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 13 13 import schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface; 14 14 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; … … 26 26 27 27 //extensionList.add(new EnergyExtension(this, resDesc.getPowerInterface(), resDesc.getEnergyEstimationPlugin())); 28 PowerInterface pi = Power ProfileFactory.createPowerInterface(this, resDesc.getPowerProfile());28 PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 29 29 accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 30 30 } -
DCWoRMS/trunk/src/schedframe/resources/computing/ComputingResource.java
r494 r495 28 28 import schedframe.resources.computing.profiles.energy.EnergyEventType; 29 29 import schedframe.resources.computing.profiles.energy.EnergyExtension; 30 import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 30 31 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 31 32 import schedframe.resources.computing.properties.DefaultPropertiesBuilder; … … 68 69 } 69 70 70 //TODO remove if possible (check if all scenarios can be realized - statistics issue) , since it'stemporary method71 //TODO remove if possible (check if all scenarios can be realized - statistics issue), since it's a temporary method 71 72 private void addFakeProcessors() { 72 73 if(getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.PE) != null){ … … 145 146 sec.execute(event); 146 147 147 148 148 //old, correctly working method 149 149 /*if (extensionList != null) { … … 188 188 } 189 189 190 protected List<? extends ComputingResource> searchDescendants(List<ResourceValidator> validators, boolean cut off) {190 protected List<? extends ComputingResource> searchDescendants(List<ResourceValidator> validators, boolean cutOff) { 191 191 192 192 List<ComputingResource> descendants = new ArrayList<ComputingResource>(); … … 198 198 ComputingResource resource = toExamine.pop(); 199 199 List<ComputingResource> resources = resource.getChildren(); 200 /*if (resources == null)201 continue;*/202 200 int numberOfRes = resources.size(); 203 201 for (int i = 0; i < numberOfRes; i++) { … … 205 203 if (resourceChild.match(validators)) { 206 204 descendants.add(resourceChild); 207 if(cut off == false) {205 if(cutOff == false) { 208 206 toExamine.addLast(resourceChild); 209 207 } … … 243 241 return null; 244 242 } 243 244 public AirThroughputInterface getAirThroughputInterface(){ 245 if (extensionList != null) { 246 for (Extension extension : extensionList) { 247 if (extension.getType() == ExtensionType.ENERGY_EXTENSION) { 248 EnergyExtension ee = (EnergyExtension)extension; 249 return ee.getAirThroughputInterface(); 250 } 251 } 252 } 253 return null; 254 } 245 255 246 256 public Scheduler getScheduler() { … … 257 267 } 258 268 259 class SimpleEventHandler implements EventHandler{269 class ComputingResourceEventHandler implements EventHandler{ 260 270 261 271 public void handleResourceEvent(Event event){ … … 282 292 283 293 public EventHandler getEventHandler(){ 284 return new SimpleEventHandler();294 return new ComputingResourceEventHandler(); 285 295 } 286 296 287 297 public void initiate(){ 298 288 299 ResourceEventCommand rec = new ResourceEventCommand(this); 289 EnergyEvent event = new EnergyEvent(EnergyEventType. POWER_STATE_CHANGED, "Resource controller");300 EnergyEvent event = new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller"); 290 301 event.setReason(EventReason.SIM_INIT); 291 302 rec.execute(event); 303 304 rec = new ResourceEventCommand(this); 305 event = new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller"); 306 event.setReason(EventReason.SIM_INIT); 307 rec.execute(event); 308 292 309 //alternative way 310 //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller")); 293 311 //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller")); 294 312 } -
DCWoRMS/trunk/src/schedframe/resources/computing/Core.java
r477 r495 3 3 import schedframe.resources.computing.description.ComputingResourceDescription; 4 4 import schedframe.resources.computing.profiles.energy.EnergyExtension; 5 import schedframe.resources.computing.profiles.energy.power.Power ProfileFactory;5 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 6 6 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 7 7 import schedframe.resources.units.CpuSpeed; … … 13 13 public Core (ComputingResourceDescription resDesc) { 14 14 super(resDesc); 15 PowerInterface pi = Power ProfileFactory.createPowerInterface(this, resDesc.getPowerProfile());15 PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 16 16 accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 17 17 } -
DCWoRMS/trunk/src/schedframe/resources/computing/DataCenter.java
r477 r495 3 3 import schedframe.resources.computing.description.ComputingResourceDescription; 4 4 import schedframe.resources.computing.profiles.energy.EnergyExtension; 5 import schedframe.resources.computing.profiles.energy.power.Power ProfileFactory;5 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 6 6 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 7 7 … … 11 11 super(resDesc); 12 12 //extensionList.add(new EnergyExtension(this, resDesc.getPowerInterface(), resDesc.getEnergyEstimationPlugin())); 13 PowerInterface pi = Power ProfileFactory.createPowerInterface(this, resDesc.getPowerProfile());13 PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 14 14 accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 15 15 } -
DCWoRMS/trunk/src/schedframe/resources/computing/Processor.java
r477 r495 8 8 import schedframe.resources.computing.extensions.ExtensionType; 9 9 import schedframe.resources.computing.profiles.energy.EnergyExtension; 10 import schedframe.resources.computing.profiles.energy.power.Power ProfileFactory;10 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 11 11 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 12 12 import schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface; … … 22 22 super(resDesc); 23 23 //extensionList.add(new EnergyExtension(this, resDesc.getPowerInterface(), resDesc.getEnergyEstimationPlugin())); 24 PowerInterface pi = Power ProfileFactory.createPowerInterface(this, resDesc.getPowerProfile());24 PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 25 25 accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 26 26 } -
DCWoRMS/trunk/src/schedframe/resources/computing/Rack.java
r477 r495 6 6 import schedframe.resources.computing.description.ComputingResourceDescription; 7 7 import schedframe.resources.computing.profiles.energy.EnergyExtension; 8 import schedframe.resources.computing.profiles.energy.power.Power ProfileFactory;8 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 9 9 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 10 10 … … 14 14 public Rack (ComputingResourceDescription resDesc) { 15 15 super(resDesc); 16 PowerInterface pi = Power ProfileFactory.createPowerInterface(this, resDesc.getPowerProfile());16 PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 17 17 accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 18 18 } -
DCWoRMS/trunk/src/schedframe/resources/computing/ResourceFactory.java
r481 r495 20 20 if (resDesc.getType().equals(StandardResourceType.DataCenter)) 21 21 return new DataCenter(resDesc); 22 else if (resDesc.getType().equals(StandardResourceType.Rack)) 23 return new Rack(resDesc); 22 24 else if (resDesc.getType().equals(StandardResourceType.ComputingNode)) 23 25 return new ComputingNode(resDesc); -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/EnergyEventType.java
r477 r495 15 15 FREQUENCY_CHANGED(64), 16 16 VOLTAGE_CHANGED(128), 17 RESOURCE_FAILED(256) 17 18 AIRFLOW_STATE_CHANGED(256), 19 20 RESOURCE_FAILED(512) 18 21 ; 19 22 -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java
r477 r495 11 11 import schedframe.resources.computing.extensions.ExtensionException; 12 12 import schedframe.resources.computing.extensions.ExtensionType; 13 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 14 import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 13 15 import schedframe.resources.computing.profiles.energy.power.PowerProfile; 14 16 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 15 17 import schedframe.scheduling.manager.tasks.JobRegistryImpl; 16 18 17 public class EnergyExtension implements Extension /*, ResourceVisitor */{19 public class EnergyExtension implements Extension{ 18 20 19 21 private Log log = LogFactory.getLog(EnergyExtension.class); … … 21 23 protected PowerInterface powerInterface; 22 24 protected PowerProfile powerProfile; 23 25 26 protected AirThroughputInterface airFlowInterface; 27 protected AirThroughputProfile airFlowProfile; 28 24 29 protected ComputingResource computingResource; 25 30 … … 29 34 } 30 35 31 @Override 36 public EnergyExtension(PowerInterface powerInterface, PowerProfile powerProfile, 37 AirThroughputInterface airFlowInterface, AirThroughputProfile airFlowProfile) { 38 super(); 39 this.powerInterface = powerInterface; 40 this.powerProfile = powerProfile; 41 this.airFlowInterface = airFlowInterface; 42 this.airFlowProfile = airFlowProfile; 43 } 44 32 45 public boolean supportsEvent(Event event) { 33 46 34 47 if(powerProfile == null || powerProfile.getEnergyEstimationPlugin() == null) 35 48 return false; 36 37 49 if(event.getType().getName().equals(EnergyEventType.POWER_STATE_CHANGED.getName())) 38 50 return true; … … 43 55 else if(event.getType().getName().equals(EnergyEventType.TASK_FINISHED.getName())) 44 56 return true; 57 58 if(airFlowProfile == null) 59 return false; 60 if(event.getType().getName().equals(EnergyEventType.AIRFLOW_STATE_CHANGED.getName())) 61 return true; 62 45 63 else return false; 46 64 47 65 } 48 49 66 50 @Override51 67 public void handleEvent(Event event) { 52 68 EnergyEvent enEvent = (EnergyEvent)event; … … 87 103 //System.out.println(this.resource.getName() + " - ESTIMATED ENERGY:" + power); 88 104 powerProfile.addToPowerUsageHistory(power); 89 105 break; 106 case AIRFLOW_STATE_CHANGED: 107 System.out.println("====="); 108 double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 109 airFlowProfile.addToPowerUsageHistory(airFlow); 110 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 111 powerProfile.addToPowerUsageHistory(power); 90 112 break; 91 113 } 92 114 } 93 94 @Override 115 95 116 public void init(Properties properties) throws ExtensionException { 96 117 // TODO Auto-generated method stub 97 118 } 98 119 99 @Override100 120 public ExtensionType getType() { 101 121 return ExtensionType.ENERGY_EXTENSION; … … 118 138 } 119 139 140 public AirThroughputInterface getAirThroughputInterface() { 141 return airFlowInterface; 142 } 143 144 public AirThroughputProfile getAirFlowProfile() { 145 return airFlowProfile; 146 } 120 147 121 148 } -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java
r477 r495 1 1 package schedframe.resources.computing.profiles.energy.airthroughput; 2 2 3 import java.util.ArrayList; 3 4 import java.util.List; 5 6 import org.joda.time.DateTimeUtils; 4 7 5 8 import schedframe.Parameters; … … 7 10 8 11 public class AirThroughputProfile { 12 13 protected List<AirFlowValue> airFlowHistory; 9 14 10 15 protected AirThroughputEstimationPlugin airThroughputEstimationPlugin; … … 16 21 this.airThroughputEstimationPlugin = airThroughputEstimationPlugin; 17 22 this.airThroughputStates = airThroughputStates; 23 this.airFlowHistory = new ArrayList<AirFlowValue>(); 18 24 } 19 25 20 26 public List<AirThroughputState> getAirThroughputStates() { 21 27 return airThroughputStates; 28 } 29 30 public void addToPowerUsageHistory(double airFlow) { 31 32 if (airFlowHistory.size() == 0) { 33 AirFlowValue usage = new AirFlowValue(DateTimeUtils.currentTimeMillis(), airFlow); 34 airFlowHistory.add(usage); 35 return; 36 } 37 38 int lastIdx = airFlowHistory.size() - 1; 39 double lastAirFlow = airFlowHistory.get(lastIdx).getValue(); 40 if (lastAirFlow != airFlow) { 41 AirFlowValue usage = airFlowHistory.get(lastIdx); 42 long currentTime = DateTimeUtils.currentTimeMillis(); 43 if (usage.getTimestamp() == currentTime) { 44 usage.setValue(airFlow); 45 if(lastIdx > 0 && airFlowHistory.get(lastIdx - 1).getValue() == airFlow) 46 airFlowHistory.remove(usage); 47 } else { 48 usage = new AirFlowValue(DateTimeUtils.currentTimeMillis(), airFlow); 49 airFlowHistory.add(usage); 50 } 51 } 52 } 53 54 public List<AirFlowValue> getAirThroughputHistory() { 55 return airFlowHistory; 22 56 } 23 57 -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/AirThroughputInterface.java
r477 r495 10 10 public String getAirThroughputState(); 11 11 12 public boolean setAirThroughputState(String airThroug putState);12 public boolean setAirThroughputState(String airThroughputState); 13 13 14 14 public boolean supportAirThroughputState(String powerState); -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/DefaultAirThroughputInterface.java
r477 r495 6 6 import schedframe.Parameters; 7 7 import schedframe.resources.computing.ComputingResource; 8 import schedframe.resources.computing.profiles.energy.EnergyEvent; 9 import schedframe.resources.computing.profiles.energy.EnergyEventType; 8 10 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 9 11 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 10 12 11 public class DefaultAirThroug putInterface implements AirThroughputInterface{13 public class DefaultAirThroughputInterface implements AirThroughputInterface{ 12 14 13 15 protected String currentAirThroughputState; 14 16 protected AirThroughputProfile airThroughputProfile; 15 17 protected ComputingResource resource; 18 19 public DefaultAirThroughputInterface(ComputingResource resource, AirThroughputProfile airThroughputProfile){ 20 this.resource = resource; 21 this.airThroughputProfile = airThroughputProfile; 22 } 16 23 17 24 public String getAirThroughputState() { … … 22 29 if(supportAirThroughputState(state)){ 23 30 currentAirThroughputState = state; 31 32 //TO DO - notifications should be called for all resources starting form the lowest layer 33 resource.handleEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, resource.getName())); 34 24 35 return true; 25 36 } … … 28 39 29 40 public boolean supportAirThroughputState(String state) { 30 31 41 for(AirThroughputState airFlowState: airThroughputProfile.getAirThroughputStates()){ 32 42 if(airFlowState.getName().equals(state)){ -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerInterfaceFactory.java
r477 r495 5 5 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 6 6 7 public class Power ProfileFactory {7 public class PowerInterfaceFactory { 8 8 9 9 … … 36 36 else if (resource.getType().getName().equals(StandardResourceType.Processor.getName())) 37 37 powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface(resource, pp); 38 else throw new IllegalArgumentException("ResourceType " + resource.getType() + " is not supported."); 38 else 39 powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingResourcePowerInterface(resource, pp); 39 40 40 41 /*switch(resource.getType()){ -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java
r477 r495 22 22 23 23 24 public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> supportedPowerStates) {24 public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates) { 25 25 this.energyEstimationPlugin = energyEstimationPlugin; 26 26 this.powerUsage = new ArrayList<PowerUsage>(); 27 this.supportedPowerStates = supportedPowerStates;27 this.supportedPowerStates = powerStates; 28 28 } 29 29 30 public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> supportedPowerStates, List<PState> pStates) {30 public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates, List<PState> pStates) { 31 31 this.energyEstimationPlugin = energyEstimationPlugin; 32 this.supportedPowerStates = supportedPowerStates;32 this.supportedPowerStates = powerStates; 33 33 this.powerUsage = new ArrayList<PowerUsage>(); 34 34 if(pStates.size() > 0) -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerUsage.java
r477 r495 1 1 package schedframe.resources.computing.profiles.energy.power; 2 2 3 public class PowerUsage { 3 import schedframe.resources.computing.profiles.energy.MeasurementHistory; 4 4 5 protected long timestamp; 6 protected double value; 5 public class PowerUsage extends MeasurementHistory{ 7 6 8 7 public PowerUsage(long timestamp, double value){ 9 this.timestamp = timestamp; 10 this.value = value; 11 } 12 13 public long getTimestamp() { 14 return timestamp; 15 } 16 17 public double getValue() { 18 return value; 19 } 20 21 public void setValue(double value) { 22 this.value = value; 8 super(timestamp, value); 23 9 } 24 10 -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingNodePowerInterface.java
r477 r495 10 10 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 11 11 12 public class ComputingNodePowerInterface extends AbstractPowerInterface{12 public class ComputingNodePowerInterface extends ComputingResourcePowerInterface{ 13 13 14 14 public static long START_TIME = 600000; -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingResourcePowerInterface.java
r477 r495 17 17 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 18 18 19 public abstract class AbstractPowerInterface implements PowerInterface{19 public class ComputingResourcePowerInterface implements PowerInterface{ 20 20 21 21 protected PowerStateName currentPowerState; … … 23 23 protected ComputingResource resource; 24 24 25 public AbstractPowerInterface(ComputingResource resource, PowerProfile powerProfile){25 public ComputingResourcePowerInterface(ComputingResource resource, PowerProfile powerProfile){ 26 26 this.resource = resource; 27 27 this.powerProfile = powerProfile; -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/DataCenterPowerInterface.java
r477 r495 7 7 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 8 8 9 public class DataCenterPowerInterface extends AbstractPowerInterface{9 public class DataCenterPowerInterface extends ComputingResourcePowerInterface{ 10 10 11 12 13 14 11 public DataCenterPowerInterface(ComputingResource resource, PowerProfile pp){ 15 12 super(resource, pp); -
DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java
r494 r495 1 1 package schedframe.resources.computing.profiles.energy.power.ui; 2 2 3 import gridsim.dcworms.DCWormsTags;4 3 5 4 import java.util.Map; … … 16 15 import schedframe.resources.units.StandardResourceUnitName; 17 16 18 public class ProcessorPowerInterface extends AbstractPowerInterface {17 public class ProcessorPowerInterface extends ComputingResourcePowerInterface { 19 18 20 19 protected PState currentPState; -
DCWoRMS/trunk/src/simulator/ConfigurationOptions.java
r493 r495 67 67 public static final String CREATEDIAGRAMS_UTILIZATION = CREATEDIAGRAMS + ".utilization"; 68 68 public static final String CREATEDIAGRAMS_ENERGYUSAGE = CREATEDIAGRAMS + ".energyusage"; 69 public static final String CREATEDIAGRAMS_AIRFLOW = CREATEDIAGRAMS + ".airflow"; 69 70 public static final String CREATEDIAGRAMS_RESOURCES_SCALE = CREATEDIAGRAMS_UTILIZATION + ".scale"; 70 71 public static final String CREATEDIAGRAMS_TASKS = CREATEDIAGRAMS + ".tasks"; … … 163 164 public boolean creatediagrams_resources = true; 164 165 public boolean creatediagrams_energyusage = true; 166 public boolean creatediagrams_airflow = true; 165 167 public boolean creatediagrams_tasks = true; 166 168 public boolean creatediagrams_taskswaitingtime = true; … … 173 175 174 176 public String[] resForEnergyChart; 177 public String[] resForAirFlowChart; 175 178 public String[] resForUtilizationChart; 176 179 … … 302 305 co.creatediagrams_energyusage = createDiagrams; 303 306 } 307 308 try { 309 co.resForAirFlowChart = bundle.getString(CREATEDIAGRAMS_AIRFLOW).split(";"); 310 if(co.resForAirFlowChart.length > 0){ 311 co.creatediagrams_airflow = true && createDiagrams; 312 } 313 } catch(MissingResourceException e){ 314 co.creatediagrams_airflow = createDiagrams; 315 } 316 304 317 try { 305 318 co.creatediagrams_tasks = Boolean.valueOf( -
DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java
r494 r495 62 62 import schedframe.resources.computing.extensions.ExtensionType; 63 63 import schedframe.resources.computing.profiles.energy.EnergyExtension; 64 import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue; 64 65 import schedframe.resources.computing.profiles.energy.power.PowerUsage; 65 66 import schedframe.resources.units.PEUnit; … … 81 82 import simulator.stats.SimulationStatistics; 82 83 import simulator.stats.implementation.out.AbstractStringSerializer; 83 import simulator.stats.implementation.out.FormatedStringSerializer;84 84 import simulator.stats.implementation.out.StringSerializer; 85 85 import csiro.mit.utils.jfreechart.timetablechart.TimetableChartFactory; … … 98 98 protected static float ALPHA = 0.5f; 99 99 protected static int GANTT_WIDTH = 1200; 100 101 //protected static final int BITS = 8; 100 102 101 protected static final int MILLI_SEC = 1000; 103 102 … … 106 105 107 106 protected static final String SIMULATION_STATISTICS_OUTPUT_FILE_NAME = "Simulation.txt"; 108 protected static final String ENERGYUSAGE_STATISTICS_OUTPUT_FILE_NAME = "Energy.txt"; 109 protected static final String RESOURCEUSAGE_STATISTICS_OUTPUT_FILE_NAME = "ResourceUtilization.txt"; 107 protected static final String RESOURCEUTILIZATION_STATISTICS_OUTPUT_FILE_NAME = "ResourceUtilization.txt"; 108 protected static final String ENERGYUSAGE_STATISTICS_OUTPUT_FILE_NAME = "EnergyUsage.txt"; 109 protected static final String AIRFLOW_STATISTICS_OUTPUT_FILE_NAME = "AirThroughput.txt"; 110 110 111 111 protected static final String DIAGRAMS_FILE_NAME_PREFIX = "Chart_"; … … 123 123 protected Map<String, GSSAccumulator> statsData; 124 124 125 pr ivateGenericUser users;125 protected GenericUser users; 126 126 protected ResourceController resourceController; 127 127 protected boolean generateDiagrams = true; … … 132 132 //RESOURCES 133 133 protected Timetable ganttDiagramPeTimetable; 134 protected Map<ResourceType, List<XYDataset>> resourceEnergyDiagrams; 134 protected Map<ResourceType, List<XYDataset>> resourcePowerUsageDiagrams; 135 protected Map<ResourceType, List<XYDataset>> resourceAirFlowDiagrams; 135 136 protected Map<ResourceType, List<XYDataset>> resourceLoadDiagrams; 136 137 protected Map<String,List<ResStat>> basicResStats; … … 161 162 this.outputFolderName = outputFolderName; 162 163 163 164 164 this.serializer = new StringSerializer(); 165 166 165 this.serializer.setDefaultNumberFormat(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT); 167 166 168 167 this.resourceController = resourceController; 169 jr = new JobRegistryImpl("");168 this.jr = new JobRegistryImpl(""); 170 169 init(); 171 170 } … … 174 173 175 174 this.startSimulationTime = DateTimeUtilsExt.getOffsetTime().getTimeInMillis(); 176 177 175 this.endSimulationTime = DateTimeUtilsExt.currentTimeMillis(); 178 176 … … 235 233 private void gatherResourceStatistics() { 236 234 237 238 //TEMPORARY CONFIGURATION SECTION239 240 235 HashMap<String, List<Stats>> type_stats = new HashMap<String, List<Stats>>(); 241 236 … … 248 243 if(ArrayUtils.contains(configuration.resForEnergyChart, resourceName)) 249 244 cStats.add(Stats.chartEnergy); 245 cStats.add(Stats.textAirFlow); 246 if(ArrayUtils.contains(configuration.resForAirFlowChart, resourceName)) 247 cStats.add(Stats.chartAirFlow); 250 248 type_stats.put(resourceName, cStats); 251 249 } 252 250 253 251 peGanttMap = new HashMap<String, TimetableEventSource>(); 254 taskGanttMap = new HashMap<String, TimetableEventGroup>(); 255 252 taskGanttMap = new HashMap<String, TimetableEventGroup>(); 256 253 257 254 resourceLoadDiagrams = new HashMap<ResourceType, List<XYDataset>>(); 258 resourceEnergyDiagrams = new HashMap<ResourceType, List<XYDataset>>(); 255 resourcePowerUsageDiagrams = new HashMap<ResourceType, List<XYDataset>>(); 256 resourceAirFlowDiagrams = new HashMap<ResourceType, List<XYDataset>>(); 259 257 260 258 ganttDiagramPeTimetable = new Timetable(new FixedMillisecond( … … 265 263 File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 266 264 + simulationIdentifier + "_" 267 + RESOURCEU SAGE_STATISTICS_OUTPUT_FILE_NAME);265 + RESOURCEUTILIZATION_STATISTICS_OUTPUT_FILE_NAME); 268 266 resourceLoadStatsFile = new PrintStream(new FileOutputStream(file)); 269 267 } catch (IOException e) { … … 280 278 energyStatsFile = null; 281 279 } 282 JobRegistry jr = new JobRegistryImpl("stats"); 280 281 PrintStream airFlowStatsFile = null; 282 try { 283 File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 284 + simulationIdentifier + "_" 285 + AIRFLOW_STATISTICS_OUTPUT_FILE_NAME); 286 airFlowStatsFile = new PrintStream(new FileOutputStream(file)); 287 } catch (IOException e) { 288 airFlowStatsFile = null; 289 } 290 283 291 basicResStats = gatherPEStats(jr.getExecutableTasks()); 284 292 peStatsPostProcessing(basicResStats); … … 291 299 for(String resourceName: resourceController.getComputingResourceLayers()){ 292 300 List<ComputingResource> resources = null; 293 try { 294 resources = new ArrayList<ComputingResource>(); 295 for(ComputingResource compRes: resourceController.getComputingResources() ){ 296 resources.addAll(compRes.getDescendantsByType(new UserResourceType(resourceName))); 297 } 298 if(resourceController.getComputingResources().get(0).getType().getName().equals(resourceName)) 299 resources.addAll(resourceController.getComputingResources()); 300 } catch (Exception e) { 301 continue; 302 } 301 302 resources = new ArrayList<ComputingResource>(); 303 for(ComputingResource compRes: resourceController.getComputingResources() ){ 304 resources.addAll(compRes.getDescendantsByType(new UserResourceType(resourceName))); 305 } 306 if(resourceController.getComputingResources().get(0).getType().getName().equals(resourceName)) 307 resources.addAll(resourceController.getComputingResources()); 308 303 309 if(type_stats.containsKey(resourceName)){ 304 Map<String, GSSAccumulator> energyCategoryStats = new TreeMap<String, GSSAccumulator>();305 Map<String, GSSAccumulator> loadCategoryStats = new TreeMap<String, GSSAccumulator>();306 310 for(ComputingResource resource: resources){ 307 311 ResourceUsageStats resourceUsage = null; 308 312 ResourceEnergyStats energyUsage = null; 313 ResourceAirFlowStats airFlow = null; 309 314 if(type_stats.get(resourceName).contains(Stats.textLoad)){ 310 315 resourceUsage = gatherResourceLoadStats(resource, basicResStats); … … 358 363 } 359 364 360 /*if(resType == ResourceType.ComputingNode){ 361 ComputingNode compNode = (ComputingNode) resource; 362 if(energyCategoryStats.containsKey(resType+"#"+compNode.getCategory().getName())){ 363 GSSAccumulator acc = energyCategoryStats.get(resType+"#"+compNode.getCategory().getName()); 364 acc.add(energyUsage.meanUsage); 365 energyCategoryStats.put(resType+"#"+compNode.getCategory().getName(), acc); 366 } else{ 367 GSSAccumulator acc = new GSSAccumulator(); 368 acc.add(energyUsage.meanUsage); 369 energyCategoryStats.put(resType+"#"+compNode.getCategory().getName(), acc); 365 if(type_stats.get(resourceName).contains(Stats.textAirFlow)){ 366 airFlow = gatherResourceAirFlowStats(resource); 367 airFlow.setMeanUsage(calculateAirFlowLoad(airFlow)); 368 airFlow.setSumUsage(airFlow.getMeanUsage() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 369 370 EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 371 if(resourceController.getComputingResources().contains(resource)) { 372 if( een != null /*&& een.getPp() != null*/ ){ 373 accStats.meanAirFlow.add(airFlow.meanValue); 374 } 375 376 } else if( een != null && een.getAirFlowProfile() != null ){ 377 ComputingResource parent = resource.getParent(); 378 een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 379 boolean top = true; 380 while(parent != null){ 381 if(een != null && een.getAirFlowProfile() != null) { 382 top = false; 383 break; 384 } 385 parent = parent.getParent(); 386 } 387 if(top == true){ 388 accStats.meanAirFlow.add(airFlow.meanValue); 389 } 370 390 } 371 372 if(loadCategoryStats.containsKey(resType+"#"+compNode.getCategory().getName())){ 373 GSSAccumulator acc = loadCategoryStats.get(resType+"#"+compNode.getCategory().getName()); 374 acc.add(resourceUsage.meanUsage); 375 loadCategoryStats.put(resType+"#"+compNode.getCategory().getName(), acc); 376 } else{ 377 GSSAccumulator acc = new GSSAccumulator(); 378 acc.add(resourceUsage.meanUsage); 379 loadCategoryStats.put(resType+"#"+compNode.getCategory().getName(), acc); 391 if (airFlowStatsFile != null) { 392 Object txt = airFlow.serialize(serializer); 393 airFlowStatsFile.println(txt); 380 394 } 381 } else if(resType == ResourceType.Processor){ 382 Processor proc = (Processor)resource; 383 if(energyCategoryStats.containsKey(resType+"#"+proc.getComputingNode().getCategory().getName())){ 384 GSSAccumulator acc = energyCategoryStats.get(resType+"#"+proc.getComputingNode().getCategory().getName()); 385 acc.add(energyUsage.meanUsage); 386 energyCategoryStats.put(resType+"#"+proc.getComputingNode().getCategory().getName(), acc); 387 } else{ 388 GSSAccumulator acc = new GSSAccumulator(); 389 acc.add(energyUsage.meanUsage); 390 energyCategoryStats.put(resType+"#"+proc.getComputingNode().getCategory().getName(), acc); 395 } 396 if(type_stats.get(resourceName).contains(Stats.chartAirFlow)){ 397 398 if (configuration.creatediagrams_airflow) { 399 createResourceAirFlowGanttDiagram(airFlow); 391 400 } 392 393 if(loadCategoryStats.containsKey(resType+"#"+proc.getComputingNode().getCategory().getName())){394 GSSAccumulator acc = loadCategoryStats.get(resType+"#"+proc.getComputingNode().getCategory().getName());395 acc.add(resourceUsage.meanUsage);396 loadCategoryStats.put(resType+"#"+proc.getComputingNode().getCategory().getName(), acc);397 } else{398 GSSAccumulator acc = new GSSAccumulator();399 acc.add(resourceUsage.meanUsage);400 loadCategoryStats.put(resType+"#"+proc.getComputingNode().getCategory().getName(), acc);401 }402 }*/403 }404 405 if(energyCategoryStats.size() > 0)406 {407 energyStatsFile.println("\n=========BY CATEGORY===========");408 for(String key: energyCategoryStats.keySet()){409 GSSAccumulator acc = energyCategoryStats.get(key);410 energyStatsFile.println(key + "- mean: " + acc.getMean()+ " sum: " +acc.getMean() * (endSimulationTime-startSimulationTime) / (3600 * MILLI_SEC) * acc.getCount());411 401 } 412 energyStatsFile.println("\n\n");413 }414 415 if(loadCategoryStats.size() > 0)416 {417 resourceLoadStatsFile.println("\n=========BY CATEGORY===========");418 for(String key: loadCategoryStats.keySet()){419 GSSAccumulator acc = loadCategoryStats.get(key);420 resourceLoadStatsFile.println(key + "- mean: " + acc.getMean());421 }422 resourceLoadStatsFile.println("\n\n");423 402 } 424 403 } … … 427 406 saveResourceGanttDiagrams(); 428 407 createAccumulatedResourceSimulationStatistic(); 408 if (airFlowStatsFile != null) { 409 airFlowStatsFile.close(); 410 } 429 411 if (energyStatsFile != null) { 430 412 energyStatsFile.close(); … … 472 454 } 473 455 } 456 474 457 private Map<String, List<ResStat>> gatherPEStats( ExecutablesList executables) { 475 476 458 477 459 Map<String, List<ResStat>> basicResStats = new TreeMap<String, List<ResStat>>(new MapPEIdComparator()); 478 //Map<Integer, Map<String, Object>> history 479 460 480 461 for (ExecTask execTask:executables) { 481 462 Executable exec = (Executable) execTask; … … 485 466 ResourceUnit resUnit = res.get(StandardResourceUnitName.PE); 486 467 //ProcessingElements pes = (ProcessingElements) resUnit ; 487 if(resUnit instanceof ProcessingElements 468 if(resUnit instanceof ProcessingElements){ 488 469 ProcessingElements pes = (ProcessingElements) resUnit; 489 470 for(ComputingResource pe: pes){ … … 491 472 long startDate = Double.valueOf(exec.getExecStartTime()).longValue() * MILLI_SEC; 492 473 long endDate = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC; 493 494 474 495 475 String uniqueTaskID = execTask.getJobId() + "_" + execTask.getId(); … … 525 505 private ResourceUsageStats gatherResourceLoadStats(ComputingResource resource, Map<String,List<ResStat>> basicStats) { 526 506 ResourceUsageStats usageStats = new ResourceUsageStats(resource.getName(), resource.getType(), "resourceLoadStats"); 507 int cnt =0; 527 508 for(String resName: basicStats.keySet()){ 528 509 try { 529 510 if(resource.getDescendantByName(resName) != null || resource.getName().compareTo(resName) == 0){ 511 cnt++; 530 512 createResourceLoadData(usageStats, basicStats.get(resName)); 531 513 } … … 535 517 } 536 518 } 519 for(Long key: usageStats.getUsage().keySet()){ 520 Double value = usageStats.getUsage().get(key)/cnt; 521 usageStats.getUsage().put(key, value); 522 } 523 537 524 return usageStats; 538 525 } 539 526 540 private TreeMap<Long, Integer> createResourceLoadData(ResourceUsageStats usageStats, List<ResStat> resStats) {541 542 TreeMap<Long, Integer> ganttData = (TreeMap)usageStats.getUsage();527 private TreeMap<Long, Double> createResourceLoadData(ResourceUsageStats usageStats, List<ResStat> resStats) { 528 529 TreeMap<Long, Double> ganttData = (TreeMap<Long, Double>)usageStats.getUsage(); 543 530 for (ResStat resStat : resStats) { 544 531 … … 546 533 long end_time = resStat.getEndDate(); 547 534 if (end_time > start_time) { 548 Integerend = ganttData.get(end_time);535 Double end = ganttData.get(end_time); 549 536 if (end == null) { 550 ganttData.put(end_time, 0 );537 ganttData.put(end_time, 0.0); 551 538 Long left = getLeftKey(ganttData, end_time); 552 539 if (left != null) { 553 IntegerleftValue = ganttData.get(left);540 Double leftValue = ganttData.get(left); 554 541 ganttData.put(end_time, leftValue); 555 542 } 556 543 } 557 544 558 Integerstart = ganttData.get(start_time);545 Double start = ganttData.get(start_time); 559 546 if (start == null) { 560 ganttData.put(start_time, 0 );547 ganttData.put(start_time, 0.0); 561 548 Long left = getLeftKey(ganttData, start_time); 562 549 if (left != null) { 563 IntegerleftValue = ganttData.get(left);550 Double leftValue = ganttData.get(left); 564 551 ganttData.put(start_time, leftValue); 565 552 } 566 553 } 567 554 568 SortedMap<Long, Integer> sm = ganttData.subMap(start_time,555 SortedMap<Long, Double> sm = ganttData.subMap(start_time, 569 556 end_time); 570 557 for (Long key : sm.keySet()) { 571 IntegerkeyVal = ganttData.get(key);558 Double keyVal = ganttData.get(key); 572 559 ganttData.put(key, keyVal + 1); 573 560 } 574 561 } 575 562 } 563 576 564 return ganttData; 577 565 } 578 566 579 private Long getLeftKey(TreeMap<Long, Integer> ganttData, Long toKey) {580 581 SortedMap<Long, Integer> sm = ganttData.headMap(toKey);567 private Long getLeftKey(TreeMap<Long, Double> ganttData, Long toKey) { 568 569 SortedMap<Long, Double> sm = ganttData.headMap(toKey); 582 570 if (sm.isEmpty()) { 583 571 return null; … … 621 609 } 622 610 623 private void createResourceEnergyGanttDiagram(ResourceEnergyStats energyUsage) { 624 625 XYDataset dataset = createResourceEnergyGanttDataSet(energyUsage, 611 612 private ResourceAirFlowStats gatherResourceAirFlowStats(ComputingResource resource) { 613 614 ResourceAirFlowStats resAirFlow = new ResourceAirFlowStats(resource.getName(), resource.getType(), "resourceAirFlowStats"); 615 Map<Long, Double> airFlow = resAirFlow.getAirFlow(); 616 617 ExtensionList extensionList = resource.getExtensionList(); 618 if(extensionList != null){ 619 for (Extension extension : extensionList) { 620 if (extension.getType() == ExtensionType.ENERGY_EXTENSION) { 621 EnergyExtension ee = (EnergyExtension)extension; 622 if(ee.getAirFlowProfile() == null) 623 break; 624 List<AirFlowValue> airFlowHistory = ee.getAirFlowProfile().getAirThroughputHistory(); 625 if(airFlowHistory.size() == 0) 626 break; 627 long lastTime = DateTimeUtilsExt.getOffsetTime().getTimeInMillis(); 628 long endSimulationTime = DateTimeUtilsExt.currentTimeMillis(); 629 double lastAirFlow = 0; 630 airFlowHistory.add(new AirFlowValue(endSimulationTime, ee.getAirFlowProfile().getAirThroughputHistory().get(ee.getAirFlowProfile().getAirThroughputHistory().size()-1).getValue())); 631 for(AirFlowValue af:airFlowHistory){ 632 airFlow.put(af.getTimestamp(), af.getValue()); 633 634 lastAirFlow = af.getValue(); 635 lastTime = af.getTimestamp(); 636 } 637 } 638 } 639 } 640 return resAirFlow; 641 } 642 643 private void createResourceEnergyGanttDiagram(ResourceEnergyStats powerUsage) { 644 645 XYDataset dataset = createResourceEnergyGanttDataSet(powerUsage, 626 646 startSimulationTime, endSimulationTime); 627 647 628 List<XYDataset> energyDiagram = resource EnergyDiagrams.get(energyUsage.getResourceType());648 List<XYDataset> energyDiagram = resourcePowerUsageDiagrams.get(powerUsage.getResourceType()); 629 649 if(energyDiagram == null){ 630 650 energyDiagram = new ArrayList<XYDataset>(); 631 651 energyDiagram.add(dataset); 632 resource EnergyDiagrams.put(energyUsage.getResourceType(), energyDiagram);652 resourcePowerUsageDiagrams.put(powerUsage.getResourceType(), energyDiagram); 633 653 } else { 634 654 energyDiagram.add(dataset); … … 637 657 } 638 658 659 private void createResourceAirFlowGanttDiagram(ResourceAirFlowStats airFlow) { 660 661 XYDataset dataset = createResourceAirFlowGanttDataSet(airFlow, 662 startSimulationTime, endSimulationTime); 663 664 List<XYDataset> airFlowDiagram = resourceAirFlowDiagrams.get(airFlow.getResourceType()); 665 if(airFlowDiagram == null){ 666 airFlowDiagram = new ArrayList<XYDataset>(); 667 airFlowDiagram.add(dataset); 668 resourceAirFlowDiagrams.put(airFlow.getResourceType(), airFlowDiagram); 669 } else { 670 airFlowDiagram.add(dataset); 671 } 672 673 } 674 639 675 private XYDataset createResourceEnergyGanttDataSet( 640 676 ResourceEnergyStats energyUsage, long start, long end) { … … 665 701 } 666 702 703 private XYDataset createResourceAirFlowGanttDataSet( 704 ResourceAirFlowStats airFlowStats, long start, long end) { 705 706 TreeMap<Long, Double> ganttdata = createResourceAirFlowGanttData(airFlowStats); 707 XYSeriesCollection dataset = new XYSeriesCollection(); 708 XYSeries data = new XYSeries(airFlowStats.getResourceName(), false, true); 709 //data.add(start, 0); 710 for (Long key : ganttdata.keySet()) { 711 Double val = ganttdata.get(key); 712 data.add(key, val); 713 } 714 data.add(end, 0); 715 dataset.addSeries(data); 716 return dataset; 717 } 718 719 private TreeMap<Long, Double> createResourceAirFlowGanttData( 720 ResourceAirFlowStats airFlowStats) { 721 722 Map<Long, Double> airFlow = airFlowStats.getAirFlow(); 723 TreeMap<Long, Double> ganttData = new TreeMap<Long, Double>(); 724 for (Long afKey : airFlow.keySet()) { 725 ganttData.put(afKey, airFlow.get(afKey)); 726 } 727 return ganttData; 728 } 667 729 668 730 private boolean saveResourceGanttDiagrams() { … … 670 732 JFreeChart peDiagram = null; 671 733 JFreeChart resourceEnergyDiagram = null; 734 JFreeChart resourceAirFlowDiagram = null; 672 735 if (!generateDiagrams) 673 736 return false; … … 701 764 } 702 765 if (configuration.creatediagrams_energyusage) { 703 for(ResourceType resType: resource EnergyDiagrams.keySet()){766 for(ResourceType resType: resourcePowerUsageDiagrams.keySet()){ 704 767 resourceEnergyDiagram = getResourcesEnergyDiagram(resType, chartName, 705 768 subtitle, simulationTime); … … 708 771 } 709 772 } 773 774 775 if (configuration.creatediagrams_airflow) { 776 for(ResourceType resType: resourceAirFlowDiagrams.keySet()){ 777 resourceAirFlowDiagram = getResourcesAirFlowDiagram(resType, chartName, 778 subtitle, simulationTime); 779 if (!saveXYPlotChart(resourceAirFlowDiagram, fileName + "AirThroughput - "+resType)) 780 return false; 781 } 782 } 710 783 return true; 711 784 } … … 713 786 private JFreeChart getResourcesLoadDiagram(ResourceType resType, String chartName, Title subtitle, 714 787 String simulationTime) { 715 String cpu = " CPU";788 String cpu = "UTILIZATION [%]"; 716 789 boolean urls = false; 717 790 boolean tooltip = true; … … 750 823 DateAxis xAxis = new DateAxis(simulationTime); 751 824 752 List<XYDataset> energyDiagram = resource EnergyDiagrams.get(resType);825 List<XYDataset> energyDiagram = resourcePowerUsageDiagrams.get(resType); 753 826 for (XYDataset dataset : energyDiagram) { 754 827 … … 759 832 XYPlot tPlot = tChart.getXYPlot(); 760 833 NumberAxis yAxis = new NumberAxis(energy); 834 yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 835 tPlot.setRangeAxis(yAxis); 836 XYStepAreaRenderer rend = (XYStepAreaRenderer) tPlot.getRenderer(); 837 rend.setShapesVisible(false); 838 cPlot.add(tPlot); 839 } 840 cPlot.setDomainAxis(xAxis); 841 cPlot.setDomainAxisLocation(AxisLocation.TOP_OR_LEFT); 842 JFreeChart chart = new JFreeChart(chartName, cPlot); 843 chart.addSubtitle(subtitle); 844 return chart; 845 } 846 847 private JFreeChart getResourcesAirFlowDiagram(ResourceType resType, String chartName, 848 Title subtitle, String simulationTime) { 849 String airFlow = "AIR FLOW [m^3/min]"; 850 boolean urls = false; 851 boolean tooltip = true; 852 boolean legend = true; 853 CombinedDomainXYPlot cPlot = new CombinedDomainXYPlot(); 854 DateAxis xAxis = new DateAxis(simulationTime); 855 856 List<XYDataset> airFlowDiagram = resourceAirFlowDiagrams.get(resType); 857 for (XYDataset dataset : airFlowDiagram) { 858 859 JFreeChart tChart = ChartFactory.createXYStepAreaChart("", "", 860 null, dataset, PlotOrientation.VERTICAL, legend, tooltip, 861 urls); 862 863 XYPlot tPlot = tChart.getXYPlot(); 864 NumberAxis yAxis = new NumberAxis(airFlow); 761 865 yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 762 866 tPlot.setRangeAxis(yAxis); … … 870 974 XYSeriesCollection dataset = new XYSeriesCollection(); 871 975 XYSeries data = new XYSeries(resStats.resourceName, false, true); 872 Map<Long, Integer> usage = resStats.getUsage();976 Map<Long, Double> usage = resStats.getUsage(); 873 977 874 978 for (Long key : usage.keySet()) { 875 Integerval = usage.get(key);876 double newv = 100*val/basicResStats.size();877 int newinv = (int)newv;878 data.add(key, new Integer(newinv));979 Double val = usage.get(key); 980 double newv = 100 * val; 981 //System.out.println(newv+":"+val+";"+basicResStats.size()); 982 data.add(key, new Double(newv)); 879 983 } 880 984 dataset.addSeries(data); … … 950 1054 } 951 1055 1056 private double calculateAirFlowLoad(ResourceAirFlowStats resAirFlowStats ){ 1057 double meanAirFlow = 0; 1058 long time = 0; 1059 double usage = 0; 1060 Map<Long, Double> airFlow = resAirFlowStats.getAirFlow(); 1061 for (Long key : airFlow.keySet()) { 1062 1063 if (time != 0) { 1064 meanAirFlow += (usage * (key - time)) 1065 / (endSimulationTime - startSimulationTime); 1066 1067 time = key; 1068 } else { 1069 time = key; 1070 } 1071 usage = (double) airFlow.get(key); 1072 } 1073 return meanAirFlow; 1074 } 1075 1076 952 1077 /*private void createPEGanttDiagram(String peName, 953 1078 String uniqueTaskID, Map<String, Object> historyItem) { … … 1006 1131 Job job = (Job) jobs.get(i); 1007 1132 1008 //List<TaskInterface> execList = JobRegistry.getInstance("COMPUTING_GRID_0#BROKER").getAllSubmittedTasks();1009 1133 List<Executable> execList = jr.getExecutableTasks().getJobExecutables(job.getId()); 1010 1134 List<TaskStats> taskStatsList = new ArrayList<TaskStats>(); … … 1346 1470 statsData.put(RESOURCES_RESERVATION_LOAD, accStats.meanEnergyUsage); 1347 1471 statsData.put(RESOURCES_QUEUE_LENGTH, accStats.meanQueueLength); 1348 1349 1472 } 1350 1473 … … 1417 1540 chartLoad, 1418 1541 textEnergy, 1419 chartEnergy; 1542 chartEnergy, 1543 textAirFlow, 1544 chartAirFlow; 1420 1545 } -
DCWoRMS/trunk/src/simulator/stats/implementation/GSSAccumulatorsStats.java
r477 r495 10 10 public GSSAccumulator meanQueueLength; 11 11 public GSSAccumulator meanEnergyUsage; 12 public GSSAccumulator meanAirFlow; 12 13 13 14 public GSSAccumulator meanTaskStartTime; … … 29 30 meanReservationLoad = new GSSAccumulator(); 30 31 meanQueueLength = new GSSAccumulator(); 31 meanEnergyUsage = new GSSAccumulator(); 32 meanEnergyUsage = new GSSAccumulator(); 33 meanAirFlow = new GSSAccumulator(); 32 34 33 35 meanTaskStartTime = new GSSAccumulator(); -
DCWoRMS/trunk/src/simulator/stats/implementation/ResourceUsageStats.java
r477 r495 15 15 public class ResourceUsageStats implements StatsInterface { 16 16 17 protected Map<Long, Integer> usage;17 protected Map<Long, Double> usage; 18 18 protected String resourceName; 19 19 protected String usageType; … … 31 31 this.resourceType = resourceType; 32 32 this.usageType = usageType; 33 this.usage = new TreeMap<Long, Integer>();33 this.usage = new TreeMap<Long, Double>(); 34 34 this.meanUsage = 0; 35 35 } … … 51 51 } 52 52 53 public Map<Long, Integer> getUsage() {53 public Map<Long, Double> getUsage() { 54 54 return this.usage; 55 55 } -
DCWoRMS/trunk/src/simulator/stats/implementation/out/StatsSerializer.java
r477 r495 4 4 import simulator.stats.implementation.GSSAccumulatorsStats; 5 5 import simulator.stats.implementation.JobStats; 6 import simulator.stats.implementation.ResourceAirFlowStats; 6 7 import simulator.stats.implementation.ResourceEnergyStats; 7 8 import simulator.stats.implementation.ResourceStats; … … 28 29 public Object visit(ResourceEnergyStats arg); 29 30 31 public Object visit(ResourceAirFlowStats arg); 30 32 31 33 public Object visit(GSSAccumulatorsStats arg); -
DCWoRMS/trunk/src/simulator/stats/implementation/out/StringSerializer.java
r477 r495 11 11 import simulator.stats.implementation.GSSAccumulatorsStats; 12 12 import simulator.stats.implementation.JobStats; 13 import simulator.stats.implementation.ResourceAirFlowStats; 13 14 import simulator.stats.implementation.ResourceEnergyStats; 14 15 import simulator.stats.implementation.ResourceStats; … … 258 259 259 260 public Object visit(ResourceUsageStats resourceUsageStats) { 260 Map<Long, Integer> resourceUsage = resourceUsageStats.getUsage();261 Map<Long, Double> resourceUsage = resourceUsageStats.getUsage(); 261 262 262 263 int mapSize = resourceUsage.size(); … … 297 298 buffer.append(resourceUsageStats.getResourceName()); 298 299 buffer.append(fieldSeparator); 299 Integervalue = resourceUsage.get(timestamp);300 Double value = resourceUsage.get(timestamp); 300 301 buffer.append(timestamp); 301 302 buffer.append(fieldSeparator); … … 371 372 } 372 373 374 public Object visit(ResourceAirFlowStats resourceAirFlowStats) { 375 Map<Long, Double> resourceAirFlow = resourceAirFlowStats.getAirFlow(); 376 377 int mapSize = resourceAirFlow.size(); 378 /* 379 * FIXME: 380 * Integer.MAX_VALUE = 2147483647. We assume, that each line contains 381 * max 30 signs - this gives max 71582788 lines. If resourceUsage map 382 * contains more elements then we have a problem, because content of 383 * resourceUsage map will not fit in the buffer. 384 * This will need further attention in the future. 385 */ 386 int maxSize = (Integer.MAX_VALUE / 30 ) - 1; 387 if(mapSize >= maxSize){ 388 log.error("Resource usage data is to long to fit in the buffer."); 389 return null; 390 } 391 392 int size = 30 * resourceAirFlow.size(); 393 394 StringBuffer buffer = null; 395 396 if(printedHeaders.add(resourceAirFlowStats.getUsageType())) { 397 buffer = new StringBuffer(size + 42); 398 String[] headers = resourceAirFlowStats.getHeaders(); 399 for(int i = 0; i < headers.length; i++) 400 { 401 buffer.append(headers[i]); 402 buffer.append(fieldSeparator); 403 } 404 buffer.append(System.getProperty("line.separator")); 405 } else { 406 buffer = new StringBuffer(size); 407 } 408 409 410 for (Long timestamp : resourceAirFlow.keySet()) { 411 412 buffer.append(resourceAirFlowStats.getResourceName()); 413 buffer.append(fieldSeparator); 414 Double value = resourceAirFlow.get(timestamp); 415 buffer.append(timestamp); 416 buffer.append(fieldSeparator); 417 buffer.append(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT 418 .format(value)); 419 buffer.append(fieldSeparator); 420 buffer.append(System.getProperty("line.separator")); 421 422 } 423 424 if(resourceAirFlow.size() > 0) { 425 buffer.append("mean: "+resourceAirFlowStats.getMeanUsage() + " sum: " +resourceAirFlowStats.getSumUsage()); 426 buffer.append(System.getProperty("line.separator")); 427 } 428 429 return buffer.toString(); 430 } 431 373 432 public Object visit(GSSAccumulatorsStats accStats) { 374 433
Note: See TracChangeset
for help on using the changeset viewer.