Changeset 497


Ignore:
Timestamp:
10/11/12 09:07:11 (13 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/trunk/src
Files:
1 deleted
18 edited
1 moved

Legend:

Unmodified
Added
Removed
  • DCWoRMS/trunk/src/example/energy/CPUEnergyEstimationPlugin.java

    r477 r497  
    11package example.energy; 
    22 
    3 import schedframe.resources.ResourceStatus; 
    43import schedframe.resources.computing.ComputingResource; 
    54import schedframe.resources.computing.Processor; 
     
    1413                        ComputingResource resource) { 
    1514                Processor cpu = (Processor)resource; 
    16                 if(resource.getPowerInterface().getPowerState().getName().equals(StandardPowerStateName.OFF)) 
     15                if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) 
    1716                        return 0; 
    18                 if(resource.getStatus() == ResourceStatus.BUSY) 
     17                else { 
    1918                        try { 
    2019                                return cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPState()); 
    2120                        } catch (NoSuchFieldException e) { 
    22                                 return 0; 
     21                                try { 
     22                                        return cpu.getPowerInterface().getPowerConsumption(StandardPowerStateName.ON); 
     23                                } catch (NoSuchFieldException e1) { 
     24                                } 
    2325                        } 
    24                 else  
    25                         return 1;  
     26                        return 1; 
     27                } 
     28 
    2629        } 
    2730 
    28         public String getName() { 
    29                 return getClass().getName(); 
    30         } 
    31  
    32  
    3331} 
  • DCWoRMS/trunk/src/example/energy/ComputingNodeEnergyEstimationPlugin.java

    r477 r497  
    1717                        try{ 
    1818                                power = power + cpu.getPowerInterface().getRecentPowerUsage().getValue(); 
    19                         } catch(Exception e){ 
    20                                 //power = power + cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPowerState()); 
     19                        } catch (Exception e){ 
     20                                 
    2121                        } 
    2222                } 
    23  
    2423                try { 
    25                         power += node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState()); 
     24                        power = power + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState()); 
    2625                } catch (NoSuchFieldException e) { 
    2726                } 
     
    3029        } 
    3130 
    32         public String getName() { 
    33                 return getClass().getName(); 
    34         } 
    3531 
    3632} 
  • DCWoRMS/trunk/src/example/energy/DataCenterEnergyEstimationPlugin.java

    r477 r497  
    1818                        power += (powerUsage == null ? 0 : powerUsage.getValue()); 
    1919                } 
    20                  
    21                 //System.out.println( new DateTime() + "ENERGY CONSUMPT BY: " + resMan.getResourceName() +" IS: " + power); 
     20 
    2221                return power; 
    2322        } 
    2423 
    25         public String getName() { 
    26                 return getClass().getName(); 
    27         } 
    28  
    2924} 
  • DCWoRMS/trunk/src/example/globalplugin/BaseGlobalPlugin.java

    r490 r497  
    4646        } 
    4747         
     48        public String getName() { 
     49                return getClass().getName(); 
     50        } 
    4851         
    4952} 
  • DCWoRMS/trunk/src/example/globalplugin/GridFCFSLoadBalancingPlugin.java

    r481 r497  
    7474        } 
    7575 
    76         public String getName() { 
    77                 return getClass().getName(); 
    78         } 
    79  
    80         public void init(Properties properties) { 
    81                 // no extra initialization is expected. 
    82         } 
    83          
    8476        private int findLeastLoadedResourceIdx(List<SchedulerDescription> availableResources){ 
    8577                int resourceIdx = -1; 
  • DCWoRMS/trunk/src/example/globalplugin/GridFCFSRandomPlugin.java

    r478 r497  
    7575        } 
    7676 
    77  
    78         public String getName() { 
    79                 return getClass().getName(); 
    80         } 
    81  
    82         public void init(Properties properties) { 
    83                 // no extra initialization is expected. 
    84         } 
    85  
    8677} 
  • DCWoRMS/trunk/src/example/globalplugin/GridFCFSRoundRobinPlugin.java

    r478 r497  
    7575        } 
    7676 
    77         public String getName() { 
    78                 return getClass().getName(); 
    79         } 
    80  
    81  
    8277} 
  • DCWoRMS/trunk/src/example/localplugin/FCFSCPUFreqScalingClusterLocalPlugin.java

    r493 r497  
    187187                } 
    188188        } 
    189          
    190         public String getName() { 
    191                 return getClass().getName(); 
    192         } 
    193189 
    194190} 
  • DCWoRMS/trunk/src/example/localplugin/FCFSClusterLocalPlugin.java

    r493 r497  
    5757                                         
    5858                                        /****************1. Choosing particular resources to perform execution****************/ 
    59                                         Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution2(resourceManager, task); 
     59                                        Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 
    6060                                        if (choosenResources != null) { 
    6161                                                addToSchedulingPlan(plan, task, choosenResources); 
     
    8080 
    8181        private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution( 
    82                         ClusterResourceManager resourceManager, TaskInterface<?> task) { 
    83  
    84                 Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(); 
    85  
    86                 int cpuRequest; 
    87                 try { 
    88                         cpuRequest = Double.valueOf(task.getCpuCntRequest()).intValue(); 
    89                 } catch (NoSuchFieldException e) { 
    90                         cpuRequest = 1; 
    91                 } 
    92  
    93                 if (cpuRequest != 0) { 
    94                         List<ComputingResource> choosenResources = null; 
    95                         List<Processor> processors = null; 
    96                         processors = resourceManager.getProcessors(); 
    97                         if (processors.size() < cpuRequest) { 
    98                                 // log.warn("Task requires more cpus than is availiable in this resource."); 
    99                                 return null; 
    100                         } 
    101  
    102                         choosenResources = new ArrayList<ComputingResource>(); 
    103  
    104                         for (int i = 0; i < processors.size() && cpuRequest > 0; i++) { 
    105                                 if (processors.get(i).getStatus() == ResourceStatus.FREE) { 
    106                                         choosenResources.add(processors.get(i)); 
    107                                         cpuRequest--; 
    108                                 } 
    109                         } 
    110                         if (cpuRequest > 0) { 
    111                                 // log.info("Task " + task.getJobId() + "_" + task.getId() + 
    112                                 // " requires more cpus than is availiable in this moment."); 
    113                                 return null; 
    114                         } 
    115  
    116                         ProcessingElements result = new ProcessingElements(processors.get(0).getParent().getName()); 
    117                         result.addAll(choosenResources); 
    118                         map.put(StandardResourceUnitName.PE, result); 
    119  
    120                 } 
    121                 int memoryRequest; 
    122                 try { 
    123                         memoryRequest = Double.valueOf(task.getMemoryRequest()).intValue(); 
    124                 } catch (NoSuchFieldException e) { 
    125                         memoryRequest = 0; 
    126                 } 
    127                 if (memoryRequest != 0) { 
    128                         List<ComputingNode> nodes = resourceManager.getComputingNodes(); 
    129  
    130                         Memory memory = null; 
    131                         for (ComputingNode node : nodes) { 
    132                                 try{ 
    133                                         if (node.getFreeMemory() >= memoryRequest) {             
    134                                                 memory = new Memory(node.getMemory(), memoryRequest, memoryRequest); 
    135                                         }                
    136                                 } catch(NoSuchFieldException e){ 
    137                                         memory = null; 
    138                                 } 
    139                         } 
    140                         if(memory != null) 
    141                                 map.put(StandardResourceUnitName.MEMORY, memory); 
    142                         else return null; 
    143                 } 
    144  
    145                 return map; 
    146         } 
    147  
    148  
    149         private Map<ResourceUnitName, ResourceUnit> chooseResourcesForExecution2( 
    15082                        ClusterResourceManager resourceManager, TaskInterface<?> task) { 
    15183 
     
    204136                                                return map; 
    205137                                        } 
    206                                 } 
     138                                } else return map; 
    207139                        } 
    208140                } 
  • DCWoRMS/trunk/src/example/localplugin/FCFSConsolidationClusterLocalPlugin.java

    r493 r497  
    140140                return suitableNodes; 
    141141        } 
    142          
    143         public String getName() { 
    144                 return getClass().getName(); 
    145         } 
    146142 
    147143} 
  • DCWoRMS/trunk/src/example/localplugin/FCFSNodePowerManagementClusterLocalPlugin.java

    r493 r497  
    4040                ClusterResourceManager resourceManager = (ClusterResourceManager) resManager; 
    4141                SchedulingPlan plan = new SchedulingPlan(); 
    42                 // chose the events types to serve. 
    43                 // Different actions for different events are possible. 
     42 
    4443                switch (event.getType()) { 
    4544                case START_TASK_EXECUTION: 
    4645                case TASK_FINISHED: 
    47                         // our tasks are placed only in first queue (see 
    48                         // BaseLocalPlugin.placeJobsInQueues() method) 
     46 
    4947                        TaskQueue q = queues.get(0); 
    50                         // check all tasks in queue 
    5148 
    5249                        for (int i = 0; i < q.size(); i++) { 
    5350                                WorkloadUnit job = q.get(i); 
    5451                                TaskInterface<?> task = (TaskInterface<?>) job; 
    55                                 // if status of the tasks in READY 
    5652                                if (task.getStatus() == DCWormsTags.READY) { 
    5753 
     
    6561                                } 
    6662                        } 
    67  
    6863                        turnOffIdleNodes(resourceManager.getComputingNodes()); 
    69  
    7064                        break; 
    7165                } 
     
    151145                return cpuRequest > 0 ? false : true; 
    152146        } 
    153          
    154         public String getName() { 
    155                 return getClass().getName(); 
    156         } 
    157  
    158147 
    159148} 
  • DCWoRMS/trunk/src/example/localplugin/FCFSRackLocalPlugin.java

    r493 r497  
    1414import schedframe.scheduling.tasks.WorkloadUnit; 
    1515 
    16 public class RackLocalPlugin  extends BaseLocalSchedulingPlugin { 
     16public class FCFSRackLocalPlugin  extends BaseLocalSchedulingPlugin { 
    1717 
    18         public RackLocalPlugin() { 
     18        public FCFSRackLocalPlugin() { 
    1919        } 
    2020 
     
    5353        } 
    5454 
    55          
    56         public String getName() { 
    57                 return getClass().getName(); 
    58         } 
    59  
    6055 
    6156} 
  • DCWoRMS/trunk/src/example/localplugin/FCFSRandomClusterLocalPlugin.java

    r493 r497  
    4141                        // BaseLocalPlugin.placeJobsInQueues() method) 
    4242                        TaskQueue q = queues.get(0); 
     43                         
    4344                        // check all tasks in queue 
    44  
    4545                        for (int i = 0; i < q.size(); i++) { 
    4646                                WorkloadUnit job = q.get(i); 
     
    4848                                // if status of the tasks in READY 
    4949                                if (task.getStatus() == DCWormsTags.READY) { 
    50                                         /*for(ResourceUnitName key:resManager.getSharedResourceUnits().keySet()){ 
    51                                                 System.out.println(key.getName()); 
    52                                         }*/ 
    53                                         addToSchedulingPlan(plan, task); 
    54                                         /*String nodeName = chooseRandomProvider(resourceManager); 
     50 
     51                                        String nodeName = chooseRandomProvider(resourceManager); 
    5552                                        if (nodeName != null) { 
    5653                                                addToSchedulingPlan(plan, task, nodeName); 
    57                                         }*/ 
     54                                        } 
    5855                                } 
    5956                        } 
     
    6865                return nodes.get(nodeIdx).getName(); 
    6966        } 
    70          
    71         public String getName() { 
    72                 return getClass().getName(); 
    73         } 
    74  
    7567 
    7668} 
  • DCWoRMS/trunk/src/example/timeestimation/DefaultTimeEstimationPlugin.java

    r490 r497  
    4444 
    4545                // estimate remainingTaskLength 
    46                 double remainingLength =  task.getLength() * (1 - completionPercentage); 
     46                double remainingLength =  task.getLength() * (1 - completionPercentage/100); 
    4747                 
    4848                // do the calculation 
  • DCWoRMS/trunk/src/schedframe/resources/computing/ComputingNode.java

    r495 r497  
    3939         
    4040        public ComputingNodePowerInterface getPowerInterface(){ 
    41                 ComputingNodePowerInterface powerProfile = null; 
     41                ComputingNodePowerInterface powerInterface = null; 
    4242                if(extensionList.isExtensionAvailable(ExtensionType.ENERGY_EXTENSION)){ 
    4343                        EnergyExtension ee = (EnergyExtension)extensionList.getExtension(ExtensionType.ENERGY_EXTENSION); 
    44                         powerProfile = (ComputingNodePowerInterface)ee.getPowerInterface(); 
     44                        powerInterface = (ComputingNodePowerInterface)ee.getPowerInterface(); 
    4545                } 
    46                 return powerProfile; 
     46                return powerInterface; 
    4747        } 
    4848 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ComputingNodePowerInterface.java

    r495 r497  
    2828                currentPowerState = state; 
    2929                ComputingNode computingNode = (ComputingNode) resource; 
     30                boolean pePowerStateChangeStatus = false; 
    3031                if(computingNode.getProcessors() != null) 
    3132                { 
    3233                        for(ComputingResource child:computingNode.getProcessors()){ 
    33                                 child.getPowerInterface().setPowerState(state); 
     34                                if(child.getPowerInterface() != null){ 
     35                                        pePowerStateChangeStatus = child.getPowerInterface().setPowerState(state);       
     36                                } 
    3437                        } 
    35                 } else { 
     38                }  
     39                 
     40                if(!pePowerStateChangeStatus){ 
    3641                        computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getName())); 
    3742                } 
    38                  
     43 
    3944                if(state == StandardPowerStateName.OFF){ 
    4045                        computingNode.setStatus(ResourceStatus.UNAVAILABLE); 
     
    4651                return true; 
    4752        } 
    48          
    49         /*public double getPowerConsumption(PowerState state) { 
    50                 if(currentPowerState == PowerState.OFF) 
    51                         return 0; 
    52                 else if(currentPowerState == PowerState.ON) 
    53                         return 750; 
    54                 else return 500; 
    55         }*/ 
    56  
    57         /*public boolean supportPowerState(PowerState state) { 
    58                 switch(state){ 
    59                         case ON:  
    60                                 return true; 
    61                         case OFF:  
    62                                 return true; 
    63                         case SLEEP:  
    64                                 return true; 
    65                         case HIBERNATE:  
    66                                 return true; 
    67                         default:  
    68                                 return false; 
    69                 } 
    70         } 
    71  
    72         public List<PowerState> getSupportedPowerStates() { 
    73                 return Arrays.asList(new PowerState[]{PowerState.ON, PowerState.OFF, PowerState.SLEEP, PowerState.HIBERNATE}); 
    74         }*/ 
    7553 
    7654        public void turnOn(){ 
  • DCWoRMS/trunk/src/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java

    r495 r497  
    8181                        currentPState = newPState; 
    8282                        CpuSpeed speed = (CpuSpeed)resource.getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.CPUSPEED).get(0); 
    83                         speed.setAmount(Double.valueOf(currentPState.getFrequency()).intValue()); 
     83                        //speed.setAmount(Double.valueOf(currentPState.getFrequency()).intValue()); 
    8484                        //new ResourceEventCommand(resource).execute(EnergyEventType.FREQUENCY_CHANGED); 
    8585                        resource.handleEvent(new EnergyEvent(EnergyEventType.FREQUENCY_CHANGED, resource.getName())); 
  • DCWoRMS/trunk/src/schedframe/scheduling/policy/local/LocalManagementSystem.java

    r493 r497  
    66import eduni.simjava.Sim_system; 
    77import gridsim.Accumulator; 
     8import gridsim.GridSimTags; 
    89import gridsim.ResourceCalendar; 
    910import gridsim.dcworms.DCWormsTags; 
     
    115116 
    116117                case DCWormsTags.TASK_READY_FOR_EXECUTION: 
    117                          
    118118                        ExecTask execTask = (ExecTask) ev.get_data(); 
    119119                        try { 
     
    347347                        ExecTask task = iter.next(); 
    348348                        Executable exec = (Executable)task; 
     349                        exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * timeSpan/exec.getEstimatedDuration()); 
     350                         
    349351                        UsedResourcesList usedResourcesList = exec.getUsedResources(); 
    350352                        PEUnit peUnit = (PEUnit)usedResourcesList.getLast().getResourceUnits() 
    351353                                        .get(StandardResourceUnitName.PE); 
    352  
    353354                        double load = getMIShare(timeSpan, peUnit); 
    354                         exec.setCompletionPercentage(100 * timeSpan/exec.getEstimatedDuration()); 
    355355                        addTotalLoad(load); 
    356356                } 
     
    401401                         
    402402                        Map<ResourceUnitName, ResourceUnit> choosenResources = exec.getUsedResources().getLast().getResourceUnits(); 
    403                         double time = execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.RESOURCE_STATE_CHANGED),  
    404                                         execTask, choosenResources, exec.getCompletionPercentage()); 
     403                        int time =  Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.RESOURCE_STATE_CHANGED),  
     404                                        execTask, choosenResources, exec.getCompletionPercentage())).intValue(); 
    405405 
    406406                        //check if the new estimated end time is equal to the previous one; if yes the continue without update 
     
    408408                                continue; 
    409409                        } 
     410                        exec.setEstimatedDuration(time); 
    410411                        ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_EXECUTION_FINISHED); 
    411412                        scheduler.sim_cancel(filter, null); 
     
    449450 
    450451                Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(); 
    451                 ResourceManager resourceManager = this.resourceManager; 
     452                LocalResourceManager resourceManager = getResourceManager(); 
    452453                if(resourceName != null){ 
    453454                        ComputingResource resource = null; 
     
    471472                        List<ResourceUnit> availableUnits = null; 
    472473                        try { 
    473                                 availableUnits = getResourceManager().getPE(); 
     474                                availableUnits = resourceManager.getPE(); 
    474475                        } catch (ResourceException e) { 
    475476                                return null; 
  • DCWoRMS/trunk/src/simulator/stats/implementation/DCWormsStatistics.java

    r496 r497  
    315315                                        if(type_stats.get(resourceName).contains(Stats.textLoad)){ 
    316316                                                resourceUsage = gatherResourceLoadStats(resource, basicResStats); 
    317                                                 resourceUsage.setMeanValue(calculateResourceLoad(resource, basicResLoad)); 
     317                                                resourceUsage.setMeanValue(calculateMeanValue(resourceUsage)); 
    318318                                                if (resourceLoadStatsFile != null) { 
    319319                                                        Object txt = resourceUsage.serialize(serializer); 
     
    452452 
    453453                        List<ResourceHistoryItem> resHistItemList = exec.getUsedResources(); 
     454                        if(resHistItemList.size() == 0) 
     455                                return basicResStats; 
    454456                        Map<ResourceUnitName, ResourceUnit> res = resHistItemList.get(resHistItemList.size() - 1).getResourceUnits(); 
    455457                        ResourceUnit resUnit = res.get(StandardResourceUnitName.PE); 
     
    492494        } 
    493495         
    494         private ResourceUsageStats gatherResourceLoadStats(ComputingResource resource, Map<String,List<ResStat>> basicStats) { 
     496        private ResourceUsageStats gatherResourceLoadStats(ComputingResource resource, Map<String, List<ResStat>> basicStats) { 
    495497                ResourceUsageStats usageStats = new ResourceUsageStats(resource.getName(), resource.getType(), "resourceLoadStats"); 
    496                 int cnt =0; 
     498                int cnt = 0; 
    497499                for(String resName: basicStats.keySet()){ 
    498500                        try { 
    499501                                if(resource.getDescendantByName(resName) != null || resource.getName().compareTo(resName) == 0){ 
     502                                        createResourceLoadData(usageStats, basicStats.get(resName)); 
    500503                                        cnt++; 
    501                                         createResourceLoadData(usageStats, basicStats.get(resName)); 
    502504                                } 
    503505                        } catch (ResourceException e) { 
     
    508510                for(Long key: usageStats.getHistory().keySet()){ 
    509511                        Double value = usageStats.getHistory().get(key)/cnt; 
    510                         usageStats.getHistory().put(key, 100*value); 
     512                        usageStats.getHistory().put(key, value); 
    511513                } 
    512514 
     
    627629        private void createResourceLoadDiagram(ResourceUsageStats resLoadStats) { 
    628630 
     631                for(Long key: resLoadStats.getHistory().keySet()){ 
     632                        Double value = resLoadStats.getHistory().get(key) * 100; 
     633                        resLoadStats.getHistory().put(key, value); 
     634                } 
     635 
    629636                XYDataset dataset = createResourceChartDataSet(resLoadStats, 
    630637                                startSimulationTime, endSimulationTime); 
     
    861868 
    862869 
    863  
     870        //TO DO 
    864871        private void createAccumulatedResourceSimulationStatistic() { 
    865872 
     
    867874                for(ComputingResource compRes: resources){ 
    868875                        //for(ComputingResource child :compRes.getChildren()){ 
     876                         
     877                                //ResourceUsageStats resourceUsage = gatherResourceLoadStats(compRes, basicResStats); 
     878                                //double load = calculateMeanValue(resourceUsage); 
    869879                                double load = calculateResourceLoad(compRes, basicResLoad); 
    870880                                accStats.meanTotalLoad.add(load); 
     
    876886        } 
    877887 
    878         private HashMap<String, Double> calculatePELoad(Map<String,List<ResStat>> basicResStats){ 
    879                 HashMap<String, Double> peLoad = new HashMap<String, Double>(); 
     888        private Map<String, Double> calculatePELoad(Map<String, List<ResStat>> basicResStats){ 
     889                Map<String, Double> peLoad = new HashMap<String, Double>(); 
    880890                for(String resName: basicResStats.keySet()){ 
    881891                        List<ResStat> resStats = basicResStats.get(resName); 
Note: See TracChangeset for help on using the changeset viewer.