Changeset 495 for DCWoRMS/trunk


Ignore:
Timestamp:
10/10/12 12:12:06 (13 years ago)
Author:
wojtekp
Message:
 
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  
    1010import schedframe.resources.computing.extensions.ExtensionType; 
    1111import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    12 import schedframe.resources.computing.profiles.energy.power.PowerProfileFactory; 
     12import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    1313import schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface; 
    1414import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
     
    2626                 
    2727                //extensionList.add(new EnergyExtension(this, resDesc.getPowerInterface(), resDesc.getEnergyEstimationPlugin())); 
    28                 PowerInterface pi = PowerProfileFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
     28                PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
    2929                accept(new EnergyExtension(pi, resDesc.getPowerProfile()));      
    3030        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/ComputingResource.java

    r494 r495  
    2828import schedframe.resources.computing.profiles.energy.EnergyEventType; 
    2929import schedframe.resources.computing.profiles.energy.EnergyExtension; 
     30import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 
    3031import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    3132import schedframe.resources.computing.properties.DefaultPropertiesBuilder; 
     
    6869        } 
    6970 
    70         //TODO remove if possible (check if all scenarios can be realized - statistics issue) , since it's temporary method 
     71        //TODO remove if possible (check if all scenarios can be realized - statistics issue), since it's a temporary method 
    7172        private void addFakeProcessors() { 
    7273                if(getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.PE) != null){ 
     
    145146                sec.execute(event); 
    146147 
    147                  
    148148                //old, correctly working method 
    149149                /*if (extensionList != null) { 
     
    188188        } 
    189189         
    190         protected List<? extends ComputingResource> searchDescendants(List<ResourceValidator> validators, boolean cutoff) { 
     190        protected List<? extends ComputingResource> searchDescendants(List<ResourceValidator> validators, boolean cutOff) { 
    191191 
    192192                List<ComputingResource> descendants = new ArrayList<ComputingResource>(); 
     
    198198                                ComputingResource resource = toExamine.pop(); 
    199199                                List<ComputingResource> resources = resource.getChildren(); 
    200                                 /*if (resources == null) 
    201                                         continue;*/ 
    202200                                int numberOfRes = resources.size(); 
    203201                                for (int i = 0; i < numberOfRes; i++) { 
     
    205203                                        if (resourceChild.match(validators)) { 
    206204                                                descendants.add(resourceChild); 
    207                                                 if(cutoff == false) { 
     205                                                if(cutOff == false) { 
    208206                                                        toExamine.addLast(resourceChild); 
    209207                                                } 
     
    243241                return null; 
    244242        } 
     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        } 
    245255 
    246256        public Scheduler getScheduler() { 
     
    257267        } 
    258268 
    259         class SimpleEventHandler implements EventHandler{ 
     269        class ComputingResourceEventHandler implements EventHandler{ 
    260270                 
    261271                public void handleResourceEvent(Event event){ 
     
    282292         
    283293        public EventHandler getEventHandler(){ 
    284                 return new SimpleEventHandler(); 
     294                return new ComputingResourceEventHandler(); 
    285295        } 
    286296         
    287297        public void initiate(){ 
     298                 
    288299                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"); 
    290301                event.setReason(EventReason.SIM_INIT); 
    291302                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                 
    292309                //alternative way 
     310                //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller")); 
    293311                //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller")); 
    294312        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/Core.java

    r477 r495  
    33import schedframe.resources.computing.description.ComputingResourceDescription; 
    44import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    5 import schedframe.resources.computing.profiles.energy.power.PowerProfileFactory; 
     5import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    66import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    77import schedframe.resources.units.CpuSpeed; 
     
    1313        public Core (ComputingResourceDescription resDesc) { 
    1414                super(resDesc); 
    15                 PowerInterface pi = PowerProfileFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
     15                PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
    1616                accept(new EnergyExtension(pi, resDesc.getPowerProfile()));      
    1717        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/DataCenter.java

    r477 r495  
    33import schedframe.resources.computing.description.ComputingResourceDescription; 
    44import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    5 import schedframe.resources.computing.profiles.energy.power.PowerProfileFactory; 
     5import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    66import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    77 
     
    1111                super(resDesc); 
    1212                //extensionList.add(new EnergyExtension(this, resDesc.getPowerInterface(), resDesc.getEnergyEstimationPlugin())); 
    13                 PowerInterface pi = PowerProfileFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
     13                PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
    1414                accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 
    1515        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/Processor.java

    r477 r495  
    88import schedframe.resources.computing.extensions.ExtensionType; 
    99import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    10 import schedframe.resources.computing.profiles.energy.power.PowerProfileFactory; 
     10import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    1111import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    1212import schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface; 
     
    2222                super(resDesc); 
    2323                //extensionList.add(new EnergyExtension(this, resDesc.getPowerInterface(), resDesc.getEnergyEstimationPlugin())); 
    24                 PowerInterface pi = PowerProfileFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
     24                PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
    2525                accept(new EnergyExtension(pi, resDesc.getPowerProfile()));      
    2626        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/Rack.java

    r477 r495  
    66import schedframe.resources.computing.description.ComputingResourceDescription; 
    77import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    8 import schedframe.resources.computing.profiles.energy.power.PowerProfileFactory; 
     8import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    99import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    1010 
     
    1414        public Rack (ComputingResourceDescription resDesc) { 
    1515                super(resDesc); 
    16                 PowerInterface pi = PowerProfileFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
     16                PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
    1717                accept(new EnergyExtension(pi, resDesc.getPowerProfile()));      
    1818        } 
  • DCWoRMS/trunk/src/schedframe/resources/computing/ResourceFactory.java

    r481 r495  
    2020                if (resDesc.getType().equals(StandardResourceType.DataCenter)) 
    2121                        return new DataCenter(resDesc); 
     22                else if (resDesc.getType().equals(StandardResourceType.Rack)) 
     23                        return  new Rack(resDesc); 
    2224                else if (resDesc.getType().equals(StandardResourceType.ComputingNode)) 
    2325                        return  new ComputingNode(resDesc); 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/EnergyEventType.java

    r477 r495  
    1515        FREQUENCY_CHANGED(64), 
    1616        VOLTAGE_CHANGED(128), 
    17         RESOURCE_FAILED(256) 
     17         
     18        AIRFLOW_STATE_CHANGED(256), 
     19         
     20        RESOURCE_FAILED(512) 
    1821        ; 
    1922 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java

    r477 r495  
    1111import schedframe.resources.computing.extensions.ExtensionException; 
    1212import schedframe.resources.computing.extensions.ExtensionType; 
     13import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 
     14import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 
    1315import schedframe.resources.computing.profiles.energy.power.PowerProfile; 
    1416import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    1517import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    1618 
    17 public class EnergyExtension implements Extension/*, ResourceVisitor */{ 
     19public class EnergyExtension implements Extension{ 
    1820 
    1921        private Log log = LogFactory.getLog(EnergyExtension.class); 
     
    2123        protected PowerInterface powerInterface; 
    2224        protected PowerProfile powerProfile; 
    23  
     25         
     26        protected AirThroughputInterface airFlowInterface; 
     27        protected AirThroughputProfile airFlowProfile; 
     28         
    2429        protected ComputingResource computingResource; 
    2530 
     
    2934        } 
    3035 
    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 
    3245        public boolean supportsEvent(Event event) { 
    3346 
    3447                if(powerProfile == null || powerProfile.getEnergyEstimationPlugin() == null) 
    3548                        return false; 
    36                  
    3749                if(event.getType().getName().equals(EnergyEventType.POWER_STATE_CHANGED.getName())) 
    3850                        return true; 
     
    4355                else if(event.getType().getName().equals(EnergyEventType.TASK_FINISHED.getName())) 
    4456                        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                 
    4563                else return false; 
    4664 
    4765        } 
    48          
    4966 
    50         @Override 
    5167        public void handleEvent(Event event) { 
    5268                EnergyEvent enEvent = (EnergyEvent)event; 
     
    87103                        //System.out.println(this.resource.getName() + " - ESTIMATED ENERGY:" + power); 
    88104                        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); 
    90112                        break; 
    91113                } 
    92114        } 
    93          
    94         @Override 
     115 
    95116        public void init(Properties properties) throws ExtensionException { 
    96117                // TODO Auto-generated method stub 
    97118        } 
    98119 
    99         @Override 
    100120        public ExtensionType getType() { 
    101121                return ExtensionType.ENERGY_EXTENSION; 
     
    118138        } 
    119139 
     140        public AirThroughputInterface getAirThroughputInterface() { 
     141                return airFlowInterface; 
     142        } 
     143 
     144        public AirThroughputProfile getAirFlowProfile() { 
     145                return airFlowProfile; 
     146        } 
    120147 
    121148} 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java

    r477 r495  
    11package schedframe.resources.computing.profiles.energy.airthroughput; 
    22 
     3import java.util.ArrayList; 
    34import java.util.List; 
     5 
     6import org.joda.time.DateTimeUtils; 
    47 
    58import schedframe.Parameters; 
     
    710 
    811public class AirThroughputProfile { 
     12         
     13        protected List<AirFlowValue> airFlowHistory; 
    914         
    1015        protected AirThroughputEstimationPlugin airThroughputEstimationPlugin; 
     
    1621                this.airThroughputEstimationPlugin = airThroughputEstimationPlugin; 
    1722                this.airThroughputStates = airThroughputStates; 
     23                this.airFlowHistory = new ArrayList<AirFlowValue>(); 
    1824        } 
    1925 
    2026        public List<AirThroughputState> getAirThroughputStates() { 
    2127                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; 
    2256        } 
    2357         
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/AirThroughputInterface.java

    r477 r495  
    1010        public String getAirThroughputState(); 
    1111         
    12         public boolean setAirThroughputState(String airThrougputState); 
     12        public boolean setAirThroughputState(String airThroughputState); 
    1313         
    1414        public boolean supportAirThroughputState(String powerState); 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/DefaultAirThroughputInterface.java

    r477 r495  
    66import schedframe.Parameters; 
    77import schedframe.resources.computing.ComputingResource; 
     8import schedframe.resources.computing.profiles.energy.EnergyEvent; 
     9import schedframe.resources.computing.profiles.energy.EnergyEventType; 
    810import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 
    911import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 
    1012 
    11 public class DefaultAirThrougputInterface implements AirThroughputInterface{ 
     13public class DefaultAirThroughputInterface implements AirThroughputInterface{ 
    1214 
    1315        protected String currentAirThroughputState; 
    1416        protected AirThroughputProfile airThroughputProfile; 
    1517        protected ComputingResource resource; 
     18         
     19        public DefaultAirThroughputInterface(ComputingResource resource, AirThroughputProfile airThroughputProfile){ 
     20                this.resource = resource; 
     21                this.airThroughputProfile = airThroughputProfile; 
     22        } 
    1623         
    1724        public String getAirThroughputState() { 
     
    2229                if(supportAirThroughputState(state)){ 
    2330                        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 
    2435                        return true; 
    2536                } 
     
    2839 
    2940        public boolean supportAirThroughputState(String state) { 
    30  
    3141                for(AirThroughputState airFlowState: airThroughputProfile.getAirThroughputStates()){ 
    3242                        if(airFlowState.getName().equals(state)){ 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerInterfaceFactory.java

    r477 r495  
    55import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    66 
    7 public class PowerProfileFactory { 
     7public class PowerInterfaceFactory { 
    88 
    99 
     
    3636                else if (resource.getType().getName().equals(StandardResourceType.Processor.getName())) 
    3737                        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); 
    3940 
    4041                /*switch(resource.getType()){ 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java

    r477 r495  
    2222         
    2323 
    24         public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> supportedPowerStates) { 
     24        public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates) { 
    2525                this.energyEstimationPlugin = energyEstimationPlugin; 
    2626                this.powerUsage = new ArrayList<PowerUsage>(); 
    27                 this.supportedPowerStates = supportedPowerStates; 
     27                this.supportedPowerStates = powerStates; 
    2828        } 
    2929         
    30         public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> supportedPowerStates,  List<PState> pStates) { 
     30        public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates,  List<PState> pStates) { 
    3131                this.energyEstimationPlugin = energyEstimationPlugin; 
    32                 this.supportedPowerStates = supportedPowerStates; 
     32                this.supportedPowerStates = powerStates; 
    3333                this.powerUsage = new ArrayList<PowerUsage>(); 
    3434                if(pStates.size() > 0) 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/PowerUsage.java

    r477 r495  
    11package schedframe.resources.computing.profiles.energy.power; 
    22 
    3 public class PowerUsage { 
     3import schedframe.resources.computing.profiles.energy.MeasurementHistory; 
    44 
    5         protected long timestamp; 
    6         protected double value; 
     5public class PowerUsage extends MeasurementHistory{ 
    76 
    87        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); 
    239        } 
    2410         
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingNodePowerInterface.java

    r477 r495  
    1010import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 
    1111 
    12 public class ComputingNodePowerInterface extends AbstractPowerInterface{ 
     12public class ComputingNodePowerInterface extends ComputingResourcePowerInterface{ 
    1313 
    1414        public static long START_TIME = 600000; 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingResourcePowerInterface.java

    r477 r495  
    1717import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 
    1818 
    19 public abstract class AbstractPowerInterface implements PowerInterface{ 
     19public class ComputingResourcePowerInterface implements PowerInterface{ 
    2020 
    2121        protected PowerStateName currentPowerState; 
     
    2323        protected ComputingResource resource; 
    2424         
    25         public AbstractPowerInterface(ComputingResource resource, PowerProfile powerProfile){ 
     25        public ComputingResourcePowerInterface(ComputingResource resource, PowerProfile powerProfile){ 
    2626                this.resource = resource; 
    2727                this.powerProfile = powerProfile; 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/DataCenterPowerInterface.java

    r477 r495  
    77import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 
    88 
    9 public class DataCenterPowerInterface extends AbstractPowerInterface{ 
     9public class DataCenterPowerInterface extends ComputingResourcePowerInterface{ 
    1010 
    11  
    12  
    13          
    1411        public DataCenterPowerInterface(ComputingResource resource, PowerProfile pp){ 
    1512                super(resource, pp); 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java

    r494 r495  
    11package schedframe.resources.computing.profiles.energy.power.ui; 
    22 
    3 import gridsim.dcworms.DCWormsTags; 
    43 
    54import java.util.Map; 
     
    1615import schedframe.resources.units.StandardResourceUnitName; 
    1716 
    18 public class ProcessorPowerInterface extends AbstractPowerInterface { 
     17public class ProcessorPowerInterface extends ComputingResourcePowerInterface { 
    1918 
    2019        protected PState currentPState; 
  • DCWoRMS/trunk/src/simulator/ConfigurationOptions.java

    r493 r495  
    6767        public static final String CREATEDIAGRAMS_UTILIZATION = CREATEDIAGRAMS + ".utilization"; 
    6868        public static final String CREATEDIAGRAMS_ENERGYUSAGE = CREATEDIAGRAMS + ".energyusage"; 
     69        public static final String CREATEDIAGRAMS_AIRFLOW = CREATEDIAGRAMS + ".airflow"; 
    6970        public static final String CREATEDIAGRAMS_RESOURCES_SCALE = CREATEDIAGRAMS_UTILIZATION + ".scale"; 
    7071        public static final String CREATEDIAGRAMS_TASKS = CREATEDIAGRAMS + ".tasks"; 
     
    163164        public boolean creatediagrams_resources = true; 
    164165        public boolean creatediagrams_energyusage = true; 
     166        public boolean creatediagrams_airflow = true; 
    165167        public boolean creatediagrams_tasks = true; 
    166168        public boolean creatediagrams_taskswaitingtime = true; 
     
    173175         
    174176        public String[] resForEnergyChart; 
     177        public String[] resForAirFlowChart; 
    175178        public String[] resForUtilizationChart; 
    176179         
     
    302305                        co.creatediagrams_energyusage = createDiagrams; 
    303306                } 
     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                 
    304317                try { 
    305318                        co.creatediagrams_tasks = Boolean.valueOf( 
  • DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java

    r494 r495  
    6262import schedframe.resources.computing.extensions.ExtensionType; 
    6363import schedframe.resources.computing.profiles.energy.EnergyExtension; 
     64import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue; 
    6465import schedframe.resources.computing.profiles.energy.power.PowerUsage; 
    6566import schedframe.resources.units.PEUnit; 
     
    8182import simulator.stats.SimulationStatistics; 
    8283import simulator.stats.implementation.out.AbstractStringSerializer; 
    83 import simulator.stats.implementation.out.FormatedStringSerializer; 
    8484import simulator.stats.implementation.out.StringSerializer; 
    8585import csiro.mit.utils.jfreechart.timetablechart.TimetableChartFactory; 
     
    9898        protected static float ALPHA = 0.5f; 
    9999        protected static int GANTT_WIDTH = 1200; 
    100  
    101         //protected static final int BITS = 8; 
     100         
    102101        protected static final int MILLI_SEC = 1000; 
    103102 
     
    106105 
    107106        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"; 
    110110 
    111111        protected static final String DIAGRAMS_FILE_NAME_PREFIX = "Chart_"; 
     
    123123        protected Map<String, GSSAccumulator> statsData; 
    124124         
    125         private GenericUser users; 
     125        protected GenericUser users; 
    126126        protected ResourceController resourceController; 
    127127        protected boolean generateDiagrams = true; 
     
    132132        //RESOURCES 
    133133        protected Timetable ganttDiagramPeTimetable; 
    134         protected Map<ResourceType, List<XYDataset>> resourceEnergyDiagrams; 
     134        protected Map<ResourceType, List<XYDataset>> resourcePowerUsageDiagrams; 
     135        protected Map<ResourceType, List<XYDataset>> resourceAirFlowDiagrams; 
    135136        protected Map<ResourceType, List<XYDataset>> resourceLoadDiagrams; 
    136137        protected Map<String,List<ResStat>> basicResStats; 
     
    161162                this.outputFolderName = outputFolderName; 
    162163 
    163  
    164164                this.serializer = new StringSerializer(); 
    165  
    166165                this.serializer.setDefaultNumberFormat(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT); 
    167166 
    168167                this.resourceController = resourceController; 
    169                 jr = new JobRegistryImpl(""); 
     168                this.jr = new JobRegistryImpl(""); 
    170169                init(); 
    171170        } 
     
    174173 
    175174                this.startSimulationTime = DateTimeUtilsExt.getOffsetTime().getTimeInMillis(); 
    176  
    177175                this.endSimulationTime = DateTimeUtilsExt.currentTimeMillis(); 
    178176 
     
    235233        private void gatherResourceStatistics() { 
    236234                 
    237                  
    238                 //TEMPORARY CONFIGURATION SECTION 
    239                  
    240235                HashMap<String, List<Stats>> type_stats = new HashMap<String, List<Stats>>(); 
    241236                 
     
    248243                        if(ArrayUtils.contains(configuration.resForEnergyChart, resourceName)) 
    249244                                cStats.add(Stats.chartEnergy); 
     245                        cStats.add(Stats.textAirFlow); 
     246                        if(ArrayUtils.contains(configuration.resForAirFlowChart, resourceName)) 
     247                                cStats.add(Stats.chartAirFlow); 
    250248                        type_stats.put(resourceName, cStats); 
    251249                }                
    252250                 
    253251                peGanttMap = new HashMap<String, TimetableEventSource>(); 
    254                 taskGanttMap = new HashMap<String, TimetableEventGroup>(); 
    255                  
     252                taskGanttMap = new HashMap<String, TimetableEventGroup>();               
    256253                 
    257254                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>>(); 
    259257                 
    260258                ganttDiagramPeTimetable = new Timetable(new FixedMillisecond( 
     
    265263                        File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 
    266264                                        + simulationIdentifier + "_" 
    267                                         + RESOURCEUSAGE_STATISTICS_OUTPUT_FILE_NAME); 
     265                                        + RESOURCEUTILIZATION_STATISTICS_OUTPUT_FILE_NAME); 
    268266                        resourceLoadStatsFile = new PrintStream(new FileOutputStream(file)); 
    269267                } catch (IOException e) { 
     
    280278                        energyStatsFile = null; 
    281279                } 
    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 
    283291                basicResStats = gatherPEStats(jr.getExecutableTasks()); 
    284292                peStatsPostProcessing(basicResStats); 
     
    291299                for(String resourceName: resourceController.getComputingResourceLayers()){ 
    292300                        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                 
    303309                        if(type_stats.containsKey(resourceName)){ 
    304                                 Map<String, GSSAccumulator> energyCategoryStats = new TreeMap<String, GSSAccumulator>(); 
    305                                 Map<String, GSSAccumulator> loadCategoryStats = new TreeMap<String, GSSAccumulator>(); 
    306310                                for(ComputingResource resource: resources){ 
    307311                                        ResourceUsageStats resourceUsage = null; 
    308312                                        ResourceEnergyStats energyUsage = null; 
     313                                        ResourceAirFlowStats airFlow = null; 
    309314                                        if(type_stats.get(resourceName).contains(Stats.textLoad)){ 
    310315                                                resourceUsage = gatherResourceLoadStats(resource, basicResStats); 
     
    358363                                        } 
    359364                                         
    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                                                        } 
    370390                                                } 
    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); 
    380394                                                } 
    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); 
    391400                                                } 
    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()); 
    411401                                        } 
    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"); 
    423402                                } 
    424403                        } 
     
    427406                saveResourceGanttDiagrams(); 
    428407                createAccumulatedResourceSimulationStatistic(); 
     408                if (airFlowStatsFile != null) { 
     409                        airFlowStatsFile.close(); 
     410                } 
    429411                if (energyStatsFile != null) { 
    430412                        energyStatsFile.close(); 
     
    472454                } 
    473455        } 
     456         
    474457        private Map<String, List<ResStat>> gatherPEStats( ExecutablesList executables) { 
    475  
    476458                 
    477459                Map<String, List<ResStat>> basicResStats = new TreeMap<String, List<ResStat>>(new MapPEIdComparator()); 
    478                 //Map<Integer, Map<String, Object>> history 
    479                  
     460 
    480461                for (ExecTask execTask:executables) { 
    481462                        Executable exec = (Executable) execTask; 
     
    485466                        ResourceUnit resUnit = res.get(StandardResourceUnitName.PE); 
    486467                        //ProcessingElements pes = (ProcessingElements) resUnit ; 
    487                         if(resUnit instanceof ProcessingElements ){ 
     468                        if(resUnit instanceof ProcessingElements){ 
    488469                                ProcessingElements pes = (ProcessingElements) resUnit; 
    489470                                for(ComputingResource pe: pes){ 
     
    491472                                        long startDate = Double.valueOf(exec.getExecStartTime()).longValue() * MILLI_SEC; 
    492473                                        long endDate = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC; 
    493  
    494474 
    495475                                        String uniqueTaskID = execTask.getJobId() + "_" + execTask.getId(); 
     
    525505        private ResourceUsageStats gatherResourceLoadStats(ComputingResource resource, Map<String,List<ResStat>> basicStats) { 
    526506                ResourceUsageStats usageStats = new ResourceUsageStats(resource.getName(), resource.getType(), "resourceLoadStats"); 
     507                int cnt =0; 
    527508                for(String resName: basicStats.keySet()){ 
    528509                        try { 
    529510                                if(resource.getDescendantByName(resName) != null || resource.getName().compareTo(resName) == 0){ 
     511                                        cnt++; 
    530512                                        createResourceLoadData(usageStats, basicStats.get(resName)); 
    531513                                } 
     
    535517                        } 
    536518                } 
     519                for(Long key: usageStats.getUsage().keySet()){ 
     520                        Double value = usageStats.getUsage().get(key)/cnt; 
     521                        usageStats.getUsage().put(key, value); 
     522                } 
     523 
    537524                return usageStats; 
    538525        } 
    539526         
    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(); 
    543530                for (ResStat resStat : resStats) { 
    544531                         
     
    546533                        long end_time = resStat.getEndDate(); 
    547534                        if (end_time > start_time) { 
    548                                 Integer end = ganttData.get(end_time); 
     535                                Double end = ganttData.get(end_time); 
    549536                                if (end == null) { 
    550                                         ganttData.put(end_time, 0); 
     537                                        ganttData.put(end_time, 0.0); 
    551538                                        Long left = getLeftKey(ganttData, end_time); 
    552539                                        if (left != null) { 
    553                                                 Integer leftValue = ganttData.get(left); 
     540                                                Double leftValue = ganttData.get(left); 
    554541                                                ganttData.put(end_time, leftValue); 
    555542                                        } 
    556543                                } 
    557544 
    558                                 Integer start = ganttData.get(start_time); 
     545                                Double start = ganttData.get(start_time); 
    559546                                if (start == null) { 
    560                                         ganttData.put(start_time, 0); 
     547                                        ganttData.put(start_time, 0.0); 
    561548                                        Long left = getLeftKey(ganttData, start_time); 
    562549                                        if (left != null) { 
    563                                                 Integer leftValue = ganttData.get(left); 
     550                                                Double leftValue = ganttData.get(left); 
    564551                                                ganttData.put(start_time, leftValue); 
    565552                                        } 
    566553                                } 
    567554 
    568                                 SortedMap<Long, Integer> sm = ganttData.subMap(start_time, 
     555                                SortedMap<Long, Double> sm = ganttData.subMap(start_time, 
    569556                                                end_time); 
    570557                                for (Long key : sm.keySet()) { 
    571                                         Integer keyVal = ganttData.get(key); 
     558                                        Double keyVal = ganttData.get(key); 
    572559                                        ganttData.put(key, keyVal + 1); 
    573560                                } 
    574561                        } 
    575562                } 
     563 
    576564                return ganttData; 
    577565        } 
    578566 
    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); 
    582570                if (sm.isEmpty()) { 
    583571                        return null; 
     
    621609        } 
    622610         
    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, 
    626646                                startSimulationTime, endSimulationTime); 
    627647                 
    628                 List<XYDataset> energyDiagram = resourceEnergyDiagrams.get(energyUsage.getResourceType()); 
     648                List<XYDataset> energyDiagram = resourcePowerUsageDiagrams.get(powerUsage.getResourceType()); 
    629649                if(energyDiagram == null){ 
    630650                        energyDiagram = new ArrayList<XYDataset>(); 
    631651                        energyDiagram.add(dataset); 
    632                         resourceEnergyDiagrams.put(energyUsage.getResourceType(), energyDiagram); 
     652                        resourcePowerUsageDiagrams.put(powerUsage.getResourceType(), energyDiagram); 
    633653                } else { 
    634654                        energyDiagram.add(dataset); 
     
    637657        } 
    638658 
     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         
    639675        private XYDataset createResourceEnergyGanttDataSet( 
    640676                        ResourceEnergyStats energyUsage, long start, long end) { 
     
    665701        } 
    666702 
     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        } 
    667729 
    668730        private boolean saveResourceGanttDiagrams() { 
     
    670732                JFreeChart peDiagram = null; 
    671733                JFreeChart resourceEnergyDiagram = null; 
     734                JFreeChart resourceAirFlowDiagram = null; 
    672735                if (!generateDiagrams) 
    673736                        return false; 
     
    701764                } 
    702765                if (configuration.creatediagrams_energyusage) { 
    703                         for(ResourceType resType: resourceEnergyDiagrams.keySet()){ 
     766                        for(ResourceType resType: resourcePowerUsageDiagrams.keySet()){ 
    704767                                resourceEnergyDiagram = getResourcesEnergyDiagram(resType, chartName, 
    705768                                                subtitle, simulationTime); 
     
    708771                        } 
    709772                } 
     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                } 
    710783                return true; 
    711784        } 
     
    713786        private JFreeChart getResourcesLoadDiagram(ResourceType resType, String chartName, Title subtitle, 
    714787                        String simulationTime) { 
    715                 String cpu = "CPU"; 
     788                String cpu = "UTILIZATION [%]"; 
    716789                boolean urls = false; 
    717790                boolean tooltip = true; 
     
    750823                DateAxis xAxis = new DateAxis(simulationTime); 
    751824 
    752                 List<XYDataset> energyDiagram = resourceEnergyDiagrams.get(resType); 
     825                List<XYDataset> energyDiagram = resourcePowerUsageDiagrams.get(resType); 
    753826                for (XYDataset dataset : energyDiagram) { 
    754827 
     
    759832                        XYPlot tPlot = tChart.getXYPlot(); 
    760833                        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); 
    761865                        yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 
    762866                        tPlot.setRangeAxis(yAxis); 
     
    870974                XYSeriesCollection dataset = new XYSeriesCollection(); 
    871975                XYSeries data = new XYSeries(resStats.resourceName, false, true); 
    872                 Map<Long, Integer> usage = resStats.getUsage(); 
     976                Map<Long, Double> usage = resStats.getUsage(); 
    873977                 
    874978                for (Long key : usage.keySet()) { 
    875                         Integer val = 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)); 
    879983                } 
    880984                dataset.addSeries(data); 
     
    9501054        } 
    9511055         
     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         
    9521077        /*private void createPEGanttDiagram(String peName, 
    9531078                        String uniqueTaskID, Map<String, Object> historyItem) { 
     
    10061131                        Job job = (Job) jobs.get(i); 
    10071132 
    1008                         //List<TaskInterface> execList = JobRegistry.getInstance("COMPUTING_GRID_0#BROKER").getAllSubmittedTasks(); 
    10091133                        List<Executable> execList = jr.getExecutableTasks().getJobExecutables(job.getId()); 
    10101134                        List<TaskStats> taskStatsList = new ArrayList<TaskStats>(); 
     
    13461470                statsData.put(RESOURCES_RESERVATION_LOAD, accStats.meanEnergyUsage); 
    13471471                statsData.put(RESOURCES_QUEUE_LENGTH, accStats.meanQueueLength); 
    1348  
    13491472        } 
    13501473 
     
    14171540        chartLoad, 
    14181541        textEnergy, 
    1419         chartEnergy; 
     1542        chartEnergy, 
     1543        textAirFlow, 
     1544        chartAirFlow; 
    14201545} 
  • DCWoRMS/trunk/src/simulator/stats/implementation/GSSAccumulatorsStats.java

    r477 r495  
    1010        public GSSAccumulator meanQueueLength; 
    1111        public GSSAccumulator meanEnergyUsage; 
     12        public GSSAccumulator meanAirFlow; 
    1213 
    1314        public GSSAccumulator meanTaskStartTime; 
     
    2930                meanReservationLoad = new GSSAccumulator(); 
    3031                meanQueueLength = new GSSAccumulator(); 
    31                 meanEnergyUsage = new GSSAccumulator(); 
     32                meanEnergyUsage = new GSSAccumulator();  
     33                meanAirFlow = new GSSAccumulator();  
    3234 
    3335                meanTaskStartTime = new GSSAccumulator(); 
  • DCWoRMS/trunk/src/simulator/stats/implementation/ResourceUsageStats.java

    r477 r495  
    1515public class ResourceUsageStats implements StatsInterface { 
    1616 
    17         protected Map<Long, Integer> usage; 
     17        protected Map<Long, Double> usage; 
    1818        protected String resourceName; 
    1919        protected String usageType; 
     
    3131                this.resourceType = resourceType; 
    3232                this.usageType = usageType; 
    33                 this.usage = new TreeMap<Long, Integer>(); 
     33                this.usage = new TreeMap<Long, Double>(); 
    3434                this.meanUsage = 0; 
    3535        } 
     
    5151        }        
    5252 
    53         public Map<Long, Integer> getUsage() { 
     53        public Map<Long, Double> getUsage() { 
    5454                return this.usage; 
    5555        } 
  • DCWoRMS/trunk/src/simulator/stats/implementation/out/StatsSerializer.java

    r477 r495  
    44import simulator.stats.implementation.GSSAccumulatorsStats; 
    55import simulator.stats.implementation.JobStats; 
     6import simulator.stats.implementation.ResourceAirFlowStats; 
    67import simulator.stats.implementation.ResourceEnergyStats; 
    78import simulator.stats.implementation.ResourceStats; 
     
    2829        public Object visit(ResourceEnergyStats arg); 
    2930 
     31        public Object visit(ResourceAirFlowStats arg); 
    3032         
    3133        public Object visit(GSSAccumulatorsStats arg); 
  • DCWoRMS/trunk/src/simulator/stats/implementation/out/StringSerializer.java

    r477 r495  
    1111import simulator.stats.implementation.GSSAccumulatorsStats; 
    1212import simulator.stats.implementation.JobStats; 
     13import simulator.stats.implementation.ResourceAirFlowStats; 
    1314import simulator.stats.implementation.ResourceEnergyStats; 
    1415import simulator.stats.implementation.ResourceStats; 
     
    258259 
    259260        public Object visit(ResourceUsageStats resourceUsageStats) { 
    260                 Map<Long, Integer> resourceUsage = resourceUsageStats.getUsage(); 
     261                Map<Long, Double> resourceUsage = resourceUsageStats.getUsage(); 
    261262                 
    262263                int mapSize = resourceUsage.size(); 
     
    297298                        buffer.append(resourceUsageStats.getResourceName()); 
    298299                        buffer.append(fieldSeparator); 
    299                         Integer value = resourceUsage.get(timestamp); 
     300                        Double value = resourceUsage.get(timestamp); 
    300301                        buffer.append(timestamp); 
    301302                        buffer.append(fieldSeparator); 
     
    371372        } 
    372373 
     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 
    373432        public Object visit(GSSAccumulatorsStats accStats) { 
    374433 
Note: See TracChangeset for help on using the changeset viewer.