Changeset 1207


Ignore:
Timestamp:
11/26/13 11:56:07 (11 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/branches/coolemall/src
Files:
43 added
1 deleted
86 edited
3 copied
3 moved

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/ExecTask.java

    r1191 r1207  
    55import schedframe.scheduling.tasks.TaskInterface; 
    66import schedframe.scheduling.tasks.phases.ResourceConsumption; 
     7import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile; 
    78import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
    89 
     
    1516        public List<String> getVisitedResources(); 
    1617         
     18        public ResourceConsumptionProfile getResourceConsumptionProfile(); 
    1719        public ResourceConsumption getCurrentResourceConsumption(); 
    1820} 
  • DCWoRMS/branches/coolemall/src/dcworms/schedframe/scheduling/Executable.java

    r1157 r1207  
    22 
    33 
     4import example.energy.coolemall.CoolEmAllTestbedMeasurements; 
    45import gridsim.GridSim; 
    56import gridsim.dcworms.DCWormsTags; 
     
    78import java.util.ArrayList; 
    89import java.util.HashMap; 
     10import java.util.LinkedList; 
    911import java.util.List; 
    1012import java.util.Map; 
     
    1416import org.joda.time.DateTimeUtilsExt; 
    1517import org.joda.time.ReadableDuration; 
     18import org.qcg.broker.schemas.resreqs.ResourceConsumptionProfileType; 
     19import org.qcg.broker.schemas.resreqs.ResourceConsumptionType; 
     20import org.qcg.broker.schemas.resreqs.StringParameterType; 
    1621 
    1722import qcg.shared.constants.BrokerConstants; 
    1823 
    1924import schedframe.resources.computing.ComputingResource; 
     25import schedframe.resources.units.PEUnit; 
    2026import schedframe.resources.units.ProcessingElements; 
    2127import schedframe.resources.units.StandardResourceUnitName; 
     
    3036import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile; 
    3137import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
     38import simulator.stats.implementation.ResourceUsefulWorkStats; 
    3239 
    3340/** 
     
    6067        protected double finishTime;  
    6168         
     69        private ResourceConsumptionProfile resourceConsumptionProfile; 
     70         
    6271        public Executable(Task t){ 
    6372                this.task = t; 
     
    8392                this.submissionTime =  currentTime; 
    8493        this.totalCompletionTime = 0.0; 
     94        preparePhases(null); 
    8595         } 
    8696         
     
    168178         
    169179        if(status == DCWormsTags.INEXEC){ 
     180                loadResourceConsumptionProfile(); 
    170181                task.setStatus((int) BrokerConstants.TASK_STATUS_RUNNING); 
    171182        } else if(status == DCWormsTags.QUEUED){ 
     
    202213                for (ComputingResource resource : pes) { 
    203214 
    204                         trackResource(resource.getName()); 
     215                        trackResource(resource.getFullName()); 
    205216                         
    206217                        ComputingResource parent = resource.getParent(); 
    207218                                List<String> visitedResource = getVisitedResources(); 
    208219                                String [] visitedResourcesArray = visitedResource.toArray(new String[visitedResource.size()]); 
    209                         while (parent != null && !ArrayUtils.contains(visitedResourcesArray, parent.getName())) { 
    210                                 trackResource(parent.getName()); 
     220                        while (parent != null && !ArrayUtils.contains(visitedResourcesArray, parent.getFullName())) { 
     221                                trackResource(parent.getFullName()); 
    211222                                parent = parent.getParent(); 
    212223                        } 
     
    218229                        status = DCWormsTags.INEXEC; 
    219230                        setCompletionPercentage(0); 
    220                         task.getResourceConsumptionProfile().setCurrentPhase(task.getResourceConsumptionProfile().getCurrentPhase() + 1); 
     231                        resourceConsumptionProfile.setCurrentPhase(resourceConsumptionProfile.getCurrentPhase() + 1); 
    221232                         
    222233                        DateTime currentDateTime = new DateTime(); 
     
    386397         
    387398        public ResourceConsumptionProfile getResourceConsumptionProfile(){ 
    388                 return task.getResourceConsumptionProfile(); 
     399                return resourceConsumptionProfile; 
    389400        } 
    390401 
    391402        public ResourceConsumption getCurrentResourceConsumption(){ 
    392                 return task.getResourceConsumptionProfile().getCurrentResourceConsumption(); 
     403                return resourceConsumptionProfile.getCurrentResourceConsumption(); 
    393404        } 
    394405         
     
    396407                return task.getApplicationName(); 
    397408        } 
    398  
     409         
     410        private void preparePhases(String resourceType) { 
     411                LinkedList<ResourceConsumption> resourceConsumptionList = new LinkedList<ResourceConsumption>(); 
     412                 
     413                long usefulWork = -1; 
     414                 
     415                if(task.getDescription().getExecution() == null || task.getDescription().getExecution().getResourceConsumptionProfile() == null 
     416                                || task.getDescription().getExecution().getResourceConsumptionProfile().length == 0 ){ 
     417                        ResourceConsumption resConsumption = null; 
     418                        try { 
     419                                resConsumption = new ResourceConsumption(getLength(), task.getComputingResourceRequirements()); 
     420                        } catch (NoSuchFieldException e) { 
     421                                // TODO Auto-generated catch block 
     422                                e.printStackTrace(); 
     423                        } 
     424                        resourceConsumptionList.add(resConsumption); 
     425                }else{ 
     426                        boolean found = false; 
     427                        if(resourceType != null){ 
     428                                for(ResourceConsumptionProfileType resConsumptioProfile: task.getDescription().getExecution().getResourceConsumptionProfile()){ 
     429                                        if(resConsumptioProfile.getType() != null && resConsumptioProfile.getType().equals(resourceType)){ 
     430                                                for(ResourceConsumptionType resConsumption: resConsumptioProfile.getResourceConsumption()){ 
     431                                                        ResourceConsumption resourceConsumption = new ResourceConsumption(resConsumption); 
     432                                                        resourceConsumptionList.add(resourceConsumption); 
     433                                                } 
     434                                                for(StringParameterType prop: resConsumptioProfile.getProperties()){ 
     435                                                        if(prop.getName().equals("usefulWork")){ 
     436                                                                usefulWork = Double.valueOf(prop.getContent()).longValue(); 
     437                                                                break; 
     438                                                        } 
     439                                                } 
     440                                                found = true; 
     441                                                break; 
     442                                        } 
     443                                }        
     444                        }                        
     445                        if(!found){ 
     446                                for(ResourceConsumptionType resConsumption: task.getDescription().getExecution().getResourceConsumptionProfile()[0].getResourceConsumption()){ 
     447                                        ResourceConsumption resourceConsumption = new ResourceConsumption(resConsumption); 
     448                                        resourceConsumptionList.add(resourceConsumption); 
     449                                } 
     450                                 
     451                                for(StringParameterType prop: task.getDescription().getExecution().getResourceConsumptionProfile()[0].getProperties()){ 
     452                                        if(prop.getName().equals("usefulWork")){ 
     453                                                usefulWork = Double.valueOf(prop.getContent()).longValue(); 
     454                                                break; 
     455                                        } 
     456                                } 
     457                        } 
     458                } 
     459                 
     460                usefulWork = (usefulWork != -1) ? usefulWork : this.getLength(); 
     461                this.resourceConsumptionProfile = new ResourceConsumptionProfile(resourceConsumptionList); 
     462                this.resourceConsumptionProfile.setUsefulWork(usefulWork); 
     463 
     464        } 
     465 
     466        private boolean loadResourceConsumptionProfile(){ 
     467 
     468                PEUnit peUnit = (PEUnit)getUsedResources().getLast().getResourceUnits() 
     469                                .get(StandardResourceUnitName.PE); 
     470                if(peUnit instanceof ProcessingElements){ 
     471                        ProcessingElements pes = (ProcessingElements) peUnit; 
     472                        for (ComputingResource resource : pes) { 
     473                                while(resource != null && resource.getResourceCharacteristic().getParameters().get("product") == null){ 
     474                                        resource = resource.getParent(); 
     475                                } 
     476                                if(resource != null) { 
     477                                        String productName = resource.getResourceCharacteristic().getParameters().get("product").get(0).getContent(); 
     478                                        if(productName.equals("Fusion G - T40N")) 
     479                                                preparePhases("amdf"); 
     480                                        else if(productName.equals("Atom - D510")) 
     481                                                preparePhases("atom64"); 
     482                                        else if(productName.equals("Atom - N2600")) 
     483                                                preparePhases("atom64"); 
     484                                        else if(productName.equals("Core i7 - 2715QE")) 
     485                                                preparePhases("i7-2715QE"); 
     486                                        else if(productName.equals("Core i7 - 3615QE")) 
     487                                                preparePhases("i7-3615QE"); 
     488                                } 
     489                                return true; 
     490                        } 
     491                } 
     492                return false; 
     493                 
     494        } 
    399495} 
  • DCWoRMS/branches/coolemall/src/example/energy/BaseEnergyEstimationPlugin.java

    r751 r1207  
    33import schedframe.Parameters; 
    44import schedframe.PluginConfiguration; 
    5 import schedframe.resources.computing.ComputingResource; 
    65import schedframe.resources.computing.profiles.energy.EnergyEvent; 
    76import schedframe.resources.computing.profiles.energy.power.plugin.EnergyEstimationPlugin; 
     7import schedframe.resources.devices.PhysicalResource; 
    88import schedframe.scheduling.manager.tasks.JobRegistry; 
    99 
     
    1717         
    1818        @Override 
    19         public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) { 
     19        public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) { 
    2020                throw new RuntimeException("Not implemented."); 
    2121        } 
    2222 
    2323        @Override 
    24         public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) { 
     24        public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) { 
    2525                throw new RuntimeException("Not implemented."); 
    2626        } 
  • DCWoRMS/branches/coolemall/src/example/energy/DataCenterEnergyEstimationPlugin.java

    r520 r1207  
    22 
    33import schedframe.resources.computing.ComputingNode; 
    4 import schedframe.resources.computing.ComputingResource; 
    54import schedframe.resources.computing.DataCenter; 
    65import schedframe.resources.computing.profiles.energy.EnergyEvent; 
    76import schedframe.resources.computing.profiles.energy.power.PowerUsage; 
     7import schedframe.resources.devices.PhysicalResource; 
    88import schedframe.scheduling.manager.tasks.JobRegistry; 
    99 
     
    1212        @Override 
    1313        public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, 
    14                         ComputingResource resource) { 
     14                        PhysicalResource resource) { 
    1515                double power = 0; 
    1616                DataCenter dataCenter = (DataCenter)resource; 
  • DCWoRMS/branches/coolemall/src/example/energy/DefaultEnergyEstimationPlugin.java

    r546 r1207  
    33import schedframe.resources.computing.ComputingResource; 
    44import schedframe.resources.computing.profiles.energy.EnergyEvent; 
     5import schedframe.resources.devices.PhysicalResource; 
    56import schedframe.scheduling.manager.tasks.JobRegistry; 
    67 
     
    910 
    1011 
    11         public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) { 
     12        public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) { 
    1213                double powerConsumption = 0; 
    1314                try { 
     
    1718                } 
    1819                 
    19                 powerConsumption = powerConsumption + getChildrenPowerConsumption(resource); 
    20                  
    21                 for(ComputingResource child:resource.getChildren()){ 
    22                         try { 
    23                                 //powerConsumption = powerConsumption + child.getPowerInterface().getRecentPowerUsage().getValue();  
    24                         } catch (Exception e) { 
     20                ComputingResource cr = (ComputingResource) resource; 
     21                powerConsumption = powerConsumption + getChildrenPowerConsumption(cr); 
    2522 
    26                         } 
    27                 } 
    2823                return powerConsumption; 
    2924        } 
  • DCWoRMS/branches/coolemall/src/example/energy/NodeEnergyEstimationPlugin.java

    r532 r1207  
    22 
    33import schedframe.resources.computing.ComputingNode; 
    4 import schedframe.resources.computing.ComputingResource; 
    54import schedframe.resources.computing.Processor; 
    65import schedframe.resources.computing.profiles.energy.EnergyEvent; 
     6import schedframe.resources.devices.Device; 
     7import schedframe.resources.devices.PhysicalResource; 
    78import schedframe.scheduling.manager.tasks.JobRegistry; 
    89 
    9 public class ComputingNodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin { 
     10public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin { 
    1011 
    1112        public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, 
    12                         ComputingResource resource) { 
     13                        PhysicalResource resource) { 
    1314                double powerConsumption = 0; 
    1415                ComputingNode node = (ComputingNode) resource; 
     
    2223                try { 
    2324                        powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState()); 
     25                        for(Device dev: node.getResourceCharacteristic().getDevices()){ 
     26                                powerConsumption = powerConsumption + dev.getPowerInterface().getRecentPowerUsage().getValue(); 
     27                        } 
    2428                } catch (NoSuchFieldException e) { 
    2529                } 
  • DCWoRMS/branches/coolemall/src/example/energy/ProcessorEnergyEstimationPlugin.java

    r901 r1207  
    22 
    33import schedframe.resources.ResourceStatus; 
    4 import schedframe.resources.computing.ComputingResource; 
    54import schedframe.resources.computing.Processor; 
    65import schedframe.resources.computing.profiles.energy.EnergyEvent; 
    76import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 
     7import schedframe.resources.devices.PhysicalResource; 
    88import schedframe.scheduling.manager.tasks.JobRegistry; 
    99 
     
    1111 
    1212        public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, 
    13                         ComputingResource resource) { 
     13                        PhysicalResource resource) { 
    1414                double powerConsumption; 
     15 
    1516                Processor cpu = (Processor)resource; 
    1617                if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) 
  • DCWoRMS/branches/coolemall/src/example/energy/coolemall/CB1EnergyEstimationPlugin.java

    r913 r1207  
    11package example.energy.coolemall; 
    22 
    3 import schedframe.Parameter; 
    4 import schedframe.resources.computing.ComputingResource; 
     3import schedframe.resources.computing.coolemall.ComputeBox1; 
     4import schedframe.resources.computing.coolemall.NodeGroup; 
    55import schedframe.resources.computing.profiles.energy.EnergyEvent; 
    6 import schedframe.resources.computing.recs.ComputeBox1; 
    7 import schedframe.resources.computing.recs.NodeGroup; 
     6import schedframe.resources.devices.PhysicalResource; 
    87import schedframe.scheduling.manager.tasks.JobRegistry; 
    98import example.energy.BaseEnergyEstimationPlugin; 
     
    1211 
    1312        public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, 
    14                         ComputingResource resource) { 
     13                        PhysicalResource resource) { 
    1514                double powerConsumption = 0; 
    1615                ComputeBox1 computeBox1 = (ComputeBox1)resource; 
     
    2221                        } 
    2322                } 
    24  
    25                 try { 
    26                         powerConsumption = powerConsumption + computeBox1.getPowerInterface().getPowerConsumption(computeBox1.getPowerInterface().getPowerState()); 
    27                 } catch (NoSuchFieldException e) { 
    28                         Parameter param = computeBox1.getResourceCharacteristic().getParameters().get("maxPower"); 
    29                         if(param != null) 
    30                                 powerConsumption = powerConsumption + Double.valueOf(param.get(0).getContent()); 
    31                 } 
    32  
    33                  
     23                powerConsumption = (powerConsumption + CoolEmAllTestbedMeasurements.OTHER_DEVICES_POWER_CONSUMPTION)/CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY; 
    3424                return powerConsumption; 
    3525        } 
  • DCWoRMS/branches/coolemall/src/example/energy/coolemall/NodeEnergyEstimationPlugin.java

    r1146 r1207  
    11package example.energy.coolemall; 
    22 
    3 import schedframe.Parameter; 
    4 import schedframe.events.scheduling.EventReason; 
    5 import schedframe.resources.computing.ComputingResource; 
    63import schedframe.resources.computing.Processor; 
     4import schedframe.resources.computing.coolemall.Node; 
    75import schedframe.resources.computing.profiles.energy.EnergyEvent; 
    8 import schedframe.resources.computing.recs.Node; 
     6import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 
     7import schedframe.resources.devices.Device; 
     8import schedframe.resources.devices.PhysicalResource; 
    99import schedframe.scheduling.manager.tasks.JobRegistry; 
     10import testbed_hpc.Node_Fan_Mapping; 
    1011import example.energy.BaseEnergyEstimationPlugin; 
    1112 
    1213public class NodeEnergyEstimationPlugin extends BaseEnergyEstimationPlugin { 
    1314 
    14         private static int OUT_START_ID = 0; 
    15         private static int OUT_END_ID = 8; 
     15        //private static int OUT_START_ID = 0; 
     16        //private static int OUT_END_ID = 8; 
    1617         
    1718        public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, 
    18                         ComputingResource resource) { 
     19                        PhysicalResource resource) { 
    1920                double powerConsumption = 0; 
    2021                Node node = (Node) resource; 
     
    2627                        } 
    2728                } 
    28                 try { 
    29                         powerConsumption = powerConsumption + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState()); 
    30                 } catch (NoSuchFieldException e) { 
    31                         Parameter param = node.getResourceCharacteristic().getParameters().get("maxPower"); 
    32                         if(param != null) 
    33                                 powerConsumption = powerConsumption + Double.valueOf(param.get(0).getContent()); 
    34                 } 
     29                if(node.getPowerInterface().getPowerState().equals(StandardPowerStateName.ON)){ 
     30                        //powerConsumption = powerConsumption + CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION; 
     31                        for(Device device: node.getParent().getResourceCharacteristic().getDevices()){ 
     32                                if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){ 
     33                                        if(device.getPowerInterface().getRecentPowerUsage().getValue() == -1){ 
     34                                                powerConsumption = powerConsumption + CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION; 
     35                                        }else 
     36                                                powerConsumption = powerConsumption + device.getPowerInterface().getRecentPowerUsage().getValue(); 
     37                                        break; 
     38                                } 
     39                        } 
     40                }  
     41 
    3542 
    3643                return powerConsumption; 
    3744        } 
    3845 
    39         public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) { 
     46        /*public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) { 
    4047 
    4148                double airThroughput = 0; 
     
    4451                                return airThroughput; 
    4552                                //airThroughput = resource.getAirThroughputInterface().getAirFlow(StandardAirThroughputStateName.FAN_OFF); 
    46                         else 
     53                        else { 
    4754                                airThroughput = resource.getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState()); 
     55                                //airThroughput = computingResource.getResourceCharacteristic().getDevices().get(0).getAirThroughputInterface().getAirFlow(resource.getAirThroughputInterface().getAirThroughputState()); 
     56                                //airThroughput = 0.28; 
     57                        } 
    4858                } catch (NoSuchFieldException e) { 
    4959                        // TODO Auto-generated catch block 
     
    5161                } 
    5262                 
    53                 Integer resId = Integer.parseInt(resource.getName().split("_")[1]); 
     63                //Integer resId = Integer.parseInt(resource.getName().split("_")[1]); 
     64                //ComputingResource computingResource = (ComputingResource) resource; 
    5465                //we estimate the air flow related to the outlets (nodes placed in the outlet row of RECS) 
    55                 if(resId >= OUT_START_ID  && resId <= OUT_END_ID){ 
    56                         for(ComputingResource compResource: resource.getParent().getChildren()){ 
    57                                 Integer id = Integer.parseInt(compResource.getName().split("_")[1]); 
    58                                 //we take into account the inlet air flow (nodes placed "behind" the given node) 
    59                                 if(id - resId == 9 || id - resId == -9){ 
    60                                         try { 
    61                                                 airThroughput = airThroughput + compResource.getAirThroughputInterface().getAirFlow(compResource.getAirThroughputInterface().getAirThroughputState())/2; 
    62                                         } catch (NoSuchFieldException e) { 
    63                  
    64                                         } 
    65                                 } 
    66                         } 
    67                 } 
     66                //if(resId >= OUT_START_ID  && resId <= OUT_END_ID){ 
     67                //      for(ComputingResource compResource: computingResource.getParent().getChildren()){ 
     68                //              Integer id = Integer.parseInt(compResource.getName().split("_")[1]); 
     69                //              //we take into account the inlet air flow (nodes placed "behind" the given node) 
     70                //              if(id - resId == 9 || id - resId == -9){ 
     71                //                      try { 
     72                //                              airThroughput = airThroughput + compResource.getAirThroughputInterface().getAirFlow(compResource.getAirThroughputInterface().getAirThroughputState())/2; 
     73                //                      } catch (NoSuchFieldException e) { 
     74                // 
     75                //                      } 
     76                //              } 
     77                //      } 
     78                //} 
    6879 
    6980                return airThroughput; 
    70         } 
     81        }*/ 
    7182 
    72         public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource) { 
     83        /*public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource) { 
    7384                double tout = 0; 
    7485                double tin = 21.3; 
     
    8394                Integer resId = Integer.parseInt(resource.getName().split("_")[1]); 
    8495                 
     96                ComputingResource computingResource = (ComputingResource) resource; 
     97                 
    8598                //we estimate outlet temperature (related to the temperature of the nodes placed in outlet row) 
    86                 for(ComputingResource compResource: resource.getParent().getChildren()){ 
     99                for(ComputingResource compResource: computingResource.getParent().getChildren()){ 
    87100                        Integer id = Integer.parseInt(compResource.getName().split("_")[1]); 
    88101                        //we take into account the power of nodes placed "behind" the given nodes 
     
    98111                tout = tin + delta1 * (power1/(Q * C * ro)) +  delta2 * (power2/(Q * C * ro));; 
    99112                return tout; 
    100         } 
     113        }*/ 
    101114         
    102115} 
  • DCWoRMS/branches/coolemall/src/example/energy/coolemall/NodeGroupEnergyEstimationPlugin.java

    r913 r1207  
    11package example.energy.coolemall; 
    22 
    3 import schedframe.Parameter; 
    4 import schedframe.resources.computing.ComputingResource; 
     3import schedframe.resources.computing.coolemall.Node; 
     4import schedframe.resources.computing.coolemall.NodeGroup; 
    55import schedframe.resources.computing.profiles.energy.EnergyEvent; 
    6 import schedframe.resources.computing.recs.Node; 
    7 import schedframe.resources.computing.recs.NodeGroup; 
     6import schedframe.resources.devices.PhysicalResource; 
    87import schedframe.scheduling.manager.tasks.JobRegistry; 
    98import example.energy.BaseEnergyEstimationPlugin; 
     
    1211 
    1312        public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, 
    14                         ComputingResource resource) { 
     13                        PhysicalResource resource) { 
     14                 
    1515                double powerConsumption = 0; 
    1616                NodeGroup nodeGroup = (NodeGroup)resource; 
    17                 for(Node cn: nodeGroup.getNodes()){ 
     17                for(Node node: nodeGroup.getNodes()){ 
    1818                        try{ 
    19                                 powerConsumption = powerConsumption + cn.getPowerInterface().getRecentPowerUsage().getValue(); 
     19                                powerConsumption = powerConsumption + node.getPowerInterface().getRecentPowerUsage().getValue(); 
    2020                        } catch (Exception e){ 
    21                                  
    2221                        } 
    23                 } 
    24                 try { 
    25                         powerConsumption = powerConsumption + nodeGroup.getPowerInterface().getPowerConsumption(nodeGroup.getPowerInterface().getPowerState()); 
    26                 } catch (NoSuchFieldException e) { 
    27                         Parameter param = nodeGroup.getResourceCharacteristic().getParameters().get("maxPower"); 
    28                         if(param != null) 
    29                                 powerConsumption = powerConsumption + Double.valueOf(param.get(0).getContent()); 
    3022                } 
    3123 
  • DCWoRMS/branches/coolemall/src/example/energy/coolemall/ProcessorEnergyEstimationPlugin.java

    r913 r1207  
    11package example.energy.coolemall; 
    22 
    3 import schedframe.Parameter; 
     3import dcworms.schedframe.scheduling.ExecTask; 
    44import schedframe.resources.ResourceStatus; 
    5 import schedframe.resources.computing.ComputingResource; 
     5import schedframe.resources.computing.Core; 
    66import schedframe.resources.computing.Processor; 
    77import schedframe.resources.computing.profiles.energy.EnergyEvent; 
    88import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 
     9import schedframe.resources.devices.PhysicalResource; 
    910import schedframe.scheduling.manager.tasks.JobRegistry; 
     11import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
     12import schedframe.scheduling.tasks.phases.PhaseBehaviour; 
    1013import example.energy.BaseEnergyEstimationPlugin; 
    1114 
     
    1316 
    1417        public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, 
    15                         ComputingResource resource) { 
    16                 double powerConsumption = 0; 
     18                        PhysicalResource resource) { 
     19                 
     20                /*double powerConsumption = 0; 
    1721                Processor cpu = (Processor)resource; 
    1822                if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) 
     
    3842                        } 
    3943                } 
     44                return powerConsumption;*/ 
     45                double powerConsumption = 0; 
     46                Processor proc = (Processor)resource; 
     47                if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) 
     48                        return 0; 
     49                else { 
     50                        double processorLoad; 
     51                        double sumCoresLoad = 0; 
     52                         
     53                        int nrOfThreadsOnCpu = 1; 
     54                         
     55                        if(proc.getResourceCharacteristic().getParameters().get("product") != null){ 
     56                                String productName = proc.getResourceCharacteristic().getParameters().get("product").get(0).getContent(); 
     57                                if(productName.equals("Fusion G - T40N")) 
     58                                        nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Fusion_G_T40N_NR_OF_THREADS; 
     59                                else if(productName.equals("Atom - D510")) 
     60                                        nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Atom_D510_NR_OF_THREADS; 
     61                                else if(productName.equals("Atom - N2600")) 
     62                                        nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Atom_N2600_NR_OF_THREADS; 
     63                                else if(productName.equals("Core i7 - 2715QE")) 
     64                                        nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Core_i7_2715QE_NR_OF_THREADS; 
     65                                else if(productName.equals("Core i7 - 3615QE")) 
     66                                        nrOfThreadsOnCpu = CoolEmAllTestbedMeasurements.Core_i7_3615QE_NR_OF_THREADS; 
     67                        } 
     68 
     69                        for(Core core: proc.getCores()){ 
     70                                 
     71                                if(core.getStatus().equals(ResourceStatus.BUSY)){ 
     72                                        JobRegistry jr = new JobRegistryImpl(core.getFullName()); 
     73                                        for(ExecTask task: jr.getRunningTasks()){ 
     74                                                double cpuUsage = 100; 
     75                                                double nrOfThreadsOfApplciation = 1; 
     76                                                for(PhaseBehaviour pb: task.getCurrentResourceConsumption().getBehaviourList()){ 
     77                                                        if(pb.getResouceName().equals("PM_CPU_Usage")){ 
     78                                                                cpuUsage = pb.getUtilization(); 
     79                                                        } 
     80                                                        if(pb.getResouceName().equals("PM_Threads")){ 
     81                                                                nrOfThreadsOfApplciation = pb.getUtilization(); 
     82                                                                break; 
     83                                                        } 
     84                                                } 
     85                                                sumCoresLoad = sumCoresLoad + cpuUsage * (nrOfThreadsOnCpu / nrOfThreadsOfApplciation); 
     86                                        } 
     87                                } 
     88                        } 
     89                        processorLoad = 100 * sumCoresLoad/proc.getCores().size(); 
     90                        double lowestLoadLevel = 100; 
     91                        double highestLoadLevel = 0; 
     92                        if(proc.getPowerInterface().getPState().getLoadPowerUsage().containsKey(new Double(processorLoad))){ 
     93                                powerConsumption = proc.getPowerInterface().getPState().getLoadPowerUsage().get(new Double(processorLoad)); 
     94                                //System.out.println("power from profile: " + powerConsumption); 
     95                        } else { 
     96                                for(Double load: proc.getPowerInterface().getPState().getLoadPowerUsage().keySet()){ 
     97                                        if(lowestLoadLevel > load){ 
     98                                                lowestLoadLevel = load; 
     99                                        } 
     100                                        if(highestLoadLevel < load){ 
     101                                                highestLoadLevel = load; 
     102                                        } 
     103                                } 
     104                                if(processorLoad == 0){ 
     105                                        try{ 
     106                                                powerConsumption = proc.getPowerInterface().getSupportedPowerStates().get(0).getPowerUsage(); 
     107                                                //System.out.println("load = 0; power = idle power usage: " + powerConsumption); 
     108                                        } catch (Exception e){ 
     109                                                powerConsumption = 0.7 * proc.getPowerInterface().getPState().getLoadPowerUsage().get(new Double(highestLoadLevel)); 
     110                                                //System.out.println("error load = 0; power = 0.7 max power: " + powerConsumption); 
     111                                        } 
     112                                } else { 
     113                                         
     114                                        double lowerLoadLevel = lowestLoadLevel; 
     115                                        double higherLoadLevel = highestLoadLevel; 
     116                                         
     117                                        try{ 
     118                                         
     119                                                for(Double load: proc.getPowerInterface().getPState().getLoadPowerUsage().keySet()){ 
     120                                                        if(processorLoad > load){ 
     121                                                                lowerLoadLevel = load; 
     122                                                        } 
     123                                                        else if(processorLoad < load){ 
     124                                                                higherLoadLevel = load; 
     125                                                                break; 
     126                                                        } 
     127                                                } 
     128                                                double powerBelow; 
     129                                                double powerAbove; 
     130                                                double a; 
     131                                                double b; 
     132                                                if(lowerLoadLevel != higherLoadLevel) 
     133                                                { 
     134                                                        powerBelow = proc.getPowerInterface().getPState().getLoadPowerUsage().get(lowerLoadLevel); 
     135                                                        powerAbove = proc.getPowerInterface().getPState().getLoadPowerUsage().get(higherLoadLevel); 
     136                                                        a = (powerAbove - powerBelow)/(higherLoadLevel - lowerLoadLevel); 
     137                                                        b = powerAbove - a * higherLoadLevel; 
     138                                                } else { 
     139                                                        powerBelow = proc.getPowerInterface().getPState().getLoadPowerUsage().get(lowestLoadLevel); 
     140                                                        powerAbove = proc.getPowerInterface().getPState().getLoadPowerUsage().get(highestLoadLevel); 
     141                                                        a = (powerAbove - powerBelow)/(highestLoadLevel - lowestLoadLevel); 
     142                                                        b = powerAbove - a * highestLoadLevel; 
     143                                                } 
     144                                                powerConsumption = a * processorLoad + b; 
     145                                                /*System.out.println("a" +lowestLoadLevel + ";" +highestLoadLevel); 
     146                                                System.out.println("b" +lowerLoadLevel + ";" +higherLoadLevel); 
     147                                                System.out.println("c" +powerBelow + ";" +powerAbove); 
     148                                                System.out.println(resource.getFullName() + "load: " + processorLoad + "linear power estimation " + powerConsumption);*/ 
     149         
     150                                        } catch (Exception e){ 
     151                                                powerConsumption = 0.7 * proc.getPowerInterface().getPState().getLoadPowerUsage().get(new Double(highestLoadLevel));     
     152                                                //System.out.println("error; power = 0.7 max power: " + powerConsumption); 
     153                                        } 
     154                                } 
     155                        } 
     156                } 
     157                         
     158 
     159                powerConsumption = powerConsumption - CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION; 
     160                //System.out.println("estiamted power consumption: " + powerConsumption); 
    40161                return powerConsumption; 
    41162        } 
  • DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ClusterPlugin.java

    r575 r1207  
    145145                List<ComputingResource> nodes; 
    146146                Properties properties = new Properties(); 
    147                 properties.setProperty("type", StandardResourceType.ComputingNode.getName()); 
     147                properties.setProperty("type", StandardResourceType.Node.getName()); 
    148148                // properties.setProperty("status", ResourceStatus.FREE.toString()); 
    149149                nodes = (List<ComputingResource>) unitsManager.filterResources(properties); 
    150150                 
    151151                //always return the same node from the list 
    152                 return nodes.get(0).getName(); 
     152                return nodes.get(0).getFullName(); 
    153153        } 
    154154 
  • DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_ConsolidationClusterPlugin.java

    r574 r1207  
    9898                                } 
    9999                        } 
    100                         ProcessingElements result = new ProcessingElements(node.getName()); 
     100                        ProcessingElements result = new ProcessingElements(node.getFullName()); 
    101101                        result.addAll(choosenResources); 
    102102                        map.put(StandardResourceUnitName.PE, result); 
  • DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_FanManagementClusterPlugin.java

    r778 r1207  
    88 
    99import schedframe.events.scheduling.SchedulingEvent; 
     10import schedframe.resources.StandardResourceType; 
    1011import schedframe.resources.computing.ComputingNode; 
    1112import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName; 
    1213import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName; 
     14import schedframe.resources.devices.Device; 
    1315import schedframe.scheduling.manager.resources.ClusterResourceManager; 
    1416import schedframe.scheduling.manager.resources.ResourceManager; 
     
    5456                                        if (node != null) { 
    5557                                                //if there are two or more tasks ( running on the given node then 
    56                                                 if(new JobRegistryImpl(node.getName()).getRunningTasks().size() > 0) 
    57                                                         node.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO")); 
    58                                                 else  
    59                                                         node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON); 
     58                                                if(new JobRegistryImpl(node.getFullName()).getRunningTasks().size() > 0){ 
     59                                                        List<Device> devices = node.getResourceCharacteristic().getDevices(); 
     60                                                        for(Device dev : devices){ 
     61                                                                if(dev.getType().equals(StandardResourceType.Fan)){ 
     62                                                                        dev.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO")); 
     63                                                                } 
     64                                                        } 
     65                                                } 
     66                                                else { 
     67                                                        List<Device> devices = node.getResourceCharacteristic().getDevices(); 
     68                                                        for(Device dev : devices){ 
     69                                                                if(dev.getType().equals(StandardResourceType.Fan)){ 
     70                                                                        dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.ON);        
     71                                                                } 
     72                                                        } 
     73                                                } 
    6074                                                notSelectedNodes.remove(node); 
    61                                                 addToSchedulingPlan(plan, task, node.getName()); 
     75                                                addToSchedulingPlan(plan, task, node.getFullName()); 
    6276                                        } 
    6377                                } 
     
    98112        private void adjustOtherFans(List<ComputingNode> nodes){ 
    99113                for(ComputingNode node : nodes){ 
     114                        List<Device> devices = node.getResourceCharacteristic().getDevices(); 
    100115                        if(node.getFreeProcessorsNumber() == node.getProcessorsNumber()){ 
    101                                 node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_OFF); 
    102                         } else if(new JobRegistryImpl(node.getName()).getRunningTasks().size() > 1) 
    103                                 node.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO")); 
    104                         else  
    105                                 node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON); 
     116                                for(Device dev : devices){ 
     117                                        if(dev.getType().equals(StandardResourceType.Fan)){ 
     118                                                dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.OFF); 
     119                                        } 
     120                                } 
     121                        } else if(new JobRegistryImpl(node.getFullName()).getRunningTasks().size() > 1){ 
     122                                for(Device dev : devices){ 
     123                                        if(dev.getType().equals(StandardResourceType.Fan)){ 
     124                                                dev.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("FAN_ON_TURBO")); 
     125                                        } 
     126                                } 
     127                        } 
     128                        else { 
     129                                for(Device dev : devices){ 
     130                                        if(dev.getType().equals(StandardResourceType.Fan)){ 
     131                                                dev.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.ON); 
     132                                        } 
     133                                } 
     134                        } 
    106135                } 
    107136        } 
  • DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_NodePowerManagementClusterPlugin.java

    r531 r1207  
    9090                                } 
    9191                        } 
    92                         ProcessingElements result = new ProcessingElements(nodes.get(0).getName()); 
     92                        ProcessingElements result = new ProcessingElements(nodes.get(0).getFullName()); 
    9393                        result.addAll(choosenResources); 
    9494                        map.put(StandardResourceUnitName.PE, result); 
  • DCWoRMS/branches/coolemall/src/example/localplugin/FCFSBF_RandomClusterPlugin.java

    r574 r1207  
    6161                List<ComputingNode> nodes = resourceManager.getComputingNodes(); 
    6262                int nodeIdx = rand.nextInt(nodes.size()); 
    63                 return nodes.get(nodeIdx).getName(); 
     63                return nodes.get(nodeIdx).getFullName(); 
    6464        } 
    6565 
  • DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/FCFSBF_RECS_SP.java

    r1100 r1207  
    66import schedframe.events.scheduling.SchedulingEvent; 
    77import schedframe.exceptions.ResourceException; 
    8 import schedframe.resources.CoolEmAllResourceType; 
     8import schedframe.resources.StandardResourceType; 
    99import schedframe.resources.computing.ComputingResource; 
    1010import schedframe.scheduling.manager.resources.ClusterResourceManager; 
     
    6464                List<ComputingResource> nodes = null; 
    6565                try { 
    66                         nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node); 
     66                        nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(StandardResourceType.Node); 
    6767                } catch (ResourceException e) { 
    6868                        // TODO Auto-generated catch block 
     
    7070                } 
    7171                int nodeIdx = rand.nextInt(nodes.size()); 
    72                 return nodes.get(nodeIdx).getName(); 
     72                return nodes.get(nodeIdx).getFullName(); 
    7373        } 
    7474 
  • DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/computebox1/CB1_FCFS_Random_SP.java

    r1099 r1207  
    11package example.localplugin.coolemall.computebox1; 
    22 
     3import java.util.ArrayList; 
     4import java.util.HashMap; 
    35import java.util.List; 
     6import java.util.Map; 
    47import java.util.Random; 
    58 
    69import schedframe.events.scheduling.SchedulingEvent; 
    710import schedframe.exceptions.ResourceException; 
    8 import schedframe.resources.CoolEmAllResourceType; 
     11import schedframe.resources.ResourceStatus; 
     12import schedframe.resources.StandardResourceType; 
    913import schedframe.resources.computing.ComputingResource; 
     14import schedframe.resources.computing.Core; 
     15import schedframe.resources.computing.coolemall.Node; 
     16import schedframe.resources.units.ProcessingElements; 
     17import schedframe.resources.units.ResourceUnit; 
     18import schedframe.resources.units.ResourceUnitName; 
     19import schedframe.resources.units.StandardResourceUnitName; 
    1020import schedframe.scheduling.manager.resources.ClusterResourceManager; 
    1121import schedframe.scheduling.manager.resources.ResourceManager; 
     
    1727import schedframe.scheduling.queue.TaskQueueList; 
    1828import schedframe.scheduling.tasks.TaskInterface; 
     29import testbed_hpc.Node_Fan_Mapping; 
    1930import example.localplugin.BaseLocalSchedulingPlugin; 
    2031import gridsim.dcworms.DCWormsTags; 
     
    2637        public CB1_FCFS_Random_SP () { 
    2738                rand = new Random(47); 
     39                Node_Fan_Mapping.init(); 
    2840        } 
    2941 
     
    4961                                if (task.getStatus() == DCWormsTags.READY) { 
    5062 
    51                                         String nodeName = chooseRandomProvider(resourceManager); 
    52                                         if (nodeName != null) { 
    53                                                 addToSchedulingPlan(plan, task, nodeName); 
     63                                        Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 
     64                                        if (choosenResources != null) { 
     65                                                addToSchedulingPlan(plan, task, choosenResources); 
    5466                                        } 
    5567                                } 
     
    6173 
    6274        @SuppressWarnings("unchecked") 
    63         private String chooseRandomProvider(ClusterResourceManager resourceManager) { 
    64                 List<ComputingResource> nodes = null; 
     75        private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution( 
     76                        ClusterResourceManager resourceManager, TaskInterface<?> task) { 
     77 
     78                Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(); 
     79                 
     80                List<Node> nodes = null; 
    6581                try { 
    66                         nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node); 
     82                        nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node); 
    6783                } catch (ResourceException e) { 
    6884                        // TODO Auto-generated catch block 
    6985                        e.printStackTrace(); 
    7086                } 
    71                 int nodeIdx = rand.nextInt(nodes.size()); 
    72                 return nodes.get(nodeIdx).getName(); 
     87                List<Node> avNodes = filterNodes(nodes, task); 
     88                if(avNodes.size() == 0) 
     89                        return null; 
     90                Node node = randomNode(avNodes); 
     91                int cpuRequest; 
     92                try { 
     93                        cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue(); 
     94                } catch (NoSuchFieldException e) { 
     95                        cpuRequest = 0; 
     96                } 
     97 
     98                if (cpuRequest != 0) { 
     99 
     100                        List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();   
     101                         
     102                        List<Core> cores = node.getCores();                      
     103                        for (int i = 0; i < cores.size() && cpuRequest > 0; i++) { 
     104                                if (cores.get(i).getStatus() == ResourceStatus.FREE) { 
     105                                        choosenResources.add(cores.get(i)); 
     106                                        cpuRequest--; 
     107                                } 
     108                        } 
     109                        if (cpuRequest > 0) { 
     110                                return null; 
     111                        } 
     112                        //choosenResources.add(node.getProcessors().get(0)); 
     113                        ProcessingElements pe = new ProcessingElements(); 
     114                        pe.addAll(choosenResources); 
     115                        map.put(StandardResourceUnitName.PE, pe); 
     116                        return map; 
     117                } 
     118                return null; 
     119        } 
     120         
     121        private List<Node> filterNodes(List<Node> nodes, TaskInterface<?> task){ 
     122                List<Node> filteredNodes = new ArrayList<Node>(); 
     123                int cpuRequest; 
     124                try { 
     125                        cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue(); 
     126                } catch (NoSuchFieldException e) { 
     127                        cpuRequest = 0; 
     128                } 
     129                for (Node node : nodes) { 
     130 
     131                        if (cpuRequest != 0) { 
     132 
     133                                List<Core> cores = node.getCores(); 
     134                                if (cores.size() < cpuRequest) { 
     135                                        if(cores.size() == 0){ 
     136                                                if(node.getProcessors().size() < cpuRequest) 
     137                                                        continue; 
     138                                        } 
     139                                } 
     140 
     141                                int freeCores = 0; 
     142                                for(Core core: cores){ 
     143                                        if(core.getStatus() == ResourceStatus.FREE) 
     144                                                freeCores++; 
     145                                } 
     146                                 
     147                                if(freeCores < cpuRequest) 
     148                                        continue; 
     149                                 
     150                                filteredNodes.add(node); 
     151                        } 
     152                } 
     153                 
     154                return filteredNodes; 
     155        } 
     156         
     157        private Node randomNode(List<Node> nodes){ 
     158                return nodes.get(rand.nextInt(nodes.size())); 
    73159        } 
    74160 
  • DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Consolidation_SP.java

    r1102 r1207  
    1010import schedframe.events.scheduling.SchedulingEvent; 
    1111import schedframe.exceptions.ResourceException; 
    12 import schedframe.resources.CoolEmAllResourceType; 
    1312import schedframe.resources.ResourceStatus; 
     13import schedframe.resources.StandardResourceType; 
    1414import schedframe.resources.computing.ComputingResource; 
    1515import schedframe.resources.computing.Processor; 
     16import schedframe.resources.computing.coolemall.Node; 
    1617import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 
    17 import schedframe.resources.computing.recs.Node; 
    1818import schedframe.resources.units.Memory; 
    1919import schedframe.resources.units.ProcessingElements; 
     
    5555                        List<Node> nodes; 
    5656                        try { 
    57                                 nodes = (List<Node>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node); 
     57                                nodes = (List<Node>) resourceManager.getResourcesOfType(StandardResourceType.Node); 
    5858                        } catch (ResourceException e) { 
    5959                                break; 
     
    140140                                } 
    141141                        } 
    142                         ProcessingElements result = new ProcessingElements(node.getName()); 
     142                        ProcessingElements result = new ProcessingElements(node.getFullName()); 
    143143                        result.addAll(choosenResources); 
    144144                        map.put(StandardResourceUnitName.PE, result); 
     
    183183        private void turnOffIdleNodes(List<Node> nodes){ 
    184184                for(Node node : nodes){ 
    185                         JobRegistry jr = new JobRegistryImpl(node.getName()); 
     185                        JobRegistry jr = new JobRegistryImpl(node.getFullName()); 
    186186                        if(jr.getRunningTasks().size() == 0) 
    187187                                node.getPowerInterface().setPowerState(StandardPowerStateName.OFF); 
  • DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_LB_SP.java

    r1102 r1207  
    55import schedframe.events.scheduling.SchedulingEvent; 
    66import schedframe.exceptions.ResourceException; 
    7 import schedframe.resources.CoolEmAllResourceType; 
     7import schedframe.resources.StandardResourceType; 
    88import schedframe.resources.computing.ComputingResource; 
    9 import schedframe.resources.computing.recs.Node; 
     9import schedframe.resources.computing.coolemall.Node; 
    1010import schedframe.scheduling.manager.resources.ClusterResourceManager; 
    1111import schedframe.scheduling.manager.resources.ResourceManager; 
     
    6262                List<ComputingResource> nodes = null; 
    6363                try { 
    64                         nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node); 
     64                        nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(StandardResourceType.Node); 
    6565                } catch (ResourceException e) { 
    6666                        // TODO Auto-generated catch block 
     
    6868                } 
    6969                int nodeIdx = findLeastLoadedResourceIdx(nodes); 
    70                 return nodes.get(nodeIdx).getName(); 
     70                return nodes.get(nodeIdx).getFullName(); 
    7171        } 
    7272         
     
    7777                for(int i = 0; i < nodes.size(); i++){ 
    7878                        Node node = (Node) nodes.get(i); 
    79                         JobRegistry jr = new JobRegistryImpl(node.getName()); 
     79                        JobRegistry jr = new JobRegistryImpl(node.getFullName()); 
    8080                        int totalLoad = jr.getRunningTasks().size();  
    8181                        if(totalLoad < minLoad){ 
  • DCWoRMS/branches/coolemall/src/example/localplugin/coolemall/recs/RECS_FCFS_Random_SP.java

    r1103 r1207  
    22 
    33import java.util.ArrayList; 
     4import java.util.HashMap; 
    45import java.util.List; 
     6import java.util.Map; 
    57import java.util.Random; 
    68 
    79import schedframe.events.scheduling.SchedulingEvent; 
    810import schedframe.exceptions.ResourceException; 
    9 import schedframe.resources.CoolEmAllResourceType; 
     11import schedframe.resources.ResourceStatus; 
     12import schedframe.resources.StandardResourceType; 
    1013import schedframe.resources.computing.ComputingNode; 
    11 import schedframe.resources.computing.profiles.energy.airthroughput.StandardAirThroughputStateName; 
     14import schedframe.resources.computing.ComputingResource; 
     15import schedframe.resources.computing.Core; 
     16import schedframe.resources.computing.profiles.energy.airthroughput.UserAirThroughputStateName; 
     17import schedframe.resources.devices.Device; 
     18import schedframe.resources.units.ProcessingElements; 
     19import schedframe.resources.units.ResourceUnit; 
     20import schedframe.resources.units.ResourceUnitName; 
     21import schedframe.resources.units.StandardResourceUnitName; 
    1222import schedframe.scheduling.manager.resources.ClusterResourceManager; 
    1323import schedframe.scheduling.manager.resources.ResourceManager; 
     
    1929import schedframe.scheduling.queue.TaskQueueList; 
    2030import schedframe.scheduling.tasks.TaskInterface; 
     31import testbed_hpc.Node_Fan_Mapping; 
    2132import example.localplugin.BaseLocalSchedulingPlugin; 
    2233import gridsim.dcworms.DCWormsTags; 
     
    2839        public RECS_FCFS_Random_SP () { 
    2940                rand = new Random(47); 
     41                Node_Fan_Mapping.init(); 
    3042        } 
    3143 
     
    4759                        List<ComputingNode> notSelectedNodes = null; 
    4860                        try { 
    49                                 notSelectedNodes = (List<ComputingNode>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node); 
     61                                notSelectedNodes = (List<ComputingNode>) resourceManager.getResourcesOfType(StandardResourceType.Node); 
    5062                        } catch (ResourceException e) { 
    5163                                // TODO Auto-generated catch block 
     
    5769                                // if status of the tasks in READY 
    5870                                if (task.getStatus() == DCWormsTags.READY) { 
    59                                         ComputingNode node = chooseRandomProvider(resourceManager); 
     71                                        Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 
     72                                        if (choosenResources != null) { 
     73                                                addToSchedulingPlan(plan, task, choosenResources); 
     74                                        } 
     75                                        /*ComputingNode node = chooseRandomProvider(resourceManager); 
    6076                                        if (node != null) { 
    61                                                 node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON); 
     77                                                //node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON); 
    6278                                                notSelectedNodes.remove(node); 
    6379                                                addToSchedulingPlan(plan, task, node.getName()); 
    64                                         } 
     80                                        }*/ 
    6581                                } 
    6682                        } 
     
    7591                List<ComputingNode> nodes = null; 
    7692                try { 
    77                         nodes = (List<ComputingNode>) resourceManager.getResourcesOfType(CoolEmAllResourceType.Node); 
     93                        nodes = (List<ComputingNode>) resourceManager.getResourcesOfType(StandardResourceType.Node); 
    7894                } catch (ResourceException e) { 
    7995                        // TODO Auto-generated catch block 
     
    94110                return filteredNodes; 
    95111        } 
     112         
     113        private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution( 
     114                        ClusterResourceManager resourceManager, TaskInterface<?> task) { 
     115 
     116                Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(); 
     117                 
     118                List<ComputingNode> nodes = null; 
     119                try { 
     120                        nodes = (List<ComputingNode>) resourceManager.getResourcesOfType(StandardResourceType.Node); 
     121                } catch (ResourceException e1) { 
     122                        // TODO Auto-generated catch block 
     123                        e1.printStackTrace(); 
     124                } 
     125                List<ComputingNode> avNodes = filterNodes(nodes, task); 
     126                if(avNodes.size() == 0) 
     127                        return null; 
     128                ComputingNode node = randomNode(avNodes); 
     129 
     130                int cpuRequest; 
     131                try { 
     132                        cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue(); 
     133                } catch (NoSuchFieldException e) { 
     134                        cpuRequest = 0; 
     135                } 
     136 
     137                if (cpuRequest != 0) { 
     138 
     139                        List<Core> cores = node.getProcessors().get(0).getCores(); 
     140 
     141                        List<ComputingResource> choosenResources = new ArrayList<ComputingResource>();                           
     142                        for (int i = 0; i < cores.size(); i++) { 
     143                                if (cores.get(i).getStatus() == ResourceStatus.FREE) { 
     144                                        //choosenResources.add(cores.get(i)); 
     145                                        cpuRequest--; 
     146                                } 
     147                        } 
     148                        if (cpuRequest > 0) { 
     149                                return null; 
     150                        } 
     151                        choosenResources.add(node.getProcessors().get(0)); 
     152                        ProcessingElements pe = new ProcessingElements(); 
     153                        pe.addAll(choosenResources); 
     154                        map.put(StandardResourceUnitName.PE, pe); 
     155                        return map; 
     156                } 
     157                return null; 
     158        } 
     159         
     160        private List<ComputingNode> filterNodes(List<ComputingNode> nodes, TaskInterface<?> task){ 
     161                List<ComputingNode> filteredNodes = new ArrayList<ComputingNode>(); 
     162                for (ComputingNode node : nodes) { 
     163                        int cpuRequest; 
     164                        try { 
     165                                cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue(); 
     166                        } catch (NoSuchFieldException e) { 
     167                                cpuRequest = 0; 
     168                        } 
     169 
     170                        if (cpuRequest != 0) { 
     171 
     172                                List<Core> cores = node.getProcessors().get(0).getCores(); 
     173                                if (cores.size() < cpuRequest) { 
     174                                        if(cores.size() == 0){ 
     175                                                if(node.getProcessors().size() < cpuRequest) 
     176                                                        continue; 
     177                                        } 
     178                                } 
     179 
     180                                int freeCores = 0; 
     181                                for(Core core: cores){ 
     182                                        if(core.getStatus() == ResourceStatus.FREE) 
     183                                                freeCores++; 
     184                                } 
     185                                 
     186                                if(freeCores != cores.size()) 
     187                                        continue; 
     188                                 
     189                                filteredNodes.add(node); 
     190                        } 
     191                } 
     192                 
     193                return filteredNodes; 
     194        } 
     195         
     196        private ComputingNode randomNode(List<ComputingNode> nodes){ 
     197                return nodes.get(rand.nextInt(nodes.size())); 
     198        } 
     199         
    96200        private void adjustOtherFans(List<ComputingNode> nodes) { 
    97201                for (ComputingNode node : nodes) { 
     202                         
    98203                        if (node.getProcessors().size() == node.getFreeProcessorsNumber()) { 
    99                                 node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_OFF); 
     204                                for(Device device: node.getParent().getResourceCharacteristic().getDevices()){ 
     205                                        if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){ 
     206                                                device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("Off")); 
     207                                                break; 
     208                                        } 
     209                                } 
     210 
    100211                        } else { 
    101                                 node.getAirThroughputInterface().setAirThroughputState(StandardAirThroughputStateName.FAN_ON); 
     212                                for(Device device: node.getParent().getResourceCharacteristic().getDevices()){ 
     213                                        if(device.getFullName().equals(Node_Fan_Mapping.getNode_fan().get(node.getFullName()))){ 
     214                                                device.getAirThroughputInterface().setAirThroughputState(new UserAirThroughputStateName("On")); 
     215                                                break; 
     216                                        } 
     217                                } 
    102218                        } 
    103219                } 
  • DCWoRMS/branches/coolemall/src/schedframe/SimulatedEnvironment.java

    r768 r1207  
    33import gridsim.GridSim; 
    44 
     5import java.util.ArrayList; 
    56import java.util.HashSet; 
    67import java.util.Iterator; 
     
    1011 
    1112import schedframe.exceptions.ResourceException; 
     13import schedframe.resources.ResourceHistoryChanges; 
    1214import schedframe.resources.computing.ComputingResource; 
    1315import schedframe.scheduling.Scheduler; 
    1416 
    15 public class ResourceController { 
     17public class SimulatedEnvironment { 
    1618 
    1719        protected static Scheduler scheduler; 
     
    1921        protected List<Initializable> toInit; 
    2022        protected Set<String> compResLayers; 
     23        protected static List<ResourceHistoryChanges> compResHistory = new ArrayList<ResourceHistoryChanges>(); 
    2124         
    22         public ResourceController(Scheduler logicalStructure, List<ComputingResource> compResources){ 
     25        public SimulatedEnvironment(Scheduler logicalStructure, List<ComputingResource> compResources){ 
    2326                scheduler = logicalStructure; 
    2427                computingResources = compResources; 
     
    3740                for (int i = 0; i < computingResources.size() && resourceWithName == null; i++) { 
    3841                        ComputingResource resource = computingResources.get(i); 
    39                         if (resource.getName().equals(resourceName)) 
     42                        if (resource.getFullName().equals(resourceName)) 
    4043                                resourceWithName = resource; 
    4144                        else 
     
    152155        } 
    153156 
     157        public static void traceResource(long timestamp, String resourceName, String operation, String paramter){ 
     158                ResourceHistoryChanges rhc = new ResourceHistoryChanges(timestamp, resourceName, operation, paramter); 
     159                compResHistory.add(rhc); 
     160        } 
     161 
     162        public static List<ResourceHistoryChanges> getCompResHistory() { 
     163                return compResHistory; 
     164        } 
    154165} 
  • DCWoRMS/branches/coolemall/src/schedframe/events/ResourceEventCommand.java

    r477 r1207  
    11package schedframe.events; 
    22 
    3 import schedframe.resources.computing.ComputingResource; 
     3import schedframe.resources.devices.PhysicalResource; 
    44 
    55public class ResourceEventCommand implements EventCommand { 
    66 
    7         private ComputingResource compResource; 
     7        private PhysicalResource resource; 
    88         
    9         public ResourceEventCommand(ComputingResource compResource) { 
    10                 this.compResource = compResource; 
     9        public ResourceEventCommand(PhysicalResource resource) { 
     10                this.resource = resource; 
    1111        } 
    1212         
     
    1717 
    1818        public void execute(Event event) { 
    19                 compResource.getEventHandler().handleResourceEvent(event); 
     19                resource.getEventHandler().handleResourceEvent(event); 
    2020        } 
    2121 
  • DCWoRMS/branches/coolemall/src/schedframe/events/scheduling/SchedulingEventCommand.java

    r477 r1207  
    1616        public void execute(EventType evType) { 
    1717                SchedulingEvent ev = new SchedulingEvent(evType); 
    18                 ev.setSource(compResource.getName()); 
     18                ev.setSource(compResource.getFullName()); 
    1919                compResource.getEventHandler().handleSchedulingEvent(ev); 
    2020        } 
     
    2222        public void execute(Event event) { 
    2323                SchedulingEvent ev = new SchedulingEvent(event.getType()); 
    24                 ev.setSource(compResource.getName()); 
     24                ev.setSource(compResource.getFullName()); 
    2525                compResource.getEventHandler().handleSchedulingEvent(ev); 
    2626        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/CoolEmAllResourceType.java

    r1095 r1207  
    33public enum CoolEmAllResourceType implements ResourceType { 
    44         
    5         ComputeBox2, 
    6         ComputeBox1, 
    7         NodeGroup, 
    8         Node, 
    9         Processor, 
    10         Core; 
    11  
     5        ComputeBox2("Room"), 
     6        ComputeBox1("Rack"), 
     7        NodeGroup("NodeGroup"), 
     8        Node("Node"), 
     9        Processor("Processor"), 
     10        Core("Core"); 
     11         
     12        private String label; 
     13         
     14        CoolEmAllResourceType(String label){ 
     15                this.label = label; 
     16        } 
    1217        public String getName() { 
    1318                return toString(); 
    1419        } 
     20        public String getLabel(){ 
     21                return label; 
     22        } 
    1523} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/Resource.java

    r893 r1207  
    11package schedframe.resources; 
     2 
    23 
    34 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/ResourceTypeFactory.java

    r1097 r1207  
    55         
    66        public static ResourceType createResourceType(String typeName){ 
    7                  
     7 
    88                if(typeName.equals(StandardResourceType.Grid.getName())) 
    99                        return StandardResourceType.Grid; 
     
    1515                        return StandardResourceType.Rack; 
    1616 
    17                 else if (typeName.equals(StandardResourceType.ComputingNode.getName())) 
    18                         return StandardResourceType.ComputingNode; 
     17                else if (typeName.equals(StandardResourceType.Node.getName())) 
     18                        return StandardResourceType.Node; 
    1919                 
    2020                else if (typeName.equals(StandardResourceType.Processor.getName())) 
     
    2424                        return StandardResourceType.Core; 
    2525                 
     26                else if (typeName.equals(CoolEmAllResourceType.ComputeBox2.getName())) 
     27                        return CoolEmAllResourceType.ComputeBox2; 
     28                 
    2629                else if (typeName.equals(CoolEmAllResourceType.ComputeBox1.getName())) 
    2730                        return CoolEmAllResourceType.ComputeBox1; 
     
    3033                        return CoolEmAllResourceType.NodeGroup; 
    3134                 
    32                 else if (typeName.equals(CoolEmAllResourceType.Node.getName())) 
    33                         return CoolEmAllResourceType.Node; 
     35                else if (typeName.equals(StandardResourceType.CRAH.getName())) 
     36                        return StandardResourceType.CRAH; 
     37                 
     38                else if (typeName.equals(StandardResourceType.Fan.getName())) 
     39                        return StandardResourceType.Fan; 
     40                 
     41                else if (typeName.equals(StandardResourceType.Inlet.getName())) 
     42                        return StandardResourceType.Inlet; 
     43                 
     44                else if (typeName.equals(StandardResourceType.Outlet.getName())) 
     45                        return StandardResourceType.Outlet; 
     46                 
     47                else if (typeName.equals(StandardResourceType.CoolingDevice.getName())) 
     48                        return StandardResourceType.CoolingDevice; 
     49                 
     50                else if (typeName.equals(StandardResourceType.Heatsink.getName())) 
     51                        return StandardResourceType.Heatsink; 
    3452                 
    3553                else if (typeName.equals(StandardResourceType.ResourceProvider.getName())) 
     
    4260                        return StandardResourceType.LS; 
    4361                 
    44                 else return new UserResourceType(typeName); 
     62                return new UserResourceType(typeName); 
    4563        } 
    4664} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/StandardResourceType.java

    r1095 r1207  
    77        DataCenter, 
    88        Rack, 
    9         ComputingNode, 
     9        Node, 
    1010        Processor, 
    1111        Core, 
     
    1313        ResourceProvider, 
    1414        GS, 
    15         LS; 
     15        LS, 
     16        Fan, 
     17        Refrigeration, 
     18        Heatpipe, 
     19        ILC, 
     20        LCU, 
     21        CRAH, 
     22        HVAC, 
     23        Inlet, 
     24        Outlet, 
     25        Heatsink, 
     26        Sensor, 
     27        Network, 
     28        CoolingDevice, 
     29        PowerSupply; 
    1630 
    1731        public String getName() { 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingNode.java

    r756 r1207  
    33import java.util.List; 
    44import java.util.Properties; 
    5  
    65 
    76import schedframe.resources.ResourceStatus; 
     
    109import schedframe.resources.computing.extensions.ExtensionType; 
    1110import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    12 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputInterfaceFactory; 
    13 import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 
    14 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    1511import schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface; 
    16 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    1712import schedframe.resources.computing.properties.ComputingNodePropertiesBuilder; 
    1813import schedframe.resources.computing.properties.PropertiesDirector; 
     
    3227                //accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 
    3328                //accept(new EnergyExtension(pi, resDesc.getPowerProfile(), ai, resDesc.getAirThroughputProfile()));     
    34         } 
    35          
    36         /*public ComputingNode (String resourceName, ResourceCharacteristics resourceCharacteristic, Category cat, PowerInterface powerInterface) { 
    37                 super(resourceName, ResourceType.COMPUTING_NODE, resourceCharacteristic); 
    38                 category = cat; 
    39                 accept(powerInterface); 
    40         //      extensionList.add(new EnergyExtension(this, "example.energy.ComputingNodeEnergyEstimationPlugin")); 
    41         }*/ 
    42          
     29        }        
    4330         
    4431        public ComputingNodePowerInterface getPowerInterface(){ 
     
    8673         
    8774        public Memory getMemory() throws NoSuchFieldException { 
    88                 return (Memory) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.MEMORY); 
     75                return (Memory) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.MEMORY); 
    8976        } 
    9077         
     
    9582         
    9683        private Cost getCost() throws NoSuchFieldException { 
    97                 return (Cost) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.COST); 
     84                return (Cost) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.COST); 
    9885        } 
    9986 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ComputingResource.java

    r1005 r1207  
    99import java.util.Properties; 
    1010 
    11 import schedframe.Initializable; 
    1211import schedframe.events.Event; 
    1312import schedframe.events.EventHandler; 
     
    1716import schedframe.events.scheduling.SchedulingEventCommand; 
    1817import schedframe.exceptions.ResourceException; 
    19 import schedframe.resources.Resource; 
    2018import schedframe.resources.ResourceStatus; 
    2119import schedframe.resources.ResourceType; 
    2220import schedframe.resources.computing.description.ComputingResourceDescription; 
    2321import schedframe.resources.computing.extensions.Extension; 
    24 import schedframe.resources.computing.extensions.ExtensionList; 
    2522import schedframe.resources.computing.extensions.ExtensionListImpl; 
    26 import schedframe.resources.computing.extensions.ExtensionType; 
    2723import schedframe.resources.computing.profiles.energy.EnergyEvent; 
    2824import schedframe.resources.computing.profiles.energy.EnergyEventType; 
    2925import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    30 import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 
    31 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    32 import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface; 
    3326import schedframe.resources.computing.properties.DefaultPropertiesBuilder; 
    3427import schedframe.resources.computing.properties.PropertiesDirector; 
     
    3831import schedframe.resources.computing.validator.ResourceTypeValidator; 
    3932import schedframe.resources.computing.validator.ResourceValidator; 
    40 import schedframe.resources.units.PEUnit; 
    41 import schedframe.resources.units.ResourceUnit; 
    42 import schedframe.resources.units.StandardResourceUnitName; 
     33import schedframe.resources.devices.Device; 
     34import schedframe.resources.devices.PhysicalResource; 
    4335import schedframe.scheduling.Scheduler; 
    4436 
    45 public class ComputingResource implements Resource, Initializable{ 
    46          
    47         protected String name; 
    48         protected ResourceType type; 
    49         protected String category; 
    50         protected ResourceStatus status; 
     37public class ComputingResource extends PhysicalResource{ 
    5138 
    5239        protected ComputingResource parent; 
     
    5441         
    5542        protected Scheduler scheduler; 
    56         protected ResourceCharacteristics resourceCharacteristic; 
    57         protected ExtensionList extensionList; 
    58          
    59  
    60         public ExtensionList getExtensionList() { 
    61                 return extensionList; 
    62         } 
     43        //protected ResourceCharacteristics resourceCharacteristic; 
     44 
    6345 
    6446        public ComputingResource(ComputingResourceDescription resDesc) { 
     
    6951                this.extensionList = new ExtensionListImpl(1); 
    7052                initCharacteristics(resDesc); 
    71                 accept(new EnergyExtension(this, resDesc.getPowerProfile(), resDesc.getAirThroughputProfile(), resDesc.getThermalProfile()));    
    72                 addFakeProcessors(); 
    73         } 
    74  
    75         //TODO remove if possible (check if all scenarios can be realized - statistics issue), since it's a temporary method 
    76         private void addFakeProcessors() { 
    77                 if(getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.PE) != null){ 
    78                         for(ResourceUnit resUnit: getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.PE)){ 
    79                                 PEUnit peUnit = (PEUnit) resUnit; 
    80                                 for(int i = 0; i < peUnit.getAmount(); i++){ 
    81                                         schemas.ComputingResource fakeCompResource = new schemas.ComputingResource(); 
    82                                         fakeCompResource.setClazz("Processor"); 
    83                                         addChild(ResourceFactory.createResource(new ComputingResourceDescription(fakeCompResource))); 
    84                                 } 
    85                         } 
    86                 } 
     53                accept(new EnergyExtension.Builder().resource(this).powerProfile(resDesc.getPowerProfile()).airFlowProfile(resDesc.getAirThroughputProfile()).thermalProfile(resDesc.getThermalProfile()).build());      
    8754        } 
    8855 
    8956        protected void initCharacteristics(ComputingResourceDescription resDesc){ 
    90                 resourceCharacteristic = new ResourceCharacteristics.Builder().resourceUnits(resDesc.getResourceUnits()).location(resDesc.getLocation()).parameters(resDesc.getParameters()).build(); 
     57                resourceCharacteristic = ComputingResourceCharacteristics.builder().resourceUnits(resDesc.getResourceUnits()).location(resDesc.getLocation()).parameters(resDesc.getParameters()).device(resDesc.getDevices()).build(); 
     58                for(Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()){ 
     59                        device.setComputingResource(this); 
     60                } 
    9161        } 
    9262         
     
    11282        } 
    11383 
    114         public String getName() { 
    115                 return name; 
    116         } 
    117          
    11884        public String getFullName() { 
    11985                if(this.getResourceCharacteristic().getParameters().get("fullPath") != null){ 
     
    12793        } 
    12894 
    129         public ResourceType getType() { 
    130                 return type; 
    131         } 
    132  
    133         public ResourceCharacteristics getResourceCharacteristic() { 
    134                 return resourceCharacteristic; 
    135         } 
    136  
    137         public ResourceStatus getStatus() { 
    138                 return status; 
     95        public ComputingResourceCharacteristics getResourceCharacteristic() { 
     96                return (ComputingResourceCharacteristics)resourceCharacteristic; 
    13997        } 
    14098 
     
    245203        } 
    246204         
    247         public String getCategory(){ 
    248                 return category; 
    249         } 
    250          
    251         public PowerInterface getPowerInterface(){ 
    252                 Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION); 
    253                 if(extension != null){ 
    254                         EnergyExtension ee = (EnergyExtension)extension; 
    255                         return ee.getPowerInterface(); 
    256                 } 
    257                 return null; 
    258         } 
    259          
    260         public AirThroughputInterface getAirThroughputInterface(){ 
    261                 Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION); 
    262                 if(extension != null){ 
    263                         EnergyExtension ee = (EnergyExtension)extension; 
    264                         return ee.getAirThroughputInterface(); 
    265                 } 
    266                 return null; 
    267         } 
    268          
    269         public ThermalInterface getThermalInterface(){ 
    270                 Extension extension = getExtension(ExtensionType.ENERGY_EXTENSION); 
    271                 if(extension != null){ 
    272                         EnergyExtension ee = (EnergyExtension)extension; 
    273                         return ee.getThermalInterface(); 
    274                 } 
    275                 return null; 
    276         } 
    277  
    278         private Extension getExtension(ExtensionType type){ 
    279                 if (extensionList != null) { 
    280                         for (Extension extension : extensionList) { 
    281                                 if (extension.getType() == type) { 
    282                                         return extension; 
    283                                 } 
    284                         } 
    285                 } 
    286                 return null; 
    287         } 
    288          
    289205        public Scheduler getScheduler() { 
    290206                return scheduler; 
     
    307223                                        if (extension.supportsEvent(event)) { 
    308224                                                extension.handleEvent(event); 
     225                                        } 
     226                                } 
     227                                 
     228                                for (Device device: ((ComputingResourceCharacteristics)resourceCharacteristic).getDevices()) { 
     229                                        for (Extension extension : device.getExtensionList()) { 
     230                                                if (extension.supportsEvent(event)) { 
     231                                                        //extension.handleEvent(event); 
     232                                                } 
    309233                                        } 
    310234                                } 
     
    332256        } 
    333257         
    334         public void initiate(){ 
    335                  
     258        public final void initiate(){ 
     259                for(Device dev: this.getResourceCharacteristic().getDevices()){ 
     260                        dev.initiate(); 
     261                } 
    336262                ResourceEventCommand rec = new ResourceEventCommand(this); 
    337263                EnergyEvent event = new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller"); 
     
    343269                rec.execute(event); 
    344270                 
     271                rec = new ResourceEventCommand(this); 
     272                event = new EnergyEvent(EnergyEventType.TEMPERATURE_CHANGED, "Resource controller"); 
     273                event.setReason(EventReason.SIM_INIT); 
     274                rec.execute(event); 
     275                 
    345276                //alternative way 
    346277                //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller")); 
    347278                //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller")); 
    348279        } 
    349          
    350          
    351         private void accept(EnergyExtension e){ 
    352                 extensionList.add(e); 
    353         } 
     280 
     281 
    354282} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Core.java

    r756 r1207  
    11package schedframe.resources.computing; 
    22 
     3import schedframe.resources.StandardResourceType; 
    34import schedframe.resources.computing.description.ComputingResourceDescription; 
    4 import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    5 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    6 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    75import schedframe.resources.units.CpuSpeed; 
    86import schedframe.resources.units.StandardResourceUnitName; 
     
    1816 
    1917        public Processor getProcessor(){ 
    20                 return (Processor)parent; 
     18                ComputingResource compRes = parent; 
     19                while(compRes != null && !compRes.getType().equals(StandardResourceType.Processor)){ 
     20                        compRes = compRes.getParent(); 
     21                } 
     22                Processor proc = null; 
     23                try{ 
     24                        proc = (Processor)compRes; 
     25                } catch(ClassCastException e) { 
     26                } 
     27                return proc; 
     28        } 
     29         
     30        public ComputingNode getNode(){ 
     31                ComputingResource compRes = parent; 
     32                while(compRes != null && !compRes.getType().equals(StandardResourceType.Node)){ 
     33                        compRes = compRes.getParent(); 
     34                } 
     35                ComputingNode compNode = null; 
     36                try{ 
     37                        compNode = (ComputingNode)compRes; 
     38                } catch(ClassCastException e) { 
     39                } 
     40                return compNode; 
    2141        } 
    2242         
     
    4262 
    4363        private CpuSpeed getSpeedUnit() throws NoSuchFieldException{ 
    44                 return (CpuSpeed) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.CPUSPEED); 
     64                return (CpuSpeed) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.CPUSPEED); 
    4565        } 
    4666 
     
    4868                super.initCharacteristics(resDesc); 
    4969                try{ 
    50                         resourceCharacteristic.addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0)); 
     70                        ((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0)); 
    5171                } catch(Exception e){ 
    52                         resourceCharacteristic.addResourceUnit(new CpuSpeed(name,  1, 0)); 
     72                        ((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name,  1, 0)); 
    5373                } 
    5474        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/DataCenter.java

    r756 r1207  
    2020        @SuppressWarnings("unchecked") 
    2121        public List<ComputingNode> getComputingNodes(){ 
    22                 return (List<ComputingNode>) getDescendantsByType(StandardResourceType.ComputingNode); 
     22                return (List<ComputingNode>) getDescendantsByType(StandardResourceType.Node); 
    2323        } 
    2424         
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Processor.java

    r883 r1207  
    99import schedframe.resources.computing.extensions.ExtensionType; 
    1010import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    11 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    12 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    1311import schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface; 
    1412import schedframe.resources.computing.properties.CpuPropertiesBuilder; 
     
    2725        } 
    2826 
    29  
    30         public ComputingNode getComputingNode(){ 
    31                 return (ComputingNode)parent; 
     27        public ComputingNode getNode(){ 
     28                ComputingResource compRes = parent; 
     29                while(compRes != null && !compRes.getType().equals(StandardResourceType.Node)){ 
     30                        compRes = compRes.getParent(); 
     31                } 
     32                ComputingNode compNode = null; 
     33                try{ 
     34                        compNode = (ComputingNode)compRes; 
     35                } catch(Exception e) { 
     36                } 
     37                return compNode; 
    3238        } 
    3339         
     
    6369 
    6470        private CpuSpeed getSpeedUnit() throws NoSuchFieldException{ 
    65                 return (CpuSpeed) resourceCharacteristic.getResourceUnit(StandardResourceUnitName.CPUSPEED); 
     71                return (CpuSpeed) ((ComputingResourceCharacteristics)resourceCharacteristic).getResourceUnit(StandardResourceUnitName.CPUSPEED); 
    6672        } 
    6773         
     
    8086                super.initCharacteristics(resDesc); 
    8187                try{ 
    82                         resourceCharacteristic.addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0)); 
     88                        ((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name, Integer.valueOf(resDesc.getCompResourceParameterValue("speed")) * 1, 0)); 
    8389                } catch(Exception e){ 
    84                         resourceCharacteristic.addResourceUnit(new CpuSpeed(name,  1, 0)); 
     90                        ((ComputingResourceCharacteristics)resourceCharacteristic).addResourceUnit(new CpuSpeed(name,  1, 0)); 
    8591                } 
    8692        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/Rack.java

    r756 r1207  
    55import schedframe.resources.StandardResourceType; 
    66import schedframe.resources.computing.description.ComputingResourceDescription; 
    7 import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    8 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    9 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    107 
    118public class Rack extends ComputingResource{ 
     
    2017        @SuppressWarnings("unchecked") 
    2118        public List<ComputingNode> getComputingNodes(){ 
    22                 return (List<ComputingNode>) getDescendantsByType(StandardResourceType.ComputingNode); 
     19                return (List<ComputingNode>) getDescendantsByType(StandardResourceType.Node); 
    2320        } 
    2421         
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ResourceCharacteristics.java

    r1007 r1207  
    11package schedframe.resources.computing; 
    2  
    3 import java.util.ArrayList; 
    4 import java.util.HashMap; 
    5 import java.util.List; 
    6 import java.util.Map; 
    72 
    83import schedframe.Parameters; 
    94import schedframe.resources.computing.location.Location; 
    10 import schedframe.resources.units.ResourceUnit; 
    11 import schedframe.resources.units.ResourceUnitName; 
    125 
    136 
     
    169        private static final long serialVersionUID = 2719535186621622647L; 
    1710 
    18         protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 
     11        protected Location location; 
    1912        protected Parameters parameters; 
    20         protected Location location; 
     13        //protected Location location; 
     14        //protected List<Device> devices; 
    2115 
    2216        /*public ResourceCharacteristics(Map<ResourceUnitName, List<AbstractResourceUnit>> resUnits){ 
     
    3226        }*/ 
    3327         
    34         public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() { 
    35                 if(resUnits == null) 
    36                         return new HashMap<ResourceUnitName, List<ResourceUnit>>(); 
    37                 return resUnits; 
    38         } 
     28 
    3929         
    40         public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException{ 
    41                 if(getResourceUnits().containsKey(unitName)) 
    42                         return getResourceUnits().get(unitName).get(0); 
    43                 else throw new NoSuchFieldException("Resource unit " + unitName +  
    44                                 " is not available in this resource "); 
    45         } 
    46          
    47         public void addResourceUnit(ResourceUnit unit){  
    48                 if(resUnits == null){ 
    49                         resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(2); 
    50                 } 
    51                 List<ResourceUnit> list = null; 
    52                 if(resUnits.containsKey(unit.getName())){ 
    53                         list = resUnits.get(unit.getName()); 
    54                 } else { 
    55                         list = new ArrayList<ResourceUnit>(1); 
    56                         resUnits.put(unit.getName(), list); 
    57                 } 
    58                 list.add(unit); 
    59         } 
    60          
    61          
    62         public static class Builder { 
    63                    
    64                 protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 
    65                 protected Location location; 
    66                 protected Parameters parameters; 
    67                  
    68                 public Builder location(Location loc){this.location = loc; return this; } 
    69         public Builder parameters(Parameters params){this.parameters = params; return this; } 
    70         public Builder resourceUnits(Map<ResourceUnitName, List<ResourceUnit>> units){this.resUnits = units; return this; } 
    71         public Builder resourceUnits(){this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(2); return this; } 
    72          
    73         public ResourceCharacteristics build() { 
    74             return new ResourceCharacteristics(this); 
    75         } 
    76         } 
    77          
    78         private ResourceCharacteristics(Builder builder) { 
    79                 this.location = builder.location; 
    80                 this.parameters = builder.parameters; 
    81                 this.resUnits = builder.resUnits; 
    82         } 
    83  
    8430        public Parameters getParameters() { 
    8531                if(parameters == null) 
     
    9137                return location; 
    9238        } 
     39         
     40        protected ResourceCharacteristics(Builder<?> builder) { 
     41                //this.location = builder.location; 
     42                this.parameters = builder.parameters; 
     43                this.location = builder.location; 
     44                //this.devices = builder.devices; 
     45        } 
     46         
     47    public static abstract class Builder<T extends Builder<T>> { 
     48           
     49                protected Location location; 
     50                protected Parameters parameters; 
     51 
     52        public T parameters(Parameters params){this.parameters = params; return self(); } 
     53                public T location(Location loc){this.location = loc; return self(); } 
     54                 
     55        protected abstract T self(); 
     56 
     57        public ResourceCharacteristics build() { 
     58            return new ResourceCharacteristics(this); 
     59        } 
     60    } 
     61    private static class Builder2 extends Builder<Builder2> { 
     62        @Override 
     63        protected Builder2 self() { 
     64            return this; 
     65        } 
     66    } 
     67 
     68    public static Builder<?> builder() { 
     69        return new Builder2(); 
     70    } 
     71         
     72        /*public static class Builder { 
     73                   
     74                protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 
     75                //protected Location location; 
     76                protected Parameters parameters; 
     77                //protected List<Device> devices; 
     78                 
     79                //public Builder location(Location loc){this.location = loc; return this; } 
     80        public Builder parameters(Parameters params){this.parameters = params; return this; } 
     81        //public Builder device(List<Device> dev){this.devices = dev; return this; } 
     82        public Builder resourceUnits(Map<ResourceUnitName, List<ResourceUnit>> units){this.resUnits = units; return this; } 
     83        public Builder resourceUnits(){this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(2); return this; } 
     84         
     85        public ResourceCharacteristics build() { 
     86            return new ResourceCharacteristics(this); 
     87        } 
     88        } 
     89        */ 
     90 
    9391 
    9492} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/ResourceFactory.java

    r1095 r1207  
    11package schedframe.resources.computing; 
    22 
    3 import schedframe.resources.CoolEmAllResourceType; 
    43import schedframe.resources.StandardResourceType; 
    54import schedframe.resources.computing.description.ComputingResourceDescription; 
    6 import schedframe.resources.computing.recs.ComputeBox1; 
    7 import schedframe.resources.computing.recs.Node; 
    8 import schedframe.resources.computing.recs.NodeGroup; 
    95import schedframe.scheduling.Scheduler; 
    106import schedframe.scheduling.manager.resources.ManagedResources; 
    117import schedframe.scheduling.plugin.SchedulingPlugin; 
    128import schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin; 
    13 import schedframe.scheduling.policy.AbstractManagementSystem; 
    14 import schedframe.scheduling.policy.global.GridBroker; 
    15 import schedframe.scheduling.policy.local.LocalManagementSystem; 
    169import schedframe.scheduling.queue.TaskQueueList; 
    17 import simulator.DCWormsConstants; 
    1810 
    1911 
    20 public class ResourceFactory { 
     12public interface ResourceFactory { 
    2113 
    22         public static ComputingResource createResource(ComputingResourceDescription resDesc){ 
    23                  
    24                 if (resDesc.getType().equals(StandardResourceType.DataCenter)) 
    25                         return new DataCenter(resDesc); 
    26                 else if (resDesc.getType().equals(StandardResourceType.Rack)) 
    27                         return new Rack(resDesc); 
    28                 else if (resDesc.getType().equals(StandardResourceType.ComputingNode)) 
    29                         return new ComputingNode(resDesc); 
    30                 else if (resDesc.getType().equals(StandardResourceType.Processor)) 
    31                         return new Processor(resDesc); 
    32                 else if (resDesc.getType().equals(StandardResourceType.Core)) 
    33                         return new Core(resDesc); 
    34                 else if (resDesc.getType().equals(CoolEmAllResourceType.ComputeBox1)) 
    35                         return new ComputeBox1(resDesc); 
    36                 else if (resDesc.getType().equals(CoolEmAllResourceType.NodeGroup)) 
    37                         return new NodeGroup(resDesc); 
    38                 else if (resDesc.getType().equals(CoolEmAllResourceType.Node)) 
    39                         return new Node(resDesc); 
    40                 else if (resDesc.getType().equals(CoolEmAllResourceType.Processor)) 
    41                         return new Processor(resDesc); 
    42                 else if (resDesc.getType().equals(CoolEmAllResourceType.Core)) 
    43                         return new Core(resDesc); 
    44                 else 
    45                         return new ComputingResource(resDesc); 
     14        public ComputingResource createComputingResource(ComputingResourceDescription resDesc); 
     15 
     16        //public Device createDevice(DeviceDescription devDesc); 
    4617         
    47                 /*switch(resDesc.getType()){ 
    48                         case Grid: return new Grid(resDesc); 
    49                         case DataCenter: return new DataCenter(resDesc); 
    50                         case ComputingNode: return new ComputingNode(resDesc); 
    51                         case Processor: return new Processor(resDesc); 
    52                 default: 
    53                         return new ComputingResource(resDesc); 
    54                 }*/ 
    55         } 
    56  
    57         public static Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception{ 
    58                 AbstractManagementSystem ms; 
    59                 switch(type){ 
    60                         case GS: { 
    61                                 ms = new GridBroker("grid", 
    62                                                 schedulingPlugin, execTimeEstimationPlugin, queues); 
    63                                 return new Scheduler(ms, type, managedResources); 
    64                         } 
    65                         case LS: { 
    66                                 ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, 
    67                                                 schedulingPlugin, execTimeEstimationPlugin, queues); 
    68                                 return new Scheduler(ms, type, managedResources); 
    69                         } 
    70  
    71                 default:{ 
    72                                 ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, 
    73                                                 schedulingPlugin, execTimeEstimationPlugin, queues); 
    74                                 return new Scheduler(ms, type, managedResources); 
    75                         } 
    76                 } 
    77         } 
     18        public Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception; 
    7819} 
    7920 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/ComputeBox1.java

    r1098 r1207  
    1 package schedframe.resources.computing.recs; 
     1package schedframe.resources.computing.coolemall; 
    22 
    33import java.util.List; 
     
    66import schedframe.resources.StandardResourceType; 
    77import schedframe.resources.computing.ComputingNode; 
    8 import schedframe.resources.computing.Processor; 
    98import schedframe.resources.computing.Rack; 
    109import schedframe.resources.computing.description.ComputingResourceDescription; 
     
    2322        @SuppressWarnings("unchecked") 
    2423        public List<ComputingNode> getNodes(){ 
    25                 return (List<ComputingNode>) getDescendantsByType(CoolEmAllResourceType.Node); 
    26         } 
    27          
    28         @SuppressWarnings("unchecked") 
    29         public List<Processor> getProcessors(){ 
    30                 return (List<Processor>) getDescendantsByType(StandardResourceType.Processor); 
     24                return (List<ComputingNode>) getDescendantsByType(StandardResourceType.Node); 
    3125        } 
    3226 
     27 
    3328} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/Node.java

    r785 r1207  
    1 package schedframe.resources.computing.recs; 
     1package schedframe.resources.computing.coolemall; 
     2 
     3import java.util.ArrayList; 
     4import java.util.List; 
    25 
    36import schedframe.resources.computing.ComputingNode; 
     7import schedframe.resources.computing.Core; 
     8import schedframe.resources.computing.Processor; 
    49import schedframe.resources.computing.description.ComputingResourceDescription; 
    510 
     
    1015                // TODO Auto-generated constructor stub 
    1116        } 
     17         
     18        public List<Core> getCores(){ 
     19                List<Core> cores = new ArrayList<Core>(); 
     20                for(Processor proc: getProcessors()){ 
     21                        cores.addAll(proc.getCores()); 
     22                } 
     23                return cores; 
     24        } 
     25 
     26        public List<Core> getFreeCores(){ 
     27                List<Core> freeCores = new ArrayList<Core>(); 
     28                for(Processor proc: getProcessors()){ 
     29                        freeCores.addAll(proc.getFreeCores()); 
     30                } 
     31                return freeCores; 
     32        } 
    1233 
    1334} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/coolemall/NodeGroup.java

    r1098 r1207  
    1 package schedframe.resources.computing.recs; 
     1package schedframe.resources.computing.coolemall; 
    22 
    33import java.util.List; 
    44 
    5 import schedframe.resources.CoolEmAllResourceType; 
    65import schedframe.resources.StandardResourceType; 
    76import schedframe.resources.computing.ComputingResource; 
     
    1716        @SuppressWarnings("unchecked") 
    1817        public List<Node> getNodes(){ 
    19                 return (List<Node>) getDescendantsByType(CoolEmAllResourceType.Node); 
     18                return (List<Node>) getDescendantsByType(StandardResourceType.Node); 
    2019        } 
    2120         
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ComputingResourceDescription.java

    r1113 r1207  
    11package schedframe.resources.computing.description; 
    22 
    3 import java.io.FileInputStream; 
    4 import java.io.FileNotFoundException; 
    5 import java.io.IOException; 
    63import java.util.ArrayList; 
     4import java.util.Collection; 
     5import java.util.HashMap; 
     6import java.util.Iterator; 
    77import java.util.List; 
    8 import java.util.PropertyResourceBundle; 
    9 import java.util.ResourceBundle; 
     8import java.util.Map; 
    109 
    11 import schedframe.Parameter; 
    1210import schedframe.Parameters; 
    13 import schedframe.Property; 
    1411import schedframe.resources.ResourceTypeFactory; 
    15 import schedframe.resources.computing.location.Location; 
    16 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 
    17 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 
    18 import schedframe.resources.computing.profiles.energy.airthroughput.plugin.AirThroughputEstimationPlugin; 
    19 import schedframe.resources.computing.profiles.energy.airthroughput.plugin.DefaultAirThroughputEstimationPlugin; 
    20 import schedframe.resources.computing.profiles.energy.power.PState; 
    21 import schedframe.resources.computing.profiles.energy.power.PowerProfile; 
    22 import schedframe.resources.computing.profiles.energy.power.PowerState; 
    23 import schedframe.resources.computing.profiles.energy.power.PowerStateNameFactory; 
    24 import schedframe.resources.computing.profiles.energy.power.Transition; 
    25 import schedframe.resources.computing.profiles.energy.power.plugin.EnergyEstimationPlugin; 
    26 import schedframe.resources.computing.profiles.energy.thermal.ThermalProfile; 
    27 import schedframe.resources.computing.profiles.energy.thermal.plugin.DefaultTemperatureEstimationPlugin; 
    28 import schedframe.resources.computing.profiles.energy.thermal.plugin.TemperatureEstimationPlugin; 
     12import schedframe.resources.devices.Device; 
     13import schedframe.resources.devices.description.DeviceDescription; 
     14import schedframe.resources.devices.description.PhysicalResourceDescription; 
    2915import schedframe.resources.units.ResourceUnit; 
    3016import schedframe.resources.units.ResourceUnitFactory; 
     17import schedframe.resources.units.ResourceUnitName; 
    3118import schedframe.resources.utils.ResourceIdGenerator; 
    3219import schemas.ComputingResource; 
    33 import schemas.PowerUsage; 
    34 import schemas.Profile; 
    35 import simulator.utils.InstanceFactory; 
    36 import example.energy.DefaultEnergyEstimationPlugin; 
    3720 
    38 public class ComputingResourceDescription extends ExecutingResourceDescription { 
    3921 
    40         //protected Map<ResourceUnitName, List<AbstractResourceUnit>> resUnits; 
    41         protected PowerProfile powerProfile; 
    42         protected AirThroughputProfile airThroughputProfile; 
    43         protected ThermalProfile thermalProfile; 
    44         protected Location location; 
    45         protected String category; 
    46         //protected Parameters parameters; 
     22public class ComputingResourceDescription extends PhysicalResourceDescription implements ExecutingResourceDescription { 
    4723 
     24        protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 
     25        protected List<Device> devices; 
     26         
    4827        public ComputingResourceDescription(ComputingResource computingResource) { 
    4928 
     
    5534                if (computingResource.getComputingResourceTypeChoiceSequence() != null) { 
    5635                        initResourceUnits(computingResource.getComputingResourceTypeChoiceSequence().getResourceUnit()); 
    57                         try { 
    58                                 if(System.getProperty("coolemall.resdesc") != null){ 
    59                                         schemas.EnergyEstimationPlugin eep = new schemas.EnergyEstimationPlugin(); 
    60                                         eep.setName(getEEP(createEEPQuery(computingResource), System.getProperty("coolemall.resdesc"))); 
    61                                         if(computingResource.getComputingResourceTypeChoiceSequence().getProfile() != null) { 
    62                                                 if(computingResource.getComputingResourceTypeChoiceSequence().getProfile().getPowerProfile() != null) { 
    63                                                         computingResource.getComputingResourceTypeChoiceSequence().getProfile().getPowerProfile().setEnergyEstimationPlugin(eep); 
    64                                                 } 
    65                                         } else { 
    66                                                 schemas.Profile p = new schemas.Profile(); 
    67                                                 computingResource.getComputingResourceTypeChoiceSequence().setProfile(p); 
    68                                                 schemas.PowerProfile pp = new schemas.PowerProfile(); 
    69                                                 computingResource.getComputingResourceTypeChoiceSequence().getProfile().setPowerProfile(pp); 
    70                                                 computingResource.getComputingResourceTypeChoiceSequence().getProfile().getPowerProfile().setEnergyEstimationPlugin(eep); 
    71                                         } 
    72                                 } 
    73                         } catch (FileNotFoundException e) { 
    74                         } catch (IOException e) { 
    75                         } 
     36 
    7637                        initProfiles(computingResource.getComputingResourceTypeChoiceSequence().getProfile()); 
    7738                        initLocation(computingResource.getComputingResourceTypeChoiceSequence().getLocation()); 
     39                        initDevices(computingResource.getComputingResourceTypeChoiceSequence().getDevice()); 
    7840                        this.parameters = extractParameters(computingResource.getComputingResourceTypeChoiceSequence().getParameter()); 
    7941                } 
     
    9759                } 
    9860        } 
    99  
    100         private void initProfiles(Profile profile) { 
    101                 if (profile != null) { 
    102                         initPowerProfile(profile.getPowerProfile()); 
    103                         initAirThroughputProfile(profile.getAirThroughputProfile()); 
    104                         initThermalProfile(profile.getThermalProfile()); 
    105                 } 
    106         } 
    10761         
    108         private void initPowerProfile(schemas.PowerProfile powerProfileCharacteristic) { 
    109                  
    110                 if (powerProfileCharacteristic != null) { 
    111                         EnergyEstimationPlugin energyEstimationPlugin = null; 
    112                         List<PowerState> powerStates = null; 
    113                         List<PState> pStates = null; 
    114                         if(powerProfileCharacteristic.getEnergyEstimationPlugin() != null){ 
    115                                 String energyEstimationPluginName = powerProfileCharacteristic.getEnergyEstimationPlugin().getName(); 
    116                                 if(energyEstimationPluginName != null) { 
    117                                         energyEstimationPlugin = (EnergyEstimationPlugin) InstanceFactory.createInstance( 
    118                                                         energyEstimationPluginName, EnergyEstimationPlugin.class);                       
    119                                 } else { 
    120                                         energyEstimationPlugin = new DefaultEnergyEstimationPlugin(); 
    121                                 } 
    122                                 Parameters params = extractParameters(powerProfileCharacteristic.getEnergyEstimationPlugin().getParameter()); 
    123                                 energyEstimationPlugin.init(params); 
     62        private void initDevices(schemas.Device[] dev) { 
     63                if (dev != null){ 
     64                        this.devices = new ArrayList<Device>(); 
     65                        for(int i = 0; i < dev.length; i++){ 
     66                                Device device = new Device(new DeviceDescription(dev[i])); 
     67                                this.devices.add(device); 
    12468                        } 
    125                          
    126                         if(powerProfileCharacteristic.getPowerStates() != null) { 
    127                                 powerStates = new ArrayList<PowerState>(); 
    128                                 int powerStateCount = powerProfileCharacteristic.getPowerStates().getPowerStateCount(); 
    129                                 for (int i = 0; i < powerStateCount ; i++) { 
    130                                         schemas.PowerState ps = powerProfileCharacteristic.getPowerStates().getPowerState(i); 
    131                                         List<Transition> transitions = new ArrayList<Transition>(); 
    132                                         int transitionCount = ps.getTransitionCount(); 
    133                                         for (int j = 0; j < transitionCount; j++) { 
    134                                                 schemas.Transition t = ps.getTransition(j); 
    135                                                 Transition transition = new Transition(PowerStateNameFactory.createPowerStateName(t.getTo()), t 
    136                                                                 .getPowerUsage().getContent(), t.getTime().getContent()); 
    137                                                 Parameters params = extractParameters(t.getParameter()); 
    138                                                 transition.init(params); 
    139                                                 transitions.add(transition); 
    140                                         } 
    141                                         //CoolEmAll DEBB description case 
    142                                         if(ps.getPowerUsage() == null){ 
    143                                                 ps.setPowerUsage(new PowerUsage("0")); 
    144                                         } 
    145                                         PowerState powerState = new PowerState(PowerStateNameFactory.createPowerStateName(ps.getName()), ps 
    146                                                         .getPowerUsage().getContent(), transitions); 
    147                                         Parameters params = extractParameters(ps.getParameter()); 
    148                                         powerState.init(params); 
    149                                         powerStates.add(powerState); 
    150                                 } 
    151                         } 
    152                          
    153                         if(powerProfileCharacteristic.getParameter() != null){ 
    154                                 pStates = new ArrayList<PState>(); 
    155                                 int parameterCount = powerProfileCharacteristic.getParameterCount(); 
    156                                 for(int i = 0; i < parameterCount; i++){ 
    157                                         schemas.Parameter parameter = powerProfileCharacteristic.getParameter(i); 
    158                                         if(parameter.getName().equals("pState")){ 
    159                                                 PState.Builder builder = new PState.Builder(); 
    160                                                 int propertyCount = parameter.getParameterTypeSequence().getPropertyCount(); 
    161                                                 for(int j = 0; j < propertyCount; j++){ 
    162                                                         schemas.Property property = parameter.getParameterTypeSequence().getProperty(j); 
    163                                                         if(property.getName().equals("name")){ 
    164                                                                  builder = builder.name(property.getStringValueWithUnit(0).getContent()); 
    165                                                         } else if (property.getName().equals("frequency")){ 
    166                                                                  builder = builder.frequency(Double.valueOf(property.getStringValueWithUnit(0).getContent())); 
    167                                                         } else if (property.getName().equals("voltage")){ 
    168                                                                 builder = builder.voltage(Double.valueOf(property.getStringValueWithUnit(0).getContent())); 
    169                                                         } else if (property.getName().equals("powerUsage")){ 
    170                                                                 if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){ 
    171                                                                         builder = builder.powerUsage(Double.valueOf(property.getStringValueWithUnit(0).getContent()));   
    172                                                                 } 
    173                                                         } else if (property.getName().equals("powerUsageMin")){ 
    174                                                                 if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){ 
    175                                                                         builder = builder.powerUsageMin(Double.valueOf(property.getStringValueWithUnit(0).getContent()));        
    176                                                                 } 
    177                                                         } else if (property.getName().equals("powerUsageMax")){ 
    178                                                                 if(property.getStringValueWithUnit(0).getContent() != null && property.getStringValueWithUnit(0).getContent().length() > 0){ 
    179                                                                         builder = builder.powerUsageMax(Double.valueOf(property.getStringValueWithUnit(0).getContent()));        
    180                                                                 } 
    181                                                         } 
    182                                                 } 
    183                                                 PState pState = builder.build(); 
    184                                                 pStates.add(pState); 
    185                                         } 
    186                                 }        
    187                         } 
    188                         this.powerProfile = new PowerProfile(energyEstimationPlugin, powerStates, pStates); 
    189                         Parameters params = extractParameters(powerProfileCharacteristic.getParameter()); 
    190                         this.powerProfile.init(params); 
    19169                } 
    19270        } 
    19371 
    194         private void initAirThroughputProfile(schemas.AirThroughputProfile airThroughputProfile) { 
    195                 if (airThroughputProfile != null) { 
    196                          
    197                         AirThroughputEstimationPlugin airThroughputEstimationPlugin = null; 
    198                         List<AirThroughputState> airThroughputStates = null; 
    199                         if(airThroughputProfile.getAirThroughputEstimationPlugin() != null){ 
    200                                 String airThroughputEstimationPluginName = airThroughputProfile.getAirThroughputEstimationPlugin().getName(); 
    201                                 if(airThroughputEstimationPluginName != null) { 
    202                                         airThroughputEstimationPlugin = (AirThroughputEstimationPlugin) InstanceFactory.createInstance( 
    203                                                         airThroughputEstimationPluginName, AirThroughputEstimationPlugin.class);                         
    204                                 } else { 
    205                                         airThroughputEstimationPlugin = new DefaultAirThroughputEstimationPlugin(); 
    206                                 } 
    207                                 Parameters params = extractParameters(airThroughputProfile.getAirThroughputEstimationPlugin().getParameter()); 
    208                                 airThroughputEstimationPlugin.init(params); 
    209                         } 
    210                         if(airThroughputProfile.getAirThroughputStates() != null){ 
    211                                 airThroughputStates = new ArrayList<AirThroughputState>(); 
    212                                 int airThrouhputStateCount = airThroughputProfile.getAirThroughputStates().getAirThroughputStateCount(); 
    213                                 for (int i = 0; i < airThrouhputStateCount; i++) { 
    214                                         schemas.AirThroughputState ats = airThroughputProfile.getAirThroughputStates().getAirThroughputState(i); 
    215                                         AirThroughputState airThroughputState = new AirThroughputState(ats.getName(), ats.getValue() 
    216                                                         .getContent(), ats.getPowerUsage().getContent()); 
    217                                         Parameters params = extractParameters(ats.getParameter()); 
    218                                         airThroughputState.init(params); 
    219                                         airThroughputStates.add(airThroughputState); 
    220                                 } 
    221                         } 
    222                         this.airThroughputProfile = new AirThroughputProfile(airThroughputEstimationPlugin, airThroughputStates); 
    223                         Parameters params = extractParameters(airThroughputProfile.getParameter()); 
    224                         this.airThroughputProfile.init(params); 
    225                 } 
     72        public String getCompResourceParameterValue(String name){ 
     73                return getParameters().get(name).get(0).getContent(); 
    22674        } 
    227          
    228         private void initThermalProfile(schemas.ThermalProfile thermalProfile) { 
    229                  
    230                 if (thermalProfile != null) { 
    231                          
    232                         TemperatureEstimationPlugin temperatureEstimationPlugin = null; 
    233  
    234                         if(thermalProfile.getTemperatureEstimationPlugin() != null){ 
    235                                 String temperatureEstimationPluginName = thermalProfile.getTemperatureEstimationPlugin().getName(); 
    236                                 if(temperatureEstimationPluginName != null) { 
    237                                         temperatureEstimationPlugin = (TemperatureEstimationPlugin) InstanceFactory.createInstance( 
    238                                                         temperatureEstimationPluginName, TemperatureEstimationPlugin.class);                     
    239                                 } else { 
    240                                         temperatureEstimationPlugin = new DefaultTemperatureEstimationPlugin(); 
    241                                 } 
    242                                 Parameters params = extractParameters(thermalProfile.getTemperatureEstimationPlugin().getParameter()); 
    243                                 temperatureEstimationPlugin.init(params); 
    244                         } 
    245                         this.thermalProfile = new ThermalProfile(); 
    246                         Parameters params = extractParameters(thermalProfile.getParameter()); 
    247                         this.thermalProfile.init(params); 
    248                 } 
    249         } 
    250          
    251         private void initLocation(schemas.Location l) { 
    252                 if (location != null) { 
    253                         this.location = new Location(l.getHorizontal(), l.getVertical(), l.getDepth()); 
    254                         Parameters params = extractParameters(l.getParameter()); 
    255                         this.location.init(params); 
    256                 } 
    257         } 
    258  
    25975 
    26076        /*private Properties initProperties(schemas.Parameter[] parameters){ 
     
    285101                return prop; 
    286102        }*/ 
    287          
    288         private Parameters extractParameters(schemas.Parameter[] parameters){ 
    289                  
    290                 Parameters params = null; 
    291                  
    292                 if(parameters.length != 0) 
    293                         params = new Parameters(); 
    294                  
    295                 for(int i = 0; i < parameters.length; i++){ 
    296                         schemas.Parameter parameter = parameters[i]; 
    297                         Parameter param = new Parameter(parameter.getName()); 
    298                         if(parameter.getParameterTypeSequence() != null && parameter.getParameterTypeSequence().getProperty() != null) 
    299                         {                                                        
    300                                 int propertyCount = parameter.getParameterTypeSequence().getPropertyCount(); 
    301                                 for(int j = 0; j < propertyCount; j++){ 
    302                                         schemas.Property property = parameter.getParameterTypeSequence().getProperty(j); 
    303                                         Property prop = new Property(property.getName()); 
    304                                         int stringValueWithUnitCount = property.getStringValueWithUnitCount(); 
    305                                         for(int k = 0; k < stringValueWithUnitCount; k++){ 
    306                                                 prop.add(property.getStringValueWithUnit(k)); 
    307                                         } 
    308                                         param.addProperty(prop); 
    309                                 } 
    310                         } else { 
    311                                 int stringValueWithUnitCount =  parameter.getStringValueWithUnitCount(); 
    312                                 for(int j = 0; j < stringValueWithUnitCount; j++){ 
    313                                         param.add(parameter.getStringValueWithUnit(j)); 
    314                                 } 
    315                         } 
    316                         params.put(parameter.getName(), param); 
    317                 } 
    318                 return params; 
    319         } 
    320103 
    321         public PowerProfile getPowerProfile() { 
    322                 return powerProfile; 
    323         } 
    324104 
    325         public AirThroughputProfile getAirThroughputProfile() { 
    326                 return airThroughputProfile; 
    327         } 
    328  
    329         public ThermalProfile getThermalProfile() { 
    330                 return thermalProfile; 
    331         } 
    332          
    333         public Location getLocation() { 
    334                 return location; 
    335         } 
    336  
    337         public String getCategory() { 
    338                 return category; 
     105        public List<Device> getDevices() { 
     106                return devices; 
    339107        } 
    340108 
    341109 
    342         /***COOLEMALL CASE RELATED***/ 
    343  
    344         private static ResourceBundle recsBundle; 
    345          
    346         private ResourceBundle getRecsBundle(String fileName) throws FileNotFoundException, IOException{ 
    347                 if(recsBundle == null){ 
    348                         recsBundle = new PropertyResourceBundle(new FileInputStream(fileName)); 
     110        public void addResourceUnit(ResourceUnit unit) { 
     111                if (this.resUnits == null) 
     112                        this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(1); 
     113                List<ResourceUnit> list = null; 
     114                if (this.resUnits.containsKey(unit.getName())) { 
     115                        list = this.resUnits.get(unit.getName()); 
     116                } else { 
     117                        list = new ArrayList<ResourceUnit>(1); 
     118                        this.resUnits.put(unit.getName(), list); 
    349119                } 
    350                 return recsBundle; 
     120                list.add(unit); 
    351121        } 
    352122         
    353         protected String getEEP(String query, String fileName) throws FileNotFoundException, IOException{ 
    354                 ResourceBundle recsBundle = getRecsBundle(fileName); 
    355                 return recsBundle.getString(query); 
     123        public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException { 
     124                return getResourceUnitList(unitName).get(0); 
    356125        } 
    357          
    358         protected String createEEPQuery(ComputingResource compRes) { 
    359                 String query = compRes.getClazz() + "EEP"; 
    360                 return query; 
     126 
     127        public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException { 
     128                if (resUnits.containsKey(unitName)) 
     129                        return resUnits.get(unitName); 
     130                else 
     131                        throw new NoSuchFieldException("Resource unit " + unitName + " is not available in resource " + this.id); 
     132        } 
     133 
     134        public Collection<ResourceUnit> getResourceUnit() { 
     135                if (resUnits == null) 
     136                        return null; 
     137                List<ResourceUnit> values = new ArrayList<ResourceUnit>(); 
     138                Collection<List<ResourceUnit>> lists = resUnits.values(); 
     139                Iterator<List<ResourceUnit>> itr = lists.iterator(); 
     140 
     141                while (itr.hasNext()) { 
     142                        List<ResourceUnit> list = itr.next(); 
     143                        values.addAll(list); 
     144                } 
     145 
     146                return values; 
     147        } 
     148 
     149        public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() { 
     150                return resUnits; 
    361151        } 
    362152} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ExecutingResourceDescription.java

    r477 r1207  
    11package schedframe.resources.computing.description; 
    22 
    3 import java.util.ArrayList; 
    43import java.util.Collection; 
    5 import java.util.HashMap; 
    6 import java.util.Iterator; 
    74import java.util.List; 
    85import java.util.Map; 
    96 
    10 import schedframe.Parameters; 
    11 import schedframe.resources.ResourceType; 
    127import schedframe.resources.units.ResourceUnit; 
    138import schedframe.resources.units.ResourceUnitName; 
    149 
    15 public class ExecutingResourceDescription extends AbstractResourceDescription { 
     10public interface ExecutingResourceDescription { 
     11         
     12        public void addResourceUnit(ResourceUnit unit); 
     13         
     14        public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException ; 
    1615 
    17         protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 
    18         protected Parameters parameters; 
     16        public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException; 
     17 
     18        public Collection<ResourceUnit> getResourceUnit(); 
    1919         
    20         public ExecutingResourceDescription(ResourceType type) { 
    21                 super(type); 
    22         } 
    23  
    24         public Parameters getParameters() { 
    25                 return parameters; 
    26         } 
    27          
    28         public String getCompResourceParameterValue(String name){ 
    29                 return getParameters().get(name).get(0).getContent(); 
    30         } 
    31          
    32         public void addResourceUnit(ResourceUnit unit) { 
    33                 if (this.resUnits == null) 
    34                         this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(1); 
    35                 List<ResourceUnit> list = null; 
    36                 if (this.resUnits.containsKey(unit.getName())) { 
    37                         list = this.resUnits.get(unit.getName()); 
    38                 } else { 
    39                         list = new ArrayList<ResourceUnit>(1); 
    40                         this.resUnits.put(unit.getName(), list); 
    41                 } 
    42                 list.add(unit); 
    43         } 
    44          
    45         public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException { 
    46                 return getResourceUnitList(unitName).get(0); 
    47         } 
    48  
    49         public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException { 
    50                 if (resUnits.containsKey(unitName)) 
    51                         return resUnits.get(unitName); 
    52                 else 
    53                         throw new NoSuchFieldException("Resource unit " + unitName + " is not available in resource " + this.id); 
    54         } 
    55  
    56         public Collection<ResourceUnit> getResourceUnit() { 
    57                 if (resUnits == null) 
    58                         return null; 
    59                 List<ResourceUnit> values = new ArrayList<ResourceUnit>(); 
    60                 Collection<List<ResourceUnit>> lists = resUnits.values(); 
    61                 Iterator<List<ResourceUnit>> itr = lists.iterator(); 
    62  
    63                 while (itr.hasNext()) { 
    64                         List<ResourceUnit> list = itr.next(); 
    65                         values.addAll(list); 
    66                 } 
    67  
    68                 return values; 
    69         } 
    70  
    71         public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() { 
    72                 return resUnits; 
    73         } 
     20        public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits(); 
    7421} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/description/ResourceDescription.java

    r477 r1207  
    55import java.util.List; 
    66 
     7import schedframe.Parameters; 
    78import schedframe.resources.ResourceType; 
    89 
    910 
    10 public abstract class AbstractResourceDescription { 
     11public abstract class ResourceDescription { 
    1112 
    1213        protected String id; 
    1314        protected ResourceType type; 
    14         protected List<AbstractResourceDescription> children; 
     15        protected List<ResourceDescription> children; 
     16        protected Parameters parameters; 
    1517         
    16         public AbstractResourceDescription(ResourceType type){ 
     18        public ResourceDescription(ResourceType type){ 
    1719                this.type = type; 
    18                 this.children = null; 
    1920        } 
    2021 
    21         public List<AbstractResourceDescription> getChildren() { 
     22        public List<ResourceDescription> getChildren() { 
    2223                return children; 
    2324        } 
    2425         
    25         public void setChildren(List<AbstractResourceDescription> children) { 
     26        public void setChildren(List<ResourceDescription> children) { 
    2627                this.children = children; 
    2728        } 
    2829         
    29         public void addChildren(AbstractResourceDescription child) { 
     30        public void addChildren(ResourceDescription child) { 
    3031                //child.setParent(this); 
    3132                if(children == null) 
    32                         children = new ArrayList<AbstractResourceDescription> (1); 
     33                        children = new ArrayList<ResourceDescription> (1); 
    3334                this.children.add(child); 
    3435        } 
     
    4041        public ResourceType getType() { 
    4142                return type; 
     43        } 
     44         
     45        public Parameters getParameters() { 
     46                return parameters; 
    4247        } 
    4348         
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/EnergyExtension.java

    r1165 r1207  
    77 
    88import schedframe.events.Event; 
    9 import schedframe.resources.computing.ComputingResource; 
    109import schedframe.resources.computing.extensions.Extension; 
    1110import schedframe.resources.computing.extensions.ExtensionException; 
     
    2019import schedframe.resources.computing.profiles.energy.thermal.ThermalProfile; 
    2120import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface; 
     21import schedframe.resources.devices.PhysicalResource; 
    2222import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
     23import simulator.DataCenterWorkloadSimulator; 
    2324 
    2425public class EnergyExtension implements Extension{ 
     
    3536        protected ThermalProfile thermalProfile; 
    3637         
    37         protected ComputingResource computingResource; 
    38  
    39  
    40         public EnergyExtension(ComputingResource computingResource, PowerInterface powerInterface, PowerProfile powerProfile) { 
     38        protected PhysicalResource resource; 
     39 
     40 
     41        /*public EnergyExtension(PhysicalResource resource, PowerInterface powerInterface, PowerProfile powerProfile) { 
     42                super(); 
     43                this.resource = resource; 
    4144                this.powerProfile = powerProfile; 
    42                 this.powerInterface = PowerInterfaceFactory.createPowerInterface(computingResource, powerProfile); 
    43         } 
    44          
    45         public EnergyExtension(ComputingResource computingResource, PowerProfile powerProfile, 
     45                this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); 
     46        } 
     47         
     48        public EnergyExtension(PhysicalResource resource, PowerProfile powerProfile, 
    4649                        AirThroughputProfile airFlowProfile) { 
    4750                super(); 
    48                 this.computingResource = computingResource; 
     51                this.resource = resource; 
    4952                this.powerProfile = powerProfile; 
    50                 this.powerInterface = PowerInterfaceFactory.createPowerInterface(computingResource, powerProfile); 
     53                this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); 
    5154                this.airFlowProfile = airFlowProfile; 
    52                 this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(computingResource, airFlowProfile); 
    53         } 
    54          
    55         public EnergyExtension(ComputingResource computingResource, PowerProfile powerProfile, 
     55                this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(resource, airFlowProfile); 
     56        } 
     57         
     58        public EnergyExtension(PhysicalResource resource, PowerProfile powerProfile, 
    5659                        AirThroughputProfile airFlowProfile, ThermalProfile thermalProfile) { 
    5760                super(); 
    58                 this.computingResource = computingResource; 
     61                this.resource = resource; 
    5962                this.powerProfile = powerProfile; 
    60                 this.powerInterface = PowerInterfaceFactory.createPowerInterface(computingResource, powerProfile); 
     63                this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); 
    6164                this.airFlowProfile = airFlowProfile; 
    62                 this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(computingResource, airFlowProfile); 
     65                this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(resource, airFlowProfile); 
    6366                this.thermalProfile = thermalProfile; 
    64                 this.thermalInterface = ThermalInterfaceFactory.createThermalInterface(computingResource, thermalProfile); 
    65         } 
    66  
     67                this.thermalInterface = ThermalInterfaceFactory.createThermalInterface(resource, thermalProfile); 
     68        }*/ 
     69 
     70        public static class Builder { 
     71                   
     72                protected PhysicalResource resource; 
     73                protected PowerInterface powerInterface; 
     74                protected PowerProfile powerProfile; 
     75                 
     76                protected AirThroughputInterface airFlowInterface; 
     77                protected AirThroughputProfile airFlowProfile; 
     78                 
     79                protected ThermalInterface thermalInterface; 
     80                protected ThermalProfile thermalProfile; 
     81                 
     82                public Builder resource(PhysicalResource res) {this.resource = res; return this;} 
     83                 
     84                public Builder powerProfile(PowerProfile pp){this.powerProfile = pp; this.powerInterface = PowerInterfaceFactory.createPowerInterface(resource, powerProfile); return this; } 
     85 
     86        public Builder airFlowProfile(AirThroughputProfile atp){this.airFlowProfile = atp; this.airFlowInterface = AirThroughputInterfaceFactory.createAirThroughputInterface(resource, airFlowProfile); return this; } 
     87 
     88        public Builder thermalProfile(ThermalProfile tp){this.thermalProfile = tp; this.thermalInterface = ThermalInterfaceFactory.createThermalInterface(resource, thermalProfile); return this; } 
     89 
     90        public EnergyExtension build() { 
     91            return new EnergyExtension(this); 
     92        } 
     93        } 
     94         
     95        private EnergyExtension(Builder builder) { 
     96                this.resource = builder.resource; 
     97                this.powerInterface = builder.powerInterface; 
     98                this.powerProfile = builder.powerProfile; 
     99                 
     100                this.airFlowInterface = builder.airFlowInterface ; 
     101                this.airFlowProfile = builder.airFlowProfile; 
     102                 
     103                this.thermalInterface = builder.thermalInterface; 
     104                this.thermalProfile = builder.thermalProfile; 
     105        } 
     106 
     107         
    67108        public boolean supportsEvent(Event event) { 
    68109 
     
    82123                if(event.getType().getName().equals(EnergyEventType.AIRFLOW_STATE_CHANGED.getName())) 
    83124                        return true; 
     125                if(event.getType().getName().equals(EnergyEventType.TEMPERATURE_CHANGED.getName())) 
     126                        return true; 
    84127                 
    85128                else return false; 
     
    90133                EnergyEvent enEvent = (EnergyEvent)event; 
    91134                double power = 0; 
    92                 double temperature = 0; 
     135                boolean status = false; 
    93136                try{ 
    94137                        switch (enEvent.getType()) { 
    95138                         
    96139                        case POWER_STATE_CHANGED: 
    97                                 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
     140                                power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 
    98141                                /*if(computingResource instanceof ComputingNode){ 
    99142                                        ComputingNode node = (ComputingNode)computingResource; 
     
    109152                                        } 
    110153                                } 
    111                                 else*/ powerProfile.addToPowerUsageHistory(power); 
    112                                 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    113                                 thermalProfile.addToTemperatureHistory(temperature); 
     154                                else*/  
     155                                 
     156                                status = powerProfile.addToPowerUsageHistory(power); 
    114157                                break; 
    115158                                 
    116159                        case FREQUENCY_CHANGED: 
    117                                 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    118                                 powerProfile.addToPowerUsageHistory(power); 
    119                                 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    120                                 thermalProfile.addToTemperatureHistory(temperature); 
     160                                power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 
     161                                status = powerProfile.addToPowerUsageHistory(power); 
    121162                                break; 
    122163                                 
    123164                        case TASK_STARTED: 
    124                                 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    125                                 powerProfile.addToPowerUsageHistory(power); 
    126                                 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    127                                 thermalProfile.addToTemperatureHistory(temperature); 
     165                                power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 
     166                                status = powerProfile.addToPowerUsageHistory(power); 
    128167                                break; 
    129168         
    130169                        case TASK_FINISHED: 
    131                                 //System.out.println(this.resource.getName() + " - ENERGY EXTENSION: TASK FINISHED"); 
    132                                 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    133                                 //System.out.println(this.resource.getName() + " - ESTIMATED ENERGY:" + power); 
    134                                 powerProfile.addToPowerUsageHistory(power); 
    135                                 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    136                                 thermalProfile.addToTemperatureHistory(temperature); 
     170                                power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 
     171                                status = powerProfile.addToPowerUsageHistory(power); 
    137172                                break; 
    138173                                 
    139174                        case RESOURCE_UTILIZATION_CHANGED: 
    140                                 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    141                                 powerProfile.addToPowerUsageHistory(power); 
    142                                 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    143                                 thermalProfile.addToTemperatureHistory(temperature); 
     175                                power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 
     176                                status = powerProfile.addToPowerUsageHistory(power); 
    144177                                break; 
    145178                                 
    146179                        case AIRFLOW_STATE_CHANGED: 
    147                                 double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    148                                 airFlowProfile.addToPowerUsageHistory(airFlow); 
    149                                 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
    150                                 powerProfile.addToPowerUsageHistory(power); 
    151                                 temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
     180                                double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 
     181                                airFlowProfile.addToAirFlowHistory(airFlow); 
     182                                break; 
     183                                 
     184                        case TEMPERATURE_CHANGED: 
     185                                double temperature = powerProfile.getEnergyEstimationPlugin().estimateTemperature(enEvent, new JobRegistryImpl(resource.getFullName()), resource); 
    152186                                thermalProfile.addToTemperatureHistory(temperature); 
    153187                                break; 
     
    156190                         
    157191                } 
     192                if(status){ 
     193                        DataCenterWorkloadSimulator.getEventManager().sendToResources(resource.getType(), 0, new EnergyEvent(EnergyEventType.TEMPERATURE_CHANGED, resource.getFullName())); 
     194                } 
    158195        } 
    159196 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputInterfaceFactory.java

    r753 r1207  
    11package schedframe.resources.computing.profiles.energy.airthroughput; 
    22 
     3import schedframe.resources.StandardResourceType; 
    34import schedframe.resources.computing.ComputingResource; 
    45import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 
    56import schedframe.resources.computing.profiles.energy.airthroughput.ui.ComputingResourceAirThroughputInterface; 
     7import schedframe.resources.devices.PhysicalResource; 
     8import schedframe.resources.devices.PhysicalResourceAirThroughputInterface; 
     9import schedframe.resources.devices.coolemall.FanAirThroughputInterface; 
    610 
    711public class AirThroughputInterfaceFactory { 
    812         
    9         public static AirThroughputInterface createAirThroughputInterface(ComputingResource resource, AirThroughputProfile atp){ 
     13        public static AirThroughputInterface createAirThroughputInterface(PhysicalResource resource, AirThroughputProfile atp){ 
    1014                if(atp == null) 
    1115                        return null; 
    12                 AirThroughputInterface airThroughputInterface = new ComputingResourceAirThroughputInterface(resource, atp); 
    13  
     16                AirThroughputInterface airThroughputInterface = null; 
     17                if(resource.getType().getName().equals(StandardResourceType.CRAH.getName())) 
     18                        airThroughputInterface = new PhysicalResourceAirThroughputInterface(resource, atp); 
     19                else if(resource.getType().getName().equals(StandardResourceType.Fan.getName())) 
     20                        airThroughputInterface = new FanAirThroughputInterface(resource, atp); 
     21                else if(resource.getType().getName().equals(StandardResourceType.Inlet.getName())) 
     22                        airThroughputInterface = new FanAirThroughputInterface(resource, atp); 
     23                else if(resource.getType().getName().equals(StandardResourceType.Outlet.getName())) 
     24                        airThroughputInterface = new FanAirThroughputInterface(resource, atp); 
     25                else if(resource.getType().getName().equals(StandardResourceType.CoolingDevice.getName())) 
     26                        airThroughputInterface = new PhysicalResourceAirThroughputInterface(resource, atp); 
     27                else 
     28                        airThroughputInterface = new ComputingResourceAirThroughputInterface((ComputingResource)resource, atp); 
    1429                return airThroughputInterface; 
    1530        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java

    r495 r1207  
    2828        } 
    2929         
    30         public void addToPowerUsageHistory(double airFlow) { 
     30        public void addToAirFlowHistory(double airFlow) { 
    3131 
    3232                if (airFlowHistory.size() == 0) { 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/StandardAirThroughputStateName.java

    r753 r1207  
    33public enum  StandardAirThroughputStateName implements AirThroughputStateName{ 
    44 
    5         FAN_ON, 
    6         FAN_OFF; 
     5        ON, 
     6        OFF; 
    77 
    88        public String getName() { 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/AirThroughputInterface.java

    r754 r1207  
    44 
    55import schedframe.Parameters; 
     6import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue; 
    67import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 
    78import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputStateName; 
     
    910public interface AirThroughputInterface { 
    1011         
    11         public AirThroughputStateName  getAirThroughputState(); 
     12        public AirThroughputStateName getAirThroughputState(); 
    1213         
    1314        public boolean setAirThroughputState(AirThroughputStateName airThroughputState); 
     
    2122        public double getPowerConsumption(AirThroughputStateName state) throws NoSuchFieldException; 
    2223         
     24        public AirFlowValue getRecentAirFlow(); 
     25         
     26        List<AirFlowValue> getAirFlowHistory(); 
     27         
    2328        public Parameters getParameters(); 
     29         
     30         
    2431} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/airthroughput/ui/ComputingResourceAirThroughputInterface.java

    r754 r1207  
    44import java.util.List; 
    55 
     6import org.joda.time.DateTimeUtils; 
     7 
    68import schedframe.Parameters; 
    79import schedframe.resources.computing.ComputingResource; 
    810import schedframe.resources.computing.profiles.energy.EnergyEvent; 
    911import schedframe.resources.computing.profiles.energy.EnergyEventType; 
     12import schedframe.resources.computing.profiles.energy.airthroughput.AirFlowValue; 
    1013import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 
    1114import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputState; 
     
    2225                this.resource = resource; 
    2326                this.airThroughputProfile = airThroughputProfile; 
    24                 this.currentAirThroughputState = StandardAirThroughputStateName.FAN_ON; 
     27                this.currentAirThroughputState = StandardAirThroughputStateName.ON; 
    2528        } 
    2629         
     
    3437                         
    3538                        //TO DO - notifications should be called for all resources starting form the lowest layer 
    36                         resource.handleEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, resource.getName())); 
     39                        resource.handleEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, resource.getFullName())); 
     40                        resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName())); 
    3741                        return true; 
    3842                } 
     
    8387        } 
    8488         
     89        public AirFlowValue getRecentAirFlow() { 
     90                AirFlowValue airFlow = null; 
     91                int lastIdx = getAirFlowHistory().size() - 1; 
     92                if(lastIdx >= 0) 
     93                        airFlow = getAirFlowHistory().get(lastIdx); 
     94                else {   
     95                        try { 
     96                                airFlow = new AirFlowValue(DateTimeUtils.currentTimeMillis(), getAirFlow(currentAirThroughputState)); 
     97                        } catch (NoSuchFieldException e) { 
     98                        } 
     99                } 
     100                return airFlow; 
     101        } 
     102         
     103        public List<AirFlowValue> getAirFlowHistory(){ 
     104                return airThroughputProfile.getAirThroughputHistory(); 
     105        } 
     106         
     107         
    85108        public Parameters getParameters() { 
    86109                return airThroughputProfile.getParameters(); 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PState.java

    r1119 r1207  
    11package schedframe.resources.computing.profiles.energy.power; 
     2 
     3import java.util.Map; 
     4import java.util.TreeMap; 
    25 
    36public class PState { 
     
    912        protected double powerUsageMin; 
    1013        protected double powerUsageMax; 
    11  
     14        //protected List<LoadPowerUsage> loadPowerUsageList; 
     15        protected Map<Double, Double> loadPowerUsage; 
     16         
    1217        /*public PState(PStateType name, double frequency, double voltage, double power) { 
    1318                super(); 
     
    3843                return powerUsageMax; 
    3944        } 
    40          
     45        /*public List<LoadPowerUsage> getLoadPowerUsageList() { 
     46                return loadPowerUsageList; 
     47        }*/ 
     48        public Map<Double, Double> getLoadPowerUsage() { 
     49                if(loadPowerUsage == null) { 
     50                        return new TreeMap<Double, Double>(); 
     51                } 
     52                return loadPowerUsage; 
     53        } 
     54 
    4155        public static class Builder { 
    4256           
     
    4761                protected double powerUsageMin; 
    4862                protected double powerUsageMax; 
     63                //protected List<LoadPowerUsage> loadPowerUsageList = new ArrayList<LoadPowerUsage>(); 
     64                protected Map<Double, Double> loadPowerUsage = new TreeMap<Double, Double>(); 
    4965                 
    5066                public Builder name(String name){this.name = name; return this; } 
     
    5470        public Builder powerUsageMin(double rate){this.powerUsageMin = rate; return this; } 
    5571        public Builder powerUsageMax(double rate){this.powerUsageMax = rate; return this; } 
     72        //public Builder loadPowerUsage(LoadPowerUsage lpu){this.loadPowerUsageList.add(lpu); return this; } 
     73        public Builder loadPowerUsage(double load, double power){this.loadPowerUsage.put(load, power); return this; } 
    5674         
    5775        public PState build() { 
     
    6785                this.powerUsageMin = builder.powerUsageMin; 
    6886                this.powerUsageMax = builder.powerUsageMax; 
     87                //this.loadPowerUsageList = builder.loadPowerUsageList; 
     88                this.loadPowerUsage = builder.loadPowerUsage; 
    6989        } 
     90 
     91 
    7092} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PowerInterfaceFactory.java

    r1104 r1207  
    11package schedframe.resources.computing.profiles.energy.power; 
    22 
    3 import schedframe.resources.CoolEmAllResourceType; 
    43import schedframe.resources.StandardResourceType; 
    54import schedframe.resources.computing.ComputingResource; 
    65import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
     6import schedframe.resources.devices.PhysicalResource; 
     7import schedframe.resources.devices.PhysicalResourcePowerInterface; 
    78 
    89public class PowerInterfaceFactory { 
    910 
    10  
    11  
    12         //new1 
    13         /*public static PowerInterface createPowerProfile(ResourceType resourceType, List<PowerState> powerStates, List<PState> pStates, String eepn){ 
    14  
    15                 PowerInterface powerProfile; 
    16  
    17                 switch(resourceType){ 
    18                         case DataCenter: powerProfile = new DataCenterPowerInterfaceNew(eepn, powerStates); break; 
    19                         case ComputingNode: powerProfile = new ComputingNodePowerInterfaceNew(eepn, powerStates); break; 
    20                         case Processor: powerProfile = new CPUPowerInterfaceNew(eepn, powerStates, pStates); break; 
    21                         default: 
    22                                 throw new IllegalArgumentException("ResourceType " + resourceType + " is not supported."); 
    23                 } 
    24  
    25                 return powerProfile; 
    26         }*/ 
    2711         
    28         public static PowerInterface createPowerInterface(ComputingResource resource, PowerProfile pp){ 
     12        public static PowerInterface createPowerInterface(PhysicalResource resource, PowerProfile pp){ 
    2913                if(pp == null) 
    3014                        return null; 
    3115                PowerInterface powerInterface; 
    32  
     16                 
    3317                if(resource.getType().getName().equals(StandardResourceType.DataCenter.getName())) 
    34                         powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.DataCenterPowerInterface(resource, pp); 
    35                 else if (resource.getType().getName().equals(StandardResourceType.ComputingNode.getName())) 
    36                         powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface(resource, pp); 
     18                        powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.DataCenterPowerInterface((ComputingResource)resource, pp); 
     19                else if (resource.getType().getName().equals(StandardResourceType.Node.getName())) 
     20                        powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface((ComputingResource)resource, pp); 
    3721                else if (resource.getType().getName().equals(StandardResourceType.Processor.getName())) 
    38                         powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface(resource, pp); 
    39                 else if (resource.getType().getName().equals(CoolEmAllResourceType.Node.getName())) 
    40                         powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface(resource, pp); 
     22                        powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface((ComputingResource)resource, pp); 
     23                else if (resource.getType().getName().equals(StandardResourceType.CRAH.getName())) 
     24                        powerInterface = new PhysicalResourcePowerInterface(resource, pp); 
     25                else if (resource.getType().getName().equals(StandardResourceType.Fan.getName())) 
     26                        powerInterface = new PhysicalResourcePowerInterface(resource, pp); 
     27                else if (resource.getType().getName().equals(StandardResourceType.Inlet.getName())) 
     28                        powerInterface = new PhysicalResourcePowerInterface(resource, pp); 
     29                else if (resource.getType().getName().equals(StandardResourceType.Outlet.getName())) 
     30                        powerInterface = new PhysicalResourcePowerInterface(resource, pp); 
     31                else if (resource.getType().getName().equals(StandardResourceType.CoolingDevice.getName())) 
     32                        powerInterface = new PhysicalResourcePowerInterface(resource, pp); 
     33                else if (resource.getType().getName().equals(StandardResourceType.Heatsink.getName())) 
     34                        powerInterface = new PhysicalResourcePowerInterface(resource, pp); 
    4135                else  
    42                         powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingResourcePowerInterface(resource, pp); 
     36                        powerInterface = new schedframe.resources.computing.profiles.energy.power.ui.ComputingResourcePowerInterface((ComputingResource)resource, pp); 
    4337 
    4438                /*switch(resource.getType()){ 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/PowerProfile.java

    r1167 r1207  
    2424        public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates) { 
    2525                this.energyEstimationPlugin = energyEstimationPlugin; 
     26                this.supportedPowerStates = powerStates; 
    2627                this.powerUsage = new ArrayList<PowerUsage>(); 
    27                 this.supportedPowerStates = powerStates; 
     28                initDefaultPowerStates(); 
    2829        } 
    2930         
    30         public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates,  List<PState> pStates) { 
     31        public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates, List<PState> pStates) { 
    3132                this.energyEstimationPlugin = energyEstimationPlugin; 
    3233                this.supportedPowerStates = powerStates; 
     
    3738                        supportedPStates.put(pState.getName(), pState); 
    3839                } 
     40                initDefaultPowerStates(); 
    3941        } 
    4042         
     
    6062        } 
    6163         
    62         public List<PowerState> getSupportedPowerStates() throws NoSuchFieldException{ 
     64        public List<PowerState> getSupportedPowerStates() { 
    6365                if(supportedPowerStates == null) 
    64                         throw new NoSuchFieldException("Supported power states are not defined."); 
     66                        return new ArrayList<PowerState>(); 
    6567                return supportedPowerStates; 
    6668        } 
     
    111113        } 
    112114 
    113  
     115        protected void initDefaultPowerStates(){ 
     116                boolean supportsON = false; 
     117                boolean supportsOFF = false; 
     118                if(supportedPowerStates == null){ 
     119                        supportedPowerStates = new ArrayList<PowerState>(); 
     120                } 
     121                for(PowerState ps: supportedPowerStates){ 
     122                        if(ps.getName().equals(StandardPowerStateName.ON)){ 
     123                                supportsON = true; 
     124                        } else if (ps.getName().equals(StandardPowerStateName.OFF)){ 
     125                                supportsOFF = true; 
     126                        } 
     127                } 
     128                 
     129                if(!supportsON){ 
     130                        supportedPowerStates.add(new PowerState(StandardPowerStateName.ON, -1, new ArrayList<Transition>())); 
     131                } 
     132                if(!supportsOFF){ 
     133                        supportedPowerStates.add(new PowerState(StandardPowerStateName.OFF, -1, new ArrayList<Transition>())); 
     134                } 
     135        } 
    114136} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/plugin/EnergyEstimationPlugin.java

    r477 r1207  
    22 
    33import schedframe.Plugin; 
    4 import schedframe.resources.computing.ComputingResource; 
    54import schedframe.resources.computing.profiles.energy.EnergyEvent; 
     5import schedframe.resources.devices.PhysicalResource; 
    66import schedframe.scheduling.manager.tasks.JobRegistry; 
    77 
    88public interface EnergyEstimationPlugin extends Plugin { 
    99         
    10         public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 
     10        public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource); 
    1111 
    12         public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 
     12        public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource); 
    1313 
    14         public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 
     14        public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, PhysicalResource resource); 
    1515 
    1616} 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingNodePowerInterface.java

    r1166 r1207  
    11package schedframe.resources.computing.profiles.energy.power.ui; 
    22 
     3 
     4 
     5import org.joda.time.DateTime; 
     6 
     7import schedframe.SimulatedEnvironment; 
    38import schedframe.resources.ResourceStatus; 
    49import schedframe.resources.computing.ComputingNode; 
     
    3843                 
    3944                if(!pePowerStateChangeStatus){ 
    40                         computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getName())); 
     45                        computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getFullName())); 
    4146                } 
    4247 
     
    4853                } 
    4954                //computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getName())); 
     55                //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName()); 
    5056                return true; 
    5157        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingResourcePowerInterface.java

    r579 r1207  
    44import java.util.List; 
    55 
     6import org.joda.time.DateTime; 
    67import org.joda.time.DateTimeUtils; 
    78 
    89import schedframe.Parameters; 
     10import schedframe.SimulatedEnvironment; 
    911import schedframe.resources.ResourceStatus; 
    1012import schedframe.resources.computing.ComputingResource; 
     
    4648                        } 
    4749                        //notifications from all levels 
    48                         resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getName())); 
     50                        resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName())); 
    4951 
    5052                        //notification from last level 
    5153                        //if (resource.getChildren() == null) resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource)); 
    5254                         
     55                        //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName()); 
    5356                        return true; 
    5457                } 
     
    7073 
    7174        public boolean supportPowerState(PowerStateName state) { 
    72                 try { 
    73                         for(PowerState powerState: powerProfile.getSupportedPowerStates()){ 
    74                                 if(powerState.getName().equals(state)){ 
    75                                         return true; 
    76                                 } 
     75                for(PowerState powerState: powerProfile.getSupportedPowerStates()){ 
     76                        if(powerState.getName().equals(state)){ 
     77                                return true; 
    7778                        } 
    78                 } catch (NoSuchFieldException e) { 
    79                         return false; 
    8079                } 
    8180                return false; 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/DataCenterPowerInterface.java

    r495 r1207  
    11package schedframe.resources.computing.profiles.energy.power.ui; 
    22 
     3import org.joda.time.DateTime; 
     4 
     5import schedframe.SimulatedEnvironment; 
    36import schedframe.resources.computing.ComputingResource; 
    47import schedframe.resources.computing.DataCenter; 
     
    2326                        child.getPowerInterface().setPowerState(state); 
    2427                } 
    25  
     28                //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "POWER_STATE_CHANGED", state.getName()); 
    2629                return true; 
    2730        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java

    r782 r1207  
    44import java.util.Map; 
    55 
     6import org.joda.time.DateTime; 
     7 
     8import schedframe.SimulatedEnvironment; 
    69import schedframe.resources.ResourceStatus; 
    710import schedframe.resources.computing.ComputingResource; 
     
    1619 
    1720        protected PState currentPState; 
    18  
    1921 
    2022        public ProcessorPowerInterface(ComputingResource resource, PowerProfile pp){ 
     
    3436                                resource.setStatus(ResourceStatus.FREE); 
    3537                        } 
    36                         resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getName()));          
     38                        resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getFullName()));              
    3739                } 
    3840 
     
    6870                        //speed.setAmount(Double.valueOf(currentPState.getFrequency()).intValue()); 
    6971                        //new ResourceEventCommand(resource).execute(EnergyEventType.FREQUENCY_CHANGED); 
    70                         resource.handleEvent(new EnergyEvent(EnergyEventType.FREQUENCY_CHANGED, resource.getName())); 
     72                        resource.handleEvent(new EnergyEvent(EnergyEventType.FREQUENCY_CHANGED, resource.getFullName())); 
    7173                        //resource.getScheduler().sendInternal(GridSimTags.SCHEDULE_NOW, DCWormsTags.UPDATE, resource.getName()); 
     74                         
     75                        //ResourceController.traceResource(new DateTime().getMillis(), resource.getFullName(), "PSTATE_CHANGED", pStateName); 
    7276                        return true; 
    7377                } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/profiles/energy/thermal/ThermalInterfaceFactory.java

    r803 r1207  
    11package schedframe.resources.computing.profiles.energy.thermal; 
    22 
     3import schedframe.resources.StandardResourceType; 
    34import schedframe.resources.computing.ComputingResource; 
    45import schedframe.resources.computing.profiles.energy.thermal.ui.ComputingResourceThermalInterface; 
    56import schedframe.resources.computing.profiles.energy.thermal.ui.ThermalInterface; 
     7import schedframe.resources.devices.PhysicalResource; 
     8import schedframe.resources.devices.PhysicalResourceThermalInterface; 
    69 
    710public class ThermalInterfaceFactory { 
    8         public static ThermalInterface createThermalInterface(ComputingResource resource, ThermalProfile tp){ 
     11        public static ThermalInterface createThermalInterface(PhysicalResource resource, ThermalProfile tp){ 
    912                if(tp == null) 
    1013                        return null; 
    11                 ThermalInterface thermalInterface = new ComputingResourceThermalInterface(resource, tp); 
    12  
     14                ThermalInterface thermalInterface; 
     15                if (resource.getType().getName().equals(StandardResourceType.CRAH.getName())) 
     16                        thermalInterface = new PhysicalResourceThermalInterface(resource, tp); 
     17                else if (resource.getType().getName().equals(StandardResourceType.Fan.getName())) 
     18                        thermalInterface = new PhysicalResourceThermalInterface(resource, tp); 
     19                else  
     20                        thermalInterface = new ComputingResourceThermalInterface((ComputingResource)resource, tp); 
    1321                return thermalInterface; 
    1422        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/properties/ResourceProperties.java

    r477 r1207  
    33import java.util.Properties; 
    44 
    5 import schedframe.resources.computing.description.AbstractResourceDescription; 
     5import schedframe.resources.computing.description.ResourceDescription; 
    66 
    77public class ResourceProperties extends Properties{ 
     
    1616        } 
    1717         
    18         public ResourceProperties(AbstractResourceDescription ard){ 
     18        public ResourceProperties(ResourceDescription ard){ 
    1919                 
    2020        } 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/computing/validator/ResourceNameValidator.java

    r477 r1207  
    1313        @Override 
    1414        public boolean validate(ComputingResource resource) { 
    15                 return resource.getName().equals(name); 
     15                return resource.getFullName().equals(name); 
    1616        } 
    1717 
  • DCWoRMS/branches/coolemall/src/schedframe/resources/utils/ResourceIdGenerator.java

    r816 r1207  
    22 
    33import java.util.HashMap; 
    4  
    5 import schedframe.resources.ResourceType; 
    64 
    75public class ResourceIdGenerator { 
     
    119        public static int getId(String key){ 
    1210 
    13                 int value = 0; 
     11                int value = 1; 
    1412                if(resourceCounter.containsKey(key)){ 
    1513                        value = resourceCounter.get(key); 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/ResourceHistoryItem.java

    r477 r1207  
    88import schedframe.resources.units.ResourceUnitName; 
    99 
     10//TODO - change name 
    1011public class ResourceHistoryItem { 
    1112 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/SchedulerDescription.java

    r477 r1207  
    22 
    33import java.util.ArrayList; 
     4import java.util.Collection; 
    45import java.util.HashMap; 
    56import java.util.Iterator; 
     
    910import schedframe.resources.StandardResourceType; 
    1011import schedframe.resources.computing.description.ExecutingResourceDescription; 
     12import schedframe.resources.computing.description.ResourceDescription; 
    1113import schedframe.resources.providers.ResourceProvider; 
    12 import schedframe.resources.units.AbstractResourceUnit; 
    1314import schedframe.resources.units.ResourceUnit; 
    1415import schedframe.resources.units.ResourceUnitName; 
    1516import schedframe.scheduling.queue.QueueDescription; 
    1617 
    17 public class SchedulerDescription extends ExecutingResourceDescription{ 
     18public class SchedulerDescription extends ResourceDescription implements ExecutingResourceDescription{ 
    1819 
    1920        protected ResourceProvider provider; 
    2021        protected List<QueueDescription> accesQueues; 
     22        protected Map<ResourceUnitName, List<ResourceUnit>> resUnits; 
    2123 
    2224        public SchedulerDescription(ResourceProvider provider){ 
     
    6264                return provider; 
    6365        } 
     66         
     67        public void addResourceUnit(ResourceUnit unit) { 
     68                if (this.resUnits == null) 
     69                        this.resUnits = new HashMap<ResourceUnitName, List<ResourceUnit>>(1); 
     70                List<ResourceUnit> list = null; 
     71                if (this.resUnits.containsKey(unit.getName())) { 
     72                        list = this.resUnits.get(unit.getName()); 
     73                } else { 
     74                        list = new ArrayList<ResourceUnit>(1); 
     75                        this.resUnits.put(unit.getName(), list); 
     76                } 
     77                list.add(unit); 
     78        } 
     79         
     80        public ResourceUnit getResourceUnit(ResourceUnitName unitName) throws NoSuchFieldException { 
     81                return getResourceUnitList(unitName).get(0); 
     82        } 
     83 
     84        public List<ResourceUnit> getResourceUnitList(ResourceUnitName unitName) throws NoSuchFieldException { 
     85                if (resUnits.containsKey(unitName)) 
     86                        return resUnits.get(unitName); 
     87                else 
     88                        throw new NoSuchFieldException("Resource unit " + unitName + " is not available in resource " + this.id); 
     89        } 
     90 
     91        public Collection<ResourceUnit> getResourceUnit() { 
     92                if (resUnits == null) 
     93                        return null; 
     94                List<ResourceUnit> values = new ArrayList<ResourceUnit>(); 
     95                Collection<List<ResourceUnit>> lists = resUnits.values(); 
     96                Iterator<List<ResourceUnit>> itr = lists.iterator(); 
     97 
     98                while (itr.hasNext()) { 
     99                        List<ResourceUnit> list = itr.next(); 
     100                        values.addAll(list); 
     101                } 
     102 
     103                return values; 
     104        } 
     105 
     106        public Map<ResourceUnitName, List<ResourceUnit>> getResourceUnits() { 
     107                return resUnits; 
     108        } 
    64109} 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/resources/ClusterResourceManager.java

    r477 r1207  
    2323        public List<ComputingNode> getComputingNodes(){ 
    2424                try { 
    25                         return (List<ComputingNode>) getResourcesOfType(StandardResourceType.ComputingNode); 
     25                        return (List<ComputingNode>) getResourcesOfType(StandardResourceType.Node); 
    2626                } catch (ResourceException e) { 
    2727                        return new ArrayList<ComputingNode>(); 
     
    4040        @SuppressWarnings("unchecked") 
    4141        public List<ComputingNode> getComputingNodes(Properties properties){ 
    42                 properties.setProperty("type", StandardResourceType.ComputingNode.toString()); 
     42                properties.setProperty("type", StandardResourceType.Node.toString()); 
    4343                return (List<ComputingNode>) filterResources(properties); 
    4444 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/manager/resources/LocalResourceManager.java

    r1054 r1207  
    1919import schedframe.resources.StandardResourceType; 
    2020import schedframe.resources.computing.ComputingResource; 
     21import schedframe.resources.computing.ComputingResourceCharacteristics; 
    2122import schedframe.resources.computing.ResourceCharacteristics; 
    2223import schedframe.resources.computing.validator.ResourcePropertiesValidator; 
     
    138139                for (int i = 0; i < computingResources.size() && resourceWithName == null; i++) { 
    139140                        ComputingResource resource = computingResources.get(i); 
    140                         if (resource.getName().equals(resourceName)) 
     141                        if (resource.getFullName().equals(resourceName)) 
    141142                                resourceWithName = resource; 
    142143                        else 
     
    154155                        while (!toExamine.isEmpty()) { 
    155156                                ComputingResource resource = toExamine.pop(); 
    156                                 ResourceCharacteristics resourceCharacteristic = resource.getResourceCharacteristic(); 
     157                                ComputingResourceCharacteristics resourceCharacteristic = (ComputingResourceCharacteristics)resource.getResourceCharacteristic(); 
    157158                                List<ResourceUnit> units = null; 
    158159                                units = resourceCharacteristic.getResourceUnits().get(unitName); 
     
    266267                for(int i = 0 ; i < computingResources.size() && resourceWithName == null; i++){ 
    267268                        ComputingResource resource = computingResources.get(i); 
    268                         if(resource.getName().equals(resName)) 
     269                        if(resource.getFullName().equals(resName)) 
    269270                                resourceWithName = resource; 
    270271                        else 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/policy/local/LocalManagementSystem.java

    r1162 r1207  
    2424 
    2525import qcg.shared.constants.BrokerConstants; 
    26 import schedframe.ResourceController; 
     26import schedframe.SimulatedEnvironment; 
    2727import schedframe.events.scheduling.SchedulingEvent; 
    2828import schedframe.events.scheduling.SchedulingEventType; 
     
    323323                        ExecTask task = iter.next(); 
    324324                        Executable exec = (Executable)task; 
    325                         //exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * timeSpan/exec.getEstimatedDuration()); 
    326325                        exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * (timeSpan / exec.getEstimatedDuration())); 
    327326                        UsedResourcesList usedResourcesList = exec.getUsedResources(); 
     
    338337                        for (ComputingResource resource : pes) { 
    339338                                resource.handleEvent(new EnergyEvent(eventType, obj)); 
     339                                //DataCenterWorkloadSimulator.getEventManager().sendToResources(resource.getType(), 0, new EnergyEvent(eventType, obj)); 
    340340                        } 
    341341                        /*try { 
     
    350350                        ComputingResource resource = null; 
    351351                        try { 
    352                                 resource = ResourceController.getComputingResourceByName(peUnit.getResourceId()); 
     352                                resource = SimulatedEnvironment.getComputingResourceByName(peUnit.getResourceId()); 
    353353                        } catch (ResourceException e) { 
    354354                                return; 
     
    428428                        if(exec.getResourceConsumptionProfile().getCurrentResourceConsumption() == exec.getResourceConsumptionProfile().getResourceConsumptionList().getLast()){ 
    429429                                scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_FINISHED, execTask); 
     430                                PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 
     431                                notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 
    430432                        } else { 
    431433                                scheduler.sendInternal(phaseDuration, DCWormsTags.TASK_EXECUTION_CHANGED, execTask); 
     434                                PEUnit peUnit = (PEUnit)exec.getUsedResources().getLast().getResourceUnits().get(StandardResourceUnitName.PE); 
     435                                notifyComputingResources(peUnit, EnergyEventType.RESOURCE_UTILIZATION_CHANGED, exec); 
    432436                        } 
    433437                } 
     
    540544                                        job.setStatus((int)BrokerConstants.JOB_STATUS_SUBMITTED); 
    541545                        } catch (Exception e) { 
    542                                 // TODO Auto-generated catch block 
    543546                                e.printStackTrace(); 
    544547                        } 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Job.java

    r1159 r1207  
    77import org.qcg.broker.schemas.resreqs.types.TaskStatesName; 
    88 
    9 import gridsim.dcworms.DCWormsTags; 
    109 
    1110import java.io.StringWriter; 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/Task.java

    r1194 r1207  
    44import java.io.StringWriter; 
    55import java.util.ArrayList; 
    6 import java.util.LinkedList; 
    76import java.util.List; 
    87 
     
    2221import org.qcg.broker.schemas.resreqs.ProcessesResourceRequirements; 
    2322import org.qcg.broker.schemas.resreqs.Requirements; 
    24 import org.qcg.broker.schemas.resreqs.ResourceConsumptionType; 
    2523import org.qcg.broker.schemas.resreqs.TaskResourceRequirements; 
    2624import org.qcg.broker.schemas.resreqs.TimePeriod; 
     
    3129import schedframe.scheduling.WorkloadUnitHandler; 
    3230import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    33 import schedframe.scheduling.tasks.phases.ResourceConsumption; 
    34 import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile; 
    3531import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
    3632 
     
    7571        private long workloadLogWaitTime; 
    7672         
    77         private ResourceConsumptionProfile resourceConsumptionProfile; 
    7873 
    7974        public Task(org.qcg.broker.schemas.resreqs.Task task){ 
     
    9691        } 
    9792 
    98         private void preparePhases() { 
    99                 LinkedList<ResourceConsumption> resourceConsumptionList = new LinkedList<ResourceConsumption>(); 
    100                  
    101                 if(task.getExecution() == null || task.getExecution().getResourceConsumptionProfile() == null){ 
    102                         ResourceConsumption resConsumption = null; 
    103                         try { 
    104                                 resConsumption = new ResourceConsumption(this.length, getComputingResourceRequirements()); 
    105                         } catch (NoSuchFieldException e) { 
    106                                 // TODO Auto-generated catch block 
    107                                 e.printStackTrace(); 
    108                         } 
    109                         resourceConsumptionList.add(resConsumption); 
    110                 } 
    111                 else{ 
    112                         for(ResourceConsumptionType resConsumption: task.getExecution().getResourceConsumptionProfile().getResourceConsumption()){ 
    113                                 ResourceConsumption resourceConsumption = new ResourceConsumption(resConsumption); 
    114                                 resourceConsumptionList.add(resourceConsumption); 
    115                         } 
    116                 } 
    117                 this.resourceConsumptionProfile = new ResourceConsumptionProfile(resourceConsumptionList); 
    118                  
    119         //      System.out.println("======"+task.getExecution().getExecutable().getApplication().getName()); 
    120         } 
     93         
    12194         
    12295        public DateTime getExecutionStartTime() throws NoSuchFieldException { 
     
    310283        } 
    311284         
    312         protected ComputingResourceBaseTypeItem[] getComputingResourceRequirements() throws NoSuchFieldException{ 
     285        public ComputingResourceBaseTypeItem[] getComputingResourceRequirements() throws NoSuchFieldException{ 
    313286                 
    314287                Requirements req = this.task.getRequirements(); 
     
    450423        public void setLength(long length) { 
    451424                this.length = length; 
    452                 preparePhases(); 
    453425        } 
    454426 
     
    515487                wuh.handleTask(this); 
    516488        } 
    517          
    518         public ResourceConsumptionProfile getResourceConsumptionProfile(){ 
    519                 return resourceConsumptionProfile; 
    520         } 
    521          
     489 
    522490        public String getApplicationName(){ 
    523491                try{ 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/TaskInterface.java

    r1190 r1207  
    77 
    88import schedframe.DescriptionContainer; 
    9 import schedframe.scheduling.tasks.phases.ResourceConsumptionProfile; 
    109import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
    1110 
     
    111110        public long getWorkloadLogWaitTime(); 
    112111         
    113         public ResourceConsumptionProfile getResourceConsumptionProfile(); 
     112        //public ResourceConsumptionProfile getResourceConsumptionProfile(); 
    114113         
    115114        public String getApplicationName(); 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumption.java

    r1129 r1207  
    99import org.qcg.broker.schemas.resreqs.ComputingResourceParameterType; 
    1010import org.qcg.broker.schemas.resreqs.PhaseBehaviourType; 
    11 import org.qcg.broker.schemas.resreqs.ReferenceType; 
     11import org.qcg.broker.schemas.resreqs.StringParameterType; 
     12 
    1213import org.qcg.broker.schemas.resreqs.ResourceConsumptionType; 
    1314 
     
    3637        if(resConsumptionType.getReferenceHardware() != null){ 
    3738                for (int i = 0; i < resConsumptionType.getReferenceHardware().getReference().length; i++){ 
    38                         ReferenceType rt = resConsumptionType.getReferenceHardware().getReference(i); 
    39                         referenceHardware.put(rt.getName(), rt.getContent()); 
     39                        StringParameterType spt = resConsumptionType.getReferenceHardware().getReference(i); 
     40                        referenceHardware.put(spt.getName(), spt.getContent()); 
    4041                } 
    4142        } 
  • DCWoRMS/branches/coolemall/src/schedframe/scheduling/tasks/phases/ResourceConsumptionProfile.java

    r896 r1207  
    22 
    33import java.util.LinkedList; 
    4 import java.util.List; 
    54 
    65public class ResourceConsumptionProfile { 
    76         
    87        protected LinkedList<ResourceConsumption> resourceConsumptionList; 
    9         protected int currentPhase; 
     8        protected long usefulWork; 
     9        private int currentPhase; 
    1010         
    1111        public ResourceConsumptionProfile() { 
     
    3737                this.currentPhase = currentPhase; 
    3838        } 
     39 
     40        public long getUsefulWork() { 
     41                return usefulWork; 
     42        } 
     43 
     44        public void setUsefulWork(long usefulWork) { 
     45                this.usefulWork = usefulWork; 
     46        } 
    3947} 
  • DCWoRMS/branches/coolemall/src/simulator/ConfigurationOptions.java

    r802 r1207  
    5252        public static final String READ_SCENARIO_INPUT_FOLDER = READ_SCENARIO_MODIFIER 
    5353                        + ".inputfolder"; 
    54          
     54        /** The input folder with application profiles */ 
     55        public static final String READ_SCENARIO_APPLCIATION_PROFILES = READ_SCENARIO_MODIFIER + ".applicationProfiles"; 
    5556        /** The name of the workload file */ 
    5657        public static final String READ_SCENARIO_WORKLOAD_FILE = READ_SCENARIO_MODIFIER 
     
    7980        public static final String JOBS_STATISTICS = CREATESTATISTICS + ".jobs"; 
    8081        public static final String SIMULATION_STATISTICS = CREATESTATISTICS + ".simulation"; 
    81          
    82         public static final String COOLEMALL = "coolemall"; 
    83         public static final String COOLEMALL_RESOURCE = COOLEMALL + ".resdesc"; 
    84  
     82 
     83        public static final String PRESSURE_DROP = "pressuredrop"; 
     84        public static final String OUTLET_ROOM_AIR_TEMPERATURE = "outletroomairtemperature"; 
     85        public static final String INLET_ROOM_AIR_TEMPERATURE = "inletroomairtemperature"; 
     86        public static final String AMBIENT_AIR_TEMPERATURE = "ambientairtemperature"; 
     87        public static final String AIR_FLOW_VOLUME = "airflowvolume"; 
     88        public static final String ALPHA = "alpha"; 
     89         
    8590        /** 
    8691         * The main output folders base name 
     
    101106         * Suffix for read scenario output folder 
    102107         */ 
    103         public String statsOutputSubfolderNameRerad = null; 
     108        public String statsOutputSubfolderNameRead = null; 
    104109         
    105110        /* =============================================================================================== */ 
     
    137142         */ 
    138143        public String inputFolder = null; 
     144         
     145        public String appProfilesFolder = null; 
    139146         
    140147        public String inputTar = null; 
     
    184191        public String [] resForUtilizationChart; 
    185192         
    186         public String coolEmAllResdescFileName = null; 
    187  
     193        public static double pressureDrop; 
     194        public static double outletRoomAirTempeature; 
     195        public static double inletRoomAirTempeature; 
     196        public static double ambientAirTempeature; 
     197        public static double airFlowVolume; 
     198        public static double alpha 
     199        ; 
    188200        /** 
    189201         * An empty constructor. 
     
    255267                         
    256268                        try { 
     269                                co.appProfilesFolder  = getSeparatorTerminatedPath(bundle 
     270                                        .getString(READ_SCENARIO_APPLCIATION_PROFILES)); 
     271                        } catch (MissingResourceException e) { 
     272                                co.appProfilesFolder  = null; 
     273                        } 
     274                         
     275                        try { 
    257276                                co.inputWorkloadFileName = bundle 
    258277                                                .getString(READ_SCENARIO_WORKLOAD_FILE); 
     
    346365                try { 
    347366                        co.statsOutputSubfolderNameCreate = bundle.getString(STATS_OUTPUT_SUBFOLDER_NAME); 
    348                         co.statsOutputSubfolderNameRerad = co.statsOutputSubfolderNameCreate; 
     367                        co.statsOutputSubfolderNameRead = co.statsOutputSubfolderNameCreate; 
    349368                } catch(MissingResourceException e){ 
    350369                        co.statsOutputSubfolderNameCreate = "stats_create"; 
    351                         co.statsOutputSubfolderNameRerad = "stats_read"; 
     370                        co.statsOutputSubfolderNameRead = "stats_read"; 
    352371                } 
    353372 
     
    370389                        co.numberOfSimulations = 1; 
    371390                } 
    372                  
    373                 try { 
    374                         co.coolEmAllResdescFileName = bundle.getString(COOLEMALL_RESOURCE); 
    375                         System.setProperty("coolemall.resdesc", co.coolEmAllResdescFileName); 
    376                 } catch(MissingResourceException e){ 
    377                         co.coolEmAllResdescFileName = null; 
    378                 } 
     391 
     392                try { 
     393                        ConfigurationOptions.pressureDrop = Double.valueOf(bundle.getString(PRESSURE_DROP)).doubleValue(); 
     394                } catch(MissingResourceException e){ 
     395                        ConfigurationOptions.pressureDrop = 175.337; 
     396                } 
     397                 
     398                try { 
     399                        ConfigurationOptions.outletRoomAirTempeature = Double.valueOf(bundle.getString(OUTLET_ROOM_AIR_TEMPERATURE)).doubleValue(); 
     400                } catch(MissingResourceException e){ 
     401                        ConfigurationOptions.outletRoomAirTempeature = 23; 
     402                } 
     403                 
     404                try { 
     405                        ConfigurationOptions.inletRoomAirTempeature = Double.valueOf(bundle.getString(INLET_ROOM_AIR_TEMPERATURE)).doubleValue(); 
     406                } catch(MissingResourceException e){ 
     407                        ConfigurationOptions.inletRoomAirTempeature = 17; 
     408                } 
     409                 
     410                try { 
     411                        ConfigurationOptions.ambientAirTempeature = Double.valueOf(bundle.getString(AMBIENT_AIR_TEMPERATURE)).doubleValue(); 
     412                } catch(MissingResourceException e){ 
     413                        ConfigurationOptions.ambientAirTempeature = 17; 
     414                } 
     415                 
     416                try { 
     417                        ConfigurationOptions.airFlowVolume = Double.valueOf(bundle.getString(AIR_FLOW_VOLUME)).doubleValue(); 
     418                } catch(MissingResourceException e){ 
     419                        ConfigurationOptions.airFlowVolume = 0.304; 
     420                } 
     421                 
     422                try { 
     423                        ConfigurationOptions.alpha = Double.valueOf(bundle.getString(ALPHA)).doubleValue(); 
     424                } catch(MissingResourceException e){ 
     425                        ConfigurationOptions.alpha = 0.02; 
     426                } 
     427                 
    379428                return co; 
    380429        } 
  • DCWoRMS/branches/coolemall/src/simulator/DCWormsUsers.java

    r1160 r1207  
    2222import org.apache.commons.logging.LogFactory; 
    2323import org.joda.time.DateTime; 
    24 import org.qcg.broker.schemas.jobdesc.ParentType; 
    25 import org.qcg.broker.schemas.jobdesc.Workflow; 
    26 import org.qcg.broker.schemas.jobdesc.types.TaskStatesName; 
    2724 
    2825import qcg.shared.constants.BrokerConstants; 
     
    244241                         
    245242                } 
    246                 System.out.println("finished sending jobs"); 
    247243        } 
    248244         
  • DCWoRMS/branches/coolemall/src/simulator/DataCenterWorkloadSimulator.java

    r1142 r1207  
    1414import javax.swing.filechooser.FileFilter; 
    1515 
     16import org.apache.commons.io.FilenameUtils; 
    1617import org.apache.commons.logging.Log; 
    1718import org.apache.commons.logging.LogFactory; 
     
    2122 
    2223import schedframe.Initializable; 
    23 import schedframe.ResourceController; 
     24import schedframe.SimulatedEnvironment; 
    2425import simulator.reader.ResourceReader; 
    2526import simulator.stats.AccumulatedStatistics; 
     
    5152         * The name of the simulator application 
    5253         */ 
    53         public static final String SIMULATOR_NAME = "Data Center Workload Simulator"; 
     54        public static final String SIMULATOR_NAME = "Data Center Workload and Resource Management Simulator"; 
     55         
     56        /** 
     57         * The simulation mode 
     58         */ 
     59        public static String MODE = "Standard"; 
    5460 
    5561        /** 
     
    183189                } 
    184190 
    185                 if (log.isInfoEnabled()) 
     191                if (log.isInfoEnabled()){ 
    186192                        log.info("Done :: " + SIMULATOR_NAME + " has finished " 
    187193                                        + noOfSimulations + " simulation runs ::"); 
     194                        log.info("Simulation finished with status: 0"); 
     195                } 
    188196 
    189197                System.out.flush(); 
     
    259267 
    260268                ResourceReader resourceReader = new ResourceReader( 
    261                                 options); 
    262                 ResourceController rc = resourceReader.read(); 
     269                                options.resdescFileName); 
     270                SimulatedEnvironment rc = resourceReader.read(); 
    263271                eventManager = new EventManager("eventManager", rc); 
    264272                 
     
    268276                rc.setInitList(null); 
    269277                 
    270                 DCWormsUsers wl = new DCWormsUsers("Users", 
     278                DCWormsUsers users = new DCWormsUsers("Users", 
    271279                                rc.getScheduler().get_name(), workload); 
    272280                 
     281                System.out.println("Starting simulation..."); 
     282 
    273283                GridSimWrapper.startSimulation(); 
    274284                long stopSimulation = System.currentTimeMillis(); 
    275285 
     286                System.out.println("Simulation finished"); 
     287 
    276288                DCWormsStatistics stats = new DCWormsStatistics(simulationIdentifier, 
    277                                 options, wl, statsOutputPath, rc); 
     289                                options, users, statsOutputPath, rc); 
    278290                accumulatedStatistics.add(stats); 
    279291                if (log.isInfoEnabled()) 
     
    301313                String wlFileName = options.inputWorkloadFileName; 
    302314 
     315                String appProfilesFolder = options.appProfilesFolder; 
    303316                if (options.inputFolder != null) { 
    304317                        File f = null; 
     
    318331                swfReader = AbstractWAReader.getInstace(wlFileName); 
    319332 
    320                 WorkloadLoader workload = new WorkloadLoader(xmlJobReader, swfReader); 
     333                WorkloadLoader workload = new WorkloadLoader(xmlJobReader, swfReader, appProfilesFolder); 
    321334                workload.load(); 
    322335 
     
    346359                                prefix = options.inputFolder; 
    347360                        } else if (options.inputWorkloadFileName != null) { 
    348                                 prefix = new File(options.inputWorkloadFileName).getParent(); 
     361                                prefix = FilenameUtils.getFullPath(new File(options.inputWorkloadFileName).getAbsolutePath()); 
    349362                        } else { 
    350363                                prefix = System.getProperty("user.dir"); 
    351364                        } 
    352                         statsOutputPath = prefix + File.separator 
    353                                         + options.statsOutputSubfolderNameRerad; 
     365                        //statsOutputPath = prefix + File.separator 
     366                        //              + options.statsOutputSubfolderNameRead; 
     367                        statsOutputPath = options.statsOutputSubfolderNameRead; 
    354368                } 
    355369                statsOutputPath += File.separator; 
  • DCWoRMS/branches/coolemall/src/simulator/reader/EnvironmentWrapper.java

    r477 r1207  
    1818public class EnvironmentWrapper { 
    1919 
    20         Environment environment; 
     20        private Environment environment; 
    2121 
    2222        public void wrap(Environment environment) { 
     
    5353        public ComputingResource[] getComputingResources() throws UnknownParameter{ 
    5454                 
    55                 ArrayList<ComputingResource>tab = null; 
    56                  
    5755                if(environment == null) 
    5856                        throw new UnknownParameter("Environment parameters are not defined."); 
     
    6159                        return null; 
    6260                 
    63                 tab = new ArrayList<ComputingResource>(); 
     61                ArrayList<ComputingResource> computingResources = new ArrayList<ComputingResource>(); 
    6462                  
    6563                for(int i = 0; i < resources.getComputingResourceCount(); i++){ 
    6664                        ComputingResource compRes = resources.getComputingResource(i); 
    67                         tab.add(compRes); 
     65                        computingResources.add(compRes); 
    6866                } 
    69                 if(tab.size() == 0) 
     67                if(computingResources.size() == 0) 
    7068                        return null; 
    7169                else 
    72                         return tab.toArray(new ComputingResource[0]); 
     70                        return computingResources.toArray(new ComputingResource[0]); 
    7371        } 
    7472         
  • DCWoRMS/branches/coolemall/src/simulator/reader/ResourceReader.java

    r1042 r1207  
    11package simulator.reader; 
    2  
    3 import gridsim.ResourceCalendar; 
    42 
    53import java.io.File; 
     
    1917import java.util.Set; 
    2018 
     19import org.apache.commons.io.FilenameUtils; 
    2120import org.exolab.castor.xml.MarshalException; 
    2221import org.exolab.castor.xml.ValidationException; 
     
    2625import schedframe.Parameter; 
    2726import schedframe.Parameters; 
    28 import schedframe.ResourceController; 
     27import schedframe.SimulatedEnvironment; 
    2928import schedframe.exceptions.ResourceException; 
     29import schedframe.resources.CoolEmAllResourceFactory; 
    3030import schedframe.resources.Resource; 
    3131import schedframe.resources.StandardResourceType; 
    3232import schedframe.resources.computing.ComputingResource; 
    3333import schedframe.resources.computing.ResourceFactory; 
    34 import schedframe.resources.computing.description.AbstractResourceDescription; 
     34import schedframe.resources.computing.StandardResourceFactory; 
    3535import schedframe.resources.computing.description.ComputingResourceDescription; 
     36import schedframe.resources.computing.description.ResourceDescription; 
    3637import schedframe.resources.units.ResourceUnit; 
    3738import schedframe.resources.units.ResourceUnitName; 
     
    4546import schemas.ManagedComputingResources; 
    4647import schemas.StringValueWithUnit; 
    47 import simulator.ConfigurationOptions; 
     48import simulator.DataCenterWorkloadSimulator; 
    4849import simulator.utils.InstanceFactory; 
     50import test.DEBBTranslator.src.PLMXMLTranslator; 
    4951 
    5052public class ResourceReader { 
    5153         
    5254        private static String COOLEMALL_RESDESC_PREFIX = "DCWORMS"; 
    53         protected String resDescFileName; 
    54  
    55         protected ResourceCalendar resourceCalendar; 
    56         protected List<Initializable> toInit = new ArrayList<Initializable>(); 
    57          
     55        private String resDescFileName; 
     56        private ResourceFactory resFactory; 
     57                 
    5858        private ExecutionTimeEstimationPlugin execTimeEstimationPlugin; 
    59         private String globalSchedulingPluginName; 
    6059         
    6160        private Set<String> compResLayers; 
    62          
    63         public ResourceReader(ConfigurationOptions options) throws IOException { 
    64  
    65                 resDescFileName = options.resdescFileName; 
    66                 globalSchedulingPluginName = "example.globalplugin.GridFCFSRoundRobinPlugin"; 
    67                 prepareCalendar(); 
    68                 compResLayers = new LinkedHashSet<String>(); 
    69         } 
    70  
    71         public ResourceController read() throws MarshalException, ValidationException, FileNotFoundException, Exception, 
     61        private List<Initializable> toInit; 
     62         
     63        public ResourceReader(String resdescFileName) throws IOException { 
     64 
     65                this.resDescFileName = resdescFileName; 
     66                this.resFactory = new StandardResourceFactory(); 
     67                this.compResLayers = new LinkedHashSet<String>(); 
     68                this.toInit = new ArrayList<Initializable>(); 
     69        } 
     70 
     71        public SimulatedEnvironment read() throws MarshalException, ValidationException, FileNotFoundException, Exception, 
    7272                        UnknownParameter { 
    7373 
    7474                File file = new File(resDescFileName); 
    75                  
    76                 Environment env; 
     75 
     76                Environment env = null; 
    7777                try{ 
    7878                        env = Environment.unmarshal(new FileReader(file)); 
     79                         
    7980                } catch (Exception e){   
    80                         File dcwormsFile = new File(file.getParent() + "/" + COOLEMALL_RESDESC_PREFIX + "_" + file.getName()); 
    81                         env = Environment.unmarshal(new FileReader(dcwormsFile)); 
    82                 } 
    83                  
     81                        //e.printStackTrace(); 
     82                        try{ 
     83                                File dcwormsFile = new File(FilenameUtils.getFullPath(file.getAbsolutePath()) + COOLEMALL_RESDESC_PREFIX + "_" + file.getName()); 
     84                                env = Environment.unmarshal(new FileReader(dcwormsFile)); 
     85                        } catch (Exception e2){ 
     86                                PLMXMLTranslator plmxmlTranslator = new PLMXMLTranslator(); 
     87                                String trasnlatedFileName = plmxmlTranslator.translate(new String[]{file.getAbsolutePath()}); 
     88                                File dcwormsFile = new File(trasnlatedFileName);                         
     89                                //File dcwormsFile = new File(FilenameUtils.getFullPath(file.getAbsolutePath()) + COOLEMALL_RESDESC_PREFIX + "_" + file.getName()); 
     90 
     91                                env = Environment.unmarshal(new FileReader(dcwormsFile)); 
     92                        } 
     93                } 
     94                 
     95                if(env.getResources().getMode().equals("CoolEmAll")){ 
     96                        DataCenterWorkloadSimulator.MODE = "CoolEmAll"; 
     97                        resFactory = new CoolEmAllResourceFactory(); 
     98                } 
    8499                System.out.println("started creating environment description"); 
    85100                List<ComputingResourceDescription> mainCompResDescList = createEnvironmentDescription(env); 
     
    94109                System.out.println("finished creating schedulers"); 
    95110 
    96                 ResourceController rc = new ResourceController(mainScheduler, computingResources); 
     111                SimulatedEnvironment simEnv = new SimulatedEnvironment(mainScheduler, computingResources); 
    97112                Collections.sort(toInit, new ResourceTypeComparator(new ArrayList<String>(compResLayers))); 
    98                 rc.setInitList(toInit); 
    99                 rc.setCompResLayers(compResLayers); 
    100                 return rc; 
     113                simEnv.setInitList(toInit); 
     114                simEnv.setCompResLayers(compResLayers); 
     115                return simEnv; 
    101116        } 
    102117 
     
    181196                 
    182197                for(ComputingResourceDescription mainExecResDes : mainCompResDesList){ 
    183                         ComputingResource mainResource = ResourceFactory.createResource(mainExecResDes); 
     198                        ComputingResource mainResource = resFactory.createComputingResource(mainExecResDes); 
    184199                        toExamine.push(mainExecResDes); 
    185200                        resStructure.push(mainResource); 
     
    192207                        toInit.add(parentResource); 
    193208                        compResLayers.add(parentResource.getType().getName()); 
    194                         List<AbstractResourceDescription> childrenResDesc = parentResDesc.getChildren(); 
     209                        List<ResourceDescription> childrenResDesc = parentResDesc.getChildren(); 
    195210                        if (childrenResDesc == null){ 
    196211                                continue; 
     
    200215                                ComputingResourceDescription compResDesc = (ComputingResourceDescription) childrenResDesc.get(i); 
    201216                                toExamine.push(compResDesc); 
    202                                 ComputingResource resource = ResourceFactory.createResource(compResDesc); 
     217                                ComputingResource resource = resFactory.createComputingResource(compResDesc); 
    203218                                parentResource.addChild(resource); 
    204219                                resStructure.push(resource); 
     
    254269                } 
    255270                else{ 
    256                         SchedulingPlugin schedulingPlugin = (SchedulingPlugin) InstanceFactory.createInstance(globalSchedulingPluginName, 
    257                                         SchedulingPlugin.class); 
    258                         TaskQueueList queues = new TaskQueueList(1); 
    259                         TaskQueue queue = new TaskQueue(false); 
    260                         queues.add(queue); 
    261                         ManagedResources managedResources = new ManagedResources(mainCompResourceList, new HashMap<ResourceUnitName, List<ResourceUnit>>()); 
    262                         mainScheduler = ResourceFactory.createScheduler(StandardResourceType.GS, "grid", schedulingPlugin , execTimeEstimationPlugin,  queues, managedResources); 
    263  
    264                         for(Scheduler lr: mainSchedulers){ 
    265                                 mainScheduler.addChild(lr); 
    266                         } 
    267                         //necessary if children list isn't initialized in Scheduler 
    268                         //mainScheduler.init(); 
     271                        throw new Exception("Worng schedule definition"); 
    269272                } 
    270273                return mainScheduler; 
     
    332335                //TODO - refactor (create scheduler in 1 line) 
    333336                if(schedulerDef.getClazz().equals("GridBroker")){ 
    334                         scheduler = ResourceFactory.createScheduler(StandardResourceType.GS, "grid", schedulingPlugin, execTimeEstimationPlugin, queues, managedResources); 
     337                        scheduler = resFactory.createScheduler(StandardResourceType.GS, "grid", schedulingPlugin, execTimeEstimationPlugin, queues, managedResources); 
    335338                } else { 
    336                         scheduler = ResourceFactory.createScheduler(StandardResourceType.LS, schedulerDef.getName(), schedulingPlugin, execTimeEstimationPlugin,  queues, managedResources); 
     339                        scheduler = resFactory.createScheduler(StandardResourceType.LS, schedulerDef.getName(), schedulingPlugin, execTimeEstimationPlugin,  queues, managedResources); 
    337340                } 
    338341                return scheduler; 
     
    374377                                ComputingResource computingResource; 
    375378                                try { 
    376                                         if(resourceName.equals(mainCompRes.getName())) 
     379                                        if(mainCompRes.getFullName().contains(resourceName)) 
    377380                                                computingResource = mainCompRes; 
    378381                                        else 
     
    421424                return resourceUnits; 
    422425        } 
    423          
    424         private void prepareCalendar() { 
    425                 long seed = 11L * 13L * 17L * 19L * 23L + 1L; 
    426                 double timeZone = 0.0; 
    427                 double peakLoad = 0.0; // the resource load during peak hour 
    428                 double offPeakLoad = 0.0; // the resource load during off-peak hr 
    429                 double holidayLoad = 0.0; // the resource load during holiday 
    430  
    431                 // incorporates weekends so the grid resource is on 7 days a week 
    432                 LinkedList<Integer> Weekends = new LinkedList<Integer>(); 
    433                 Weekends.add(java.util.Calendar.SATURDAY); 
    434                 Weekends.add(java.util.Calendar.SUNDAY); 
    435  
    436                 // incorporates holidays. However, no holidays are set in this example 
    437                 LinkedList<Integer> Holidays = new LinkedList<Integer>(); 
    438                 resourceCalendar = new ResourceCalendar(timeZone, peakLoad, offPeakLoad, holidayLoad, Weekends, Holidays, 
    439                                 seed); 
    440         } 
     426 
    441427         
    442428        class ResourceTypeComparator implements Comparator<Initializable>{ 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/DCWormsStatistics.java

    r1199 r1207  
    77import java.io.IOException; 
    88import java.io.PrintStream; 
     9import java.text.DecimalFormat; 
    910import java.text.NumberFormat; 
    1011import java.util.ArrayList; 
     
    1415import java.util.Date; 
    1516import java.util.HashMap; 
     17import java.util.HashSet; 
    1618import java.util.List; 
    1719import java.util.Map; 
     20import java.util.Set; 
    1821import java.util.SortedMap; 
    1922import java.util.TreeMap; 
     
    5457 
    5558import schedframe.ExecutablesList; 
    56 import schedframe.ResourceController; 
     59import schedframe.SimulatedEnvironment; 
    5760import schedframe.exceptions.ResourceException; 
    5861import schedframe.resources.ResourceType; 
     
    6669import schedframe.resources.computing.profiles.energy.power.PowerUsage; 
    6770import schedframe.resources.computing.profiles.energy.thermal.TemperatureValue; 
    68 import schedframe.resources.units.PEUnit; 
     71import schedframe.resources.devices.Device; 
     72import schedframe.resources.devices.PhysicalResource; 
    6973import schedframe.resources.units.ProcessingElements; 
    7074import schedframe.resources.units.ResourceUnit; 
     
    8286import simulator.GenericUser; 
    8387import simulator.stats.GSSAccumulator; 
     88import simulator.stats.MetricsCalculator; 
    8489import simulator.stats.SimulationStatistics; 
    8590import simulator.stats.implementation.out.AbstractStringSerializer; 
    8691import simulator.stats.implementation.out.CoolEmAllStringSerializer; 
     92import simulator.stats.implementation.out.StringSerializer; 
    8793import csiro.mit.utils.jfreechart.timetablechart.TimetableChartFactory; 
    8894import csiro.mit.utils.jfreechart.timetablechart.data.Timetable; 
     
    9399import dcworms.schedframe.scheduling.Executable; 
    94100import eduni.simjava.Sim_stat; 
     101import example.energy.coolemall.CoolEmAllTestbedMeasurements; 
    95102 
    96103public class DCWormsStatistics implements SimulationStatistics { 
     
    111118        protected static final String AIRFLOW_STATISTICS_OUTPUT_FILE_NAME = "AirThroughput.txt"; 
    112119        protected static final String TEMPERATURE_STATISTICS_OUTPUT_FILE_NAME = "Temperature.txt"; 
    113  
     120        protected static final String USEFUL_WORK_STATISTICS_OUTPUT_FILE_NAME = "UsefulWork.txt"; 
     121        protected static final String DEVICE_STATISTICS_OUTPUT_FILE_NAME = "Devices.txt"; 
     122        protected static final String NODES_AVAILABILITY_STATISTICS_OUTPUT_FILE_NAME = "NodesAvailability.txt"; 
     123        protected static final String METRICS_STATISTICS_OUTPUT_FILE_NAME = "Metrics.txt"; 
     124        protected static final String RESOURCE_HISTORY_OUTPUT_FILE_NAME = "ResourceHistyory.txt"; 
     125         
    114126        protected static final String DIAGRAMS_FILE_NAME_PREFIX = "Chart_"; 
    115127        protected static final String STATS_FILE_NAME_PREFIX = "Stats_"; 
     
    127139         
    128140        protected GenericUser users; 
    129         protected ResourceController resourceController; 
     141        protected SimulatedEnvironment resourceController; 
    130142        protected boolean generateDiagrams = true; 
    131143        protected AbstractStringSerializer serializer; 
     
    154166        protected TaskSeriesCollection ganttDiagramTaskSeriesCollection; 
    155167        protected TaskSeriesCollection ganttDiagramWaitingTimeSeriesCollection; 
    156         protected Map<String, List<String>> task_processorsMap; 
     168        protected Map<String, Set<ComputingResource>> task_processorsMap; 
    157169 
    158170        protected JobRegistry jr; 
    159  
     171        protected MetricsCalculator metCalc; 
    160172         
    161173        public DCWormsStatistics(String simulationIdentifier, ConfigurationOptions co, GenericUser users, 
    162                         String outputFolderName, ResourceController resourceController) { 
     174                        String outputFolderName, SimulatedEnvironment resourceController) { 
    163175                this.simulationIdentifier = simulationIdentifier; 
    164176                this.configuration = co; 
     
    167179                this.outputFolderName = outputFolderName; 
    168180 
    169                 this.serializer = new CoolEmAllStringSerializer(); 
     181                this.serializer = new StringSerializer(); 
     182                 
     183                if(DataCenterWorkloadSimulator.MODE.equals("CoolEmAll")){ 
     184                        this.serializer = new CoolEmAllStringSerializer();       
     185                } 
    170186                this.serializer.setDefaultNumberFormat(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT); 
    171187 
     
    173189                this.jr = new JobRegistryImpl(""); 
    174190                init(); 
     191                metCalc = new MetricsCalculator(); 
    175192        } 
    176193 
     
    183200                this.endSimulationTime = DateTimeUtilsExt.currentTimeMillis(); 
    184201 
     202                metCalc.setStartTime(startSimulationTime); 
     203                metCalc.setEndTime(endSimulationTime); 
     204                 
    185205                long s = 0; 
    186206                long e = 0; 
     
    211231 
    212232        private void init() { 
    213                 task_processorsMap = new HashMap<String, List<String>>(); 
     233                task_processorsMap = new HashMap<String, Set<ComputingResource>>(); 
    214234                accStats = new GSSAccumulatorsStats(); 
    215235                statsData = new HashMap<String, GSSAccumulator>(); 
     
    229249                if (simulationStatsFile != null) { 
    230250                        Object txt = accStats.serialize(this.serializer); 
     251                         
     252                        DecimalFormat df = new DecimalFormat(); 
     253                        df.setMaximumFractionDigits(3); 
     254                        df.setGroupingUsed(false); 
     255                         
     256                        /*log.info("#STATS " + "Performance statistics"); 
     257                        log.info("#STATS " + "Makespan: " + accStats.makespan.getMean() + " [s]"); 
     258                        log.info("#STATS " + "Task completion time - " + "min: " + accStats.meanTaskCompletionTime.getMin() + "; max: " + accStats.meanTaskCompletionTime.getMax() + " [s]"); 
     259                        log.info("#STATS " + "Mean task execution time: " + accStats.meanTaskExecutionTime.getMean() + " [s]"); 
     260                        log.info("#STATS " + "System load: " + accStats.meanTotalLoad.getMean() * 100 + " [%]");*/ 
     261                         
     262                        System.out.println("#STATS " + "===== Performance statistics ====="); 
     263                        System.out.println("#STATS " + "Makespan: " + df.format(accStats.makespan.getMean()) + " [s]"); 
     264                        System.out.println("#STATS " + "Task completion time - " + "min: " + df.format(accStats.meanTaskCompletionTime.getMin()) + " [s]" + "; max: " + df.format(accStats.meanTaskCompletionTime.getMax()) + " [s]"); 
     265                        System.out.println("#STATS " + "Mean task execution time: " + df.format(accStats.meanTaskExecutionTime.getMean()) + " [s]"); 
     266                        System.out.println("#STATS " + "System load: " + df.format(accStats.meanTotalLoad.getMean() * 100) + " [%]"); 
     267                         
    231268                        simulationStatsFile.println(txt); 
    232269                } 
     
    238275 
    239276        /************* RESOURCE STATISTICS SECTION **************/ 
    240         private void gatherResourceStatistics() { 
     277        public void gatherResourceStatistics() { 
    241278                 
    242279                HashMap<String, List<Stats>> type_stats = new HashMap<String, List<Stats>>(); 
    243280                 
    244                 for(String resourceName: resourceController.getComputingResourceLayers()){ 
     281                for(String resourceTypeName: resourceController.getComputingResourceLayers()){ 
    245282                        List<Stats> cStats = new ArrayList<Stats>(); 
    246283                        cStats.add(Stats.textLoad); 
    247                         if(ArrayUtils.contains(configuration.resForUtilizationChart, resourceName)) 
     284                        if(ArrayUtils.contains(configuration.resForUtilizationChart, resourceTypeName)) 
    248285                                cStats.add(Stats.chartLoad); 
    249286                        cStats.add(Stats.textEnergy); 
    250                         if(ArrayUtils.contains(configuration.resForEnergyChart, resourceName)) 
     287                        if(ArrayUtils.contains(configuration.resForEnergyChart, resourceTypeName)) 
    251288                                cStats.add(Stats.chartEnergy); 
    252289                        cStats.add(Stats.textAirFlow); 
    253                         if(ArrayUtils.contains(configuration.resForAirFlowChart, resourceName)) 
     290                        if(ArrayUtils.contains(configuration.resForAirFlowChart, resourceTypeName)) 
    254291                                cStats.add(Stats.chartAirFlow); 
    255292                        cStats.add(Stats.textTemperature); 
    256                         if(ArrayUtils.contains(configuration.resForTemperatureChart, resourceName)) 
     293                        if(ArrayUtils.contains(configuration.resForTemperatureChart, resourceTypeName)) 
    257294                                cStats.add(Stats.chartTemperature); 
    258                         type_stats.put(resourceName, cStats); 
     295                        type_stats.put(resourceTypeName, cStats); 
     296 
    259297                }                
    260298                 
     
    269307                ganttDiagramTimetable = new Timetable(new FixedMillisecond( 
    270308                                startSimulationTime), new FixedMillisecond(endSimulationTime)); 
     309                 
    271310                 
    272311                PrintStream resourceLoadStatsFile = null; 
     
    310349                } 
    311350 
     351                PrintStream deviceStatsFile = null; 
     352                try { 
     353                        File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 
     354                                        + simulationIdentifier + "_" 
     355                                        + DEVICE_STATISTICS_OUTPUT_FILE_NAME); 
     356                        deviceStatsFile = new PrintStream(new FileOutputStream(file)); 
     357                } catch (IOException e) { 
     358                        deviceStatsFile = null; 
     359                } 
     360                 
     361                PrintStream nodesAvailabilityStatsFile = null; 
     362                try { 
     363                        File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 
     364                                        + simulationIdentifier + "_" 
     365                                        + NODES_AVAILABILITY_STATISTICS_OUTPUT_FILE_NAME); 
     366                        nodesAvailabilityStatsFile = new PrintStream(new FileOutputStream(file)); 
     367                } catch (IOException e) { 
     368                        nodesAvailabilityStatsFile = null; 
     369                } 
     370                 
     371                PrintStream metricsStatsFile = null; 
     372                try { 
     373                        File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 
     374                                        + simulationIdentifier + "_" 
     375                                        + METRICS_STATISTICS_OUTPUT_FILE_NAME); 
     376                        metricsStatsFile = new PrintStream(new FileOutputStream(file)); 
     377                } catch (IOException e) { 
     378                        metricsStatsFile = null; 
     379                } 
     380                 
     381                PrintStream usefulWorkStatsFile = null; 
     382                try { 
     383                        File file = new File(outputFolderName + STATS_FILE_NAME_PREFIX 
     384                                        + simulationIdentifier + "_" 
     385                                        + USEFUL_WORK_STATISTICS_OUTPUT_FILE_NAME); 
     386                        usefulWorkStatsFile = new PrintStream(new FileOutputStream(file)); 
     387                } catch (IOException e) { 
     388                        usefulWorkStatsFile = null; 
     389                } 
     390                 
    312391                basicResStats = gatherPEStats(jr.getTasks()); 
    313392                peStatsPostProcessing(basicResStats); 
     
    318397                } 
    319398                 
    320                 for(String resourceName: resourceController.getComputingResourceLayers()){ 
    321                         List<ComputingResource> resources = null; 
    322  
    323                         resources = new ArrayList<ComputingResource>(); 
     399                List<ComputingResource> compResources = null; 
     400                for(String resourceTypeName: resourceController.getComputingResourceLayers()){ 
     401                        GSSAccumulator resourceEnergyAccumulator = new GSSAccumulator(); 
     402                        GSSAccumulator maxResourceEnergyAccumulator = new GSSAccumulator(); 
     403                        GSSAccumulator calculationsEnergyAccumulator = new GSSAccumulator(); 
     404                        compResources = new ArrayList<ComputingResource>(); 
    324405                        for(ComputingResource compRes: resourceController.getComputingResources() ){ 
    325                                 resources.addAll(compRes.getDescendantsByType(new UserResourceType(resourceName))); 
    326                         } 
    327                         if(resourceController.getComputingResources().get(0).getType().getName().equals(resourceName)) 
    328                                 resources.addAll(resourceController.getComputingResources()); 
    329                  
    330                         if(type_stats.containsKey(resourceName)){ 
    331                                 for(ComputingResource resource: resources){ 
     406                                compResources.addAll(compRes.getDescendantsByType(new UserResourceType(resourceTypeName))); 
     407                        } 
     408                        if(resourceController.getComputingResources().get(0).getType().getName().equals(resourceTypeName)) 
     409                                compResources.addAll(resourceController.getComputingResources()); 
     410                        if(type_stats.containsKey(resourceTypeName)){ 
     411                 
     412                                 
     413                                for(ComputingResource compResource: compResources){ 
    332414                                        ResourceUsageStats resourceUsage = null; 
    333415                                        ResourcePowerStats energyUsage = null; 
    334416                                        ResourceAirFlowStats airFlow = null; 
    335417                                        ResourceTemperatureStats temperature = null; 
    336                                         if(type_stats.get(resourceName).contains(Stats.textLoad)){ 
    337                                                 resourceUsage = gatherResourceLoadStats(resource, basicResStats); 
     418                                        ResourceUsefulWorkStats usefulWork = null; 
     419                                        if(type_stats.get(resourceTypeName).contains(Stats.textLoad)){ 
     420                                                resourceUsage = gatherResourceLoadStats(compResource, basicResStats); 
    338421                                                resourceUsage.setMeanValue(calculateMeanValue(resourceUsage)); 
    339422                                                if (resourceLoadStatsFile != null) { 
     
    341424                                                        resourceLoadStatsFile.print(txt); 
    342425                                                } 
    343                                         } 
    344                                         if(type_stats.get(resourceName).contains(Stats.chartLoad)){ 
     426 
     427                                        } 
     428                                        if(type_stats.get(resourceTypeName).contains(Stats.chartLoad)){ 
    345429                                                if (configuration.creatediagrams_resutilization) { 
    346430                                                        createResourceLoadDiagram(resourceUsage); 
    347431                                                } 
    348432                                        } 
    349                                         if(type_stats.get(resourceName).contains(Stats.textEnergy)){ 
    350                                                 energyUsage = gatherResourcePowerConsumptionStats(resource); 
     433                                        if(type_stats.get(resourceTypeName).contains(Stats.textEnergy)){ 
     434                                                energyUsage = gatherResourcePowerConsumptionStats(compResource); 
    351435                                                energyUsage.setMeanValue(calculateMeanValue(energyUsage)); 
    352436                                                energyUsage.setSumValue(energyUsage.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 
    353                                                  
    354                                                 EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
    355                                                 if(resourceController.getComputingResources().contains(resource)) { 
     437                                                resourceEnergyAccumulator.add(energyUsage.getSumValue()); 
     438                                                maxResourceEnergyAccumulator.add(calculateMaxValue(energyUsage)); 
     439                                                double calulcationsEnergy = 0; 
     440                                                try { 
     441                                                        /*boolean doCalc = false; 
     442                                                        double prevTimestamp = 0; 
     443                                                        for(Long key: resourceUsage.getHistory().keySet()){ 
     444                                                                if(doCalc){ 
     445                                                                        System.out.println(energyUsage.getHistory().get(key)); 
     446                                                                        calulcationsEnergy = calulcationsEnergy + energyUsage.getHistory().get(prevTimestamp) * (key - prevTimestamp) /(3600 * MILLI_SEC); 
     447                                                                        doCalc  = false; 
     448                                                                } 
     449                                                                if(resourceUsage.getHistory().get(key)>0){ 
     450                                                                        prevTimestamp = key; 
     451                                                                        doCalc = true; 
     452                                                                } 
     453                                                        }*/ 
     454                                                        boolean doCalc = false; 
     455                                                        long prevTimestamp = 0; 
     456                                                        for(Long key: energyUsage.getHistory().keySet()){ 
     457                                                                if(doCalc){ 
     458                                                                        double load = 0; 
     459                                                                        if(resourceUsage.getHistory().get(prevTimestamp)!= null){ 
     460                                                                                load = resourceUsage.getHistory().get(prevTimestamp); 
     461                                                                        } 
     462                                                                        calulcationsEnergy = calulcationsEnergy + load * energyUsage.getHistory().get(prevTimestamp) * (key - prevTimestamp) /(3600.0 * MILLI_SEC); 
     463                                                                        doCalc = false; 
     464                                                                } 
     465                                                                if(energyUsage.getHistory().get(key) > compResource.getPowerInterface().getSupportedPowerStates().get(0).getPowerUsage() - CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION){ 
     466                                                                         
     467                                                                        prevTimestamp = key; 
     468                                                                        doCalc = true; 
     469                                                                } 
     470                                                        } 
     471                                                        //calulcationsEnergy = energyUsage.getSumValue() -  
     472                                                        //      ((1 - resourceUsage.getMeanValue()) * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)) *  
     473                                                        //      (compResource.getPowerInterface().getSupportedPowerStates().get(0).getPowerUsage() - CoolEmAllTestbedMeasurements.SINGLE_FAN_ON_POWER_CONSUMPTION); 
     474                                                        //System.out.println(compResource.getFullName() + ";" + resourceUsage.getMeanValue() +":"+ calulcationsEnergy  + ":" + energyUsage.getSumValue()); 
     475                                                        calculationsEnergyAccumulator.add(calulcationsEnergy); 
     476                                                } catch (Exception e) { 
     477                                                        e.printStackTrace(); 
     478                                                } 
     479                                                EnergyExtension een = (EnergyExtension)(compResource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
     480                                                if(resourceController.getComputingResources().contains(compResource)) { 
    356481                                                        if( een != null && een.getPowerProfile() != null &&  een.getPowerProfile().getEnergyEstimationPlugin() != null){ 
    357482                                                                accStats.meanEnergyUsage.add(energyUsage.getSumValue()); 
     
    359484 
    360485                                                } else if( een != null && een.getPowerProfile() != null &&  een.getPowerProfile().getEnergyEstimationPlugin() != null){ 
    361                                                         ComputingResource parent = resource.getParent(); 
     486                                                        ComputingResource parent = compResource.getParent(); 
    362487                                                        boolean top = true; 
    363488                                                        while(parent != null){ 
     
    377502                                                        energyStatsFile.print(txt); 
    378503                                                } 
    379                                         } 
    380                                         if(type_stats.get(resourceName).contains(Stats.chartEnergy)){ 
    381  
     504                                                 
     505                                                for(Device device: compResource.getResourceCharacteristic().getDevices()){ 
     506                                                        GSSAccumulator devAccumulator = new GSSAccumulator(); 
     507                                                        ResourcePowerStats deviceEnergyUsage = gatherResourcePowerConsumptionStats(device); 
     508                                                        deviceEnergyUsage.setMeanValue(calculateMeanValue(deviceEnergyUsage)); 
     509                                                        deviceEnergyUsage.setSumValue(deviceEnergyUsage.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 
     510                                                        devAccumulator.add(deviceEnergyUsage.getSumValue()); 
     511                                                        metCalc.addMetricsData(device.getType().getName(), devAccumulator); 
     512                                                        if (deviceStatsFile != null) { 
     513                                                                Object txt = deviceEnergyUsage.serialize(serializer); 
     514                                                                deviceStatsFile.print(txt); 
     515                                                        } 
     516                                                         
     517                                                        if(ArrayUtils.contains(configuration.resForEnergyChart, device.getType().getName())){ 
     518                                                                if (configuration.creatediagrams_respowerusage) { 
     519                                                                        createResourceEnergyDiagramData(deviceEnergyUsage); 
     520                                                                } 
     521                                                        } 
     522                                                } 
     523                                        } 
     524                                        if(type_stats.get(resourceTypeName).contains(Stats.chartEnergy)){ 
    382525                                                if (configuration.creatediagrams_respowerusage) { 
    383526                                                        createResourceEnergyDiagramData(energyUsage); 
     
    385528                                        } 
    386529                                         
    387                                         if(type_stats.get(resourceName).contains(Stats.textAirFlow)){ 
    388                                                 airFlow = gatherResourceAirFlowStats(resource); 
     530                                        if(type_stats.get(resourceTypeName).contains(Stats.textAirFlow)){ 
     531                                                airFlow = gatherResourceAirFlowStats(compResource); 
    389532                                                airFlow.setMeanValue(calculateMeanValue(airFlow)); 
    390533                                                airFlow.setSumValue(airFlow.getMeanValue() * (endSimulationTime - startSimulationTime) / (60 * MILLI_SEC)); 
    391534                                                 
    392                                                 EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
    393                                                 if(resourceController.getComputingResources().contains(resource)) { 
     535                                                EnergyExtension een = (EnergyExtension)(compResource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
     536                                                if(resourceController.getComputingResources().contains(compResource)) { 
    394537                                                        if( een != null && een.getAirFlowProfile() != null &&  een.getPowerProfile().getEnergyEstimationPlugin() != null){ 
    395538                                                                accStats.meanAirFlow.add(airFlow.getMeanValue()); 
     
    397540 
    398541                                                } else if( een != null && een.getAirFlowProfile() != null ){ 
    399                                                         ComputingResource parent = resource.getParent(); 
     542                                                        ComputingResource parent = compResource.getParent(); 
    400543                                                        een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
    401544                                                        boolean top = true; 
     
    415558                                                        airFlowStatsFile.print(txt); 
    416559                                                } 
    417                                         } 
    418                                         if(type_stats.get(resourceName).contains(Stats.chartAirFlow)){ 
     560                                                 
     561                                                for(Device device: compResource.getResourceCharacteristic().getDevices()){ 
     562                                                        ResourceAirFlowStats deviceAirFlow = gatherResourceAirFlowStats(device); 
     563                                                        deviceAirFlow.setMeanValue(calculateMeanValue(deviceAirFlow)); 
     564                                                        deviceAirFlow.setSumValue(deviceAirFlow.getMeanValue() * (endSimulationTime - startSimulationTime) / (60 * MILLI_SEC)); 
     565                                                         
     566                                                        if (deviceStatsFile != null) { 
     567                                                                Object txt = deviceAirFlow.serialize(serializer); 
     568                                                                deviceStatsFile.print(txt); 
     569                                                        } 
     570                                                         
     571                                                        if(ArrayUtils.contains(configuration.resForAirFlowChart, device.getType().getName())){ 
     572                                                                if (configuration.creatediagrams_resairflow) { 
     573                                                                        createResourceAirFlowDiagramData(deviceAirFlow); 
     574                                                                } 
     575                                                        } 
     576                                                } 
     577                                        } 
     578                                        if(type_stats.get(resourceTypeName).contains(Stats.chartAirFlow)){ 
    419579 
    420580                                                if (configuration.creatediagrams_resairflow) { 
     
    423583                                        } 
    424584                                         
    425                                         if(type_stats.get(resourceName).contains(Stats.textTemperature)){ 
    426                                                 temperature = gatherResourceTemperatureStats(resource); 
     585                                        if(type_stats.get(resourceTypeName).contains(Stats.textTemperature)){ 
     586                                                temperature = gatherResourceTemperatureStats(compResource); 
    427587                                                temperature.setMeanValue(calculateMeanValue(temperature)); 
    428588                                                temperature.setSumValue(temperature.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 
    429589                                                 
    430                                                 EnergyExtension een = (EnergyExtension)(resource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
    431                                                 if(resourceController.getComputingResources().contains(resource)) { 
     590                                                EnergyExtension een = (EnergyExtension)(compResource.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
     591                                                if(resourceController.getComputingResources().contains(compResource)) { 
    432592                                                        if( een != null  && een.getThermalProfile() != null &&  een.getPowerProfile().getEnergyEstimationPlugin() != null){ 
    433593                                                                accStats.meanTemperature.add(temperature.getMeanValue()); 
     
    435595 
    436596                                                } else if( een != null && een.getThermalProfile() != null ){ 
    437                                                         ComputingResource parent = resource.getParent(); 
     597                                                        ComputingResource parent = compResource.getParent(); 
    438598                                                        een = (EnergyExtension)(parent.getExtensionList().getExtension(ExtensionType.ENERGY_EXTENSION)); 
    439599                                                        boolean top = true; 
     
    453613                                                        temperatureStatsFile.print(txt); 
    454614                                                } 
    455                                         } 
    456                                         if(type_stats.get(resourceName).contains(Stats.chartTemperature)){ 
    457  
     615                                                 
     616                                                for(Device device: compResource.getResourceCharacteristic().getDevices()){ 
     617                                                        ResourceTemperatureStats deviceTemperature = gatherResourceTemperatureStats(device); 
     618                                                        deviceTemperature.setMeanValue(calculateMeanValue(deviceTemperature)); 
     619                                                        deviceTemperature.setSumValue(deviceTemperature.getMeanValue() * (endSimulationTime - startSimulationTime) / (3600 * MILLI_SEC)); 
     620                                                         
     621                                                        if (deviceStatsFile != null) { 
     622                                                                Object txt = deviceTemperature.serialize(serializer); 
     623                                                                deviceStatsFile.print(txt); 
     624                                                        } 
     625                                                         
     626                                                        if(ArrayUtils.contains(configuration.resForTemperatureChart, device.getType().getName())){ 
     627                                                                if (configuration.creatediagrams_restemperature) { 
     628                                                                        createResourceTemperatureDiagramData(deviceTemperature); 
     629                                                                } 
     630                                                        } 
     631                                                }                                                
     632                                        } 
     633                                        if(type_stats.get(resourceTypeName).contains(Stats.chartTemperature)){ 
    458634                                                if (configuration.creatediagrams_restemperature) { 
    459635                                                        createResourceTemperatureDiagramData(temperature); 
    460636                                                } 
    461637                                        } 
     638                                         
     639                                        if(type_stats.get(resourceTypeName).contains(Stats.textLoad)){ 
     640                                                usefulWork = gatherResourceUsefulWorkStats(compResource); 
     641                                                if (usefulWorkStatsFile != null) { 
     642                                                        Object txt = usefulWork.serialize(serializer); 
     643                                                        usefulWorkStatsFile.print(txt); 
     644                                                } 
     645                                        } 
     646                                         
     647                                         
     648                                        if (nodesAvailabilityStatsFile != null) { 
     649                                                ResourceAvailabilityStats ras = new ResourceAvailabilityStats(compResource.getFullName(), compResource.getType(), "availableNodes", compResource.getChildren().size(), endSimulationTime); 
     650                                                Object txt = ras.serialize(serializer); 
     651                                                nodesAvailabilityStatsFile.print(txt); 
     652                                                ras = gatherResourceAvailabilityStats(compResource); 
     653                                                txt = ras.serialize(serializer); 
     654                                                nodesAvailabilityStatsFile.print(txt); 
     655                                        } 
     656                                         
    462657                                } 
    463                         } 
    464                 } 
    465                  
     658                                metCalc.addMetricsData(resourceTypeName + "_CALC", calculationsEnergyAccumulator); 
     659                                metCalc.addMetricsData(resourceTypeName, resourceEnergyAccumulator); 
     660                                metCalc.addMetricsData(resourceTypeName + "_MAX", maxResourceEnergyAccumulator); 
     661                        } 
     662                } 
     663                 
     664                 
     665                if (metricsStatsFile != null) { 
     666                        //log.info("#STATS " + "Metrics"); 
     667                        System.out.println("#STATS " + "===== Metrics ====="); 
     668                        for(MetricsStats metric: metCalc.calulateMetrics(endSimulationTime)){ 
     669                                Object txt = metric.serialize(serializer); 
     670                                //log.info("#STATS " +  metric.getResourceName() + " " + metric.getMetricName() + ": " + metric.getValue()); 
     671                                DecimalFormat df = new DecimalFormat(); 
     672                                df.setMaximumFractionDigits(3); 
     673                                df.setGroupingUsed(false); 
     674                                System.out.println("#STATS " +  metric.getMetricName().replaceAll("_", " ") + ": " + df.format(metric.getValue()) + " [" + metric.getUnit() + "]"); 
     675                                metricsStatsFile.println(txt);   
     676                        } 
     677                } 
    466678                saveResourceUsageDiagrams(); 
    467679                createAccumulatedResourceSimulationStatistic(); 
     
    479691                        resourceLoadStatsFile.close(); 
    480692                } 
     693                 
     694                if (usefulWorkStatsFile != null) { 
     695                        usefulWorkStatsFile.close(); 
     696                } 
     697                if (deviceStatsFile != null) { 
     698                        deviceStatsFile.close(); 
     699                } 
     700                 
     701                if (nodesAvailabilityStatsFile != null) { 
     702                        nodesAvailabilityStatsFile.close(); 
     703                } 
     704                 
     705                if (metricsStatsFile != null) { 
     706                        metricsStatsFile.close(); 
     707                } 
     708 
    481709        } 
    482710 
     
    500728                } 
    501729                for(ComputingResource resource: resources){ 
    502                         if(!basicResStats.containsKey(resource.getName())){ 
    503                                 basicResStats.put(resource.getName(), new ArrayList<ResStat>()); 
     730                        if(!basicResStats.containsKey(resource.getFullName())){ 
     731                                basicResStats.put(resource.getFullName(), new ArrayList<ResStat>()); 
    504732                        } 
    505733                } 
     
    509737                 
    510738                Map<String, List<ResStat>> basicResStats = new TreeMap<String, List<ResStat>>(new MapPEIdComparator()); 
    511  
    512739                for (ExecTask execTask:executables) { 
    513740                        Executable exec = (Executable) execTask; 
     
    522749                                ProcessingElements pes = (ProcessingElements) resUnit; 
    523750                                for(ComputingResource pe: pes){ 
    524                                         String peName = pe.getName(); 
     751                                        String peName = pe.getFullName(); 
    525752                                        long startDate = Double.valueOf(exec.getExecStartTime()).longValue() * MILLI_SEC; 
    526753                                        long endDate = Double.valueOf(exec.getFinishTime()).longValue() * MILLI_SEC; 
     
    541768                                        String uniqueTaskID = getUniqueTaskId(execTask); 
    542769 
    543                                         List<String> peNames = task_processorsMap.get(uniqueTaskID); 
     770                                        Set<ComputingResource> peNames = task_processorsMap.get(uniqueTaskID); 
    544771                                        if (peNames == null) { 
    545                                                 peNames = new ArrayList<String>(); 
    546                                                 peNames.add(peName); 
     772                                                peNames = new HashSet<ComputingResource>(); 
     773                                                peNames.add(pe); 
    547774                                                task_processorsMap.put(uniqueTaskID, peNames); 
    548775                                        } else { 
    549                                                 peNames.add(peName); 
    550                                         } 
     776                                                peNames.add(pe); 
     777                                        } 
     778 
     779                                        try{ 
     780                                                double usefulWork = execTask.getResourceConsumptionProfile().getUsefulWork(); 
     781                                                //double usefulWork = gatherUsefulWorkStats(pe).getValue(); 
     782                                                GSSAccumulator uwAcc; 
     783                                                if(metCalc.getMetricsData().containsKey(pe.getFullName())){ 
     784                                                        uwAcc = metCalc.getMetricsData().get(pe.getFullName()).get(0); 
     785                                                        uwAcc.add(usefulWork); 
     786                                                } else { 
     787                                                        uwAcc = new GSSAccumulator(); 
     788                                                        uwAcc.add(usefulWork); 
     789                                                        metCalc.addMetricsData(pe.getFullName(), uwAcc); 
     790                                                } 
     791                                        }  catch (Exception e){ 
     792                                                 
     793                                        } 
     794                                         
    551795                                } 
    552                         } else if (resUnit instanceof PEUnit){ 
    553                                 PEUnit peUnit = (PEUnit) resUnit; 
    554                         } 
    555  
     796                        }  
    556797                } 
    557798                return basicResStats; 
     
    571812        } 
    572813         
     814         
    573815        private ResourceUsageStats gatherResourceLoadStats(ComputingResource resource, Map<String, List<ResStat>> basicStats) { 
    574                 ResourceUsageStats usageStats = new ResourceUsageStats(resource.getFullName(), resource.getType(), "resourceLoadStats"); 
     816                String usageType = null; 
     817                if(resource.getResourceCharacteristic().getParameters().get("load-sensor")!= null){ 
     818                        usageType = resource.getResourceCharacteristic().getParameters().get("load-sensor").get(0).getContent(); 
     819                } 
     820                ResourceUsageStats usageStats = new ResourceUsageStats(resource.getFullName(), resource.getType(), usageType); 
    575821                int cnt = 0; 
    576822                for(String resName: basicStats.keySet()){ 
    577823                        try { 
    578                                 if(resource.getDescendantByName(resName) != null || resource.getName().compareTo(resName) == 0){ 
     824                                if(resource.getDescendantByName(resName) != null || resource.getFullName().compareTo(resName) == 0){ 
    579825                                        createResourceLoadData(usageStats, basicStats.get(resName)); 
    580826                                        cnt++; 
     
    591837 
    592838                return usageStats; 
     839        } 
     840         
     841        private ResourceAvailabilityStats gatherResourceAvailabilityStats(ComputingResource resource) { 
     842                String usageType = new String ("usedNodes"); 
     843 
     844                int usedResources = 0; 
     845                for(ComputingResource compResource: resource.getChildren()){ 
     846                        double meanLoad = calculateMeanValue(gatherResourceLoadStats(compResource, basicResStats)); 
     847                        if(meanLoad > 0){ 
     848                                usedResources++; 
     849                        } 
     850                } 
     851                ResourceAvailabilityStats availabilityStats = new ResourceAvailabilityStats(resource.getFullName(), resource.getType(), usageType, usedResources, endSimulationTime); 
     852                return availabilityStats; 
     853        } 
     854         
     855        private ResourceUsefulWorkStats gatherResourceUsefulWorkStats(ComputingResource compResource) { 
     856                String usageType = "usefulWork"; 
     857                double usefulWork = 0; 
     858                JobRegistry jr = new JobRegistryImpl(compResource.getFullName()); 
     859                for(ExecTask task: jr.getFinishedTasks()){ 
     860                        usefulWork = usefulWork + task.getResourceConsumptionProfile().getUsefulWork(); 
     861                } 
     862                ResourceUsefulWorkStats usefulWorkStats = new ResourceUsefulWorkStats(compResource.getFullName(), compResource.getType(), usageType, usefulWork, endSimulationTime); 
     863                return usefulWorkStats; 
    593864        } 
    594865         
     
    629900                        } 
    630901                } 
    631  
     902                if(ganttData.get(startSimulationTime) == null) 
     903                        ganttData.put(startSimulationTime, 0.0); 
     904                if(ganttData.get(endSimulationTime) == null)     
     905                        ganttData.put(endSimulationTime, 0.0); 
    632906                return ganttData; 
    633907        } 
     
    643917         
    644918         
    645         private ResourcePowerStats gatherResourcePowerConsumptionStats(ComputingResource resource) { 
     919        private ResourcePowerStats gatherResourcePowerConsumptionStats(PhysicalResource resource) { 
    646920                double power = 0; 
    647                 ResourcePowerStats resEnergyUsage = new ResourcePowerStats(resource.getFullName(), resource.getType(), "resourcePowerConsumptionStats"); 
     921                 
     922                String usageType = null; 
     923                if(resource.getResourceCharacteristic().getParameters().get("power-sensor")!= null){ 
     924                        usageType = resource.getResourceCharacteristic().getParameters().get("power-sensor").get(0).getContent(); 
     925                } 
     926                ResourcePowerStats resEnergyUsage = new ResourcePowerStats(resource.getFullName(), resource.getType(), usageType); 
    648927                Map<Long, Double> usage = resEnergyUsage.getHistory(); 
    649928                 
     
    665944                                                usage.put(pu.getTimestamp(), pu.getValue()); 
    666945                                                 
    667                                         ///     System.out.println(resource.getName() + ":"+new DateTime(pu.getTimestamp())+";"+pu.getValue()); 
    668946                                                power = power + (pu.getTimestamp() - lastTime) * lastPower/ (3600 * MILLI_SEC); 
    669947                                                lastPower = pu.getValue(); 
     
    673951                        } 
    674952                } 
    675                 //System.out.println(power); 
    676953                return resEnergyUsage; 
    677954        } 
    678955         
    679956         
    680         private ResourceAirFlowStats gatherResourceAirFlowStats(ComputingResource resource) { 
    681  
    682                 ResourceAirFlowStats resAirFlow = new ResourceAirFlowStats(resource.getFullName(), resource.getType(), "resourceAirFlowStats"); 
     957        private ResourceAirFlowStats gatherResourceAirFlowStats(PhysicalResource resource) { 
     958 
     959                String usageType = null; 
     960                if(resource.getResourceCharacteristic().getParameters().get("airflow_volume-sensor")!= null){ 
     961                        usageType = resource.getResourceCharacteristic().getParameters().get("airflow_volume-sensor").get(0).getContent(); 
     962                } 
     963                ResourceAirFlowStats resAirFlow = new ResourceAirFlowStats(resource.getFullName(), resource.getType(), usageType); 
    683964                Map<Long, Double> airFlow = resAirFlow.getHistory(); 
    684965                 
     
    704985        } 
    705986         
    706         private ResourceTemperatureStats gatherResourceTemperatureStats(ComputingResource resource) { 
    707  
    708                 ResourceTemperatureStats resTemperature = new ResourceTemperatureStats(resource.getFullName(), resource.getType(), "resourceTemperatureStats"); 
     987        private ResourceTemperatureStats gatherResourceTemperatureStats(PhysicalResource resource) { 
     988 
     989                String usageType = null; 
     990                if(resource.getResourceCharacteristic().getParameters().get("temperature-sensor")!= null){ 
     991                        usageType = resource.getResourceCharacteristic().getParameters().get("temperature-sensor").get(0).getContent(); 
     992                } 
     993                ResourceTemperatureStats resTemperature = new ResourceTemperatureStats(resource.getFullName(), resource.getType(), usageType); 
    709994                Map<Long, Double> temperature = resTemperature.getHistory(); 
    710995                 
     
    10651350 
    10661351                        try { 
    1067                                 if(resource.getDescendantByName(resName) != null || resource.getName().compareTo(resName) == 0){ 
     1352                                if(resource.getDescendantByName(resName) != null || resource.getFullName().compareTo(resName) == 0){ 
    10681353                                        Double load = peLoad.get(resName); 
    10691354                                        sum += load; 
     
    11021387         
    11031388         
    1104  
    1105          
    1106          
     1389        private double calculateMaxValue(ResourceDynamicStats resDynamicStats ){ 
     1390                double maxValue = 0; 
     1391 
     1392                Map<Long, Double> history = resDynamicStats.getHistory(); 
     1393                for (Long key : history.keySet()) { 
     1394                        if(history.get(key) > maxValue){ 
     1395                                maxValue = history.get(key) ; 
     1396                        } 
     1397                } 
     1398                return maxValue; 
     1399        } 
    11071400         
    11081401         
     
    12211514                TaskStats taskStats = new TaskStats(task, startSimulationTime); 
    12221515                String uniqueTaskID = getUniqueTaskId(task); 
    1223                 taskStats.setProcessorsName(task_processorsMap.get(uniqueTaskID)); 
     1516                taskStats.setProcessors(task_processorsMap.get(uniqueTaskID)); 
    12241517                return taskStats; 
    12251518        } 
     
    14841777 
    14851778                public int compare(String o1, String o2)  { 
    1486                         Integer o1int; 
    1487                         Integer o2int; 
     1779                        Integer o1int = 0; 
     1780                        Integer o2int = 0; 
    14881781                        String o1string; 
    1489                         String o2string; 
    1490                         o1string = o1.substring(0, o1.indexOf("_")); 
    1491                         o2string = o2.substring(0, o2.indexOf("_")); 
    1492                         o1int = Integer.parseInt(o1.substring(o1.indexOf("_")+1)); 
    1493                         o2int = Integer.parseInt(o2.substring(o2.indexOf("_")+1)); 
    1494                         //if(o1string.compareTo(o2string) != 0) 
    1495                         //      return o1string.compareTo(o2string); 
    1496                         //else 
     1782                        String o2string = null; 
     1783 
     1784                        if(o1.contains("_")){ 
     1785                                o1string = o1.substring(0, o1.lastIndexOf("_")); 
     1786                                o1int = Integer.parseInt(o1.substring(o1.lastIndexOf("_")+1)); 
     1787                        } else { 
     1788                                o1string = o1; 
     1789                        } 
     1790                         
     1791                        if(o2.contains("_")){ 
     1792                                o2string = o2.substring(0, o2.lastIndexOf("_")); 
     1793                                o2int = Integer.parseInt(o2.substring(o2.lastIndexOf("_")+1)); 
     1794                        }else { 
     1795                                o2string = o2; 
     1796                        } 
     1797 
     1798                        if(o1int.compareTo(o2int) != 0) 
    14971799                                return o1int.compareTo(o2int); 
     1800                        else 
     1801                                return o1string.compareTo(o2string); 
    14981802                } 
    14991803        } 
     
    15731877        chartAirFlow, 
    15741878        textTemperature, 
    1575         chartTemperature; 
     1879        chartTemperature, 
     1880        textUsefulWorl; 
    15761881} 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceAirFlowStats.java

    r496 r1207  
    1212        public ResourceAirFlowStats (String resourceName, ResourceType resourceType, String usageType) { 
    1313                super(resourceName, resourceType, usageType); 
     14                if(usageType == null){ 
     15                        this.usageType = "airflow_volume"; 
     16                } 
    1417        } 
    1518 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourcePowerStats.java

    r496 r1207  
    1212        public ResourcePowerStats (String resourceName, ResourceType resourceType, String usageType) { 
    1313                super(resourceName, resourceType, usageType); 
     14                if(usageType == null){ 
     15                        this.usageType = "power"; 
     16                } 
    1417        } 
    1518 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceStats.java

    r477 r1207  
    2222 
    2323        public ResourceStats(ComputingResource compResource) { 
    24                 this.resourceName = compResource.getName(); 
     24                this.resourceName = compResource.getFullName(); 
    2525                init(); 
    2626 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceTemperatureStats.java

    r806 r1207  
    1212        public ResourceTemperatureStats (String resourceName, ResourceType resourceType, String usageType) { 
    1313                super(resourceName, resourceType, usageType); 
     14                if(usageType == null){ 
     15                        this.usageType = "temperature"; 
     16                } 
    1417        } 
    1518 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/ResourceUsageStats.java

    r496 r1207  
    1010        public ResourceUsageStats(String resourceName, ResourceType resourceType, String usageType) { 
    1111                super(resourceName, resourceType, usageType); 
     12                if(usageType == null){ 
     13                        this.usageType = "cpu_load"; 
     14                } 
    1215        } 
    1316 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/TaskStats.java

    r1199 r1207  
    22 
    33 
    4 import java.util.List; 
    5  
     4import java.util.HashSet; 
     5import java.util.Iterator; 
     6import java.util.Set; 
     7 
     8 
     9import schedframe.resources.computing.ComputingNode; 
     10import schedframe.resources.computing.ComputingResource; 
     11import schedframe.resources.computing.Core; 
     12import schedframe.resources.computing.Processor; 
     13import simulator.stats.implementation.out.StatsSerializer; 
    614import dcworms.schedframe.scheduling.Executable; 
    7  
    8 import simulator.stats.implementation.out.StatsSerializer; 
    915 
    1016/** 
     
    1420 */ 
    1521public class TaskStats implements StatsInterface { 
    16         protected List<String> processorsName; 
     22        protected Set<ComputingResource> processingElements; 
    1723        protected double reservationStartDate; 
    1824        protected double reservationFinishDate; 
     
    2632                        "ExecutionTime", "ReadyTime", "StartTime", "FlowTime", 
    2733                        "WaitingTime", "GQ_WaitingTime", "Lateness", "Tardiness", 
    28                         "ReservStartDate", "ReservFinishDate", "ProcessorName", "Energy"}; 
     34                        "ReservStartDate", "ReservFinishDate", "HostNames", "ProcessorName", "Energy", "AppName",}; 
    2935 
    3036        public TaskStats(Executable task, long startSimulationTime) { 
     
    147153        } 
    148154 
    149         public void setProcessorsName(List<String> value) { 
    150                 this.processorsName = value; 
     155        public void setProcessors(Set<ComputingResource> value) { 
     156                this.processingElements = value; 
    151157        } 
    152158 
     
    159165        } 
    160166 
    161         public List<String> getProcessorsName() { 
    162                 return processorsName; 
    163         } 
    164  
     167        public Set<String> getProcessingElementsName() { 
     168                Set<String> processingElementsNames = new HashSet<String>(); 
     169                Iterator<ComputingResource> it = processingElements.iterator(); 
     170                while(it.hasNext()) { 
     171                        ComputingResource compRes = it.next(); 
     172                        processingElementsNames.add(compRes.getFullName()); 
     173                } 
     174                return processingElementsNames; 
     175        } 
     176 
     177        public Set<String> getHostName() { 
     178                Set<String> hostNames = new HashSet<String>(); 
     179                Iterator<ComputingResource> it = processingElements.iterator(); 
     180                while(it.hasNext()) { 
     181                        ComputingResource compRes = it.next(); 
     182                        ComputingNode node = null; 
     183                        if(compRes instanceof Core){ 
     184                                Core core =(Core) compRes; 
     185                                node = (ComputingNode)core.getNode(); 
     186                        } else if(compRes instanceof Processor){ 
     187                                Processor proc = (Processor) compRes; 
     188                                node = (ComputingNode)proc.getNode(); 
     189                        } else if(compRes instanceof ComputingNode){ 
     190                                node = (ComputingNode)compRes; 
     191                        } 
     192                        if(node != null) 
     193                                hostNames.add(node.getFullName()); 
     194                } 
     195                return hostNames; 
     196        } 
     197         
    165198        public double getReservationStartDate() { 
    166199                return reservationStartDate; 
     
    170203                return reservationFinishDate; 
    171204        } 
     205         
     206        public String getExecName() { 
     207                String execName = null; 
     208                if(task.getDescription().getExecution() != null) { 
     209                        if(task.getDescription().getExecution().getStdin()!= null && task.getDescription().getExecution().getStdin().length > 0) 
     210                                execName = task.getDescription().getExecution().getStdin()[0].getName(); 
     211                        else if(task.getDescription().getExecution().getExecutable() != null && task.getDescription().getExecution().getExecutable().getApplication() != null) 
     212                                execName = task.getDescription().getExecution().getExecutable().getApplication().getName(); 
     213                } 
     214                return execName; 
     215        } 
    172216 
    173217        public String[] getHeaders() { 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/CoolEmAllStringSerializer.java

    r1140 r1207  
    11package simulator.stats.implementation.out; 
    22 
     3import java.text.DecimalFormat; 
    34import java.util.Map; 
    45 
     
    78 
    89import schedframe.resources.CoolEmAllResourceType; 
     10import schedframe.resources.ResourceHistoryChanges; 
    911import schedframe.resources.StandardResourceType; 
     12import simulator.stats.implementation.MetricsStats; 
    1013import simulator.stats.implementation.ResourceAirFlowStats; 
     14import simulator.stats.implementation.ResourceAvailabilityStats; 
     15import simulator.stats.implementation.ResourceHistoryStats; 
    1116import simulator.stats.implementation.ResourcePowerStats; 
    1217import simulator.stats.implementation.ResourceTemperatureStats; 
    1318import simulator.stats.implementation.ResourceUsageStats; 
     19import simulator.stats.implementation.ResourceUsefulWorkStats; 
    1420 
    1521public class CoolEmAllStringSerializer extends StringSerializer { 
     
    1925        public Object visit(ResourceUsageStats resourceUsageStats) { 
    2026                Map<Long, Double> resourceUsage = resourceUsageStats.getHistory(); 
    21                 String cpuMetricName = "CPU_Load"; 
     27                //String metricName = "cpu_load"; 
     28                String metricName = resourceUsageStats.getUsageType(); 
    2229                int mapSize = resourceUsage.size(); 
    2330                /* 
     
    4552                } 
    4653                 
    47                 if(resourceUsageStats.getResourceType().equals(StandardResourceType.Processor) || resourceUsageStats.getResourceType().equals(CoolEmAllResourceType.Processor)){ 
     54                if(!resourceUsageStats.getResourceType().getName().equals(StandardResourceType.Core.getName()) && !resourceUsageStats.getResourceType().getName().equals(CoolEmAllResourceType.Core.getName())){ 
    4855                        for (Long timestamp : resourceUsage.keySet()) { 
    4956                                 
    50                                 buffer.append(cpuMetricName); 
    51                                 buffer.append(fieldSeparator); 
    52                                 buffer.append(resourceUsageStats.getResourceName()); 
     57                                buffer.append(metricName); 
     58                                buffer.append(fieldSeparator); 
     59                                if(resourceUsageStats.getResourceName().startsWith("/")) 
     60                                        buffer.append(resourceUsageStats.getResourceName().substring(1)); 
     61                                else buffer.append(resourceUsageStats.getResourceName()); 
    5362                                buffer.append(fieldSeparator); 
    5463                                Double value = resourceUsage.get(timestamp); 
     
    7382        public Object visit(ResourcePowerStats resourceEnergyStats) { 
    7483                Map<Long, Double> resourceEnergy = resourceEnergyStats.getHistory(); 
    75                 String nodeMetricName = "RECS_Power"; 
     84                //String nodeMetricName = "power"; 
     85                String metricName = resourceEnergyStats.getUsageType(); 
    7686                int mapSize = resourceEnergy.size(); 
    7787                /* 
     
    98108                        buffer = new StringBuffer(size); 
    99109                } 
    100                  
    101                 if(resourceEnergyStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceEnergyStats.getResourceType().equals(CoolEmAllResourceType.Node)){ 
     110                //if(resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.ComputingNode.getName()) || resourceEnergyStats.getResourceType().getName().equals(CoolEmAllResourceType.Node.getName()) ||  
     111                                //resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.Inlet.getName())  || resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.Outlet.getName()) ||  
     112                //              resourceEnergyStats.getResourceType().getName().equals(StandardResourceType.Heatsink.getName())){ 
     113                 
    102114                        for (Long timestamp : resourceEnergy.keySet()) { 
    103115                                 
    104                                 buffer.append(nodeMetricName); 
     116                                buffer.append(metricName); 
    105117                                buffer.append(fieldSeparator); 
    106118                                if(resourceEnergyStats.getResourceName().startsWith("/")) 
     
    117129                                buffer.append(System.getProperty("line.separator")); 
    118130                        } 
    119                 } 
     131        //      } 
    120132 
    121133                int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 
     
    129141        public Object visit(ResourceAirFlowStats resourceAirFlowStats) { 
    130142                Map<Long, Double> resourceAirFlow = resourceAirFlowStats.getHistory(); 
    131                 String nodeMetricName = "RECS_Airflow"; 
     143                //String nodeMetricName = "airflow_volume"; 
     144                String metricName = resourceAirFlowStats.getUsageType(); 
    132145                int mapSize = resourceAirFlow.size(); 
    133146                /* 
     
    154167                        buffer = new StringBuffer(size); 
    155168                } 
    156                  
    157                 if(resourceAirFlowStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceAirFlowStats.getResourceType().equals(CoolEmAllResourceType.Node)){ 
     169 
     170                if(resourceAirFlowStats.getResourceType().getName().equals(StandardResourceType.Inlet.getName()) || resourceAirFlowStats.getResourceType().getName().equals(StandardResourceType.Outlet.getName())){ 
    158171                        for (Long timestamp : resourceAirFlow.keySet()) { 
    159                                  
    160                                 buffer.append(nodeMetricName); 
     172                                buffer.append(metricName); 
    161173                                buffer.append(fieldSeparator); 
    162174                                if(resourceAirFlowStats.getResourceName().startsWith("/")) 
     
    185197        public Object visit(ResourceTemperatureStats resourceTemperatureStats) { 
    186198                Map<Long, Double> resourceTemperature = resourceTemperatureStats.getHistory(); 
    187                 String nodeMetricName = "RECS_Temperature"; 
    188                 String cpuMetricName = "CPU_Temp"; 
     199                //String nodeMetricName = "temperature"; 
     200                //String cpuMetricName = "temperature"; 
     201                 
     202                String metricName = resourceTemperatureStats.getUsageType(); 
     203 
    189204                int mapSize = resourceTemperature.size(); 
    190205                /* 
     
    212227                } 
    213228                 
    214                 if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Node) ||  
    215                                 resourceTemperatureStats.getResourceType().equals(StandardResourceType.Processor) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Processor)){ 
    216                         String metricName = null; 
     229                if(resourceTemperatureStats.getResourceType().getName().equals(StandardResourceType.Node.getName()) || resourceTemperatureStats.getResourceType().getName().equals(StandardResourceType.Processor.getName())){ 
     230                        /*String metricName = null; 
    217231                        if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.ComputingNode) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Node)){ 
    218232                                metricName = nodeMetricName; 
    219233                        } else if(resourceTemperatureStats.getResourceType().equals(StandardResourceType.Processor) || resourceTemperatureStats.getResourceType().equals(CoolEmAllResourceType.Processor)){ 
    220234                                metricName = cpuMetricName; 
    221                         } 
     235                        }*/ 
    222236                        for (Long timestamp : resourceTemperature.keySet()) { 
    223237                                 
    224238                                buffer.append(metricName); 
    225239                                buffer.append(fieldSeparator); 
    226                                 buffer.append(resourceTemperatureStats.getResourceName()); 
     240                                if(resourceTemperatureStats.getResourceName().startsWith("/")) 
     241                                        buffer.append(resourceTemperatureStats.getResourceName().substring(1)); 
     242                                else buffer.append(resourceTemperatureStats.getResourceName()); 
    227243                                buffer.append(fieldSeparator); 
    228244                                Double value = resourceTemperature.get(timestamp); 
     
    245261        } 
    246262 
    247  
     263        public Object visit(MetricsStats metricsStats) { 
     264                StringBuffer buffer = null; 
     265 
     266                if(printedHeaders.add("metrics")) { 
     267                        buffer = new StringBuffer(600); 
     268                        /*String[] headers = metricsStats.getHeaders(); 
     269                        for(int i = 0; i < headers.length; i++) 
     270                        { 
     271                                buffer.append(headers[i]); 
     272                                buffer.append(fieldSeparator); 
     273                        } 
     274                        buffer.append(System.getProperty("line.separator"));*/ 
     275                } else { 
     276                        buffer = new StringBuffer(300); 
     277                } 
     278                DecimalFormat df = new DecimalFormat(); 
     279                df.setMaximumFractionDigits(3); 
     280                df.setGroupingUsed(false); 
     281                 
     282                buffer.append(metricsStats.getMetricName()); 
     283                buffer.append(fieldSeparator); 
     284                buffer.append(metricsStats.getResourceName()); 
     285                buffer.append(fieldSeparator); 
     286                buffer.append(metricsStats.getTimestamp()); 
     287                buffer.append(fieldSeparator); 
     288                buffer.append(df.format(metricsStats.getValue())); 
     289                buffer.append(fieldSeparator); 
     290 
     291                return buffer.toString(); 
     292        } 
     293         
     294        public Object visit(ResourceHistoryStats arg) { 
     295                StringBuffer buffer = null; 
     296 
     297                if(printedHeaders.add("metrics")) { 
     298                        buffer = new StringBuffer(600); 
     299                        /*String[] headers = metricsStats.getHeaders(); 
     300                        for(int i = 0; i < headers.length; i++) 
     301                        { 
     302                                buffer.append(headers[i]); 
     303                                buffer.append(fieldSeparator); 
     304                        } 
     305                        buffer.append(System.getProperty("line.separator"));*/ 
     306                } else { 
     307                        buffer = new StringBuffer(300); 
     308                } 
     309                DecimalFormat df = new DecimalFormat(); 
     310                df.setMaximumFractionDigits(3); 
     311                df.setGroupingUsed(false); 
     312                 
     313                for(ResourceHistoryChanges rhc: arg.getResHistChanges()){ 
     314                        buffer.append(rhc.getTimestamp()); 
     315                        buffer.append(fieldSeparator); 
     316                        buffer.append(rhc.getResourceName()); 
     317                        buffer.append(fieldSeparator); 
     318                        buffer.append(rhc.getOperation()); 
     319                        buffer.append(fieldSeparator); 
     320                        buffer.append(rhc.getParamter()); 
     321                        buffer.append(fieldSeparator); 
     322                        buffer.append(System.getProperty("line.separator")); 
     323                } 
     324 
     325                return buffer.toString(); 
     326        } 
     327 
     328        public Object visit(ResourceUsefulWorkStats resourceUsefulWorkStats) { 
     329                         
     330                String metricName = resourceUsefulWorkStats.getUsageType(); 
     331                 
     332                StringBuffer buffer = null; 
     333 
     334                if(printedHeaders.add("metrics")) { 
     335                        buffer = new StringBuffer(600); 
     336                        /*String[] headers = metricsStats.getHeaders(); 
     337                        for(int i = 0; i < headers.length; i++) 
     338                        { 
     339                                buffer.append(headers[i]); 
     340                                buffer.append(fieldSeparator); 
     341                        } 
     342                        buffer.append(System.getProperty("line.separator"));*/ 
     343                } else { 
     344                        buffer = new StringBuffer(300); 
     345                } 
     346                DecimalFormat df = new DecimalFormat(); 
     347                df.setMaximumFractionDigits(3); 
     348                df.setGroupingUsed(false); 
     349                if(!resourceUsefulWorkStats.getResourceType().getName().equals(StandardResourceType.Core.getName()) && !resourceUsefulWorkStats.getResourceType().getName().equals(CoolEmAllResourceType.Core.getName())){ 
     350 
     351                        buffer.append(metricName); 
     352                        buffer.append(fieldSeparator); 
     353                        buffer.append(resourceUsefulWorkStats.getResourceName()); 
     354                        buffer.append(fieldSeparator); 
     355                        buffer.append(resourceUsefulWorkStats.getTimestamp()); 
     356                        buffer.append(fieldSeparator); 
     357                        buffer.append(df.format(resourceUsefulWorkStats.getValue())); 
     358                        buffer.append(fieldSeparator); 
     359                        buffer.append(System.getProperty("line.separator")); 
     360                } 
     361                return buffer.toString(); 
     362        } 
     363         
     364 
     365        public Object visit(ResourceAvailabilityStats resourceAvailabilityStats) { 
     366                 
     367                String metricName = resourceAvailabilityStats.getUsageType(); 
     368                 
     369                StringBuffer buffer = null; 
     370 
     371                if(printedHeaders.add("metrics")) { 
     372                        buffer = new StringBuffer(600); 
     373                        /*String[] headers = metricsStats.getHeaders(); 
     374                        for(int i = 0; i < headers.length; i++) 
     375                        { 
     376                                buffer.append(headers[i]); 
     377                                buffer.append(fieldSeparator); 
     378                        } 
     379                        buffer.append(System.getProperty("line.separator"));*/ 
     380                } else { 
     381                        buffer = new StringBuffer(300); 
     382                } 
     383                DecimalFormat df = new DecimalFormat(); 
     384                df.setMaximumFractionDigits(3); 
     385                df.setGroupingUsed(false); 
     386                if(resourceAvailabilityStats.getResourceType().getName().equals(CoolEmAllResourceType.NodeGroup.getName())){ 
     387 
     388                        buffer.append(metricName); 
     389                        buffer.append(fieldSeparator); 
     390                        buffer.append(resourceAvailabilityStats.getResourceName()); 
     391                        buffer.append(fieldSeparator); 
     392                        buffer.append(resourceAvailabilityStats.getTimestamp()); 
     393                        buffer.append(fieldSeparator); 
     394                        buffer.append(df.format(resourceAvailabilityStats.getValue())); 
     395                        buffer.append(fieldSeparator); 
     396                        buffer.append(System.getProperty("line.separator")); 
     397                } 
     398                return buffer.toString(); 
     399        } 
    248400} 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/StatsSerializer.java

    r805 r1207  
    44import simulator.stats.implementation.GSSAccumulatorsStats; 
    55import simulator.stats.implementation.JobStats; 
     6import simulator.stats.implementation.MetricsStats; 
    67import simulator.stats.implementation.ResourceAirFlowStats; 
     8import simulator.stats.implementation.ResourceAvailabilityStats; 
     9import simulator.stats.implementation.ResourceHistoryStats; 
    710import simulator.stats.implementation.ResourcePowerStats; 
    811import simulator.stats.implementation.ResourceStats; 
    912import simulator.stats.implementation.ResourceTemperatureStats; 
    1013import simulator.stats.implementation.ResourceUsageStats; 
     14import simulator.stats.implementation.ResourceUsefulWorkStats; 
    1115import simulator.stats.implementation.TaskStats; 
    1216 
     
    3438        public Object visit(ResourceTemperatureStats arg); 
    3539         
     40        public Object visit(ResourceUsefulWorkStats arg); 
     41         
    3642        public Object visit(GSSAccumulatorsStats arg); 
    3743         
     44        public Object visit(MetricsStats arg); 
     45         
     46        public Object visit(ResourceHistoryStats arg); 
     47 
     48        public Object visit(ResourceAvailabilityStats resourceAvailabilityStats); 
     49         
    3850} 
  • DCWoRMS/branches/coolemall/src/simulator/stats/implementation/out/StringSerializer.java

    r1192 r1207  
    1111import simulator.stats.implementation.GSSAccumulatorsStats; 
    1212import simulator.stats.implementation.JobStats; 
     13import simulator.stats.implementation.MetricsStats; 
    1314import simulator.stats.implementation.ResourceAirFlowStats; 
     15import simulator.stats.implementation.ResourceAvailabilityStats; 
     16import simulator.stats.implementation.ResourceHistoryStats; 
    1417import simulator.stats.implementation.ResourcePowerStats; 
    1518import simulator.stats.implementation.ResourceStats; 
    1619import simulator.stats.implementation.ResourceTemperatureStats; 
    1720import simulator.stats.implementation.ResourceUsageStats; 
     21import simulator.stats.implementation.ResourceUsefulWorkStats; 
    1822import simulator.stats.implementation.TaskStats; 
    1923 
     
    4852                                                buffer.append(fieldSeparator); 
    4953                                        } 
    50                                          
    5154                                } 
    5255 
     
    108111                                        .longValue()); 
    109112                        buffer.append(fieldSeparator); 
    110                         buffer.append(taskStats.getProcessorsName()); 
     113                        buffer.append(taskStats.getHostName()); 
     114                        buffer.append(fieldSeparator); 
     115                        buffer.append(taskStats.getProcessingElementsName()); 
     116                        buffer.append(fieldSeparator); 
     117                        buffer.append(0); 
     118                        buffer.append(fieldSeparator); 
     119                        buffer.append(taskStats.getExecName()); 
    111120                        buffer.append(fieldSeparator); 
    112121                } 
     
    311320                } 
    312321                 
    313                 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 
    314                 if(lastIdx != -1) 
    315                         buffer.deleteCharAt(lastIdx); 
    316                  
    317322                if(resourceUsage.size() > 0){ 
    318323                        buffer.append("mean: " + resourceUsageStats.getMeanValue()); 
     
    373378 
    374379                } 
    375                  
    376                 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 
    377                 if(lastIdx != -1) 
    378                         buffer.deleteCharAt(lastIdx); 
    379                  
     380 
    380381                if(resourceEnergy.size() > 0) { 
    381382                        buffer.append("mean: "+resourceEnergyStats.getMeanValue() + " sum: " +resourceEnergyStats.getSumValue()); 
     
    437438 
    438439                } 
    439                 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 
    440                 if(lastIdx != -1) 
    441                         buffer.deleteCharAt(lastIdx); 
    442                  
     440 
    443441                if(resourceAirFlow.size() > 0) { 
    444442                        buffer.append("mean: "+resourceAirFlowStats.getMeanValue()); 
     
    500498 
    501499                } 
    502                  
    503                 int lastIdx = buffer.lastIndexOf(System.getProperty("line.separator")); 
    504                 if(lastIdx != -1) 
    505                         buffer.deleteCharAt(lastIdx); 
    506                  
     500 
    507501                if(resourceTemperature.size() > 0) { 
    508502                        buffer.append("mean: "+resourceTemperatureStats.getMeanValue()); 
     
    573567        } 
    574568 
     569        public Object visit(MetricsStats metricsStats) { 
     570                StringBuffer buffer = new StringBuffer(300); 
     571                return buffer.toString(); 
     572        } 
     573 
     574        public Object visit(ResourceHistoryStats arg) { 
     575                StringBuffer buffer = new StringBuffer(300); 
     576                return buffer.toString(); 
     577        } 
     578 
     579        public Object visit(ResourceUsefulWorkStats arg) { 
     580                StringBuffer buffer = new StringBuffer(300); 
     581                return buffer.toString(); 
     582        } 
     583 
     584        public Object visit(ResourceAvailabilityStats arg) { 
     585                StringBuffer buffer = new StringBuffer(300); 
     586                return buffer.toString(); 
     587        } 
     588 
     589 
    575590} 
  • DCWoRMS/branches/coolemall/src/simulator/utils/XsltTransformations.java

    r1131 r1207  
    1919import javax.xml.xpath.XPathExpressionException; 
    2020 
     21import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription; 
    2122import dcworms.schedframe.scheduling.utils.JobDescription; 
    2223import dcworms.schedframe.scheduling.utils.TaskDescription; 
     
    3536                String value =  
    3637                        //"org.apache.xalan.xsltc.trax.TransformerFactoryImpl"; 
    37                         "org.apache.xalan.processor.TransformerFactoryImpl"; 
     38                        //"org.apache.xalan.processor.TransformerFactoryImpl"; 
     39                        "net.sf.saxon.TransformerFactoryImpl"; 
    3840                Properties props = System.getProperties(); 
    3941                props.put(key, value); 
     
    191193        } 
    192194         
     195        public ApplicationProfileDescription getApplicationProfileDescription(String xmlJob){ 
     196                ApplicationProfileDescription appProfDesc = new  ApplicationProfileDescription(xmlJob); 
     197                return appProfDesc; 
     198        } 
     199         
    193200        public String extractJobId(String job){ 
    194201                Transformer t = null; 
  • DCWoRMS/branches/coolemall/src/simulator/workload/WorkloadLoader.java

    r1170 r1207  
    1717import javax.xml.xpath.XPathExpressionException; 
    1818 
     19import org.apache.commons.io.FilenameUtils; 
    1920import org.apache.commons.logging.Log; 
    2021import org.apache.commons.logging.LogFactory; 
     
    3233import simulator.workload.reader.archive.swf.SWFFields; 
    3334import simulator.workload.reader.xmlJob.XMLJobReader; 
     35import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription; 
    3436import dcworms.schedframe.scheduling.utils.JobDescription; 
    3537import dcworms.schedframe.scheduling.utils.TaskDescription; 
     
    5658         
    5759        protected Map<String, JobDescription> jobsMap; 
    58         protected Map<String, JobDescription> applicationProfilesMap; 
    59  
    60         public WorkloadLoader(XMLJobReader<org.qcg.broker.schemas.jobdesc.Job> xmlReader, WAReader<org.qcg.broker.schemas.jobdesc.Job> swfReader){ 
     60         
     61        protected String appProfilesFolder; 
     62        protected Map<String, ApplicationProfileDescription> applicationProfiles; 
     63 
     64        public WorkloadLoader(XMLJobReader<org.qcg.broker.schemas.jobdesc.Job> xmlReader, WAReader<org.qcg.broker.schemas.jobdesc.Job> swfReader, String appProfilesFolder){ 
    6165                if(swfReader == null){ 
    6266                        throw new RuntimeException("Swf reader is required to build proper tasks."); 
     
    6771                this.generatedTasksCnt = 0; 
    6872                this.jobsMap = new TreeMap<String, JobDescription>(); 
    69                 this.applicationProfilesMap = new TreeMap<String, JobDescription>(); 
     73                this.appProfilesFolder = appProfilesFolder; 
     74                this.applicationProfiles = new TreeMap<String, ApplicationProfileDescription>(); 
    7075                try { 
    7176                        this.xsltTransformation = new XsltTransformations(); 
     
    187192 
    188193                // determine which reader should be used 
    189                 String jobDesc = null; 
    190                 JobDescription job = null; 
    191                          
     194                String xmlJob = null; 
     195                JobDescription jobDesc = null; 
     196                         
     197                for(String key: waReader.getParser().getAppProfilesLocation().keySet()){ 
     198                        String xmlApp = loadApplicationProfile(waReader.getParser().getAppProfilesLocation().get(key)); 
     199                        xmlApp = this.xsltTransformation.extendJobDescription(xmlApp); 
     200                        ApplicationProfileDescription app = this.xsltTransformation.getApplicationProfileDescription(xmlApp); 
     201                        this.applicationProfiles.put(key, app); 
     202                } 
     203                 
    192204                if(this.xmlJobReader != null){ // use xml job reader. Xml job require xslt transformation 
    193                         while((jobDesc = this.xmlJobReader.readRaw()) != null){ 
    194                                 jobDesc = this.xsltTransformation.extendJobDescription(jobDesc); 
    195                                 job = createJobDescription(jobDesc, puSpeed); 
    196                                 if(job != null) 
    197                                         this.jobsMap.put(job.getJobId(), job); 
     205                        while((xmlJob = this.xmlJobReader.readRaw()) != null){ 
     206                                xmlJob = this.xsltTransformation.extendJobDescription(xmlJob); 
     207                                jobDesc = createJobDescription(xmlJob, puSpeed); 
     208                                if(jobDesc != null) 
     209                                        this.jobsMap.put(jobDesc.getJobId(), jobDesc); 
    198210                        } 
    199211                } else {                                                // use swf job reader. Job created by this reader does not require xslt transformation 
    200212                         
    201                         for(String key: waReader.getParser().getAppMapping().keySet()){ 
    202                                 jobDesc = loadApplicationProfile(waReader.getParser().getAppMapping().get(key)); 
    203                                 jobDesc = this.xsltTransformation.extendJobDescription(jobDesc); 
    204                                          
    205                                 try { 
    206                                         job = this.xsltTransformation.splitJobToTasks(jobDesc); 
    207                                 } catch (Exception e) { 
    208                                         throw new IOException(e.getMessage()); 
    209                                 } 
    210                                  
    211                                 this.applicationProfilesMap.put(key, job); 
    212                         } 
    213                          
    214                         while((jobDesc = this.waReader.readRaw()) != null){ 
     213                        while((xmlJob = this.waReader.readRaw()) != null){ 
    215214                                QcgWAJobReader qcgReader = (QcgWAJobReader)waReader; 
    216                                 if(!applicationProfilesMap.isEmpty()) 
    217                                         jobDesc = qcgReader.mergeSwfAndXmlProfile(applicationProfilesMap, jobDesc); 
    218                                 job = createJobDescription(jobDesc, puSpeed); 
    219                                 /*if(job!= null && !applicationProfilesMap.isEmpty()){ 
    220                                         for(int i = 0; i < job.getDescription().getTaskCount(); i++){ 
    221                                                 try { 
    222                                                         JobDescription xmlJobDescription = applicationProfilesMap.get(job.getDescription().getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent()); 
    223                                                         if(xmlJobDescription != null){ 
    224                                                                 for(int j = 0; j < xmlJobDescription.size(); j++){ 
    225                                                                         Task patternTask = xmlJobDescription.getDescription().getTask(j); 
    226                                                                         if(patternTask != null){ 
    227                                                                                 ResourceConsumptionProfileType rcp = patternTask.getExecution().getResourceConsumptionProfile(); 
    228                                                                                 job.getDescription().getTask(j).getExecution().setResourceConsumptionProfile(rcp); 
    229                                                                         } 
    230                                                                 } 
    231                                                         }        
    232                                                 } catch (Exception e){ 
    233                                                         continue; 
    234                                                 } 
    235                                         }                                        
    236                                 } 
    237                                 */ 
    238                                 if(job != null) 
    239                                         this.jobsMap.put(job.getJobId(), job); 
     215                                if(!applicationProfiles.isEmpty()) 
     216                                        xmlJob = qcgReader.mergeSwfAndAppProfile(applicationProfiles, xmlJob); 
     217                                jobDesc = createJobDescription(xmlJob, puSpeed); 
     218                                if(jobDesc != null) 
     219                                        this.jobsMap.put(jobDesc.getJobId(), jobDesc); 
    240220                        } 
    241221                } 
     
    302282        } 
    303283 
    304         public String loadApplicationProfile(String fileName) throws IOException{ 
     284        public String loadApplicationProfile(String pathToAppProfile) throws IOException{ 
    305285                 
    306286                BufferedReader reader = null; 
    307287                StringBuffer buffer = new StringBuffer(); 
    308288 
    309                 try { 
    310                         reader = new BufferedReader(new FileReader(fileName)); 
     289                String localPathToAppProfile; 
     290                 
     291                if(appProfilesFolder != null) { 
     292                        String folderName = FilenameUtils.getFullPath(appProfilesFolder); 
     293                        String fileName = FilenameUtils.getName(pathToAppProfile); 
     294                        localPathToAppProfile = folderName + fileName; 
     295                } else { 
     296                        localPathToAppProfile = pathToAppProfile; 
     297                } 
     298                try { 
     299                        reader = new BufferedReader(new FileReader(localPathToAppProfile )); 
    311300                        String line = null; 
    312301                         
  • DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/AbstractWAParser.java

    r1144 r1207  
    3333        protected HashMap<String, String> reverseIdMapping; // key - xmlJobId_xmlTaskId, value - swf job id 
    3434        protected HashMap<String, Long> jobIndex; 
    35         protected HashMap<String, String> appMapping; 
     35        protected HashMap<String, String> appProfilesLocation; 
    3636        protected String fields[]; 
    3737        protected int fieldsNo; 
     
    4646                this.reverseIdMapping = new HashMap<String, String>(); 
    4747                this.jobIndex = new HashMap<String, Long>(); 
    48                 this.appMapping = new HashMap<String, String>(); 
     48                this.appProfilesLocation = new HashMap<String, String>(); 
    4949                this.headerLoaded = false; 
    5050                this.buildIndex = true; 
    5151                this.fieldsNo = 18; 
     52                 
    5253        } 
    5354 
     
    152153                                String appId = valueData[0]; 
    153154                                String pathToAppProfile = valueData[1]; 
    154                                 appMapping.put(appId, pathToAppProfile); 
     155                                appProfilesLocation.put(appId, pathToAppProfile); 
    155156                                continue; 
    156157                        } 
     
    296297         
    297298         
    298         public Map<String, String> getAppMapping() { 
    299                 return appMapping; 
     299        public Map<String, String> getAppProfilesLocation() { 
     300                return appProfilesLocation; 
    300301        } 
    301302         
  • DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/QcgWAJobReader.java

    r1163 r1207  
    1515 
    1616import simulator.workload.reader.archive.swf.SWFFields; 
     17 
     18import org.qcg.broker.schemas.jobdesc.FileType; 
    1719import org.qcg.broker.schemas.jobdesc.ResourceConsumptionProfileType; 
    1820import org.qcg.broker.schemas.jobdesc.Task; 
    1921import org.qcg.broker.schemas.jobdesc.Workflow; 
    2022 
    21 import dcworms.schedframe.scheduling.utils.JobDescription; 
     23import dcworms.schedframe.scheduling.utils.ApplicationProfileDescription; 
    2224 
    2325/** 
     
    116118        } 
    117119 
    118         public String mergeSwfAndXmlProfile(Map<String, JobDescription> applicationProfilesMap, String swfJobDesc) throws IOException{ 
     120        public String mergeSwfAndAppProfile(Map<String, ApplicationProfileDescription> applicationProfiles, String swfJobDesc) throws IOException{ 
    119121                 
    120122                StringReader reader = new StringReader(swfJobDesc); 
     
    132134                for(int i = 0; i < job.getTaskCount(); i++){ 
    133135                        try { 
    134                                 JobDescription xmlJobDescription = applicationProfilesMap.get(job.getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent()); 
    135                                 if(xmlJobDescription != null){ 
    136                                         for(int j = 0; j < xmlJobDescription.size(); j++){ 
    137                                                 Task patternTask = xmlJobDescription.getDescription().getTask(j); 
    138                                                 if(patternTask != null){ 
    139                                                         ResourceConsumptionProfileType rcp = patternTask.getExecution().getResourceConsumptionProfile(); 
    140                                                         job.getTask(j).getExecution().setResourceConsumptionProfile(rcp); 
    141                                                 } 
     136                                ApplicationProfileDescription appProfileDescription = applicationProfiles.get(job.getTask(i).getExecution().getExecutable().getApplication().getAppProperty(0).getContent()); 
     137                                if(appProfileDescription != null){ 
     138                                        Task patternTask = appProfileDescription.getDescription(); 
     139                                        if(patternTask != null){ 
     140                                                ResourceConsumptionProfileType[] rcp = patternTask.getExecution().getResourceConsumptionProfile(); 
     141                                                job.getTask(i).getExecution().setResourceConsumptionProfile(rcp); 
     142                                                FileType script = new FileType(); 
     143                                                script.setName(patternTask.getId()); 
     144                                                job.getTask(i).getExecution().addStdin(script); 
    142145                                        } 
    143146                                }        
  • DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/WAParser.java

    r1144 r1207  
    4545        public int getType(); 
    4646         
    47         public Map<String, String> getAppMapping(); 
     47        public Map<String, String> getAppProfilesLocation(); 
    4848} 
  • DCWoRMS/branches/coolemall/src/simulator/workload/reader/archive/swf/QcgSWFJobReader.java

    r1202 r1207  
    221221                                         
    222222                                case SWFFields.DATA_EXECUTABLE_NUMBER: 
    223                                         String pathToAppProfile = waParser.getAppMapping().get(String.valueOf(value)); 
     223                                        String pathToAppProfile = waParser.getAppProfilesLocation().get(String.valueOf(value)); 
    224224                                        String appName = null; 
    225225                                        if(pathToAppProfile == null){ 
Note: See TracChangeset for help on using the changeset viewer.