Changeset 539 for DCWoRMS/trunk/build


Ignore:
Timestamp:
10/31/12 13:52:06 (12 years ago)
Author:
wojtekp
Message:
 
Location:
DCWoRMS/trunk/build/classes
Files:
85 added
168 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/trunk/build/classes/example/energy/BaseEnergyEstimationPlugin.java

    r477 r539  
    3131 
    3232        @Override 
    33         public double estimateEnergyDissipation(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resourceManager) { 
     33        public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resourceManager) { 
    3434                throw new RuntimeException("Not implemented."); 
    3535        } 
     
    4444        } 
    4545 
     46        public String getName() { 
     47                return getClass().getName(); 
     48        } 
    4649} 
  • DCWoRMS/trunk/build/classes/example/energy/CPUEnergyEstimationPlugin.java

    r477 r539  
    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/build/classes/example/energy/ComputingNodeEnergyEstimationPlugin.java

    r477 r539  
    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/build/classes/example/energy/DataCenterEnergyEstimationPlugin.java

    r477 r539  
    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/build/classes/example/globalplugin/BaseGlobalPlugin.java

    r477 r539  
    44import schedframe.PluginConfiguration; 
    55import schedframe.events.scheduling.SchedulingEventType; 
    6 import schedframe.scheduling.WorkloadUnitListImpl; 
     6import schedframe.scheduling.TaskList; 
    77import schedframe.scheduling.manager.resources.ResourceManager; 
    88import schedframe.scheduling.plugin.SchedulingPluginConfiguration; 
     
    1111import schedframe.scheduling.queue.TaskQueue; 
    1212import schedframe.scheduling.queue.TaskQueueList; 
    13 import schedframe.scheduling.tasks.WorkloadUnit; 
     13import schedframe.scheduling.tasks.TaskInterface; 
    1414import schemas.StringValueWithUnit; 
    1515 
     
    2222        } 
    2323         
    24         public int placeJobsInQueues(WorkloadUnitListImpl newJobs, TaskQueueList queues, ResourceManager resourceManager, 
     24        public int placeTasksInQueues(TaskList newTasks, TaskQueueList queues, ResourceManager resourceManager, 
    2525                        ModuleList moduleList) { 
    2626 
     
    2828                TaskQueue queue = queues.get(0); 
    2929 
    30                 for (int i = 0; i < newJobs.size(); i++) { 
    31                         WorkloadUnit<?> task = newJobs.get(i); 
     30                for (int i = 0; i < newTasks.size(); i++) { 
     31                        TaskInterface<?> task = newTasks.get(i); 
    3232                        queue.add(task); 
    3333                } 
     
    4646        } 
    4747         
     48        public String getName() { 
     49                return getClass().getName(); 
     50        } 
    4851         
    4952} 
  • DCWoRMS/trunk/build/classes/example/globalplugin/GridFCFSLoadBalancingPlugin.java

    r477 r539  
    1919import schedframe.scheduling.plugin.grid.ModuleList; 
    2020import schedframe.scheduling.plugin.grid.ResourceDiscovery; 
     21import schedframe.scheduling.queue.QueueDescription; 
    2122import schedframe.scheduling.queue.TaskQueue; 
    22 import schedframe.scheduling.queue.QueueDescription; 
    2323import schedframe.scheduling.queue.TaskQueueList; 
    2424import schedframe.scheduling.tasks.TaskInterface; 
     
    2929        private Log log = LogFactory.getLog(GridFCFSLoadBalancingPlugin.class); 
    3030         
    31         public SchedulingPlanInterface schedule(SchedulingEvent event, 
     31        public SchedulingPlanInterface<?> schedule(SchedulingEvent event, 
    3232                        TaskQueueList queues,  
    3333                        JobRegistry jobRegistry, 
     
    5353                 
    5454                for(int i = 0; i < size; i++) { 
    55                         WorkloadUnit<?> job = q.remove(0); 
     55                        WorkloadUnit job = q.remove(0); 
    5656                        TaskInterface<?> task = (TaskInterface<?>)job; 
    5757 
     
    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){ 
    85                  
    8677                int resourceIdx = -1; 
    8778                long minLoad = Long.MAX_VALUE; 
     79                 
    8880                for(int i = 0; i < availableResources.size(); i++){ 
    8981                        SchedulerDescription sd = availableResources.get(i); 
  • DCWoRMS/trunk/build/classes/example/globalplugin/GridFCFSRandomPlugin.java

    r477 r539  
    5353                 
    5454                for(int i = 0; i < size; i++) { 
    55                         WorkloadUnit<?> job = q.remove(0); 
     55                        WorkloadUnit job = q.remove(0); 
    5656                        TaskInterface<?> task = (TaskInterface<?>)job; 
    5757                         
     
    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/build/classes/example/globalplugin/GridFCFSRoundRobinPlugin.java

    r477 r539  
    4747                 
    4848                for(int i = 0; i < size; i++) { 
    49                         WorkloadUnit<?> job = q.remove(0); 
     49                        WorkloadUnit job = q.remove(0); 
    5050                        TaskInterface<?> task = (TaskInterface<?>)job; 
    5151                         
     
    6565                        allocation.setProcessesCount(1); 
    6666                        allocation.setProviderName(sd.getProvider().getProviderId()); 
    67                         System.out.println("----" + sd.getProvider().getProviderId()); 
    6867                        ScheduledTask scheduledTask = new ScheduledTask(task); 
    6968                        scheduledTask.setTaskId(task.getId()); 
     
    7675        } 
    7776 
    78         public String getName() { 
    79                 return getClass().getName(); 
    80         } 
    81  
    82  
    8377} 
  • DCWoRMS/trunk/build/classes/example/localplugin/FCFSCPUFreqScalingClusterLocalPlugin.java

    r477 r539  
    11package example.localplugin; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.dcworms.DCWormsTags; 
    44 
    55import java.util.ArrayList; 
     
    1818import schedframe.resources.units.ResourceUnitName; 
    1919import schedframe.resources.units.StandardResourceUnitName; 
    20 import schedframe.scheduling.ResourceHistoryItem; 
    21 import schedframe.scheduling.UsedResourceList; 
     20import schedframe.scheduling.UsedResourcesList; 
    2221import schedframe.scheduling.manager.resources.ClusterResourceManager; 
    2322import schedframe.scheduling.manager.resources.ResourceManager; 
     
    2827import schedframe.scheduling.queue.TaskQueue; 
    2928import schedframe.scheduling.queue.TaskQueueList; 
    30 import schedframe.scheduling.tasks.SubmittedTask; 
    3129import schedframe.scheduling.tasks.TaskInterface; 
    3230import schedframe.scheduling.tasks.WorkloadUnit; 
     31import dcworms.schedframe.scheduling.Executable; 
    3332 
    34 public class FCFSCPUFreqScalingClusterLocalPlugin extends BaseLocalPlugin { 
     33public class FCFSCPUFreqScalingClusterLocalPlugin extends BaseLocalSchedulingPlugin { 
    3534 
    3635        List<Processor> allocatedCPUs; 
     
    3938        } 
    4039 
    41         public SchedulingPlanInterface schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
     40        public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
    4241                        ResourceManager resManager, ModuleList modules) { 
    4342 
     
    5554                        // check all tasks in queue 
    5655                        for (int i = 0; i < q.size(); i++) { 
    57                                 WorkloadUnit<?> job = q.get(i); 
     56                                WorkloadUnit job = q.get(i); 
    5857                                TaskInterface<?> task = (TaskInterface<?>) job; 
    5958                                // if status of the tasks in READY 
    60                                 if (task.getStatus() == Gridlet.READY) { 
     59                                if (task.getStatus() == DCWormsTags.READY) { 
    6160 
    6261                                        Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 
     
    7675                case TASK_FINISHED: 
    7776                        TaskFinishedEvent finEvent = (TaskFinishedEvent) event; 
    78                         SubmittedTask subTask = (SubmittedTask )jobRegistry.getSubmittedTask(finEvent.getJobId(), finEvent.getTaskId()); 
    79                         UsedResourceList<ResourceHistoryItem> usedResourcesList = subTask.getUsedResources(); 
     77                        Executable exec = (Executable) jobRegistry.getExecutable(finEvent.getJobId(), finEvent.getTaskId()); 
     78                        UsedResourcesList usedResourcesList = exec.getUsedResources(); 
    8079                        ProcessingElements pes = (ProcessingElements)usedResourcesList.getLast().getResourceUnits().get(StandardResourceUnitName.PE); 
    8180                        List<Processor> processors =  new ArrayList<Processor>(); 
     
    8988                case TASK_REQUESTED_TIME_EXPIRED: 
    9089                        TaskRequestedTimeExpiredEvent timExpEvent = (TaskRequestedTimeExpiredEvent) event; 
    91                          subTask = (SubmittedTask )jobRegistry.getSubmittedTask(timExpEvent.getJobId(), timExpEvent.getTaskId()); 
    92                         usedResourcesList = subTask.getUsedResources(); 
     90                        exec = (Executable) jobRegistry.getExecutable(timExpEvent.getJobId(), timExpEvent.getTaskId()); 
     91                        usedResourcesList = exec.getUsedResources(); 
    9392                        pes = (ProcessingElements)usedResourcesList.getLast().getResourceUnits().get(StandardResourceUnitName.PE); 
    9493                        processors =  new ArrayList<Processor>(); 
     
    9897                        // check all tasks in queue 
    9998                        for (int i = 0; i < q.size(); i++) { 
    100                                 WorkloadUnit<?> job = q.get(i); 
     99                                WorkloadUnit job = q.get(i); 
    101100                                TaskInterface<?> task = (TaskInterface<?>) job; 
    102101                                // if status of the tasks in READY 
    103                                 if (task.getStatus() == Gridlet.READY) { 
     102                                if (task.getStatus() == DCWormsTags.READY) { 
    104103 
    105104                                        Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 
     
    188187                } 
    189188        } 
    190          
    191         public String getName() { 
    192                 return getClass().getName(); 
    193         } 
    194189 
    195190} 
  • DCWoRMS/trunk/build/classes/example/localplugin/FCFSClusterLocalPlugin.java

    r477 r539  
    11package example.localplugin; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.dcworms.DCWormsTags; 
    44 
    55import java.util.ArrayList; 
     
    3131import schedframe.scheduling.tasks.WorkloadUnit; 
    3232 
    33 public class FCFSClusterLocalPlugin extends BaseLocalPlugin { 
     33public class FCFSClusterLocalPlugin extends BaseLocalSchedulingPlugin { 
    3434 
    3535        public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
     
    4949 
    5050                        for (int i = 0; i < q.size(); i++) { 
    51                                 WorkloadUnit<?> job = q.get(i); 
     51                                WorkloadUnit job = q.get(i); 
    5252                                TaskInterface<?> task = (TaskInterface<?>) job; 
    5353                                // if status of the tasks in READY 
    54                                 if (task.getStatus() == Gridlet.READY) { 
     54                                if (task.getStatus() == DCWormsTags.READY) { 
    5555                                         
    5656                                        /****************3 ways to schedule task****************/ 
    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 
     
    178110                                } 
    179111 
    180                                 ProcessingElements result = new ProcessingElements(processors.get(0).getParent().getName()); 
     112                                ProcessingElements result = new ProcessingElements(); 
    181113                                result.addAll(choosenResources); 
    182114                                map.put(StandardResourceUnitName.PE, result); 
     
    204136                                                return map; 
    205137                                        } 
    206                                 } 
     138                                } else return map; 
    207139                        } 
    208140                } 
     
    221153        } 
    222154 
    223         public String getName() { 
    224                 return getClass().getName(); 
    225         } 
    226  
    227155} 
  • DCWoRMS/trunk/build/classes/example/localplugin/FCFSConsolidationClusterLocalPlugin.java

    r477 r539  
    11package example.localplugin; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.dcworms.DCWormsTags; 
    44 
    55import java.util.ArrayList; 
     
    3030import schedframe.scheduling.tasks.WorkloadUnit; 
    3131 
    32 public class FCFSConsolidationClusterLocalPlugin extends BaseLocalPlugin { 
     32public class FCFSConsolidationClusterLocalPlugin extends BaseLocalSchedulingPlugin { 
    3333 
    3434        public FCFSConsolidationClusterLocalPlugin () { 
    3535        } 
    3636 
    37         public SchedulingPlanInterface schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
     37        public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
    3838                        ResourceManager resManager, ModuleList modules) { 
    3939 
     
    5151 
    5252                        for (int i = 0; i < q.size(); i++) { 
    53                                 WorkloadUnit<?> job = q.get(i); 
     53                                WorkloadUnit job = q.get(i); 
    5454                                TaskInterface<?> task = (TaskInterface<?>) job; 
    5555                                // if status of the tasks in READY 
    56                                 if (task.getStatus() == Gridlet.READY) { 
     56                                if (task.getStatus() == DCWormsTags.READY) { 
    5757 
    5858                                        Map<ResourceUnitName, ResourceUnit> choosenResources = null; 
     
    140140                return suitableNodes; 
    141141        } 
    142          
    143         public String getName() { 
    144                 return getClass().getName(); 
    145         } 
    146142 
    147143} 
  • DCWoRMS/trunk/build/classes/example/localplugin/FCFSNodePowerManagementClusterLocalPlugin.java

    r477 r539  
    11package example.localplugin; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.dcworms.DCWormsTags; 
    44 
    55import java.util.ArrayList; 
     
    3030import schedframe.scheduling.tasks.WorkloadUnit; 
    3131 
    32 public class FCFSNodePowerManagementClusterLocalPlugin extends BaseLocalPlugin { 
     32public class FCFSNodePowerManagementClusterLocalPlugin extends BaseLocalSchedulingPlugin { 
    3333 
    3434        public FCFSNodePowerManagementClusterLocalPlugin () { 
    3535        } 
    3636 
    37         public SchedulingPlanInterface schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
     37        public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
    3838                        ResourceManager resManager, ModuleList modules) { 
    3939 
    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++) { 
    53                                 WorkloadUnit<?> job = q.get(i); 
     50                                WorkloadUnit job = q.get(i); 
    5451                                TaskInterface<?> task = (TaskInterface<?>) job; 
    55                                 // if status of the tasks in READY 
    56                                 if (task.getStatus() == Gridlet.READY) { 
     52                                if (task.getStatus() == DCWormsTags.READY) { 
    5753 
    5854                                        Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 
     
    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/build/classes/example/localplugin/FCFSRandomClusterLocalPlugin.java

    r477 r539  
    11package example.localplugin; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.dcworms.DCWormsTags; 
    44 
    55import java.util.List; 
     
    1919import schedframe.scheduling.tasks.WorkloadUnit; 
    2020 
    21 public class FCFSRandomClusterLocalPlugin extends BaseLocalPlugin { 
     21public class FCFSRandomClusterLocalPlugin extends BaseLocalSchedulingPlugin { 
    2222 
    2323        private Random rand; 
     
    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++) { 
    46                                 WorkloadUnit<?> job = q.get(i); 
     46                                WorkloadUnit job = q.get(i); 
    4747                                TaskInterface<?> task = (TaskInterface<?>) job; 
    4848                                // if status of the tasks in READY 
    49                                 if (task.getStatus() == Gridlet.READY) { 
    50                                         /*for(ResourceUnitName key:resManager.getSharedResourceUnits().keySet()){ 
    51                                                 System.out.println(key.getName()); 
    52                                         }*/ 
    53                                         addToSchedulingPlan(plan, task); 
    54                                         /*String nodeName = chooseRandomProvider(resourceManager); 
     49                                if (task.getStatus() == DCWormsTags.READY) { 
     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/build/classes/example/localplugin/FCFS_BFLocalPlugin.java

    r477 r539  
    11package example.localplugin; 
    22 
    3 import gridsim.Gridlet; 
     3import gridsim.dcworms.DCWormsTags; 
    44import schedframe.events.scheduling.SchedulingEvent; 
    55import schedframe.scheduling.manager.resources.ResourceManager; 
    66import schedframe.scheduling.manager.tasks.JobRegistry; 
    7 import schedframe.scheduling.plan.SchedulingPlanInterface; 
    87import schedframe.scheduling.plan.impl.SchedulingPlan; 
    98import schedframe.scheduling.plugin.grid.ModuleList; 
     
    1312import schedframe.scheduling.tasks.WorkloadUnit; 
    1413 
    15 public class FCFS_BFLocalPlugin extends BaseLocalPlugin { 
     14public class FCFS_BFLocalPlugin extends BaseLocalSchedulingPlugin { 
    1615 
    17         public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
     16        public SchedulingPlan schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 
    1817                         ResourceManager resManager, ModuleList modules) { 
    1918 
    2019                SchedulingPlan plan = new SchedulingPlan(); 
    21                 // chose the events types to serve. 
    22                 // Different actions for different events are possible. 
     20                // Chose the events types to serve. Different actions for different events are possible. 
    2321                switch (event.getType()) { 
    2422                case START_TASK_EXECUTION: 
    2523                case TASK_FINISHED: 
    26                 //case TIMER: 
     24                         
    2725                        // our tasks are placed only in first queue (see BaseLocalPlugin.placeJobsInQueues() method) 
     26                        TaskQueue q = queues.get(0); 
    2827                         
    29                         TaskQueue q = queues.get(0); 
    3028                        // check all tasks in queue 
    3129                        for (int i = 0; i < q.size(); i++) { 
    32                                 WorkloadUnit<?> job = q.get(i); 
     30                                WorkloadUnit job = q.get(i); 
    3331                                TaskInterface<?> task = (TaskInterface<?>) job; 
    3432                                 
    3533                                // if status of the tasks in READY 
    36                                 if (task.getStatus() == Gridlet.READY) { 
     34                                if (task.getStatus() == DCWormsTags.READY) { 
    3735                                        addToSchedulingPlan(plan, task); 
    3836                                } 
     
    4341        } 
    4442 
    45         public String getName() { 
    46                 return getClass().getName(); 
    47         } 
    48  
    49  
    5043} 
    5144 
  • DCWoRMS/trunk/build/classes/example/timeestimation/DefaultTimeEstimationPlugin.java

    r477 r539  
    11package example.timeestimation; 
    22 
    3 import gssim.schedframe.scheduling.ExecTask; 
    43 
    54import java.util.Map; 
    65 
    7 import schedframe.Parameters; 
    8 import schedframe.PluginConfiguration; 
     6import dcworms.schedframe.scheduling.ExecTask; 
     7 
    98import schedframe.events.scheduling.SchedulingEvent; 
    109import schedframe.resources.units.PEUnit; 
     
    1615/** 
    1716 *  
    18  * @author Marcin Krystek 
     17 * @author Marcin Krystek && Wojciech Piatek 
    1918 * 
    2019 */ 
    21 public class DefaultTimeEstimationPlugin implements schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin{ 
     20 
     21public class DefaultTimeEstimationPlugin extends BaseTimeEstimationPlugin{ 
    2222 
    2323        /* 
    2424         * This method should return an estimation of time required to execute the task. 
    2525         * Requested calculation should be done based on the resources allocated for the task, 
    26          * task description and task remaining length (in instructions). 
     26         * task description and task completion percentage. 
    2727         *  
    2828         * Example implementation calculate the estimation based on cpu processing power. 
     
    3030         * of number of allocated cpus and their speed. 
    3131         */ 
    32         public double execTimeEstimation(SchedulingEvent event, 
     32        public double execTimeEstimation(SchedulingEvent event, ExecTask task, 
    3333                        Map<ResourceUnitName, ResourceUnit> allocatedResources, 
    34                         ExecTask task, double completionPercentage) { 
     34                        double completionPercentage) { 
    3535                 
    3636                // collect all information necessary to do the calculation 
     
    4343                int cnt = peUnit.getUsedAmount(); 
    4444 
    45                 double remainingLength =  task.getLength() * (1- completionPercentage); 
     45                // estimate remainingTaskLength 
     46                double remainingLength =  task.getLength() * (1 - completionPercentage/100); 
     47                 
    4648                // do the calculation 
    4749                double execTime = (remainingLength / (cnt * speed)); 
     
    5759        } 
    5860 
    59         public PluginConfiguration getConfiguration() { 
    60                 return null; 
    61         } 
    62  
    63         public String getName() { 
    64                 return "ExampleTimeEstimationPlugin"; 
    65         } 
    66  
    67         public void init(Parameters parameters) { 
    68         } 
    69  
    7061} 
  • DCWoRMS/trunk/build/classes/org/joda/time/VCMilisProvider.java

    r477 r539  
    3939                long vc = Math.round(Sim_system.clock()); 
    4040                //System.out.println("SIMJAVA TIME: "+Sim_system.clock()); 
    41                 //System.out.println("CLOUD TIME: "+GSSIM.clock()); 
    4241                 
    4342                // change virtual seconds to milliseconds 
  • DCWoRMS/trunk/build/classes/schedframe/Property.java

    r477 r539  
    33import java.util.ArrayList; 
    44 
    5 import schemas.StringValueWithUnit; 
     5import schemas.StringValueWithUnitType; 
    66 
    7 public class Property extends ArrayList<StringValueWithUnit>{ 
     7public class Property extends ArrayList<StringValueWithUnitType>{ 
    88 
    99        /** 
  • DCWoRMS/trunk/build/classes/schedframe/ResourceController.java

    r477 r539  
    1919        protected static List<ComputingResource> computingResources; 
    2020        protected Deque<Initializable> toInit; 
     21        protected Set<String> compResLayers; 
    2122         
    2223        public  ResourceController(Scheduler logicalStructure, List<ComputingResource> compResources){ 
     
    144145        } 
    145146 
     147        public Set<String> getComputingResourceLayers() { 
     148                return compResLayers; 
     149        } 
     150 
     151        public void setCompResLayers(Set<String> compResLayers) { 
     152                this.compResLayers = compResLayers; 
     153        } 
     154 
     155 
    146156} 
  • DCWoRMS/trunk/build/classes/schedframe/events/TaskEvent.java

    r477 r539  
    77public class TaskEvent { 
    88 
    9         protected WorkloadUnit<?> task; 
     9        protected WorkloadUnit task; 
    1010        protected String resourceName; 
    1111         
    12         public TaskEvent(WorkloadUnit<?> task, 
     12        public TaskEvent(WorkloadUnit task, 
    1313                         String resourceName) { 
    1414                super(); 
     
    1717        } 
    1818         
    19         public WorkloadUnit<?> getTask() { 
     19        public WorkloadUnit getTask() { 
    2020                return task; 
    2121        } 
  • DCWoRMS/trunk/build/classes/schedframe/resources/computing/ComputingNode.java

    r477 r539  
    1010import schedframe.resources.computing.extensions.ExtensionType; 
    1111import schedframe.resources.computing.profiles.energy.EnergyExtension; 
    12 import schedframe.resources.computing.profiles.energy.power.PowerProfileFactory; 
     12import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 
    1313import schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface; 
    1414import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
     
    2626                 
    2727                //extensionList.add(new EnergyExtension(this, resDesc.getPowerInterface(), resDesc.getEnergyEstimationPlugin())); 
    28                 PowerInterface pi = PowerProfileFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
     28                PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 
    2929                accept(new EnergyExtension(pi, resDesc.getPowerProfile()));      
    3030        } 
     
    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/build/classes/schedframe/resources/computing/ComputingResource.java

    r477 r539  
    22 
    33import gridsim.GridSimTags; 
    4 import gridsim.gssim.WormsTags; 
     4import gridsim.dcworms.DCWormsTags; 
    55 
    66import java.util.ArrayList; 
     
    2828import schedframe.resources.computing.profiles.energy.EnergyEventType; 
    2929import schedframe.resources.computing.profiles.energy.EnergyExtension; 
     30import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 
    3031import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    3132import schedframe.resources.computing.properties.DefaultPropertiesBuilder; 
     
    6869        } 
    6970 
    70         //TODO remove if possible (check if all scenarios can be realized - statistics issue) , since it's temporary method 
     71        //TODO remove if possible (check if all scenarios can be realized - statistics issue), since it's a temporary method 
    7172        private void addFakeProcessors() { 
    7273                if(getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.PE) != null){ 
     
    145146                sec.execute(event); 
    146147 
    147                  
    148148                //old, correctly working method 
    149149                /*if (extensionList != null) { 
     
    157157                //if(scheduler != null && (parent != null && scheduler != parent.getScheduler())/*scheduler.getResources().contains(this)*/){ 
    158158                //      String src = event.getSource() != null ? event.getSource() : name; 
    159                 //      scheduler.sendInternal(GridSimTags.SCHEDULE_NOW, GssimTags.UPDATE, src); 
     159                //      scheduler.sendInternal(GridSimTags.SCHEDULE_NOW, DCWormsTags.UPDATE, src); 
    160160                //} 
    161161                //triggerEventUp(event); 
     
    188188        } 
    189189         
    190         protected List<? extends ComputingResource> searchDescendants(List<ResourceValidator> validators, boolean cutoff) { 
     190        protected List<? extends ComputingResource> searchDescendants(List<ResourceValidator> validators, boolean cutOff) { 
    191191 
    192192                List<ComputingResource> descendants = new ArrayList<ComputingResource>(); 
     
    198198                                ComputingResource resource = toExamine.pop(); 
    199199                                List<ComputingResource> resources = resource.getChildren(); 
    200                                 /*if (resources == null) 
    201                                         continue;*/ 
    202200                                int numberOfRes = resources.size(); 
    203201                                for (int i = 0; i < numberOfRes; i++) { 
     
    205203                                        if (resourceChild.match(validators)) { 
    206204                                                descendants.add(resourceChild); 
    207                                                 if(cutoff == false) { 
     205                                                if(cutOff == false) { 
    208206                                                        toExamine.addLast(resourceChild); 
    209207                                                } 
     
    243241                return null; 
    244242        } 
     243         
     244        public AirThroughputInterface getAirThroughputInterface(){ 
     245                if (extensionList != null) { 
     246                        for (Extension extension : extensionList) { 
     247                                if (extension.getType() == ExtensionType.ENERGY_EXTENSION) { 
     248                                        EnergyExtension ee = (EnergyExtension)extension; 
     249                                        return ee.getAirThroughputInterface(); 
     250                                } 
     251                        } 
     252                } 
     253                return null; 
     254        } 
    245255 
    246256        public Scheduler getScheduler() { 
     
    257267        } 
    258268 
    259         class SimpleEventHandler implements EventHandler{ 
     269        class ComputingResourceEventHandler implements EventHandler{ 
    260270                 
    261271                public void handleResourceEvent(Event event){ 
     
    275285                        if(scheduler != null && (parent != null && scheduler != parent.getScheduler())/*scheduler.getResources().contains(this)*/){ 
    276286                                String src = event.getSource() != null ? event.getSource() : name; 
    277                                 scheduler.sendInternal(GridSimTags.SCHEDULE_NOW, WormsTags.UPDATE, src); 
     287                                scheduler.sendInternal(GridSimTags.SCHEDULE_NOW, DCWormsTags.UPDATE, src); 
    278288                        } else if(parent != null) 
    279289                                parent.getEventHandler().handleSchedulingEvent(event); 
     
    282292         
    283293        public EventHandler getEventHandler(){ 
    284                 return new SimpleEventHandler(); 
     294                return new ComputingResourceEventHandler(); 
    285295        } 
    286296         
    287297        public void initiate(){ 
     298                 
    288299                ResourceEventCommand rec = new ResourceEventCommand(this); 
    289                 EnergyEvent event = new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller"); 
     300                EnergyEvent event = new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller"); 
    290301                event.setReason(EventReason.SIM_INIT); 
    291302                rec.execute(event); 
     303                 
     304                rec = new ResourceEventCommand(this); 
     305                event = new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller"); 
     306                event.setReason(EventReason.SIM_INIT); 
     307                rec.execute(event); 
     308                 
    292309                //alternative way 
     310                //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller")); 
    293311                //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller")); 
    294312        } 
  • DCWoRMS/trunk/build/classes/schedframe/resources/computing/Core.java

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

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

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

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

    r477 r539  
    1111import schedframe.scheduling.policy.local.LocalManagementSystem; 
    1212import schedframe.scheduling.queue.TaskQueueList; 
    13 import simulator.WormsConstants; 
     13import simulator.DCWormsConstants; 
    1414 
    1515 
     
    2020                if (resDesc.getType().equals(StandardResourceType.DataCenter)) 
    2121                        return new DataCenter(resDesc); 
     22                else if (resDesc.getType().equals(StandardResourceType.Rack)) 
     23                        return  new Rack(resDesc); 
    2224                else if (resDesc.getType().equals(StandardResourceType.ComputingNode)) 
    2325                        return  new ComputingNode(resDesc); 
     
    4648                        } 
    4749                        case LS: { 
    48                                 ms = new LocalManagementSystem(id, WormsConstants.MANAGEMENT_SYSTEM, 
     50                                ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, 
    4951                                                schedulingPlugin, execTimeEstimationPlugin, queues); 
    5052                                return new Scheduler(ms, type, managedResources); 
     
    5254 
    5355                default:{ 
    54                                 ms = new LocalManagementSystem(id, WormsConstants.MANAGEMENT_SYSTEM, 
     56                                ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, 
    5557                                                schedulingPlugin, execTimeEstimationPlugin, queues); 
    5658                                return new Scheduler(ms, type, managedResources); 
  • DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/EnergyEventType.java

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

    r477 r539  
    1111import schedframe.resources.computing.extensions.ExtensionException; 
    1212import schedframe.resources.computing.extensions.ExtensionType; 
     13import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 
     14import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 
    1315import schedframe.resources.computing.profiles.energy.power.PowerProfile; 
    1416import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 
    1517import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    1618 
    17 public class EnergyExtension implements Extension/*, ResourceVisitor */{ 
     19public class EnergyExtension implements Extension{ 
    1820 
    1921        private Log log = LogFactory.getLog(EnergyExtension.class); 
     
    2123        protected PowerInterface powerInterface; 
    2224        protected PowerProfile powerProfile; 
    23  
     25         
     26        protected AirThroughputInterface airFlowInterface; 
     27        protected AirThroughputProfile airFlowProfile; 
     28         
    2429        protected ComputingResource computingResource; 
    2530 
     
    2934        } 
    3035 
    31         @Override 
     36        public EnergyExtension(PowerInterface powerInterface, PowerProfile powerProfile, 
     37                        AirThroughputInterface airFlowInterface, AirThroughputProfile airFlowProfile) { 
     38                super(); 
     39                this.powerInterface = powerInterface; 
     40                this.powerProfile = powerProfile; 
     41                this.airFlowInterface = airFlowInterface; 
     42                this.airFlowProfile = airFlowProfile; 
     43        } 
     44 
    3245        public boolean supportsEvent(Event event) { 
    3346 
    3447                if(powerProfile == null || powerProfile.getEnergyEstimationPlugin() == null) 
    3548                        return false; 
    36                  
    3749                if(event.getType().getName().equals(EnergyEventType.POWER_STATE_CHANGED.getName())) 
    3850                        return true; 
     
    4355                else if(event.getType().getName().equals(EnergyEventType.TASK_FINISHED.getName())) 
    4456                        return true; 
     57                 
     58                if(airFlowProfile == null) 
     59                        return false;    
     60                if(event.getType().getName().equals(EnergyEventType.AIRFLOW_STATE_CHANGED.getName())) 
     61                        return true; 
     62                 
    4563                else return false; 
    4664 
    4765        } 
    48          
    4966 
    50         @Override 
    5167        public void handleEvent(Event event) { 
    5268                EnergyEvent enEvent = (EnergyEvent)event; 
     
    87103                        //System.out.println(this.resource.getName() + " - ESTIMATED ENERGY:" + power); 
    88104                        powerProfile.addToPowerUsageHistory(power); 
    89  
     105                        break; 
     106                case AIRFLOW_STATE_CHANGED: 
     107                        System.out.println("====="); 
     108                        double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
     109                        airFlowProfile.addToPowerUsageHistory(airFlow); 
     110                        power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 
     111                        powerProfile.addToPowerUsageHistory(power); 
    90112                        break; 
    91113                } 
    92114        } 
    93          
    94         @Override 
     115 
    95116        public void init(Properties properties) throws ExtensionException { 
    96117                // TODO Auto-generated method stub 
    97118        } 
    98119 
    99         @Override 
    100120        public ExtensionType getType() { 
    101121                return ExtensionType.ENERGY_EXTENSION; 
     
    118138        } 
    119139 
     140        public AirThroughputInterface getAirThroughputInterface() { 
     141                return airFlowInterface; 
     142        } 
     143 
     144        public AirThroughputProfile getAirFlowProfile() { 
     145                return airFlowProfile; 
     146        } 
    120147 
    121148} 
  • DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java

    r477 r539  
    11package schedframe.resources.computing.profiles.energy.airthroughput; 
    22 
     3import java.util.ArrayList; 
    34import java.util.List; 
     5 
     6import org.joda.time.DateTimeUtils; 
    47 
    58import schedframe.Parameters; 
     
    811public class AirThroughputProfile { 
    912         
    10         AirThroughputEstimationPlugin airThroughputEstimationPlugin; 
     13        protected List<AirFlowValue> airFlowHistory; 
     14         
     15        protected AirThroughputEstimationPlugin airThroughputEstimationPlugin; 
    1116        protected List <AirThroughputState> airThroughputStates; 
     17        protected Parameters parameters; 
    1218 
    1319        public AirThroughputProfile(AirThroughputEstimationPlugin airThroughputEstimationPlugin, List<AirThroughputState> airThroughputStates) { 
     
    1521                this.airThroughputEstimationPlugin = airThroughputEstimationPlugin; 
    1622                this.airThroughputStates = airThroughputStates; 
     23                this.airFlowHistory = new ArrayList<AirFlowValue>(); 
    1724        } 
    1825 
     
    2128        } 
    2229         
    23         public void init(Parameters parameters){ 
    24                  
     30        public void addToPowerUsageHistory(double airFlow) { 
     31 
     32                if (airFlowHistory.size() == 0) { 
     33                        AirFlowValue usage = new AirFlowValue(DateTimeUtils.currentTimeMillis(), airFlow); 
     34                        airFlowHistory.add(usage); 
     35                        return; 
     36                } 
     37 
     38                int lastIdx = airFlowHistory.size() - 1; 
     39                double lastAirFlow = airFlowHistory.get(lastIdx).getValue(); 
     40                if (lastAirFlow != airFlow) { 
     41                        AirFlowValue usage = airFlowHistory.get(lastIdx); 
     42                        long currentTime = DateTimeUtils.currentTimeMillis(); 
     43                        if (usage.getTimestamp() == currentTime) { 
     44                                usage.setValue(airFlow); 
     45                                if(lastIdx > 0 && airFlowHistory.get(lastIdx - 1).getValue() == airFlow) 
     46                                        airFlowHistory.remove(usage); 
     47                        } else { 
     48                                usage = new AirFlowValue(DateTimeUtils.currentTimeMillis(), airFlow); 
     49                                airFlowHistory.add(usage); 
     50                        } 
     51                } 
     52        } 
     53 
     54        public List<AirFlowValue> getAirThroughputHistory() { 
     55                return airFlowHistory; 
     56        } 
     57         
     58        public void init(Parameters params){ 
     59                this.parameters = params; 
     60        } 
     61 
     62        public Parameters getParameters() { 
     63                return parameters; 
    2564        } 
    2665} 
  • DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/power/PowerProfile.java

    r477 r539  
    1919        protected Map<String, PState> supportedPStates; 
    2020         
     21        protected Parameters parameters; 
     22         
    2123 
    22         public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<schedframe.resources.computing.profiles.energy.power.PowerState> supportedPowerStates) { 
     24        public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates) { 
    2325                this.energyEstimationPlugin = energyEstimationPlugin; 
    2426                this.powerUsage = new ArrayList<PowerUsage>(); 
    25                 this.supportedPowerStates = supportedPowerStates; 
     27                this.supportedPowerStates = powerStates; 
    2628        } 
    2729         
    28         public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<schedframe.resources.computing.profiles.energy.power.PowerState> supportedPowerStates,  List<schedframe.resources.computing.profiles.energy.power.PState> pStates) { 
     30        public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates,  List<PState> pStates) { 
    2931                this.energyEstimationPlugin = energyEstimationPlugin; 
    30                 this.supportedPowerStates = supportedPowerStates; 
     32                this.supportedPowerStates = powerStates; 
    3133                this.powerUsage = new ArrayList<PowerUsage>(); 
    3234                if(pStates.size() > 0) 
     
    98100        } 
    99101 
    100         public void init(Parameters parameters){ 
    101                  
     102        public void init(Parameters params){ 
     103                this.parameters = params; 
     104        } 
     105         
     106        public Parameters getParameters() { 
     107                return parameters; 
    102108        } 
    103109 
     110 
    104111} 
  • DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/power/PowerUsage.java

    r477 r539  
    11package schedframe.resources.computing.profiles.energy.power; 
    22 
    3 public class PowerUsage { 
     3import schedframe.resources.computing.profiles.energy.MeasurementHistory; 
    44 
    5         protected long timestamp; 
    6         protected double value; 
     5public class PowerUsage extends MeasurementHistory{ 
    76 
    87        public PowerUsage(long timestamp, double value){ 
    9                 this.timestamp = timestamp; 
    10                 this.value = value; 
    11         } 
    12          
    13         public long getTimestamp() { 
    14                 return timestamp; 
    15         } 
    16  
    17         public double getValue() { 
    18                 return value; 
    19         } 
    20          
    21         public void setValue(double value) { 
    22                 this.value = value; 
     8                super(timestamp, value); 
    239        } 
    2410         
  • DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/power/plugin/EnergyEstimationPlugin.java

    r477 r539  
    1010        public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 
    1111 
    12         public double estimateEnergyDissipation(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 
     12        public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 
    1313 
    1414        public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 
  • DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/power/ui/ComputingNodePowerInterface.java

    r477 r539  
    1010import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 
    1111 
    12 public class ComputingNodePowerInterface extends AbstractPowerInterface{ 
     12public class ComputingNodePowerInterface extends ComputingResourcePowerInterface{ 
    1313 
    1414        public static long START_TIME = 600000; 
     
    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/build/classes/schedframe/resources/computing/profiles/energy/power/ui/DataCenterPowerInterface.java

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

    r477 r539  
    33import java.util.List; 
    44 
     5import schedframe.Parameters; 
    56import schedframe.resources.computing.profiles.energy.power.PowerState; 
    67import schedframe.resources.computing.profiles.energy.power.PowerStateName; 
     
    2526        List<PowerUsage> getPowerUsageHistory(); 
    2627         
     28        public Parameters getParameters(); 
    2729} 
  • DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java

    r477 r539  
    11package schedframe.resources.computing.profiles.energy.power.ui; 
     2 
     3 
     4import gridsim.GridSimTags; 
     5import gridsim.dcworms.DCWormsTags; 
    26 
    37import java.util.Map; 
    48 
    5 import schedframe.events.ResourceEventCommand; 
    69import schedframe.resources.ResourceStatus; 
    710import schedframe.resources.computing.ComputingResource; 
    8 import schedframe.resources.computing.Processor; 
    911import schedframe.resources.computing.profiles.energy.EnergyEvent; 
    1012import schedframe.resources.computing.profiles.energy.EnergyEventType; 
     
    1618import schedframe.resources.units.StandardResourceUnitName; 
    1719 
    18 public class ProcessorPowerInterface extends AbstractPowerInterface { 
     20public class ProcessorPowerInterface extends ComputingResourcePowerInterface { 
    1921 
    2022        protected PState currentPState; 
     
    3638                if(powerState != currentPowerState){ 
    3739                        currentPowerState = powerState; 
    38                         //Processor cpu = (Processor) resource; 
    3940                        if(powerState == StandardPowerStateName.OFF){ 
    4041                                resource.setStatus(ResourceStatus.UNAVAILABLE); 
     
    4243                                resource.setStatus(ResourceStatus.FREE); 
    4344                        } 
    44                         resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getName())); 
    45                         //cpu.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, cpu.getName()));                  
     45                        resource.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, resource.getName()));          
    4646                } 
    4747 
     
    7979 
    8080                if(newPState != currentPState){ 
    81                         double factor = newPState.getFrequency()/currentPState.getFrequency(); 
     81                        //double factor = newPState.getFrequency()/currentPState.getFrequency(); 
    8282                        currentPState = newPState; 
    83                         CpuSpeed speed = (CpuSpeed)resource.getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.CPUSPEED).get(0); 
    84                         speed.setAmount(Double.valueOf(currentPState.getFrequency()).intValue()); 
     83                        //CpuSpeed speed = (CpuSpeed)resource.getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.CPUSPEED).get(0); 
     84                        //speed.setAmount(Double.valueOf(currentPState.getFrequency()).intValue()); 
    8585                        //new ResourceEventCommand(resource).execute(EnergyEventType.FREQUENCY_CHANGED); 
    8686                        resource.handleEvent(new EnergyEvent(EnergyEventType.FREQUENCY_CHANGED, resource.getName())); 
    87                         //resource.getScheduler().sendInternal(GridSimTags.SCHEDULE_NOW, GssimTags.UPDATE, resource.getName()); 
     87                        //resource.getScheduler().sendInternal(GridSimTags.SCHEDULE_NOW, DCWormsTags.UPDATE, resource.getName()); 
    8888                        return true; 
    8989                } 
  • DCWoRMS/trunk/build/classes/schedframe/resources/units/AbstractResourceUnit.java

    r477 r539  
    7878        public ResourceUnitProvisioner getProvisioner() { 
    7979        return provisioner; 
    80  
     80        } 
     81         
     82        public Parameters getParameters(){ 
     83                return null; 
    8184        } 
    8285 
  • DCWoRMS/trunk/build/classes/schedframe/resources/units/ResourceUnit.java

    r477 r539  
    2323        public void init(Parameters parameters); 
    2424         
     25        public Parameters getParameters(); 
     26         
    2527        public ResourceUnitProvisioner getProvisioner(); 
    2628} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/Cluster.java

    r477 r539  
    1313import gridsim.GridSimTags; 
    1414import gridsim.IO_data; 
    15 import gridsim.gssim.WormsTags; 
     15import gridsim.dcworms.DCWormsTags; 
    1616 
    1717public class Cluster extends Scheduler{ 
     
    2323        protected void processOtherRequest(Sim_event ev) { 
    2424                switch (ev.get_tag()) { 
    25                 case WormsTags.QUERY_RESOURCE_DESC: 
     25                case DCWormsTags.QUERY_RESOURCE_DESC: 
    2626                        SchedulerDescription desc = new SchedulerDescription(new LocalSystem(get_name(), null, null)); 
    2727                        Map<ResourceUnitName, List<ResourceUnit>> units = managementSystem.getResourceManager().getSharedResourceUnits(); 
     
    3030 
    3131                        IO_data data = new IO_data(desc, 0, ev.get_src()); 
    32                         send(ev.get_src(), GridSimTags.SCHEDULE_NOW, WormsTags.QUERY_RESOURCE_DESC_RESULT, data); 
     32                        send(ev.get_src(), GridSimTags.SCHEDULE_NOW, DCWormsTags.QUERY_RESOURCE_DESC_RESULT, data); 
    3333                        break; 
    3434 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/GridResourceDiscovery.java

    r477 r539  
    55import gridsim.GridSimTags; 
    66import gridsim.IO_data; 
    7 import gridsim.gssim.WormsTags; 
     7import gridsim.dcworms.DCWormsTags; 
    88 
    99import java.util.ArrayList; 
     
    5858                for(int i = 0; i < resourceList.size(); i++){ 
    5959                        int resourceId = resourceList.get(i).get_id(); 
    60                         gridBroker.send(resourceId, GridSimTags.SCHEDULE_NOW, WormsTags.QUERY_RESOURCE_DESC, null); 
     60                        gridBroker.send(resourceId, GridSimTags.SCHEDULE_NOW, DCWormsTags.QUERY_RESOURCE_DESC, null); 
    6161                } 
    6262                 
    6363                //filter only the query response messages 
    64                 Sim_type_p pred = new Sim_type_p(WormsTags.QUERY_RESOURCE_DESC_RESULT); 
     64                Sim_type_p pred = new Sim_type_p(DCWormsTags.QUERY_RESOURCE_DESC_RESULT); 
    6565                Sim_event ev = new Sim_event(); 
    6666                 
     
    8080                for(int i = 0; i < gridBroker.getChildren().size(); i++){ 
    8181                        int resourceId = gridBroker.getChildren().get(i).get_id(); 
    82                         gridBroker.send(resourceId, GridSimTags.SCHEDULE_NOW, WormsTags.QUERY_RESOURCE_DESC, null); 
     82                        gridBroker.send(resourceId, GridSimTags.SCHEDULE_NOW, DCWormsTags.QUERY_RESOURCE_DESC, null); 
    8383                } 
    8484                 
    8585                //filter only the query response messages 
    86                 Sim_type_p pred = new Sim_type_p(WormsTags.QUERY_RESOURCE_DESC_RESULT); 
     86                Sim_type_p pred = new Sim_type_p(DCWormsTags.QUERY_RESOURCE_DESC_RESULT); 
    8787                Sim_event ev = new Sim_event(); 
    8888                 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/Scheduler.java

    r477 r539  
    88import gridsim.GridSimTags; 
    99import gridsim.IO_data; 
    10 import gridsim.gssim.WormsTags; 
     10import gridsim.dcworms.DCWormsTags; 
    1111 
    1212import java.util.ArrayList; 
     
    2828import schedframe.scheduling.manager.resources.ManagedResources; 
    2929import schedframe.scheduling.policy.AbstractManagementSystem; 
     30import schedframe.scheduling.queue.QueueDescription; 
    3031import schedframe.scheduling.queue.TaskQueue; 
    31 import schedframe.scheduling.queue.QueueDescription; 
    3232import schedframe.scheduling.tasks.WorkloadUnit; 
    3333 
     
    117117                                if (obj != null) { 
    118118                                        int delay = (Integer) obj; 
    119                                         send(this.get_id(), delay, WormsTags.TIMER); 
     119                                        send(this.get_id(), delay, DCWormsTags.TIMER); 
    120120                                } 
    121121                        } 
     
    133133                                // managemetnSystem_.setEndSimulation(); 
    134134                                run = false; 
    135                                 /*Sim_stat stats = get_stat(); 
    136                                 List<Object[]> measures = stats.get_measures(); 
    137                                 for (Object[] info : measures) { 
    138                                         String measure = (String) info[0]; 
    139                                         if (measure 
    140                                                         .startsWith(GssimConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME)) { 
    141                                                 System.out.println("====="+this.get_name()+";"+stats.average(measure)); 
    142                                         } 
    143                                 }*/ 
    144135                                break; 
    145136                        } 
     
    155146 
    156147                case GridSimTags.GRIDLET_SUBMIT: 
    157                         processGSSIMJobSubmit(ev, false); 
     148                        processWorkloadUnitSubmit(ev, false); 
    158149                        break; 
    159150 
    160151                case GridSimTags.GRIDLET_SUBMIT_ACK: 
    161                         processGSSIMJobSubmit(ev, true); 
     152                        processWorkloadUnitSubmit(ev, true); 
    162153                        break; 
    163154 
    164155                case GridSimTags.GRIDLET_RETURN: 
    165                         processGSSIMJobReturn(ev); 
     156                        processWorkloadUnitReturn(ev); 
    166157                        break; 
    167158 
     
    174165        protected void processOtherRequest(Sim_event ev) { 
    175166                switch (ev.get_tag()) { 
    176                 case WormsTags.QUERY_RESOURCE_DESC: 
     167                case DCWormsTags.QUERY_RESOURCE_DESC: 
    177168                        SchedulerDescription desc = new SchedulerDescription(new LocalSystem(get_name(), null, null)); 
    178169                        Map<ResourceUnitName, List<ResourceUnit>> units = managementSystem.getResourceManager().getSharedResourceUnits(); 
     
    181172 
    182173                        IO_data data = new IO_data(desc, 0, ev.get_src()); 
    183                         send(ev.get_src(), GridSimTags.SCHEDULE_NOW, WormsTags.QUERY_RESOURCE_DESC_RESULT, data); 
     174                        send(ev.get_src(), GridSimTags.SCHEDULE_NOW, DCWormsTags.QUERY_RESOURCE_DESC_RESULT, data); 
    184175                        break; 
    185176 
     
    189180                } 
    190181        } 
    191          
    192         /*public boolean processOtherEvent(Sim_event ev) { 
    193                 return false; 
    194         }*/ 
    195          
    196         protected void processGSSIMJobReturn(Sim_event ev) { 
    197                 WorkloadUnit<?> job = (WorkloadUnit<?>) ev.get_data(); 
     182 
     183        protected void processWorkloadUnitReturn(Sim_event ev) { 
     184                WorkloadUnit job = (WorkloadUnit) ev.get_data(); 
    198185                managementSystem.notifyReturnedWorkloadUnit(job); 
    199186        } 
    200187 
    201         protected void processGSSIMJobSubmit(Sim_event ev, boolean ack) { 
    202                 WorkloadUnit<?> job = (WorkloadUnit<?>) ev.get_data(); 
     188        protected void processWorkloadUnitSubmit(Sim_event ev, boolean ack) { 
     189                WorkloadUnit job = (WorkloadUnit) ev.get_data(); 
    203190                managementSystem.notifySubmittedWorkloadUnit(job, ack); 
    204191        } 
     
    223210                this.send(this.get_id(), delay, tag, data); 
    224211        } 
    225          
    226         /*protected void send(int dest, int tag, int transaction, Object obj){ 
    227                 IO_data data = new Transaction_IO_data(transaction, obj, 8, dest); 
    228                 super.send(dest, GridSimTags.SCHEDULE_NOW, tag, data); 
    229         }*/ 
    230212         
    231213        public Sim_port getOutputPort() { 
     
    271253        public List<QueueDescription> getQueuesDescription(){ 
    272254                List<QueueDescription> queues = new ArrayList<QueueDescription>(); 
    273                 for(TaskQueue queue: managementSystem.getAccessQueues()){ 
     255                for(TaskQueue queue: managementSystem.getQueues()){ 
    274256                        QueueDescription qd; 
    275257                        try { 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/WorkloadUnitHandler.java

    r477 r539  
    11package schedframe.scheduling; 
    22 
    3 import schedframe.scheduling.tasks.Job; 
    4 import schedframe.scheduling.tasks.SubmittedTask; 
     3import dcworms.schedframe.scheduling.ExecTask; 
     4import schedframe.scheduling.tasks.JobInterface; 
    55import schedframe.scheduling.tasks.TaskInterface; 
    6 import gssim.schedframe.scheduling.ExecTask; 
    76 
    8 public  interface WorkloadUnitHandler{ 
     7public interface WorkloadUnitHandler{ 
    98         
    10         public void handleJob(Job job); 
     9        public void handleJob(JobInterface<?> job); 
    1110         
    1211        public void handleTask(TaskInterface<?> task); 
    1312         
    1413        public void handleExecutable(ExecTask task); 
    15          
    16         public void handleSubmittedTask(SubmittedTask task); 
     14 
    1715} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/manager/resources/LocalResourceManager.java

    r477 r539  
    1313import java.util.Properties; 
    1414import java.util.Set; 
    15 import java.util.Stack; 
    1615 
    1716import schedframe.exceptions.ResourceException; 
     
    175174                return resourceUnit; 
    176175        } 
    177         /*public List<AbstractResourceUnit> getAvailableResourceUnits(String resourceName) throws Exception { 
    178                 ComputingResource resource = getResourceByName(resourceName); 
    179                 List<AbstractResourceUnit> resourceUnits = new ArrayList<AbstractResourceUnit>(); 
    180                 while(resource != null){ 
    181                         for(List<AbstractResourceUnit> resUnits: resource.getResourceCharacteristic().getResourceUnits().values()) 
    182                                 resUnits.addAll(resourceUnits); 
    183                         resource = resource.getParent(); 
    184                 } 
    185                  
    186                 return resourceUnits; 
    187         }*/ 
    188176 
    189177        public List<? extends ComputingResource> filterResources(Properties properties) { 
     
    242230                                computingResources = (List<ComputingResource>) getResourcesOfType(StandardResourceType.Core); 
    243231                        } catch (ResourceException e) { 
    244                                 throw new RuntimeException("GSSIM internal error"); 
     232                                throw new RuntimeException("DCWorms internal error"); 
    245233                        } 
    246234                        PEUnit peUnit = new ProcessingElements(computingResources); 
     
    253241                                computingResources = (List<ComputingResource>) getResourcesOfType(StandardResourceType.Processor); 
    254242                        } catch (ResourceException e) { 
    255                                 throw new RuntimeException("GSSIM internal error"); 
     243                                throw new RuntimeException("DCWorms internal error"); 
    256244                        } 
    257245                        PEUnit peUnit = new ProcessingElements(computingResources); 
     
    318306                        return false; 
    319307                } 
    320                 /*ResourceUnit peUnit = resources.get(StandardResourceUnitName.PE); 
    321  
    322                 if (peUnit != null) { 
    323                         if (peUnit instanceof ProcessingElements) { 
    324                                 ProcessingElements choosenProcessors = (ProcessingElements) peUnit; 
    325  
    326                                 for (int i = 0; i < choosenProcessors.size(); i++) { 
    327                                         choosenProcessors.get(i).setStatus(ResourceStatus.BUSY); 
    328                                 } 
    329                         } 
    330                 }*/ 
    331  
    332                 /*Memory m = (Memory) resources.get(StandardResourceUnitName.MEMORY); 
    333                 if (m != null) { 
    334                         m.getProvisioner().setState(ResourceUnitState.BUSY); 
    335                 }*/ 
    336308                 
    337309                for(ResourceUnitName resUnitName: resources.keySet()){ 
     
    345317        public void freeResources(Map<ResourceUnitName, ResourceUnit> resources) { 
    346318                 
    347                 /*ResourceUnit peUnit = resources.get(StandardResourceUnitName.PE); 
    348                  
    349                 if (peUnit instanceof ProcessingElements) { 
    350                         ProcessingElements processingElements = (ProcessingElements) peUnit; 
    351  
    352                         for (int i = 0; i < processingElements.size(); i++) { 
    353                                 processingElements.get(i).setStatus(ResourceStatus.FREE); 
    354                         } 
    355                 }*/ 
    356  
    357                 /*Memory m = (Memory) resources.get(StandardResourceUnitName.MEMORY); 
    358                 if (m != null) { 
    359                         m.getProvisioner().setState(ResourceUnitState.FREE); 
    360                 }*/ 
    361                  
    362319                for(ResourceUnitName resUnitName: resources.keySet()){ 
    363320                        ResourceUnit resUnit = resources.get(resUnitName); 
     
    366323        } 
    367324 
    368  
    369325} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/manager/tasks/AbstractJobRegistry.java

    r477 r539  
    22 
    33 
    4 import java.util.Map; 
    54import java.util.concurrent.ConcurrentHashMap; 
    65 
     
    1413 
    1514 
    16 public abstract class AbstractJobRegistry /*extends ConcurrentHashMap<String, Job> */implements JobRegistry, Cloneable{ 
     15public abstract class AbstractJobRegistry /*extends ConcurrentHashMap<String, Job>*/ implements JobRegistry, Cloneable{ 
    1716         
    1817        private static final long serialVersionUID = 8409060063583755824L; 
     18 
    1919         
    20         private static Log log = LogFactory.getLog(AbstractJobRegistry.class); 
    21          
    22         protected static final ConcurrentHashMap<String, Job> jobs = new ConcurrentHashMap<String, Job>(); 
     20        protected static final ConcurrentHashMap<String, JobInterface<?>> jobs = new ConcurrentHashMap<String, JobInterface<?>>(); 
    2321         
    2422        protected AbstractJobRegistry(){ 
    25                 //log.warn("Methods from JobRegistry interface are not implemented."); 
    2623        } 
    2724         
    2825        public boolean addJob(JobInterface<?> job) { 
    29                 try { 
    30                          jobs.put(job.getId(), (Job) job); 
    31                 } catch (NoSuchFieldException e) { 
    32                         log.error(e.getMessage()); 
    33                         return false; 
    34                 } 
     26                jobs.put(job.getId(),  job); 
    3527                return true; 
    3628        } 
     
    3830        public boolean addTask(TaskInterface<?> task) { 
    3931                if(jobs.containsKey(task.getJobId())){ 
    40                         jobs.get(task.getJobId()).add((Task)task); 
     32                        getJob(task.getJobId()).add((Task)task); 
    4133                        return true; 
    4234                } else { 
     
    4537        } 
    4638 
    47         public Job get(String jobId){ 
     39        public JobInterface<?> getJobInfo(String jobId) { 
    4840                return jobs.get(jobId); 
    4941        } 
    50          
    51         public JobInterface<?> getJobInfo(String jobID) { 
    52                 return jobs.get(jobID); 
    53         } 
    5442 
    55         public TaskInterface<?> getTaskInfo(String jobID, String taskId) { 
     43        public TaskInterface<?> getTaskInfo(String jobId, String taskId) { 
    5644                Task task = null; 
    57                 Job job = jobs.get(jobID); 
     45                Job job = getJob(jobId); 
    5846                 
    5947                if(job == null) 
     
    6351                        task = job.getTask(taskId); 
    6452                } catch (NoSuchFieldException e) { 
    65                         log.error(e.getMessage()); 
    6653                } 
    6754                return task; 
    6855        } 
    6956         
    70         /*public List<JobInterface<?>> getActiveJobs() { 
    71                 log.error("getActiveJobs() not implemented."); 
    72                 return null; 
     57        public Job getJob(String jobId){ 
     58                return (Job)jobs.get(jobId); 
    7359        } 
    7460 
    75         public List<TaskInterface<?>> getActiveTasks() { 
    76                 log.error("getActiveTasks() not implemented."); 
    77                 return null; 
    78         }*/ 
    79  
    80  
    81          
    82  
    8361} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/manager/tasks/JobRegistry.java

    r477 r539  
    11package schedframe.scheduling.manager.tasks; 
    22 
    3 import gssim.schedframe.scheduling.ExecTask; 
    43 
    54import java.util.List; 
    65 
     6import dcworms.schedframe.scheduling.ExecTask; 
     7 
     8import schedframe.ExecutablesList; 
    79import schedframe.scheduling.tasks.JobInterface; 
    810import schedframe.scheduling.tasks.TaskInterface; 
     
    1113public interface JobRegistry { 
    1214 
    13         //public List<JobInterface<?>> getActiveJobs(); 
    14  
    15         //public List<TaskInterface<?>> getActiveTasks(); 
    16          
    1715        public JobInterface<?> getJobInfo(String jobId); 
    1816 
     
    3129 
    3230 
    33         //public List<SubmittedTask> getSubmittedTasks(); 
     31        public ExecutablesList getExecutableTasks();  
    3432         
    35         public ExecTask getSubmittedTask(String jobId, String taskId); 
     33        public ExecTask getExecutable(String jobId, String taskId); 
    3634 
    3735         
    38         public List<? extends TaskInterface<?>> getReadyTasks(List<JobInterface<?>> jobsList); 
     36        public List<? extends TaskInterface<?>> getAvailableTasks(List<JobInterface<?>> jobsList); 
    3937 
    4038} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/manager/tasks/JobRegistryImpl.java

    r477 r539  
    11package schedframe.scheduling.manager.tasks; 
    22 
    3 import gridsim.Gridlet; 
    4 import gssim.schedframe.scheduling.ExecTask; 
    5 import gssim.schedframe.scheduling.Executable; 
     3import gridsim.dcworms.DCWormsTags; 
    64 
    75import java.util.ArrayList; 
    8 import java.util.Collections; 
    9 import java.util.HashMap; 
    106import java.util.List; 
    11 import java.util.Map; 
    127 
    138import org.apache.commons.lang.ArrayUtils; 
    149import org.apache.commons.logging.Log; 
    1510import org.apache.commons.logging.LogFactory; 
    16 import org.joda.time.DateTime; 
    1711import org.qcg.broker.schemas.resreqs.ParentType; 
    1812import org.qcg.broker.schemas.resreqs.types.TaskStatesName; 
    1913 
     14import dcworms.schedframe.scheduling.ExecTask; 
     15 
    2016import qcg.shared.constants.BrokerConstants; 
    21 import schedframe.resources.units.ResourceUnit; 
    22 import schedframe.resources.units.ResourceUnitName; 
    23 import schedframe.scheduling.ResourceHistoryItem; 
    24 import schedframe.scheduling.plan.AllocationInterface; 
    25 import schedframe.scheduling.tasks.AbstractProcesses; 
     17import schedframe.ExecutablesList; 
    2618import schedframe.scheduling.tasks.JobInterface; 
    27 import schedframe.scheduling.tasks.SubmittedTask; 
    2819import schedframe.scheduling.tasks.Task; 
    29 import simulator.WormsConstants; 
    3020 
    3121public class JobRegistryImpl extends AbstractJobRegistry { 
     
    3727        private String context; 
    3828 
    39         //TO DO - change data structure 
    40         protected static final List<ExecTask> submittedTasks = Collections.synchronizedList(new ArrayList<ExecTask>());; 
    41         //protected static final List<ExecTaskInterface> submittedTasks = new CopyOnWriteArrayList<ExecTaskInterface>(); 
     29        //TO DO - consider data structure 
     30        protected static final ExecutablesList executables = new ExecutablesList(); 
     31        //protected static final List<ExecTask> executables = Collections.synchronizedList(new ArrayList<ExecTask>());; 
     32        //protected static final List<ExecTaskInterface> executables = new CopyOnWriteArrayList<ExecTaskInterface>(); 
    4233 
    43         public JobRegistryImpl(String context_) { 
    44                 context = context_; 
     34        public JobRegistryImpl(String context) { 
     35                this.context = context; 
    4536        } 
    4637 
    47         /*protected void setContext(String context_) { 
    48                 context = context_; 
    49         }*/ 
    50  
    51         public boolean addTask(ExecTask newTask) { 
    52                 if(getSubmittedTask(newTask.getJobId(), newTask.getId()) == null) 
    53                 { 
    54                         synchronized (submittedTasks)  { 
    55                                 submittedTasks.add(newTask); 
     38        public boolean addExecTask(ExecTask newTask) { 
     39                if(getExecutable(newTask.getJobId(), newTask.getId()) == null) { 
     40                        synchronized (executables)  { 
     41                                executables.add(newTask); 
    5642                        } 
    5743                        return true; 
     
    6046        } 
    6147 
     48        public ExecutablesList getExecutableTasks() { 
     49                return executables; 
     50        } 
    6251        public List<ExecTask> getTasks(int status) { 
    6352                List<ExecTask> taskList = new ArrayList<ExecTask>(); 
    64                 synchronized (submittedTasks)  { 
    65                         for (ExecTask task: submittedTasks) { 
     53                synchronized (executables)  { 
     54                        for (ExecTask task: executables) { 
    6655                                if (task.getStatus() == status) { 
    67                                         //SubmittedTask subTask = (SubmittedTask) task; 
    6856                                        List<String> visitedResource = task.getVisitedResources(); 
    69                                         if(ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), context)){ 
     57                                        if(ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), context)) { 
    7058                                                taskList.add(task); 
    7159                                        } 
    72                                         /*if(subTask.getVisitedResources().contains(context)){ 
    73                                                 taskList.add(subTask); 
    74                                         }*/ 
    7560                                } 
    7661                        } 
     
    8065 
    8166        public List<ExecTask> getQueuedTasks() { 
    82                 return getTasks(Gridlet.QUEUED); 
     67                return getTasks(DCWormsTags.QUEUED); 
    8368        } 
    8469         
    8570        public List<ExecTask> getRunningTasks() { 
    86                 return getTasks(Gridlet.INEXEC); 
     71                return getTasks(DCWormsTags.INEXEC); 
    8772        } 
    8873         
    8974        public List<ExecTask> getReadyTasks() { 
    90                 return getTasks(Gridlet.READY); 
     75                return getTasks(DCWormsTags.READY); 
    9176        } 
    9277         
    9378        public List<ExecTask> getFinishedTasks() { 
    94                 return getTasks(Gridlet.SUCCESS); 
     79                return getTasks(DCWormsTags.SUCCESS); 
    9580        } 
    9681         
    97          
    98         public List<ExecTask> getAllSubmittedTasks() { 
    99                 List<ExecTask> taskList; 
    100                 synchronized (submittedTasks)  { 
    101                         taskList = new ArrayList<ExecTask>(submittedTasks); 
    102                 } 
    103                 return taskList; 
    104         } 
    105  
    106         public List<SubmittedTask> getSubmittedTasks() { 
    107                 List<SubmittedTask> taskList = new ArrayList<SubmittedTask>(); 
    108                 synchronized (submittedTasks)  { 
    109                         for (ExecTask task : submittedTasks) { 
    110                                 SubmittedTask subTask = (SubmittedTask) task; 
    111                                 List<String> visitedResource = subTask.getVisitedResources(); 
    112                                 if(ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), context)){ 
    113                                         taskList.add(subTask); 
    114                                 } 
    115                                 /*if(subTask.getVisitedResources().contains(context)){ 
    116                                         taskList.add(subTask); 
    117                                 }*/ 
    118                         } 
    119                 } 
    120                 return taskList; 
    121         } 
    122          
    123         public ExecTask getSubmittedTask(String jobId, String taskId){ 
    124                 synchronized (submittedTasks)  { 
    125                         for (ExecTask task : submittedTasks) { 
    126                                 if (task.getJobId().compareTo(jobId) == 0 && task.getId().compareTo(taskId)==0) { 
     82        public ExecTask getExecutable(String jobId, String taskId){ 
     83                synchronized (executables)  { 
     84                        for (ExecTask task : executables) { 
     85                                if (task.getJobId().compareTo(jobId) == 0 && task.getId().compareTo(taskId) == 0) { 
    12786                                        return task; 
    12887                                } 
     
    13190                return null; 
    13291        } 
    133          
    13492 
    13593        @SuppressWarnings("unchecked") 
    136         public List<Task> getReadyTasks(List<JobInterface<?>> wuList) { 
    137                 List<Task> readyTasks = new ArrayList<Task>(); 
     94        public List<Task> getAvailableTasks(List<JobInterface<?>> wuList) { 
     95                List<Task> availableTasks = new ArrayList<Task>(); 
    13896                List<Task> waitingTasks = new ArrayList<Task>(); 
    13997                 
     
    143101                } 
    144102 
    145                 readyTasks.addAll(getPrecedenceConstrainedReadyTasks(waitingTasks)); 
    146                 return readyTasks; 
    147         } 
    148          
    149         public Executable getTaskExecutable(Integer executableId){ 
    150                 synchronized (submittedTasks)  { 
    151                         for (ExecTask task : submittedTasks) { 
    152                                 SubmittedTask subTask = (SubmittedTask) task; 
    153                                 Executable exec = (Executable)subTask.getGridlet(); 
    154                                 if (exec.getGridletID() == executableId) { 
    155                                         return exec; 
    156                                 } 
    157                         } 
    158                 } 
    159                 return null; 
    160         } 
    161          
    162         public List<Executable> getJobExecutables(String jobId){ 
    163                 List<Executable> list = new ArrayList<Executable>(); 
    164                 synchronized (submittedTasks)  { 
    165                         for(int i = 0; i < submittedTasks.size(); i++){ 
    166                                 SubmittedTask subTask = (SubmittedTask) submittedTasks.get(i); 
    167                                 Executable exec = (Executable)subTask.getGridlet(); 
    168                                  
    169                                 if(exec.getJobId().equals(jobId)) 
    170                                         list.add(exec); 
    171                         } 
    172                 } 
    173                 return list; 
    174         } 
    175          
    176         public JobRegistryImpl clone() { 
    177                 JobRegistryImpl jr = null; 
    178                 try { 
    179                         jr = (JobRegistryImpl) super.clone(); 
    180                 } catch (CloneNotSupportedException e) { 
    181                         // TODO Auto-generated catch block 
    182                         e.printStackTrace(); 
    183                 } 
    184  
    185                 return jr; 
    186         } 
    187  
    188         /*public AbstractExecutable getTaskExecutabls(String jobId, String taskId){ 
    189                 List<AbstractExecutable> list = new ArrayList<AbstractExecutable>(); 
    190                 synchronized (submittedTasks)  { 
    191                         for(int i = 0; i < size(); i++){ 
    192                                 SubmittedTask subTask = (SubmittedTask) submittedTasks.get(i); 
    193                                 AbstractExecutable exec = (AbstractExecutable)subTask.getGridlet(); 
    194                                  
    195                                 if(exec.getJobId().equals(jobId) && exec.getId().equals(taskId)) 
    196                                         return exec; 
    197                         } 
    198                 } 
    199                 return null; 
    200         }*/ 
    201          
    202          
    203         public Executable createExecutable(Task task, AllocationInterface allocation) { 
    204  
    205                 String refersTo = allocation.getProcessGroupId(); // null;//allocation.getRefersTo(); 
    206                 if(refersTo == null) 
    207                         refersTo = task.getId(); 
    208                          
    209                 Executable exec = null; 
    210  
    211                 if(refersTo.equals(task.getId())){ 
    212                         exec = new Executable(task); 
    213                 } else { 
    214                         List<AbstractProcesses> processes = task.getProcesses(); 
    215                         if(processes == null) { 
    216                                 try { 
    217                                         log.error("Allocation: " + allocation.getDocument() + "\nrefers to unknown task or processes set." + 
    218                                                         " Set correct value (task id or prcesses set id) for allocation refersTo attribute."); 
    219                                 } catch (Exception e) { 
    220                                         e.printStackTrace(); 
    221                                 } 
    222                         } 
    223                         boolean found = false; 
    224                         for(int j = 0; j < processes.size() && !found; j++){ 
    225                                 AbstractProcesses procesesSet = processes.get(j); 
    226                                 if(refersTo.equals(procesesSet.getId())){ 
    227                                         exec = new Executable(task, procesesSet); 
    228                                         found = true; 
    229                                 } 
    230                         } 
    231                         if(!found){ 
    232                                 log.error("Allocation refers to unknown proceses set."); 
    233                         } 
    234                 } 
    235                  
    236         //      exec.setUserID(task.getSenderId()); 
    237                 exec.setLength(task.getLength()); 
    238                 exec.setReservationId(allocation.getReservationId()); 
    239                          
    240                 /*HostInterface<?> host = allocation.getHost(); 
    241                 ComputingResourceTypeInterface<?> crt = host.getMachineParameters(); 
    242                 if(crt != null){ 
    243                         ComputingResourceTypeItemInterface<?> crti = crt.getComputingResourceTypeItem(0); 
    244                         if(crti != null){ 
    245                                 ParameterPropertyInterface<?> properties[] = crti.getHostParameter().getProperty(); 
    246                                 for(int p = 0; p < properties.length; p++){ 
    247                                         ParameterPropertyInterface<?> property = properties[p]; 
    248                                         if("chosenCPUs".equals(property.getName())){ 
    249                                                 Object cpuNames = property.getValue(); 
    250                                                 exec.addSpecificResource(ResourceParameterName.FREECPUS, cpuNames); 
    251                                         } 
    252                                 } 
    253                         } 
    254                 }*/ 
    255                 return exec; 
    256         } 
    257          
    258  
    259         public List<Executable> createExecutables(Task task) { 
    260  
    261                 List<AbstractProcesses> processes = task.getProcesses(); 
    262                  
    263                 List<Executable> executables = new ArrayList<Executable>(); 
    264  
    265                 if(processes == null || processes.size()==0){ 
    266                         Executable exec = new Executable(task); 
    267                         exec.setUserID(task.getSenderId()); 
    268                         exec.setLength(task.getLength()); 
    269                         executables.add(exec); 
    270                 } else { 
    271  
    272                         boolean found = false; 
    273                         for(int j = 0; j < processes.size() && !found; j++){ 
    274                                 AbstractProcesses procesesSet = processes.get(j); 
    275                                 Executable exec = new Executable(task, procesesSet); 
    276                                 exec.setUserID(task.getSenderId()); 
    277                                 exec.setLength(task.getLength()); 
    278                                 executables.add(exec); 
    279                         } 
    280                 } 
    281  
    282                 return  executables; 
     103                availableTasks.addAll(getPrecedenceConstrainedAvailableTasks(waitingTasks)); 
     104                return availableTasks; 
    283105        } 
    284106 
    285107 
    286         /**************************************/ 
    287         protected static Map<Integer, Map<String, Object>> history = new HashMap<Integer, Map<String,Object>>(); 
    288          
    289         public static Map<Integer, Map<String, Object>> getAllocationHistory(){ 
    290                 return history; 
    291         } 
    292          
    293         public void saveHistory (SubmittedTask submittedTask, int estimatedTime, Map<ResourceUnitName, ResourceUnit> choosenResources){ 
     108        private List<Task> getPrecedenceConstrainedAvailableTasks(List<Task> tasks){ 
    294109                 
    295                 /*submittedTask.setEstimatedDuration(estimatedTime); 
    296  
    297                 DateTime currentTime = new DateTime(); 
    298                 ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime); 
    299                 submittedTask.addUsedResources(resHistItem);*/ 
    300  
    301                 ResourceHistoryItem resHistItem = submittedTask.getUsedResources().getLast(); 
    302                 DateTime currentTime = new DateTime(); 
    303                 Map<String, Object> historyItem = new HashMap<String, Object>(); 
    304                 List<ResourceHistoryItem> list = new ArrayList<ResourceHistoryItem>(1); 
    305                 list.add(resHistItem); 
    306                 historyItem.put(WormsConstants.RESOURCES, list); 
    307                 historyItem.put(WormsConstants.START_TIME, currentTime); 
    308                 currentTime = currentTime.plusSeconds(estimatedTime); 
    309                 historyItem.put(WormsConstants.END_TIME, currentTime); 
    310  
    311                 history.put(Integer.valueOf(submittedTask.getGridletID()), historyItem); 
    312                 /*ProcessingElements pes = (ProcessingElements) choosenResources.get(ResourceParameterName.PROCESSINGELEMENTS); 
    313                 for (ComputingResource resource : pes) { 
    314                         //submittedTask.addToResPath(resource.getName()); 
    315                         submittedTask.visitResource(resource.getName()); 
    316                         ComputingResource parent = resource.getParent(); 
    317                         while (parent != null && !submittedTask.getResPath().contains(parent.getName() + "_")) { 
    318                                 submittedTask.addToResPath(parent.getName()); 
    319                                 parent = parent.getParent(); 
    320                         } 
    321                         while (parent != null && !submittedTask.getVisitedResources().contains(parent.getName() + "_")) { 
    322                                 submittedTask.visitResource(parent.getName()); 
    323                                 parent = parent.getParent(); 
    324                         } 
    325                 }*/ 
    326         } 
    327  
    328         private List<Task> getPrecedenceConstrainedReadyTasks(List<Task> tasks){ 
     110                List<Task> availableTasks = new ArrayList<Task>(); 
     111                int size = tasks.size(); 
    329112                 
    330                 List<Task> readyTasks = new ArrayList<Task>(); 
    331  
    332                 int size = tasks.size(); 
    333113                for(int i = 0; i < size; i++){ 
    334114                        int parCnt; 
    335                         int previousTaskReadyCnt = 0; 
     115                        int previousTaskSucceedCnt = 0; 
    336116                        Task task = tasks.get(i); 
    337117                        if(task.getStatus() != (int)BrokerConstants.TASK_STATUS_UNSUBMITTED) 
     
    341121                        } catch(Exception e){ 
    342122                                parCnt = 0; 
    343                                 //e.printStackTrace(); 
    344123                        } 
    345                         if(parCnt == 0) 
    346                         { 
    347                                 readyTasks.add(task); 
     124                        if(parCnt == 0){ 
     125                                availableTasks.add(task); 
    348126                        } 
    349                         else 
    350                         { 
     127                        else { 
    351128                                for(int j = 0; j < parCnt; j++){ 
    352129                                        ParentType par = task.getDescription().getWorkflow().getParent(j); 
     
    356133                                                } 
    357134                                        } 
    358                                         previousTaskReadyCnt++; 
     135                                        previousTaskSucceedCnt++; 
    359136                                } 
    360137                                 
    361                                 if(previousTaskReadyCnt == parCnt && task.getDescription().getWorkflow().getAnd() != null) 
    362                                         readyTasks.add(task); 
    363                                 else if(previousTaskReadyCnt > 0 && task.getDescription().getWorkflow().getOr() != null) 
    364                                         readyTasks.add(task); 
    365                                 else if (previousTaskReadyCnt == parCnt) 
    366                                         readyTasks.add(task); 
     138                                if(previousTaskSucceedCnt == parCnt && task.getDescription().getWorkflow().getAnd() != null) 
     139                                        availableTasks.add(task); 
     140                                else if(previousTaskSucceedCnt > 0 && task.getDescription().getWorkflow().getOr() != null) 
     141                                        availableTasks.add(task); 
     142                                else if (previousTaskSucceedCnt == parCnt) 
     143                                        availableTasks.add(task); 
    367144                        } 
    368145                }                
    369                 return readyTasks; 
     146                return availableTasks; 
    370147        } 
    371148         
     
    380157                return false; 
    381158        } 
     159 
    382160} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/plan/ScheduledTaskInterface.java

    r477 r539  
    44 
    55import schedframe.DescriptionContainer; 
    6 import schedframe.scheduling.tasks.WorkloadUnit; 
     6import schedframe.scheduling.tasks.TaskInterface; 
    77 
    88public interface ScheduledTaskInterface<T> extends DescriptionContainer<T> { 
     
    190190         
    191191 
    192         public ArrayList<AllocationInterface> getAllocations(); 
     192        public ArrayList<AllocationInterface<?>> getAllocations(); 
    193193         
    194         public WorkloadUnit<?> getTask(); 
     194        public TaskInterface<?> getTask(); 
    195195 
    196196} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/plan/SchedulingPlanInterface.java

    r477 r539  
    9999 
    100100 
    101         public ArrayList<ScheduledTaskInterface> getTasks(); 
     101        public ArrayList<ScheduledTaskInterface<?>> getTasks(); 
    102102} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/plan/impl/ScheduledTask.java

    r477 r539  
    66import org.exolab.castor.xml.MarshalException; 
    77import org.exolab.castor.xml.ValidationException; 
     8import org.qcg.broker.schemas.schedulingplan.types.AllocationStatus; 
    89 
    910import schedframe.scheduling.plan.AllocationInterface; 
    1011import schedframe.scheduling.plan.ScheduledTaskInterface; 
    1112import schedframe.scheduling.plan.ScheduledTimeInterface; 
    12 import schedframe.scheduling.tasks.WorkloadUnit; 
    13  
    14  
    15 import org.qcg.broker.schemas.schedulingplan.types.AllocationStatus; 
     13import schedframe.scheduling.tasks.TaskInterface; 
    1614 
    1715public class ScheduledTask implements ScheduledTaskInterface<org.qcg.broker.schemas.schedulingplan.Task> { 
     
    2220        public ScheduledTask(){ 
    2321                t = new org.qcg.broker.schemas.schedulingplan.Task(); 
    24                 allocationList = new ArrayList<AllocationInterface>(); 
     22                allocationList = new ArrayList<AllocationInterface<?>>(); 
    2523        } 
    2624         
    2725        public ScheduledTask(org.qcg.broker.schemas.schedulingplan.Task value){ 
    2826                t = value; 
    29                 allocationList = new ArrayList<AllocationInterface>(); 
     27                allocationList = new ArrayList<AllocationInterface<?>>(); 
    3028        } 
    3129         
     
    178176         
    179177 
    180         protected WorkloadUnit<?> task; 
    181         protected ArrayList<AllocationInterface> allocationList; 
     178        protected TaskInterface<?> task; 
     179        protected ArrayList<AllocationInterface<?>> allocationList; 
    182180 
    183         public ScheduledTask(WorkloadUnit<?> task){ 
     181        public ScheduledTask(TaskInterface<?> task){ 
    184182                this(); 
    185183                this.task = task; 
    186184        } 
    187185 
    188         public ArrayList<AllocationInterface> getAllocations() { 
     186        public ArrayList<AllocationInterface<?>> getAllocations() { 
    189187                return this.allocationList; 
    190188        } 
    191189         
    192         public WorkloadUnit<?> getTask(){ 
     190        public TaskInterface<?> getTask(){ 
    193191                return this.task; 
    194192        } 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/plan/impl/SchedulingPlan.java

    r477 r539  
    1818        public SchedulingPlan(){ 
    1919                sp = new org.qcg.broker.schemas.schedulingplan.SchedulingPlan(); 
    20                 taskList = new ArrayList<ScheduledTaskInterface>(); 
     20                taskList = new ArrayList<ScheduledTaskInterface<?>>(); 
    2121        } 
    2222         
    2323        public SchedulingPlan(org.qcg.broker.schemas.schedulingplan.SchedulingPlan value){ 
    2424                sp = value; 
    25                 taskList = new ArrayList<ScheduledTaskInterface>(); 
     25                taskList = new ArrayList<ScheduledTaskInterface<?>>(); 
    2626        } 
    2727         
     
    106106 
    107107         
    108         protected ArrayList<ScheduledTaskInterface> taskList; 
     108        protected ArrayList<ScheduledTaskInterface<?>> taskList; 
    109109 
    110         public ArrayList<ScheduledTaskInterface> getTasks() { 
     110        public ArrayList<ScheduledTaskInterface<?>> getTasks() { 
    111111 
    112112                return this.taskList; 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/plugin/SchedulingPlugin.java

    r477 r539  
    33import schedframe.Plugin; 
    44import schedframe.events.scheduling.SchedulingEvent; 
    5 import schedframe.scheduling.WorkloadUnitListImpl; 
     5import schedframe.scheduling.TaskList; 
     6import schedframe.scheduling.TaskListImpl; 
    67import schedframe.scheduling.manager.resources.ResourceManager; 
    78import schedframe.scheduling.manager.tasks.JobRegistry; 
     
    1213public interface SchedulingPlugin extends Plugin{ 
    1314 
    14         public int placeJobsInQueues(WorkloadUnitListImpl newJobs, 
     15        public int placeTasksInQueues(TaskList newTasks, 
    1516                        TaskQueueList queues,  
    1617                        ResourceManager resourceManager, ModuleList modules); 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/plugin/estimation/ExecutionTimeEstimationPlugin.java

    r477 r539  
    11package schedframe.scheduling.plugin.estimation; 
    22 
    3 import gssim.schedframe.scheduling.ExecTask; 
    43 
    5 import java.util.List; 
    64import java.util.Map; 
     5 
     6import dcworms.schedframe.scheduling.ExecTask; 
    77 
    88import schedframe.Plugin; 
     
    3232         * @return estimated execution time of a task of specified length 
    3333         */ 
    34         public double execTimeEstimation(SchedulingEvent event, Map<ResourceUnitName, ResourceUnit> allocatedResources,  
    35                                                                         ExecTask task,  
     34        public double execTimeEstimation(SchedulingEvent event, ExecTask task, Map<ResourceUnitName, ResourceUnit> allocatedResources,  
    3635                                                                        double completionPercentage); 
    3736         
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/policy/AbstractManagementSystem.java

    r477 r539  
    88import org.joda.time.DateTimeUtilsExt; 
    99 
     10import dcworms.schedframe.scheduling.ExecTask; 
     11import dcworms.schedframe.scheduling.Executable; 
     12import dcworms.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 
     13 
    1014import schedframe.PluginConfiguration; 
    1115import schedframe.events.scheduling.SchedulingEventType; 
    12 import schedframe.resources.units.StandardResourceUnitName; 
    1316import schedframe.scheduling.Scheduler; 
    1417import schedframe.scheduling.WorkloadUnitHandler; 
     
    1619import schedframe.scheduling.manager.resources.ResourceManager; 
    1720import schedframe.scheduling.manager.resources.ResourceManagerFactory; 
     21import schedframe.scheduling.manager.tasks.JobRegistry; 
    1822import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    19 import schedframe.scheduling.manager.tasks.JobRegistry; 
    2023import schedframe.scheduling.plan.AllocationInterface; 
    2124import schedframe.scheduling.plan.SchedulingPlanInterface; 
     
    2730import schedframe.scheduling.queue.TaskQueueList; 
    2831import schedframe.scheduling.tasks.Job; 
     32import schedframe.scheduling.tasks.TaskInterface; 
    2933import schedframe.scheduling.tasks.WorkloadUnit; 
    30 import simulator.WormsConstants; 
     34import simulator.DCWormsConstants; 
    3135import eduni.simjava.Sim_event; 
    3236import gridsim.GridSim; 
    3337import gridsim.GridSimTags; 
    34 import gridsim.Gridlet; 
    3538import gridsim.IO_data; 
    36 import gridsim.gssim.WormsTags; 
    37 import gssim.schedframe.scheduling.ExecTask; 
    38 import gssim.schedframe.scheduling.Executable; 
    39 import gssim.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 
     39import gridsim.dcworms.DCWormsTags; 
    4040 
    4141public abstract class AbstractManagementSystem { 
     
    4545        protected String name; 
    4646 
     47        protected TaskQueueList queues; 
    4748        protected ResourceManager resourceManager; 
    48  
    49         protected TaskQueueList queues; 
    50  
     49        protected JobRegistryImpl jobRegistry; 
     50        protected ModuleList moduleList; 
     51         
    5152        protected SchedulingPlugin schedulingPlugin; 
    52  
    5353        protected ExecutionTimeEstimationPlugin execTimeEstimationPlugin; 
    5454 
    55         protected ModuleList moduleList; 
    56          
    57         protected JobRegistryImpl jobRegistry; 
     55        protected Scheduler scheduler; 
    5856         
    5957 
     
    6765        } 
    6866         
     67        public void init(Scheduler sched, ManagedResources managedResources) { 
     68                scheduler = sched; 
     69                resourceManager = ResourceManagerFactory.createResourceManager(scheduler, managedResources); 
     70                scheduler.set_stat(DCWormsConstants.getResourcesStatisticsObject(queues.size())); 
     71                for(int i = 0; i < queues.size(); i++){ 
     72                        TaskQueue q = queues.get(i); 
     73                        if(q instanceof AbstractStatsSupportingQueue<?>){ 
     74                                AbstractStatsSupportingQueue<?> queue = (AbstractStatsSupportingQueue<?>) q; 
     75                                queue.setStats(scheduler.get_stat(), DCWormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME + "_" + Integer.toString(i)); 
     76                        } 
     77                } 
     78        } 
     79         
    6980        public void processEvent(Sim_event ev) { 
    7081                processOtherEvent(ev); 
     
    8192        } 
    8293         
     94         
    8395        public String getName() { 
    8496                return name; 
    85         } 
    86  
    87         public PluginConfiguration getSchedulingPluginConfiguration() { 
    88                 return schedulingPlugin.getConfiguration(); 
    8997        } 
    9098         
     
    106114                return jobRegistry; 
    107115        } 
     116         
     117        public Scheduler getScheduler() { 
     118                return scheduler; 
     119        } 
     120         
     121        public PluginConfiguration getSchedulingPluginConfiguration() { 
     122                return schedulingPlugin.getConfiguration(); 
     123        } 
    108124 
    109125        public boolean pluginSupportsEvent(int eventType){ 
     
    111127        } 
    112128 
    113         public abstract void notifySubmittedWorkloadUnit(WorkloadUnit<?> wu, boolean ack); 
    114  
    115         public abstract void notifyCanceledWorkloadUnit(WorkloadUnit<?> wu); 
    116  
    117         public abstract void notifyReturnedWorkloadUnit(WorkloadUnit<?> wu); 
    118  
    119         protected abstract void executeSchedulingPlan(SchedulingPlanInterface decision); 
    120  
    121  
    122  
     129        public TaskQueueList getQueues(){ 
     130                return queues; 
     131        } 
     132         
     133        public Map<String, Integer> getQueuesSize() { 
     134                Map<String, Integer> queue_size = new HashMap<String, Integer>(); 
     135                for (TaskQueue queue : queues) { 
     136                        queue_size.put(queue.getName(), queue.size()); 
     137                } 
     138                return queue_size; 
     139        } 
     140         
    123141        //POPRAWIC  (ale co? bo teraz chyba jest ok) 
    124         protected void submitWorkloadUnit(WorkloadUnit<?> wu, AllocationInterface allocation) { 
     142        protected void submitTask(TaskInterface<?> task, AllocationInterface<?> allocation) { 
    125143                String providerName = allocation.getProviderName(); 
    126144                if (providerName == null) { 
    127145                        return; 
    128146                } 
    129                 //Executable exec = (Executable) wu; 
    130                 removeFromQueue(wu); 
    131                 scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, wu);  
    132         } 
    133          
    134         protected boolean sendCanceledWorkloadUnit(int tag, Executable task, int executableId, int destId) { 
    135                  
    136                 if (tag != GridSimTags.GRIDLET_CANCEL) { 
    137                         return false; 
    138                 } 
    139  
    140                 long taskSize = 0; 
    141                 if (task != null) { 
    142                         taskSize = task.getGridletOutputSize(); 
    143                 } 
    144  
    145                 // if no Gridlet found, then create a new Gridlet but set its status 
    146                 // to FAILED. Then, most importantly, set the resource parameters 
    147                 // because the user will search/filter based on a resource ID. 
    148                 else if (task == null) { 
    149                         try { 
    150                                 taskSize = 100; 
    151                                 task = jobRegistry.getTaskExecutable(executableId); 
    152                                 task.setGridletStatus(Gridlet.FAILED); 
    153                                 int cost = resourceManager.getSharedResourceUnits().get(StandardResourceUnitName.COST) != null ? resourceManager 
    154                                                 .getSharedResourceUnits().get(StandardResourceUnitName.COST).get(0).getAmount() 
    155                                                 : 1; 
    156                                 task.setResourceParameter(scheduler.get_id(), cost); 
    157                         } catch (Exception e) { 
    158                                 // empty ... 
    159                         } 
    160                 } 
    161                 scheduler.send(scheduler.getOutputPort(), GridSimTags.SCHEDULE_NOW, tag,  new IO_data(task, taskSize, destId)); 
    162  
    163                 return true; 
    164         } 
    165  
    166         protected boolean sendFinishedWorkloadUnit(WorkloadUnit<?> wu) { 
     147                removeFromQueue(task); 
     148                scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, task);        
     149        } 
     150 
     151        protected boolean sendFinishedWorkloadUnit(WorkloadUnit wu) { 
    167152                 
    168153                Executable exec = (Executable) wu; 
    169154                if(scheduler.getParent() == null) 
    170155                { 
    171                         Job job = jobRegistry.get(exec.getJobId()); 
     156                        Job job = jobRegistry.getJob(exec.getJobId()); 
    172157 
    173158                        if(job.isFinished()){ 
    174159                                scheduler.send(job.getSenderId(), GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_RETURN, job); 
    175160                                return true; 
    176                         }else return true; 
     161                        } 
     162                        else return true; 
    177163                } 
    178164         
     
    183169 
    184170        protected void sendExecutableReadyEvent(ExecTask exec) { 
    185  
    186                 /*if (wu instanceof JobInterface) { 
    187                         scheduler.sendInternal(Long.valueOf(0).doubleValue(), GssimTags.TASK_READY_FOR_EXECUTION, 
    188                                         wu); 
    189                         return; 
    190                 }*/ 
    191171 
    192172                long delay = 0; 
     
    201181                } 
    202182 
    203                 scheduler.sendInternal(Long.valueOf(delay).doubleValue(), WormsTags.TASK_READY_FOR_EXECUTION, 
     183                scheduler.sendInternal(Long.valueOf(delay).doubleValue(), DCWormsTags.TASK_READY_FOR_EXECUTION, 
    204184                                exec); 
    205185        } 
     
    213193                                if (obj != null) { 
    214194                                        int delay = (Integer) obj; 
    215                                         scheduler.sendInternal(delay, WormsTags.TIMER, null); 
     195                                        scheduler.sendInternal(delay, DCWormsTags.TIMER, null); 
    216196                                } 
    217197                        } 
     
    219199        } 
    220200         
    221         protected boolean removeFromQueue(WorkloadUnit<?> wu) { 
     201        protected boolean removeFromQueue(TaskInterface<?> task) { 
    222202                for(TaskQueue queue : queues){ 
    223                         if(queue.contains(wu)){ 
    224                                 queue.remove(wu); 
     203                        if(queue.contains(task)){ 
     204                                queue.remove(task); 
    225205                                return true; 
    226206                        } 
     
    228208                return false; 
    229209        } 
    230  
    231         public TaskQueueList getAccessQueues(){ 
    232                 return queues; 
    233         } 
    234          
    235         public Map<String, Integer> getQueuesSize() { 
    236                 Map<String, Integer> queue_size = new HashMap<String, Integer>(); 
    237                 for (TaskQueue queue : queues) { 
    238                         queue_size.put(queue.getName(), queue.size()); 
    239                 } 
    240                 return queue_size; 
    241         } 
    242  
    243         public void init(Scheduler sched, ManagedResources managedResources) { 
    244                 scheduler = sched; 
    245                 resourceManager = ResourceManagerFactory.createResourceManager(scheduler, managedResources); 
    246                 scheduler.set_stat(WormsConstants.getResourcesStatisticsObject(queues.size())); 
    247                 for(int i = 0; i < queues.size(); i++){ 
    248                         TaskQueue q = queues.get(i); 
    249                         if(q instanceof AbstractStatsSupportingQueue<?>){ 
    250                                 AbstractStatsSupportingQueue<?> queue = (AbstractStatsSupportingQueue<?>) q; 
    251                                 queue.setStats(scheduler.get_stat(), WormsConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME + "_" + Integer.toString(i)); 
    252                         } 
    253                 } 
    254         } 
    255  
    256         protected Scheduler scheduler; 
    257  
    258         public Scheduler getScheduler() { 
    259                 return scheduler; 
    260         } 
    261210         
    262211        public abstract WorkloadUnitHandler getWorkloadUnitHandler(); 
     212         
     213        public abstract void notifySubmittedWorkloadUnit(WorkloadUnit wu, boolean ack); 
     214 
     215        public abstract void notifyReturnedWorkloadUnit(WorkloadUnit wu); 
     216 
     217        protected abstract void executeSchedulingPlan(SchedulingPlanInterface<?> decision); 
    263218 
    264219} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/policy/global/GlobalManagementSystem.java

    r477 r539  
    1111import org.qcg.broker.schemas.schedulingplan.types.AllocationStatus; 
    1212 
     13import dcworms.schedframe.scheduling.ExecTask; 
     14import dcworms.schedframe.scheduling.Executable; 
     15 
    1316import qcg.shared.constants.BrokerConstants; 
    14  
    15 import schedframe.events.scheduling.EventReason; 
    16 import schedframe.events.scheduling.SchedulingEvent; 
    1717import schedframe.events.scheduling.TaskArrivedEvent; 
    18 import schedframe.events.scheduling.TaskCanceledEvent; 
    1918import schedframe.events.scheduling.TimerEvent; 
    20 import schedframe.scheduling.Scheduler; 
     19import schedframe.scheduling.TaskListImpl; 
    2120import schedframe.scheduling.WorkloadUnitHandler; 
    22 import schedframe.scheduling.WorkloadUnitListImpl; 
    2321import schedframe.scheduling.plan.AllocationInterface; 
    2422import schedframe.scheduling.plan.ScheduledTaskInterface; 
     
    3129import schedframe.scheduling.tasks.Job; 
    3230import schedframe.scheduling.tasks.JobInterface; 
    33 import schedframe.scheduling.tasks.SubmittedTask; 
    3431import schedframe.scheduling.tasks.Task; 
    3532import schedframe.scheduling.tasks.TaskInterface; 
    3633import schedframe.scheduling.tasks.WorkloadUnit; 
    37  
    3834import eduni.simjava.Sim_event; 
    3935import gridsim.GridSim; 
    4036import gridsim.GridSimTags; 
    41 import gridsim.Gridlet; 
    4237import gridsim.IO_data; 
    43 import gridsim.gssim.WormsTags; 
    44 import gssim.schedframe.scheduling.ExecTask; 
    45 import gssim.schedframe.scheduling.Executable; 
     38import gridsim.dcworms.DCWormsTags; 
    4639 
    4740public class GlobalManagementSystem extends AbstractManagementSystem { 
     
    5447                super(providerId, entityName,  execTimeEstimationPlugin, queues); 
    5548 
    56                 /*schedulingPlugin = (GlobalSchedulingPlugin) InstanceFactory.createInstance( 
    57                                 schedulingPluginClassName, 
    58                                 GlobalSchedulingPlugin.class);*/ 
    5949                if(schedPlugin == null){ 
    6050                        throw new Exception("Can not create global scheduling plugin instance"); 
     
    6959                switch (tag) { 
    7060 
    71                 case WormsTags.TIMER: 
    72                         if (pluginSupportsEvent(WormsTags.TIMER)) { 
     61                case DCWormsTags.TIMER: 
     62                        if (pluginSupportsEvent(DCWormsTags.TIMER)) { 
    7363                                TimerEvent event = new  TimerEvent(); 
    74                                 SchedulingPlanInterface decision =  schedulingPlugin.schedule(event,  
     64                                SchedulingPlanInterface<?> decision =  schedulingPlugin.schedule(event,  
    7565                                                queues,  getJobRegistry(), getResourceManager(), moduleList); 
    7666                                executeSchedulingPlan(decision); 
     
    8171        } 
    8272         
    83         public void notifySubmittedWorkloadUnit(WorkloadUnit<?> wu, boolean ack) { 
     73        public void notifySubmittedWorkloadUnit(WorkloadUnit wu, boolean ack) { 
    8474                if (!pluginSupportsEvent(GridSimTags.GRIDLET_SUBMIT)) { 
    8575                        log.error("Plugin " + schedulingPlugin.getClass() 
     
    9080                 
    9181                registerWorkloadUnit(wu); 
    92                 /*Job job = (Job) wu; 
    93                 jobRegistry.addJob(job); 
    94  
    95                 if (log.isInfoEnabled()) 
    96                         log.info("Received job " + job.getId() + " at " + new DateTime(DateTimeUtilsExt.currentTimeMillis())); 
    97  
     82 
     83        } 
     84         
     85        private void registerWorkloadUnit(WorkloadUnit wu){ 
     86                if(!wu.isRegistered()){ 
     87                        wu.register(jobRegistry); 
     88                } 
     89                wu.accept(getWorkloadUnitHandler()); 
     90        } 
     91         
     92 
     93        protected void schedule(JobInterface<?> job){ 
    9894                List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>(); 
    9995                jobsList.add(job); 
    100                 WorkloadUnitList readyWorkloadUnits = new WorkloadUnitList(); 
    101                 readyWorkloadUnits.addAll(jobRegistry.getReadyTasks(jobsList)); 
    102                 schedulingPlugin.placeJobsInQueues(readyWorkloadUnits, queues, getResourceManager(), moduleList); 
    103  
    104                 schedule(new TaskArrivedEvent());*/ 
    105  
    106         } 
    107          
    108         private void registerWorkloadUnit(WorkloadUnit<?> wu){ 
    109                 if(!wu.isRegistered()){ 
    110                         wu.register(jobRegistry); 
    111                 } 
    112                 wu.accept(getWorkloadUnitHandler()); 
    113         } 
    114          
    115  
    116         protected void scheduleReadyTasks(Job job){ 
    117                 List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>(); 
    118                 jobsList.add(job); 
    119                 WorkloadUnitListImpl readyWorkloadUnits = new WorkloadUnitListImpl(); 
    120                 readyWorkloadUnits.addAll(jobRegistry.getReadyTasks(jobsList)); 
    121                 schedulingPlugin.placeJobsInQueues(readyWorkloadUnits, queues, getResourceManager(), moduleList); 
    122  
    123                 schedule(new TaskArrivedEvent()); 
    124         } 
    125          
    126         protected void schedule(SchedulingEvent schedulingEvent) { 
    127  
    128                 try { 
    129                         SchedulingPlanInterface decision = schedulingPlugin.schedule( 
    130                                         schedulingEvent, queues, getJobRegistry(),  getResourceManager(), moduleList); 
    131                         if (decision == null) 
    132                                 return; 
    133  
     96                TaskListImpl readyTasks = new TaskListImpl(); 
     97                readyTasks.addAll(jobRegistry.getAvailableTasks(jobsList)); 
     98                 
     99                schedulingPlugin.placeTasksInQueues(readyTasks, queues, getResourceManager(), moduleList); 
     100                SchedulingPlanInterface<?> decision = schedulingPlugin.schedule( 
     101                                new TaskArrivedEvent(), queues, getJobRegistry(),  getResourceManager(), moduleList); 
     102                if (decision != null) 
    134103                        executeSchedulingPlan(decision); 
    135  
    136                 } catch (Exception e) { 
    137                         e.printStackTrace(); 
    138                 } 
    139         } 
    140          
    141         public void notifyReturnedWorkloadUnit(WorkloadUnit<?> wu) { 
     104        } 
     105 
     106        public void notifyReturnedWorkloadUnit(WorkloadUnit wu) { 
    142107                Executable exec = (Executable) wu; 
    143108 
     
    149114                 
    150115                try { 
    151                         Job job = jobRegistry.get(exec.getJobId()); 
    152                         /*Task task = job.getTask(exec.getTaskId()); 
     116                        Job job = jobRegistry.getJob(exec.getJobId()); 
     117                        Task task = job.getTask(exec.getTaskId()); 
    153118                        if(exec.getProcessesId() == null){ 
    154119                                try { 
    155120                                        task.setStatus(exec.getStatus()); 
    156121                                } catch (Exception e) { 
    157                                         // TODO Auto-generated catch block 
    158                                         e.printStackTrace(); 
     122 
    159123                                } 
    160124                        } else { 
     
    167131                                        } 
    168132                                } 
    169                         }*/ 
     133                        } 
    170134                         
    171135                        if(job.isFinished()){ 
     
    173137                        } 
    174138                        else { 
    175                                 scheduleReadyTasks(job); 
    176                                 /*List<JobInterface<?>> jobs = new ArrayList<JobInterface<?>>(); 
    177                                 jobs.add(jobRegistry.getJobInfo(job.getId())); 
    178                                 WorkloadUnitList readyWorkloadUnits = new WorkloadUnitList(); 
    179                                 readyWorkloadUnits.addAll(jobRegistry.getReadyTasks(jobs)); 
    180                                 schedulingPlugin.placeJobsInQueues(readyWorkloadUnits, queues, 
    181                                                 getResourceManager(), moduleList); 
    182                                 schedule(new TaskArrivedEvent());*/ 
     139                                schedule(job); 
    183140                        } 
    184141                         
     
    189146        } 
    190147 
    191         public void notifyCanceledWorkloadUnit(WorkloadUnit<?> wu){; 
    192  
    193                 Executable task = (Executable) wu; 
    194                 String jobID = task.getJobId(); 
    195                 String taskID = task.getId(); 
    196                  
    197                 if(log.isDebugEnabled()) 
    198                         log.debug("Received canceled job" + jobID + "_" + taskID); 
    199                  
    200                 TaskInterface<?> ti = jobRegistry.getTaskInfo(jobID, taskID) ; 
    201                 try { 
    202  
    203                         ti.setStatus((int)BrokerConstants.JOB_STATUS_CANCELED); 
    204                          
    205                         TaskCanceledEvent event = new TaskCanceledEvent(jobID, taskID); 
    206                         event.setReason(EventReason.RESERVATION_EXCEEDED); 
    207                         schedule(event); 
    208                          
    209                 } catch (Exception e) { 
    210                         log.error("Exception during scheduling. " + e.getMessage()); 
    211                         e.printStackTrace(); 
    212                 } 
    213         } 
    214          
    215         protected void executeSchedulingPlan(SchedulingPlanInterface decision) { 
    216  
    217                 ArrayList<ScheduledTaskInterface> taskSchedulingDecisions = decision.getTasks(); 
     148        protected void executeSchedulingPlan(SchedulingPlanInterface<?> decision) { 
     149 
     150                ArrayList<ScheduledTaskInterface<?>> taskSchedulingDecisions = decision.getTasks(); 
    218151                for (int i = 0; i < taskSchedulingDecisions.size(); i++) { 
    219152 
    220                         try { 
    221                                 ScheduledTaskInterface taskDecision = taskSchedulingDecisions.get(i); 
    222          
    223                                 //log.info(decision.getDocument()); 
    224          
    225                                 String jobID = taskDecision.getJobId(); 
    226                                 String taskID = taskDecision.getTaskId(); 
    227                                  
    228                                 // Task allocations that were rejected because of lack of resources or which were canceled and  
    229                                 // not scheduled again are returned to the user. 
    230                                 if(taskDecision.getStatus() == AllocationStatus.REJECTED){ 
    231                                         Job job = jobRegistry.get(jobID); 
    232                                         scheduler.send(job.getSenderId(), GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_RETURN, job); 
    233                                         continue; 
    234                                 } 
    235                                  
    236                                 ArrayList<AllocationInterface> allocations = taskDecision.getAllocations(); 
    237  
    238                                 Task task = (Task) jobRegistry.getTaskInfo(jobID, taskID); 
    239                                 for (int j = 0; j < allocations.size(); j++) { 
    240  
    241                                         AllocationInterface allocation = allocations.get(j); 
    242                                         Executable exec = jobRegistry.createExecutable(task, allocation); 
    243                                         submitWorkloadUnit(exec, allocation); 
    244                                         task.setStatus((int)BrokerConstants.TASK_STATUS_QUEUED); 
    245                                 }                                                                
    246  
    247                         }catch (Exception e){ 
    248                                 e.printStackTrace(); 
    249                         } 
    250                 } 
    251         } 
    252  
    253         protected void submitWorkloadUnit(WorkloadUnit<?> job, AllocationInterface allocation) { 
     153                        ScheduledTaskInterface<?> taskDecision = taskSchedulingDecisions.get(i); 
     154 
     155                        //log.info(decision.getDocument()); 
     156 
     157                        String jobID = taskDecision.getJobId(); 
     158                        String taskID = taskDecision.getTaskId(); 
     159                         
     160                        // Task allocations that were rejected because of lack of resources or which were canceled and  
     161                        // not scheduled again are returned to the user. 
     162                        if(taskDecision.getStatus() == AllocationStatus.REJECTED){ 
     163                                Job job = jobRegistry.getJob(jobID); 
     164                                scheduler.send(job.getSenderId(), GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_RETURN, job); 
     165                                continue; 
     166                        } 
     167                         
     168                        Task task = (Task) jobRegistry.getTaskInfo(jobID, taskID); 
     169                         
     170                        ArrayList<AllocationInterface<?>> allocations = taskDecision.getAllocations(); 
     171                        for (int j = 0; j < allocations.size(); j++) { 
     172 
     173                                AllocationInterface<?> allocation = allocations.get(j); 
     174                                Executable exec = createExecutable(task, allocation); 
     175                                submitTask(exec, allocation); 
     176                                task.setStatus((int)BrokerConstants.TASK_STATUS_QUEUED); 
     177                        }                                                                
     178                } 
     179        } 
     180 
     181        private Executable createExecutable(Task task, AllocationInterface<?> allocation) { 
     182 
     183                String refersTo = allocation.getProcessGroupId(); // null;//allocation.getRefersTo(); 
     184                if(refersTo == null) 
     185                        refersTo = task.getId(); 
     186                         
     187                Executable exec = null; 
     188 
     189                if(refersTo.equals(task.getId())){ 
     190                        exec = new Executable(task); 
     191                } else { 
     192                        List<AbstractProcesses> processes = task.getProcesses(); 
     193                        if(processes == null) { 
     194                                try { 
     195                                        log.error("Allocation: " + allocation.getDocument() + "\nrefers to unknown task or processes set." + 
     196                                                        " Set correct value (task id or prcesses set id) for allocation refersTo attribute."); 
     197                                } catch (Exception e) { 
     198                                        e.printStackTrace(); 
     199                                } 
     200                        } 
     201                        boolean found = false; 
     202                        for(int j = 0; j < processes.size() && !found; j++){ 
     203                                AbstractProcesses procesesSet = processes.get(j); 
     204                                if(refersTo.equals(procesesSet.getId())){ 
     205                                        exec = new Executable(task, procesesSet); 
     206                                        found = true; 
     207                                } 
     208                        } 
     209                        if(!found){ 
     210                                log.error("Allocation refers to unknown proceses set."); 
     211                        } 
     212                } 
     213 
     214                exec.setReservationId(allocation.getReservationId()); 
     215                         
     216                /*HostInterface<?> host = allocation.getHost(); 
     217                ComputingResourceTypeInterface<?> crt = host.getMachineParameters(); 
     218                if(crt != null){ 
     219                        ComputingResourceTypeItemInterface<?> crti = crt.getComputingResourceTypeItem(0); 
     220                        if(crti != null){ 
     221                                ParameterPropertyInterface<?> properties[] = crti.getHostParameter().getProperty(); 
     222                                for(int p = 0; p < properties.length; p++){ 
     223                                        ParameterPropertyInterface<?> property = properties[p]; 
     224                                        if("chosenCPUs".equals(property.getName())){ 
     225                                                Object cpuNames = property.getValue(); 
     226                                                exec.addSpecificResource(ResourceParameterName.FREECPUS, cpuNames); 
     227                                        } 
     228                                } 
     229                        } 
     230                }*/ 
     231                return exec; 
     232        } 
     233         
     234        protected void submitTask(TaskInterface<?> task, AllocationInterface<?> allocation) { 
    254235 
    255236                String providerName = allocation.getProviderName(); 
     
    257238                        return; 
    258239                } 
    259                 TaskInterface<?> task = (TaskInterface<?>) job; 
    260240                removeFromQueue(task); 
    261241                 
    262242                int resID = GridSim.getEntityId(providerName); 
    263                 IO_data data = new IO_data(job, 0, resID); 
     243                IO_data data = new IO_data(task, 0, resID); 
    264244                scheduler.send(scheduler.getOutputPort(), GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, data);   
    265                  
    266                 //scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, job);                       
     245                //scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, job);       
     246                 
    267247                if(log.isDebugEnabled()) 
    268                         try { 
    269                                 log.debug("Submitted job " + job.getId() + " to " + providerName); 
    270                         } catch (NoSuchFieldException e) { 
    271                                 // TODO Auto-generated catch block 
    272                                 e.printStackTrace(); 
    273                         } 
     248                        log.debug("Submitted job " + task.getId() + " to " + providerName); 
     249 
    274250        } 
    275251 
    276252        class GlobalWorkloadUnitHandler implements  WorkloadUnitHandler{ 
    277253 
    278                 public void handleJob(Job job){ 
    279  
    280                         jobRegistry.addJob(job); 
     254                public void handleJob(JobInterface<?> job){ 
    281255                        if (log.isInfoEnabled()) 
    282256                                log.info("Received job " + job.getId() + " at " + new DateTime(DateTimeUtilsExt.currentTimeMillis())); 
    283257 
    284                         scheduleReadyTasks(job); 
     258                        jobRegistry.addJob(job); 
     259                        schedule(job); 
    285260                } 
    286261                 
     
    292267                        throw new RuntimeException("Not implemented since it isn't expected that tasks are send directly to the global scheduler."); 
    293268                } 
    294  
    295                 public void handleSubmittedTask(SubmittedTask task) { 
    296                         throw new RuntimeException("Not implemented since it isn't expected that tasks are send directly to the global scheduler."); 
    297                 } 
    298269        } 
    299270 
     
    301272                return new GlobalWorkloadUnitHandler(); 
    302273        } 
    303          
    304274 
    305275 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/policy/global/GridBroker.java

    r477 r539  
    1919public class GridBroker extends GlobalManagementSystem {  
    2020 
    21          
    2221        private static Log log = LogFactory.getLog(GridBroker.class); 
    2322 
     
    2726        public GridBroker(String name, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues) throws Exception { 
    2827                super(name, "BROKER",  schedulingPlugin, execTimeEstimationPlugin, queues); 
    29                  
    30                 //make use of plug-in interface 
    31                  
    32                 //Properties prop = new Properties(); 
    33                 //prop.put("plugin.name", name); 
    34                 //prop.put("plugin.utils.timeoperations", "gssim.scheduling.plugin.local.GssimTimeOperations"); 
    35                 //schedulingPlugin.init(prop); 
     28 
    3629                otherGridSchedulersIds = new HashSet<Integer>(); 
    37                  
    3830                moduleList = new ModuleListImpl(2); 
    39                 //this.moduleList.add(new GridResourceDiscovery(this.getScheduler())); 
    40                 //moduleList.add(new GridReservationManagerNew(this)); 
    41                  
    42                 if(log.isDebugEnabled()) 
    43                         log.debug(name + ": Creating a broker interface object"); 
    4431        } 
    4532 
    4633        public void init(Scheduler scheduler, ManagedResources managedResources) { 
    4734                super.init(scheduler, managedResources); 
    48                 //this.scheduler = scheduler; 
    49                 //this.resourceManager = ResourceManagerFactory.createResourceManager(scheduler, managedResources); 
    5035                this.moduleList.add((GridResourceDiscovery)resourceManager); 
    5136        } 
     
    5742                } 
    5843                return providerIds; 
    59                 //return GridSim.getGridResourceList(); 
    6044        } 
    6145 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/policy/local/LocalManagementSystem.java

    r477 r539  
    11package schedframe.scheduling.policy.local; 
    22 
     3import dcworms.schedframe.scheduling.ExecTask; 
     4import dcworms.schedframe.scheduling.Executable; 
    35import eduni.simjava.Sim_event; 
    46import eduni.simjava.Sim_system; 
    57import gridsim.Accumulator; 
    68import gridsim.GridSimTags; 
    7 import gridsim.Gridlet; 
    89import gridsim.ResourceCalendar; 
    9 import gridsim.gssim.WormsTags; 
    10 import gridsim.gssim.filter.SubTaskFilter; 
    11 import gssim.schedframe.scheduling.ExecTask; 
    12 import gssim.schedframe.scheduling.Executable; 
     10import gridsim.dcworms.DCWormsTags; 
     11import gridsim.dcworms.filter.ExecTaskFilter; 
    1312 
    1413import java.util.ArrayList; 
     
    2726import qcg.shared.constants.BrokerConstants; 
    2827import schedframe.ResourceController; 
    29 import schedframe.events.scheduling.EventReason; 
    3028import schedframe.events.scheduling.SchedulingEvent; 
    3129import schedframe.events.scheduling.SchedulingEventType; 
    3230import schedframe.events.scheduling.StartTaskExecutionEvent; 
    33 import schedframe.events.scheduling.TaskCanceledEvent; 
    3431import schedframe.events.scheduling.TaskFinishedEvent; 
    3532import schedframe.events.scheduling.TaskRequestedTimeExpiredEvent; 
     
    4542import schedframe.scheduling.ResourceHistoryItem; 
    4643import schedframe.scheduling.Scheduler; 
    47 import schedframe.scheduling.UsedResourceList; 
     44import schedframe.scheduling.TaskList; 
     45import schedframe.scheduling.TaskListImpl; 
     46import schedframe.scheduling.UsedResourcesList; 
    4847import schedframe.scheduling.WorkloadUnitHandler; 
    49 import schedframe.scheduling.WorkloadUnitListImpl; 
    5048import schedframe.scheduling.manager.resources.LocalResourceManager; 
    5149import schedframe.scheduling.manager.resources.ManagedResources; 
     
    6361import schedframe.scheduling.tasks.Job; 
    6462import schedframe.scheduling.tasks.JobInterface; 
    65 import schedframe.scheduling.tasks.SubmittedTask; 
    6663import schedframe.scheduling.tasks.Task; 
    6764import schedframe.scheduling.tasks.TaskInterface; 
    6865import schedframe.scheduling.tasks.WorkloadUnit; 
    69 import simulator.WormsConstants; 
     66import simulator.DCWormsConstants; 
    7067import simulator.utils.DoubleMath; 
    7168 
     
    8380 
    8481                super(providerId, entityName, execTimeEstimationPlugin, queues); 
    85  
    86                 //schedulingPlugin = (LocalSchedulingPlugin) InstanceFactory.createInstance(schedulingPluginClassName, LocalSchedulingPlugin.class); 
    8782                 
    8883                if (schedPlugin == null) { 
     
    9085                } 
    9186                this.schedulingPlugin =  schedPlugin; 
    92                 accTotalLoad = new Accumulator(); 
    93                 moduleList = new ModuleListImpl(1); 
    94  
     87                this.moduleList = new ModuleListImpl(1); 
     88                 
     89                this.accTotalLoad = new Accumulator(); 
    9590        } 
    9691 
    9792        public void init(Scheduler sched, ManagedResources managedResources) { 
    9893                super.init(sched, managedResources); 
    99                 //scheduler = sched; 
    100                 //resourceManager = ResourceManagerFactory.createResourceManager(scheduler); 
    10194                double load = 0; 
    10295                accTotalLoad.add(load); 
     
    112105                switch (tag) { 
    113106 
    114                 case WormsTags.TIMER: 
     107                case DCWormsTags.TIMER: 
    115108                        if (pluginSupportsEvent(tag)) { 
    116109                                SchedulingEvent event = new SchedulingEvent(SchedulingEventType.TIMER); 
    117                                 SchedulingPlanInterface decision =  schedulingPlugin.schedule(event,  
     110                                SchedulingPlanInterface<?> decision =  schedulingPlugin.schedule(event,  
    118111                                                queues,  getJobRegistry(), getResourceManager(), moduleList); 
    119112                                executeSchedulingPlan(decision); 
    120113                        } 
    121114                        sendTimerEvent(); 
    122  
    123115                        break; 
    124116 
    125                 case WormsTags.TASK_READY_FOR_EXECUTION: 
    126                          
    127                         ExecTask data = (ExecTask) ev.get_data(); 
    128                         try { 
    129                                 data.setStatus(Gridlet.READY); 
     117                case DCWormsTags.TASK_READY_FOR_EXECUTION: 
     118                        ExecTask execTask = (ExecTask) ev.get_data(); 
     119                        try { 
     120                                execTask.setStatus(DCWormsTags.READY); 
    130121                                if (pluginSupportsEvent(tag)) { 
    131                                         SchedulingEvent event = new StartTaskExecutionEvent(data.getJobId(), data.getId()); 
    132                                         SchedulingPlanInterface decision =  schedulingPlugin.schedule(event, 
     122                                        SchedulingEvent event = new StartTaskExecutionEvent(execTask.getJobId(), execTask.getId()); 
     123                                        SchedulingPlanInterface<?> decision =  schedulingPlugin.schedule(event, 
    133124                                                        queues,  getJobRegistry(), getResourceManager(), moduleList); 
    134125                                        executeSchedulingPlan(decision); 
     
    139130                        break; 
    140131 
    141                 case WormsTags.TASK_EXECUTION_FINISHED: 
     132                case DCWormsTags.TASK_EXECUTION_FINISHED: 
    142133                        obj = ev.get_data(); 
    143                         ExecTask task = (ExecTask) obj; 
    144                         if (task.getStatus() == Gridlet.INEXEC) { 
    145                                 finalizeExecutable(task); 
    146                                 SubmittedTask subTask = (SubmittedTask)task; 
    147                                 sendFinishedWorkloadUnit((ExecTask)subTask.getGridlet()); 
    148                                 //task.setGridletStatus(Gridlet.SUCCESS); 
    149                                 //task.finalizeGridlet(); 
    150                                 log.debug(task.getJobId() + "_" + task.getId() + " finished execution on " + new DateTime()); 
    151                                 log.info(WormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
    152                                 /*UsedResourceList<ResourceHistoryItem> lastUsedList = task.getUsedResources(); 
    153                                 Map<ResourceUnitName, AbstractResourceUnit> lastUsed = lastUsedList.getLast() 
    154                                                 .getResourceUnits(); 
    155                                 getAllocationManager().freeResources(lastUsed); 
    156                                 ProcessingElements pes = (ProcessingElements) lastUsed.get(StandardResourceUnitName.PROCESSINGELEMENTS); 
    157                                 for (ComputingResource resource : pes) { 
    158                                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, task)); 
     134                        execTask = (ExecTask) obj; 
     135                        if (execTask.getStatus() == DCWormsTags.INEXEC) { 
     136                                 
     137                                finalizeExecutable(execTask); 
     138                                sendFinishedWorkloadUnit(execTask); 
     139                                log.debug(execTask.getJobId() + "_" + execTask.getId() + " finished execution on " + new DateTime()); 
     140                                log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
     141                                if (pluginSupportsEvent(tag)) { 
     142                                        SchedulingEvent event = new TaskFinishedEvent(execTask.getJobId(), execTask.getId()); 
     143                                        SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 
     144                                                        queues, getJobRegistry(), getResourceManager(), moduleList); 
     145                                        executeSchedulingPlan(decision); 
    159146                                } 
    160                                 SubTaskFilter filter = new SubTaskFilter(task.getGridletID(), GssimTags.TASK_REQUESTED_TIME_EXPIRED); 
    161                                 scheduler.sim_cancel(filter, null); 
    162                                 super.sendFinishJob((Executable) task.getGridlet());*/ 
    163                         } 
     147                        } 
     148 
     149                        Job job = jobRegistry.getJob(execTask.getJobId()); 
     150                        if(!job.isFinished()){ 
     151                                getWorkloadUnitHandler().handleJob(job); 
     152                        } 
     153                        break; 
     154                         
     155                case DCWormsTags.TASK_REQUESTED_TIME_EXPIRED: 
     156                        obj = ev.get_data(); 
     157                        execTask = (Executable) obj; 
    164158                        if (pluginSupportsEvent(tag)) { 
    165                                 SchedulingEvent event = new TaskFinishedEvent(task.getJobId(), task.getId()); 
    166                                 SchedulingPlanInterface decision = schedulingPlugin.schedule(event, 
     159                                SchedulingEvent event = new TaskRequestedTimeExpiredEvent(execTask.getJobId(), execTask.getId()); 
     160                                SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 
    167161                                                queues, getJobRegistry(), getResourceManager(), moduleList); 
    168162                                executeSchedulingPlan(decision); 
    169163                        } 
    170                         Job job = jobRegistry.get(task.getJobId()); 
    171                         if(!job.isFinished()){ 
    172                                 getWorkloadUnitHandler().handleJob(job); 
    173                         } 
    174  
    175164                        break; 
    176                 case WormsTags.TASK_REQUESTED_TIME_EXPIRED: 
    177                         obj = ev.get_data(); 
    178                         task = (SubmittedTask) obj; 
    179                         if (pluginSupportsEvent(tag)) { 
    180                                 SchedulingEvent event = new TaskRequestedTimeExpiredEvent(task.getJobId(), task.getId()); 
    181                                 SchedulingPlanInterface decision = schedulingPlugin.schedule(event, 
    182                                                 queues, getJobRegistry(), getResourceManager(), moduleList); 
    183                                 executeSchedulingPlan(decision); 
    184                         } 
    185  
    186                         break; 
    187                 case WormsTags.UPDATE: 
     165                         
     166                case DCWormsTags.UPDATE: 
    188167                        updateProcessingTimes(ev); 
    189168                        break; 
    190169                } 
    191170        } 
    192          
    193  
    194         public void notifyReturnedWorkloadUnit(WorkloadUnit<?> wu) { 
    195                 if (pluginSupportsEvent(WormsTags.TASK_EXECUTION_FINISHED)) { 
     171 
     172        public void notifyReturnedWorkloadUnit(WorkloadUnit wu) { 
     173                if (pluginSupportsEvent(DCWormsTags.TASK_EXECUTION_FINISHED)) { 
    196174                        SchedulingEvent event = new SchedulingEvent(SchedulingEventType.TASK_FINISHED); 
    197                         SchedulingPlanInterface decision =  schedulingPlugin.schedule(event, 
     175                        SchedulingPlanInterface<?> decision =  schedulingPlugin.schedule(event, 
    198176                                        queues, getJobRegistry(), getResourceManager(), moduleList); 
    199177                        executeSchedulingPlan(decision); 
     
    203181                //} 
    204182        } 
    205  
    206         public void notifyCanceledWorkloadUnit(WorkloadUnit<?> job) { 
    207  
    208                 if (!pluginSupportsEvent(GridSimTags.GRIDLET_CANCEL)) 
    209                         return; 
    210  
    211                 Executable executable = (Executable) job; 
    212                 String jobID = executable.getJobId(); 
    213  
    214                 SchedulingPlanInterface decision = null; 
    215  
    216                 try { 
    217                         executable.setStatus((int) BrokerConstants.JOB_STATUS_CANCELED); 
    218  
    219                         TaskCanceledEvent event = new TaskCanceledEvent(executable.getJobId(), executable.getTaskId()); 
    220                         event.setReason(EventReason.RESERVATION_EXCEEDED); 
    221                         decision = schedulingPlugin 
    222                                         .schedule(event, queues, getJobRegistry(), getResourceManager(), moduleList); 
    223  
    224                         if (decision == null) 
    225                                 return; 
    226  
    227                         executeSchedulingPlan(decision); 
    228  
    229                 } catch (Exception e) { 
    230                         log.error("Exception during scheduling. " + e.getMessage()); 
    231                         e.printStackTrace(); 
    232                 } 
    233         } 
    234          
    235         protected void executeSchedulingPlan(SchedulingPlanInterface decision) { 
    236  
    237                 ArrayList<ScheduledTaskInterface> taskSchedulingDecisions = decision.getTasks(); 
     183         
     184        protected void executeSchedulingPlan(SchedulingPlanInterface<?> decision) { 
     185 
     186                ArrayList<ScheduledTaskInterface<?>> taskSchedulingDecisions = decision.getTasks(); 
    238187                for (int i = 0; i < taskSchedulingDecisions.size(); i++) { 
    239                         try { 
    240                                 ScheduledTaskInterface taskDecision = taskSchedulingDecisions.get(i); 
    241  
    242                                 // not scheduled again are returned to the user. 
    243                                 if (taskDecision.getStatus() == AllocationStatus.REJECTED) { 
    244                                         continue; 
     188                        ScheduledTaskInterface<?> taskDecision = taskSchedulingDecisions.get(i); 
     189 
     190                        if (taskDecision.getStatus() == AllocationStatus.REJECTED) { 
     191                                continue; 
     192                        } 
     193 
     194                        ArrayList<AllocationInterface<?>> allocations = taskDecision.getAllocations(); 
     195 
     196                        TaskInterface<?> task = taskDecision.getTask(); 
     197                        for (int j = 0; j < allocations.size(); j++) { 
     198 
     199                                AllocationInterface<?> allocation = allocations.get(j); 
     200                                if (allocation.isProcessing()) { 
     201                                        ExecTask exec = (ExecTask) task;                                         
     202                                        executeTask(exec, allocation.getRequestedResources()); 
     203                                } else if(resourceManager.getSchedulerName(allocation.getProviderName()) != null){ 
     204                                        allocation.setProviderName(resourceManager.getSchedulerName(allocation.getProviderName())); 
     205                                        submitTask(task, allocation); 
     206                                } else { 
     207                                        ExecTask exec = (ExecTask) task; 
     208                                        executeTask(exec, chooseResourcesForExecution(allocation.getProviderName(), exec)); 
    245209                                } 
    246  
    247                                 ArrayList<AllocationInterface> allocations = taskDecision.getAllocations(); 
    248  
    249                                 WorkloadUnit<?> task = taskDecision.getTask(); 
    250                                 for (int j = 0; j < allocations.size(); j++) { 
    251  
    252                                         AllocationInterface allocation = allocations.get(j); 
    253                                         if (allocation.isProcessing()) { 
    254                                                  
    255                                                 ExecTask exec = (ExecTask) task; 
    256                                                  
    257  
    258                                                 //Executable e = (Executable)task; 
    259                                                 /*SubmittedTask submittedTask = jobRegistry.getSubmittedTask(e.getJobId(), e.getId()); 
    260                                                 if(submittedTask == null) 
    261                                                 {       submittedTask = new SubmittedTask(e); 
    262                                                         jobRegistry.addTask(submittedTask); 
    263                                                 }*/ 
    264  
    265                                                 /*e.visitResource(scheduler.get_name()); 
    266                                                 Scheduler parentScheduler = scheduler.getParent(); 
    267                                                 while (parentScheduler != null && !e.getVisitedResources().contains(parentScheduler.get_name())) { 
    268                                                         e.visitResource(parentScheduler.get_name()); 
    269                                                         parentScheduler = parentScheduler.getParent(); 
    270                                                 }*/ 
    271                                                  
    272                                                                                                  
    273                                                 executeTask(exec, allocation.getRequestedResources()); 
    274                                         //} else if(GridSim.getEntityId(allocation.getProviderName()) != -1 || scheduler.getScheduler(allocation.getProviderName())!=null){ 
    275                                         } else if(resourceManager.getSchedulerName(allocation.getProviderName()) != null){ 
    276                                                 allocation.setProviderName(resourceManager.getSchedulerName(allocation.getProviderName())); 
    277                                                 submitWorkloadUnit(task, allocation); 
    278                                         } else { 
    279  
    280                                                 ExecTask exec = (ExecTask) task; 
    281                                                  
    282                                                         //Executable exec = jobRegistry.createExecutable(t, allocation); 
    283                                                         //exec.setResourceParameter(scheduler.get_id(), 1); 
    284                                                 /*e.visitResource(scheduler.get_name()); 
    285                                                 Scheduler parentScheduler = scheduler.getParent(); 
    286                                                 while (parentScheduler != null && !e.getVisitedResources().contains(parentScheduler.get_name())) { 
    287                                                         e.visitResource(parentScheduler.get_name()); 
    288                                                         parentScheduler = parentScheduler.getParent(); 
    289                                                 }*/ 
    290                                                 executeTask(exec, chooseResourcesForExecution(allocation.getProviderName(), (ExecTask)task)); 
    291                                         } 
    292                                 } 
    293  
    294                         } catch (Exception e) { 
    295                                 e.printStackTrace(); 
    296                         } 
     210                        } 
     211 
    297212                } 
    298213        } 
    299214 
    300215        protected void executeTask(ExecTask task, Map<ResourceUnitName, ResourceUnit> choosenResources) { 
    301         //      Executable exec = (Executable) task; 
    302          
    303                 SubmittedTask submittedTask = (SubmittedTask)task; 
     216 
     217                Executable exec = (Executable)task; 
    304218                boolean allocationStatus = getAllocationManager().allocateResources(choosenResources); 
    305219                if(allocationStatus == false) 
    306220                        return; 
    307221                removeFromQueue(task); 
    308                 //SubmittedTask submittedTask = (SubmittedTask)task; 
    309                 /* submittedTask = jobRegistry.getSubmittedTask(exec.getJobId(), exec.getId()); 
    310                 if(submittedTask == null) 
    311                 {       submittedTask = new SubmittedTask(exec); 
    312                         jobRegistry.addTask(submittedTask); 
    313                 }*/ 
    314                 double completionPercentage = (submittedTask.getLength() - submittedTask.getRemainingGridletLength())/submittedTask.getLength(); 
     222 
    315223                SchedulingEvent event = new SchedulingEvent(SchedulingEventType.START_TASK_EXECUTION); 
    316224                int time = Double.valueOf( 
    317                                 execTimeEstimationPlugin.execTimeEstimation(event, choosenResources, task, completionPercentage)).intValue(); 
     225                                execTimeEstimationPlugin.execTimeEstimation(event, task, choosenResources, exec.getCompletionPercentage())).intValue(); 
    318226                log.debug(task.getJobId() + "_" + task.getId() + " starts executing on " + new DateTime() 
    319227                                + " will finish after " + time); 
     
    322230                        return; 
    323231 
    324                 submittedTask.setEstimatedDuration(time); 
     232                exec.setEstimatedDuration(time); 
    325233                DateTime currentTime = new DateTime(); 
    326234                ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime); 
    327                 submittedTask.addUsedResources(resHistItem); 
    328                 submittedTask.setFinishTime(currentTime.getMillis() / 1000); 
    329                  
    330                 jobRegistry.saveHistory(submittedTask, time, choosenResources); 
    331                  
    332                 scheduler.sendInternal(time, WormsTags.TASK_EXECUTION_FINISHED, 
    333                                 submittedTask); 
    334  
     235                exec.addUsedResources(resHistItem); 
    335236                try { 
    336                         long expectedDuration = submittedTask.getExpectedDuration().getMillis() / 1000; 
    337                         scheduler.sendInternal(expectedDuration, WormsTags.TASK_REQUESTED_TIME_EXPIRED, submittedTask); 
     237                        exec.setStatus(DCWormsTags.INEXEC); 
     238                } catch (Exception e) { 
     239                        // TODO Auto-generated catch block 
     240                        e.printStackTrace(); 
     241                } 
     242                scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, exec); 
     243 
     244                try { 
     245                        long expectedDuration = exec.getExpectedDuration().getMillis() / 1000; 
     246                        scheduler.sendInternal(expectedDuration, DCWormsTags.TASK_REQUESTED_TIME_EXPIRED, exec); 
    338247                } catch (NoSuchFieldException e) { 
    339                         double t = submittedTask.getEstimatedDuration(); 
    340                         scheduler.sendInternal(t, WormsTags.TASK_REQUESTED_TIME_EXPIRED, submittedTask); 
    341                 } 
    342                  
    343                 submittedTask.setGridletStatus(Gridlet.INEXEC); 
    344                 log.info(WormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
     248                        double t = exec.getEstimatedDuration(); 
     249                        scheduler.sendInternal(t, DCWormsTags.TASK_REQUESTED_TIME_EXPIRED, exec); 
     250                } 
     251 
     252                log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size())); 
    345253                 
    346254                PEUnit peUnit = (PEUnit)choosenResources.get(StandardResourceUnitName.PE); 
    347                 if(peUnit instanceof ProcessingElements){ 
     255                 
     256                notifyComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec); 
     257                 
     258                /*if(peUnit instanceof ProcessingElements){ 
    348259                        ProcessingElements pes = (ProcessingElements) peUnit; 
    349260                        for (ComputingResource resource : pes) { 
    350                                 resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, submittedTask)); 
     261                                resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, exec)); 
    351262                        } 
    352263                } else { 
     
    355266                                resource = ResourceController.getComputingResourceByName(peUnit.getResourceId()); 
    356267                        } catch (ResourceException e) { 
    357                                  
    358                         } 
    359                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, submittedTask)); 
    360                 } 
    361                 /*ProcessingElements pes = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE); 
    362                 for (ComputingResource resource : pes) { 
    363                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, submittedTask)); 
    364                 }*/ 
     268                                return; 
     269                        } 
     270                        resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, exec)); 
     271                } 
     272*/ 
    365273 
    366274                /*for(ExecTaskInterface etask : jobRegistry.getRunningTasks()){ 
     
    371279        } 
    372280         
    373         public void finalizeExecutable(ExecTask exec){ 
    374                  
    375                 SubmittedTask subTask = (SubmittedTask)exec; 
    376                 subTask.setGridletStatus(Gridlet.SUCCESS); 
    377                 subTask.finalizeGridlet(); 
    378                 UsedResourceList<ResourceHistoryItem> lastUsedList = subTask.getUsedResources(); 
    379                 Map<ResourceUnitName, ResourceUnit> lastUsed = lastUsedList.getLast() 
    380                                 .getResourceUnits(); 
    381                 getAllocationManager().freeResources(lastUsed); 
    382                  
    383                 PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE); 
    384                 if(peUnit instanceof ProcessingElements){ 
    385                         ProcessingElements pes = (ProcessingElements) peUnit; 
    386                         for (ComputingResource resource : pes) { 
    387                                 resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, subTask)); 
    388                         } 
    389                 } else { 
    390                         ComputingResource resource = null; 
    391                         try { 
    392                                 resource = ResourceController.getComputingResourceByName(peUnit.getResourceId()); 
    393                         } catch (ResourceException e) { 
    394                                  
    395                         } 
    396                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, subTask)); 
    397                 } 
    398                 /*ProcessingElements pes = (ProcessingElements) lastUsed.get(StandardResourceUnitName.PE); 
    399                 for (ComputingResource resource : pes) { 
    400                         resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, subTask)); 
    401                 }*/ 
    402                 SubTaskFilter filter = new SubTaskFilter(subTask.getGridletID(), WormsTags.TASK_REQUESTED_TIME_EXPIRED); 
     281        public void finalizeExecutable(ExecTask execTask){ 
     282                 
     283                Executable exec = (Executable)execTask; 
     284                exec.finalizeExecutable(); 
     285                 
     286                ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_REQUESTED_TIME_EXPIRED); 
    403287                scheduler.sim_cancel(filter, null); 
    404288                 
    405                 Executable executable = (Executable) subTask.getGridlet(); 
    406                 Job job = jobRegistry.get(executable.getJobId()); 
    407  
    408                 Task task = null; 
     289                Task task; 
     290                Job job = jobRegistry.getJob(exec.getJobId()); 
    409291                try { 
    410                         task = job.getTask(executable.getTaskId()); 
     292                        task = job.getTask(exec.getTaskId()); 
    411293                } catch (NoSuchFieldException e) { 
    412                         e.printStackTrace(); 
    413                 } 
    414                 if(executable.getProcessesId() == null){ 
    415                         try { 
    416                                 task.setStatus(executable.getStatus()); 
     294                        return; 
     295                } 
     296                if(exec.getProcessesId() == null){ 
     297                        try { 
     298                                task.setStatus(exec.getStatus()); 
    417299                        } catch (Exception e) { 
    418300                                e.printStackTrace(); 
     
    422304                        for(int i = 0; i < processesList.size(); i++){ 
    423305                                AbstractProcesses processes = processesList.get(i); 
    424                                 if(processes.getId().equals(executable.getProcessesId())){ 
    425                                         processes.setStatus(executable.getStatus()); 
     306                                if(processes.getId().equals(exec.getProcessesId())){ 
     307                                        processes.setStatus(exec.getStatus()); 
    426308                                        break; 
    427309                                } 
    428310                        } 
    429311                } 
     312                 
     313                UsedResourcesList lastUsedList = exec.getUsedResources(); 
     314                Map<ResourceUnitName, ResourceUnit> lastUsed = lastUsedList.getLast() 
     315                                .getResourceUnits(); 
     316                getAllocationManager().freeResources(lastUsed); 
     317                 
     318                PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE); 
     319                notifyComputingResources(peUnit, EnergyEventType.TASK_FINISHED, exec); 
     320                /*if(peUnit instanceof ProcessingElements){ 
     321                        ProcessingElements pes = (ProcessingElements) peUnit; 
     322                        for (ComputingResource resource : pes) { 
     323                                resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec)); 
     324                        } 
     325                } else { 
     326                        ComputingResource resource = null; 
     327                        try { 
     328                                resource = ResourceController.getComputingResourceByName(peUnit.getResourceId()); 
     329                        } catch (ResourceException e) { 
     330                                return; 
     331                        } 
     332                        resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec)); 
     333                }*/ 
     334 
    430335                //sendFinishedWorkloadUnit(executable); 
    431336        } 
     
    441346                while (iter.hasNext()) { 
    442347                        ExecTask task = iter.next(); 
    443                         SubmittedTask subTask = (SubmittedTask)task; 
    444                         UsedResourceList<ResourceHistoryItem> usedResourcesList = subTask.getUsedResources(); 
    445                         ResourceUnit unit = usedResourcesList.getLast().getResourceUnits() 
     348                        Executable exec = (Executable)task; 
     349                        exec.setCompletionPercentage(exec.getCompletionPercentage() + 100 * timeSpan/exec.getEstimatedDuration()); 
     350                         
     351                        UsedResourcesList usedResourcesList = exec.getUsedResources(); 
     352                        PEUnit peUnit = (PEUnit)usedResourcesList.getLast().getResourceUnits() 
    446353                                        .get(StandardResourceUnitName.PE); 
    447  
    448                         double load = getMIShare(timeSpan, (PEUnit) unit); 
    449                         subTask.updateGridletFinishedSoFar(load); 
     354                        double load = getMIShare(timeSpan, peUnit); 
    450355                        addTotalLoad(load); 
    451356                } 
    452357        } 
    453  
     358        private void notifyComputingResources(PEUnit peUnit, EnergyEventType eventType, Object obj){ 
     359 
     360                if(peUnit instanceof ProcessingElements){ 
     361                        ProcessingElements pes = (ProcessingElements) peUnit; 
     362                        for (ComputingResource resource : pes) { 
     363                                resource.handleEvent(new EnergyEvent(eventType, obj)); 
     364                        } 
     365                } else { 
     366                        ComputingResource resource = null; 
     367                        try { 
     368                                resource = ResourceController.getComputingResourceByName(peUnit.getResourceId()); 
     369                        } catch (ResourceException e) { 
     370                                return; 
     371                        } 
     372                        resource.handleEvent(new EnergyEvent(eventType, obj)); 
     373                } 
     374        } 
     375         
    454376        private double getMIShare(double timeSpan, PEUnit pes) { 
    455377                double localLoad; 
     
    470392        protected void updateProcessingTimes(Sim_event ev) { 
    471393                updateProcessingProgress(); 
    472                 for (ExecTask task : jobRegistry.getRunningTasks()) { 
    473                         SubmittedTask subTask = (SubmittedTask)task; 
    474                         List<String> visitedResource = subTask.getVisitedResources(); 
     394                for (ExecTask execTask : jobRegistry.getRunningTasks()) { 
     395                        Executable exec = (Executable)execTask; 
     396                        List<String> visitedResource = exec.getVisitedResources(); 
    475397                        String originResource = ev.get_data().toString(); 
    476398                        if(!ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), originResource)){ 
     
    478400                        } 
    479401                         
    480                         Map<ResourceUnitName, ResourceUnit> choosenResources = subTask.getUsedResources().getLast().getResourceUnits(); 
    481                         double completionPercentage = (task.getLength() - subTask.getRemainingGridletLength())/task.getLength(); 
    482                         double time = execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.RESOURCE_STATE_CHANGED),  
    483                                         choosenResources, task, completionPercentage); 
    484  
    485                         /*if(!subTask.getVisitedResources().contains(ev.get_data().toString())) { 
     402                        Map<ResourceUnitName, ResourceUnit> choosenResources = exec.getUsedResources().getLast().getResourceUnits(); 
     403                        int time =  Double.valueOf(execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.RESOURCE_STATE_CHANGED),  
     404                                        execTask, choosenResources, exec.getCompletionPercentage())).intValue(); 
     405 
     406                        //check if the new estimated end time is equal to the previous one; if yes the continue without update 
     407                        if( DoubleMath.subtract((exec.getExecStartTime() + exec.getEstimatedDuration()), (new DateTime().getMillis()/1000 + time)) == 0.0){ 
    486408                                continue; 
    487                         }*/ 
    488                         //check if the new estimated end time is equal to the previous one; if yes the continue without update 
    489                         if( DoubleMath.subtract((subTask.getExecStartTime() + subTask.getEstimatedDuration()), (new DateTime().getMillis()/1000 + time)) == 0.0){ 
    490                                 continue; 
    491                         } 
    492                         SubTaskFilter filter = new SubTaskFilter(subTask.getGridletID(), WormsTags.TASK_EXECUTION_FINISHED); 
     409                        } 
     410                        exec.setEstimatedDuration(time); 
     411                        ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_EXECUTION_FINISHED); 
    493412                        scheduler.sim_cancel(filter, null); 
    494                         scheduler.sendInternal(time, WormsTags.TASK_EXECUTION_FINISHED, task); 
    495  
     413                        scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, execTask); 
    496414                } 
    497415        }        
     
    511429                                numberOfPE = numberOfPE + resUnit.getAmount(); 
    512430                        } 
    513                         //numberOfPE = getResourceManager().getPE().size(); 
    514431                } catch (Exception e) { 
    515432                        numberOfPE = 1; 
     
    532449                        ExecTask task) { 
    533450 
    534                 ResourceManager resourceManager = this.resourceManager; 
     451                Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(); 
     452                LocalResourceManager resourceManager = getResourceManager(); 
    535453                if(resourceName != null){ 
    536454                        ComputingResource resource = null; 
     
    540458                                return null; 
    541459                        } 
    542  
    543460                        resourceManager = new LocalResourceManager(resource); 
    544461                } 
    545                 Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(); 
    546  
    547462 
    548463                int cpuRequest; 
     
    553468                } 
    554469 
    555                 //PEUnit processingUnits = null; 
    556470                if (cpuRequest != 0) { 
    557471                         
    558472                        List<ResourceUnit> availableUnits = null; 
    559473                        try { 
    560                                 availableUnits = getResourceManager().getPE(); 
     474                                availableUnits = resourceManager.getPE(); 
    561475                        } catch (ResourceException e) { 
    562476                                return null; 
    563477                        } 
     478                         
    564479                        List<ResourceUnit> choosenPEUnits = new ArrayList<ResourceUnit>(); 
    565  
    566480                        for (int i = 0; i < availableUnits.size() && cpuRequest > 0; i++) { 
    567481                                PEUnit peUnit = (PEUnit) availableUnits .get(i); 
     
    576490                                return null; 
    577491                        } 
    578  
    579                         /*try { 
    580                                 List<? extends ComputingResource> processingElements = resourceManager.getResourcesOfType(StandardResourceType.Processor); 
    581                                 List<ComputingResource> choosenResources = new ArrayList<ComputingResource>(); 
    582                                 int peSize = processingElements.size(); 
    583                                 for (int i = 0; i < peSize && cpuRequest > 0; i++) { 
    584                                         if (processingElements.get(i).getStatus() == ResourceStatus.FREE) { 
    585                                                 choosenResources.add(processingElements.get(i)); 
    586                                                 cpuRequest--; 
    587                                         } 
    588                                 } 
    589                                 if (cpuRequest > 0) 
    590                                 {        
    591                                         return null; 
    592                                 } 
    593                                 processingUnits = new ProcessingElements(choosenResources); 
    594                         } catch (Exception e) { 
    595          
    596                                 List<ResourceUnit> procResUnit = resourceManager.getDistributedResourceUnits(StandardResourceUnitName.PE); 
    597  
    598                                 for(ResourceUnit resUnit: procResUnit){ 
    599                                         if (resUnit.getFreeAmount() >= cpuRequest) 
    600                                         {        
    601                                                 processingUnits = new PEUnit(resUnit.getResourceId(), cpuRequest, cpuRequest); 
    602                                                 break; 
    603                                         }  
    604                                 } 
    605                         }*/ 
    606492                        map.put(StandardResourceUnitName.PE, choosenPEUnits.get(0)); 
    607493                } 
    608                 /*int memoryRequest; 
    609                 try { 
    610                         memoryRequest = Double.valueOf(task.getMemoryRequest()).intValue(); 
    611                 } catch (NoSuchFieldException e) { 
    612                         memoryRequest = 0; 
    613                 } 
    614                 if (memoryRequest != 0) { 
    615                         List<ResourceUnit> resUnit = resourceManager.getSharedResourceUnits().get(StandardResourceUnitName.MEMORY); 
    616  
    617                         Memory memory = null; 
    618                         for (ResourceUnit memUnit : resUnit) { 
    619                                 Memory m = (Memory) memUnit; 
    620  
    621                                 if (m.getFreeAmount() >= memoryRequest) {        
    622                                         System.out.println(m.getResourceId()+ ";"+m.getAmount()+";"+m.getFreeAmount()); 
    623                                         memory = new Memory(m, memoryRequest, memoryRequest); 
    624                                 } 
    625                         } 
    626                         if(memory == null) 
    627                                 return null; 
    628                         map.put(StandardResourceUnitName.MEMORY, memory); 
    629                 }*/ 
     494 
    630495                return  map; 
    631496        } 
    632  
    633  
    634          
    635         public void notifySubmittedWorkloadUnit(WorkloadUnit<?> job, boolean ack) { 
     497         
     498        public void notifySubmittedWorkloadUnit(WorkloadUnit wu, boolean ack) { 
    636499                updateProcessingProgress(); 
    637                 registerWorkloadUnit(job); 
    638         } 
    639  
    640         private void registerWorkloadUnit(WorkloadUnit<?> wu){ 
     500                registerWorkloadUnit(wu); 
     501        } 
     502 
     503        private void registerWorkloadUnit(WorkloadUnit wu){ 
    641504                if(!wu.isRegistered()){ 
    642505                        wu.register(jobRegistry); 
     
    647510        class LocalWorkloadUnitHandler implements WorkloadUnitHandler{ 
    648511                 
    649                 public void handleJob(Job job){ 
     512                public void handleJob(JobInterface<?> job){ 
    650513 
    651514                        if (log.isInfoEnabled()) 
     
    654517                        List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>(); 
    655518                        jobsList.add(job); 
    656                         WorkloadUnitListImpl readyTasks = new WorkloadUnitListImpl(); 
    657                         for(Task task: jobRegistry.getReadyTasks(jobsList)){ 
     519                        TaskListImpl availableTasks = new TaskListImpl(); 
     520                        for(Task task: jobRegistry.getAvailableTasks(jobsList)){ 
    658521                                task.setStatus((int)BrokerConstants.TASK_STATUS_QUEUED); 
    659                                 readyTasks.add(task); 
    660                         } 
    661  
    662                         for(WorkloadUnit<?> e:readyTasks){       
    663                                 registerWorkloadUnit(e); 
    664                         } 
    665                 } 
    666                  
    667                 public void handleTask(TaskInterface<?> ti){ 
    668                         Task task = (Task)ti; 
    669                          
    670                         if(task.getProcesses() == null){ 
     522                                availableTasks.add(task); 
     523                        } 
     524 
     525                        for(TaskInterface<?> task: availableTasks){      
     526                                registerWorkloadUnit(task); 
     527                        } 
     528                } 
     529                 
     530                public void handleTask(TaskInterface<?> t){ 
     531                        Task task = (Task)t; 
     532                        List<AbstractProcesses> processes = task.getProcesses(); 
     533 
     534                        if(processes == null || processes.size() == 0){ 
    671535                                Executable exec = new Executable(task); 
    672                                 exec.setUserID(task.getSenderId()); 
    673                                 exec.setLength(task.getLength()); 
    674536                                registerWorkloadUnit(exec); 
    675537                        } else { 
    676                                 List<AbstractProcesses> processesList = task.getProcesses(); 
    677                                 for(int i = 0; i < processesList.size(); i++){   
    678                                         AbstractProcesses processes = processesList.get(i); 
    679                                         Executable exec = new Executable(task, processes); 
    680                                         exec.setUserID(task.getSenderId()); 
    681                                         exec.setLength(task.getLength()); 
     538                                for(int j = 0; j < processes.size(); j++){ 
     539                                        AbstractProcesses procesesSet = processes.get(j); 
     540                                        Executable exec = new Executable(task, procesesSet); 
    682541                                        registerWorkloadUnit(exec); 
    683542                                } 
     
    686545                 
    687546                public void handleExecutable(ExecTask task){ 
     547                         
    688548                        Executable exec = (Executable) task; 
    689  
    690                         // int cost = 
    691                         // this.resourceManager.getResourceCharacteristic().getResUnits() != 
    692                         // null ? 
    693                         // this.resourceManager.getResourceCharacteristic().getResUnits().get(ResourceParameterName.COST).getAmount() 
    694                         // : 1; 
    695  
    696                         exec.visitResource(scheduler.get_name()); 
     549                        jobRegistry.addExecTask(exec); 
     550                         
     551                        exec.trackResource(scheduler.get_name()); 
    697552                        Scheduler parentScheduler = scheduler.getParent(); 
    698                         while (parentScheduler != null && !exec.getVisitedResources().contains(parentScheduler.get_name())) { 
    699                                 exec.visitResource(parentScheduler.get_name()); 
     553                        List<String> visitedResource = exec.getVisitedResources(); 
     554                        String [] visitedResourcesArray = visitedResource.toArray(new String[visitedResource.size()]); 
     555                        while (parentScheduler != null && !ArrayUtils.contains(visitedResourcesArray, parentScheduler.get_name())) { 
     556                                exec.trackResource(parentScheduler.get_name()); 
    700557                                parentScheduler = parentScheduler.getParent(); 
    701558                        } 
    702                          
    703                         exec.setResourceParameter(scheduler.get_id(), 1); 
    704                         SubmittedTask subTask = new SubmittedTask(exec); 
    705                         jobRegistry.addTask(subTask); 
    706                         WorkloadUnitListImpl newTasks = new WorkloadUnitListImpl(); 
    707                         newTasks.add(subTask); 
    708                  
    709                         schedulingPlugin.placeJobsInQueues(newTasks, queues, getResourceManager(), moduleList); 
    710  
    711                         if (subTask.getStatus() == Gridlet.QUEUED) { 
     559                        exec.setSchedulerName(scheduler.get_id()); 
     560                         
     561                        TaskList newTasks = new TaskListImpl(); 
     562                        newTasks.add(exec); 
     563                 
     564                        schedulingPlugin.placeTasksInQueues(newTasks, queues, getResourceManager(), moduleList); 
     565 
     566                        if (exec.getStatus() == DCWormsTags.QUEUED) { 
    712567                                sendExecutableReadyEvent(exec); 
    713                         } 
    714                 } 
    715                  
    716                 public void handleSubmittedTask(SubmittedTask task){ 
    717  
    718                         task.visitResource(scheduler.get_name()); 
    719                         Scheduler parentScheduler = scheduler.getParent(); 
    720                         while (parentScheduler != null && !task.getVisitedResources().contains(parentScheduler.get_name())) { 
    721                                 task.visitResource(parentScheduler.get_name()); 
    722                                 parentScheduler = parentScheduler.getParent(); 
    723                         } 
    724  
    725                         jobRegistry.addTask(task); 
    726                         WorkloadUnitListImpl newTasks = new WorkloadUnitListImpl(); 
    727                         newTasks.add(task); 
    728                  
    729                         schedulingPlugin.placeJobsInQueues(newTasks, queues, getResourceManager(), moduleList); 
    730  
    731                         if (task.getStatus() == Gridlet.QUEUED) { 
    732                                 sendExecutableReadyEvent(task); 
    733568                        } 
    734569                } 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/queue/TaskQueue.java

    r477 r539  
    11package schedframe.scheduling.queue; 
    22 
    3 import gridsim.Gridlet; 
    4 import gssim.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 
     3import gridsim.dcworms.DCWormsTags; 
    54 
    65import org.joda.time.DateTime; 
    76 
    8 import schedframe.scheduling.tasks.WorkloadUnit; 
     7import dcworms.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 
    98 
    10 public class TaskQueue extends AbstractStatsSupportingQueue<WorkloadUnit<?>> implements Queue<WorkloadUnit<?>>{ 
     9import schedframe.scheduling.tasks.TaskInterface; 
    1110 
     11public class TaskQueue extends AbstractStatsSupportingQueue<TaskInterface<?>> implements Queue<TaskInterface<?>>{ 
    1212 
    1313        private static final long serialVersionUID = 6576299222910508209L; 
     
    1717        protected boolean supportReservation; 
    1818         
    19          
    2019        public TaskQueue (boolean supportReservation){ 
    21                 name = "Queue"; 
    22                 priority = 0; 
     20                this.name = "Queue"; 
     21                this.priority = 0; 
    2322                this.supportReservation = supportReservation; 
    24  
    2523        } 
    2624         
    27         public boolean add(WorkloadUnit<?> wu){ 
     25        public boolean add(TaskInterface<?> task){ 
    2826                try { 
    29                         wu.setStatus(Gridlet.QUEUED); 
     27                        task.setStatus(DCWormsTags.QUEUED); 
    3028                } catch(Exception e){ 
    3129                        throw new RuntimeException(e); 
    3230                } 
    33                 //updateStats(); 
    34                 return super.add(wu); 
     31                return super.add(task); 
    3532        } 
    3633         
    37         public void add(int pos, WorkloadUnit<?> wu){ 
     34        public void add(int pos, TaskInterface<?> task){ 
    3835                try { 
    39                         wu.setStatus(Gridlet.QUEUED); 
     36                        task.setStatus(DCWormsTags.QUEUED); 
    4037                } catch(Exception e){ 
    4138                        throw new RuntimeException(e); 
    4239                } 
    43                 //updateStats(); 
    44                  super.add(pos, wu); 
     40                 super.add(pos, task); 
    4541        } 
    4642         
    4743        public DateTime getArrivalTime(int pos) throws IndexOutOfBoundsException { 
    48                 //return get(pos).getSubmissionTimeToBroker(); 
    49                 return null; 
     44                return get(pos).getSubmissionTimeToBroker(); 
    5045        } 
    5146 
     
    6964                return supportReservation; 
    7065        } 
    71          
    72          
    73         /*public boolean contains (WorkloadUnitInterface<?> wu) { 
    74                 for(int i = 0; i< size();i++){ 
    75                         try { 
    76                                 if(get(i).getId().equals(wu.getId())) 
    77                                         return true; 
    78                         } catch (NoSuchFieldException e) { 
    79                                 return false; 
    80                         } 
    81                 } 
    82                 return false; 
    83         } 
    84          
    85         public boolean remove (WorkloadUnitInterface<?> wu) { 
    86                 boolean found = false; 
    87                 int index = 0; 
    88                 for(int i = 0; i< size() && !found;i++){ 
    89                         try { 
    90                                 if(get(i).getId().equals(wu.getId())) 
    91                                 { 
    92                                         found = true; 
    93                                         index = i; 
    94                                 } 
    95                                  
    96                         } catch (NoSuchFieldException e) { 
    97                                 return false; 
    98                         } 
    99                 } 
    100                 remove(index); 
    101                 return true; 
    102         }*/ 
    10366} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/AbstractProcesses.java

    r477 r539  
    33import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
    44 
    5 public abstract class AbstractProcesses<T> implements WorkloadUnit<T>{ 
     5public abstract class AbstractProcesses implements WorkloadUnit{ 
    66         
    77         
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/Job.java

    r477 r539  
    1818import schedframe.scheduling.WorkloadUnitHandler; 
    1919import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    20 import schedframe.scheduling.policy.AbstractManagementSystem; 
    2120 
    2221 
     
    179178        } 
    180179         
    181         public int getUserID(){ 
     180        public int getUserId(){ 
    182181                return this.senderId; 
    183182        } 
     
    204203                 
    205204                List<Task> readyTasks = new ArrayList<Task>(); 
    206  
    207205                int size = tasks.size(); 
     206                 
    208207                for(int i = 0; i < size; i++){ 
    209208                        int parCnt; 
     
    216215                        } catch(Exception e){ 
    217216                                parCnt = 0; 
    218                                 //e.printStackTrace(); 
    219                         } 
    220                         if(parCnt == 0) 
    221                         { 
     217                        } 
     218                        if(parCnt == 0) { 
    222219                                readyTasks.add(task); 
    223220                        } 
    224                         else 
    225                         { 
     221                        else { 
    226222                                for(int j = 0; j < parCnt; j++){ 
    227223                                        ParentType par = task.getDescription().getWorkflow().getParent(j); 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/JobInterface.java

    r477 r539  
    1111 * 
    1212 */ 
    13 public interface JobInterface<T> extends WorkloadUnit<T> { 
     13public interface JobInterface<T> extends WorkloadUnit, DescriptionContainer<T> { 
    1414 
    1515        /** 
     
    1818         * @throws NoSuchFieldException if there is no tasks for this job, and job id can not be obtained 
    1919         */ 
    20         public abstract String getId() throws NoSuchFieldException; 
     20        //public abstract String getId() throws NoSuchFieldException; 
    2121         
    2222        /** 
     
    4444         * @return constant which represents current status of this job 
    4545         */ 
    46         public int getStatus(); 
     46        //public int getStatus(); 
    4747         
    48         public int getUserID(); 
     48        //public int getUserID(); 
    4949} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/Processes.java

    r477 r539  
    11package schedframe.scheduling.tasks; 
    2  
    3 import java.util.List; 
    42 
    53import org.qcg.broker.schemas.resreqs.ComputingResourceBaseTypeItem; 
     
    196194        } 
    197195 
    198         public org.qcg.broker.schemas.resreqs.Processes getDescription(){ 
    199                 return this.pr; 
    200         } 
    201  
    202         @Override 
    203         public List getTask() { 
    204                 // TODO Auto-generated method stub 
    205                 return null; 
    206         } 
    207  
    208         @Override 
    209         public TaskInterface getTask(String taskId) throws NoSuchFieldException { 
    210                 // TODO Auto-generated method stub 
    211                 return null; 
    212         } 
    213  
    214         @Override 
    215         public int getTaskCount() { 
     196        public int getStatus() { 
     197                return this.status; 
     198        } 
     199 
     200        @Override 
     201        public int getUserId() { 
    216202                // TODO Auto-generated method stub 
    217203                return 0; 
    218204        } 
    219205 
    220         @Override 
    221         public int getStatus() { 
    222                 // TODO Auto-generated method stub 
    223                 return 0; 
    224         } 
    225  
    226         @Override 
    227         public int getUserID() { 
    228                 // TODO Auto-generated method stub 
    229                 return 0; 
    230         } 
    231  
    232         @Override 
    233         public String getDocument() throws Exception { 
    234                 // TODO Auto-generated method stub 
    235                 return null; 
    236         } 
     206 
    237207 
    238208        @Override 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/Task.java

    r477 r539  
    3030import schedframe.scheduling.WorkloadUnitHandler; 
    3131import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    32 import schedframe.scheduling.policy.AbstractManagementSystem; 
    3332import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
    3433 
     
    3837 * 
    3938 */ 
    40 public class Task /*extends AbstractTask*/ implements TaskInterface<org.qcg.broker.schemas.resreqs.Task> { 
     39public class Task implements TaskInterface<org.qcg.broker.schemas.resreqs.Task> { 
    4140         
    4241        protected static Unmarshaller unmarshaller; 
     
    7271        private int senderId; 
    7372        private long workloadLogWaitTime; 
    74         //String resPathHistory; 
    75          
     73 
    7674        public Task(org.qcg.broker.schemas.resreqs.Task task){ 
    7775                this.task = task; 
     
    8078                this.brokerSubmitTime = null; 
    8179                this.duration = null; 
    82         //      this.gridletID_ = (getJobId() + "_" + getId()).hashCode(); 
    8380                prepareTopology(); 
    8481        } 
     
    9188                this.brokerSubmitTime = null; 
    9289                this.duration = null; 
    93         //      this.gridletID_ = (getJobId() + getId()).hashCode(); 
    9490                prepareTopology(); 
    9591        } 
     
    269265        } 
    270266 
    271         public String getUserDn() { 
     267        public String getUserDN() { 
    272268                return this.task.getUserDN(); 
    273269        } 
     
    471467        }*/ 
    472468 
     469 
    473470        @Override 
    474         public List <Task> getTask() { 
    475                 List<Task> tasks = new ArrayList<Task>(); 
    476                 tasks.add(this); 
    477                 return tasks; 
    478         } 
    479  
    480         @Override 
    481         public Task getTask(String taskId) throws NoSuchFieldException { 
    482                 // TODO Auto-generated method stub 
    483                 return null; 
    484         } 
    485  
    486         @Override 
    487         public int getTaskCount() { 
     471        public int getUserId() { 
    488472                // TODO Auto-generated method stub 
    489473                return 0; 
    490474        } 
    491475 
    492         @Override 
    493         public int getUserID() { 
    494                 // TODO Auto-generated method stub 
    495                 return 0; 
    496         } 
    497  
    498476        public boolean isRegistered() { 
    499477                return isRegistered; 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/TaskInterface.java

    r477 r539  
    66import org.joda.time.ReadableDuration; 
    77 
     8import schedframe.DescriptionContainer; 
    89import schedframe.scheduling.tasks.requirements.ResourceParameterName; 
    910 
     
    1415 * 
    1516 */ 
    16 public interface TaskInterface<T> extends WorkloadUnit<T> { 
     17public interface TaskInterface<T> extends WorkloadUnit, DescriptionContainer<T> { 
    1718         
    1819        /** 
     
    2021         * @return task identifier 
    2122         */ 
    22         public abstract String getId(); 
     23        //public abstract String getId(); 
    2324         
    2425        /** 
     
    3334         * submitted this task.  
    3435         */ 
    35         public abstract String getUserDn(); 
     36        public abstract String getUserDN(); 
    3637         
    3738        /** 
     
    8788         */ 
    8889        public long getLength(); 
    89          
    90         /** 
    91          *  
    92          * @param length measured in instructions. 
    93          */ 
    94         public void setLength(long length); 
    95          
     90 
    9691        /** 
    9792         *  
    9893         * @return constant which represent current task status 
    9994         */ 
    100         public int getStatus(); 
     95        //public int getStatus(); 
    10196         
    10297         
     
    107102        public List<AbstractProcesses> getProcesses(AbstractProcessesGroup processGroup); 
    108103         
    109         public void setStatus(int status) throws Exception; 
     104        //public void setStatus(int status) throws Exception; 
    110105         
    111106        public double getCpuCntRequest() throws NoSuchFieldException; 
     
    114109         
    115110        public long getWorkloadLogWaitTime(); 
    116          
    117         //public void addToResPath(String resName); 
    118          
    119         //public String getResPath(); 
     111 
    120112                 
    121113} 
  • DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/WorkloadUnit.java

    r477 r539  
    11package schedframe.scheduling.tasks; 
    22 
    3 import java.util.List; 
    4  
    5 import schedframe.DescriptionContainer; 
    63import schedframe.scheduling.WorkloadUnitHandler; 
    74import schedframe.scheduling.manager.tasks.JobRegistryImpl; 
    8 import schedframe.scheduling.policy.AbstractManagementSystem; 
    95 
    10 public interface WorkloadUnit<T> extends DescriptionContainer<T> { 
     6public interface WorkloadUnit { 
    117 
    12         /** 
    13          *  
    14          * @return job identifier 
    15          * @throws NoSuchFieldException if there is no tasks for this job, and job id can not be obtained 
    16          */ 
    17         public abstract String getId() throws NoSuchFieldException; 
     8        public String getId(); 
    189         
    19         /** 
    20          *  
    21          * @return list of tasks which belongs to this job 
    22          */ 
    23         public abstract List<? extends TaskInterface<?>> getTask(); 
     10        public int getUserId(); 
    2411         
    25         /** 
    26          *  
    27          * @param taskId 
    28          * @return task with specified taskId 
    29          * @throws NoSuchFieldException if task with taskId does not exist in this job 
    30          */ 
    31         public abstract TaskInterface<?> getTask(String taskId) throws NoSuchFieldException; 
    32          
    33         /** 
    34          *  
    35          * @return number of tasks in this job  
    36          */ 
    37         public abstract int getTaskCount(); 
    38          
    39         /** 
    40          *  
    41          * @return constant which represents current status of this job 
    42          */ 
    4312        public int getStatus(); 
    4413         
    4514        public void setStatus(int status) throws Exception; 
    46          
     15 
    4716        public boolean isFinished(); 
    48          
    49         public int getUserID(); 
    50          
     17 
    5118        public boolean isRegistered(); 
    5219 
  • DCWoRMS/trunk/build/classes/simulator/ConfigurationOptions.java

    r477 r539  
    88import java.util.PropertyResourceBundle; 
    99import java.util.ResourceBundle; 
    10 import java.util.logging.FileHandler; 
    1110 
    1211/** 
     
    2625         * ============================================================================================= 
    2726         */ 
    28         /** Grid scheduler's plugin path */ 
    29         public static final String GRID_SCHEDULING_PLUGIN_NAME_MODIFIER = "gridschedulingpluginname"; 
    30         /** Forecast finish time plugin path */ 
    31         public static final String EXEC_TIME_ESTIMATION_PLUGIN_NAME_MODIFIER = "exectimeestimationpluginname"; 
    32         /** Local allocation policy plugin path */ 
    33         public static final String LOCAL_ALLOC_POLICY_PLUGIN_NAME_MODIFIER = "localallocpolicypluginname"; 
     27 
    3428        /** The path to the resource description file */ 
    3529        public static final String RESOURCE_DESC_MODIFIER = "resdesc"; 
     
    5852        public static final String READ_SCENARIO_INPUT_FOLDER = READ_SCENARIO_MODIFIER 
    5953                        + ".inputfolder"; 
    60         public static final String READ_SCENARIO_INPUT_TAR = READ_SCENARIO_MODIFIER+ ".tar"; 
    6154         
    6255        /** The name of the workload file */ 
     
    6457                        + ".workloadfilename"; 
    6558 
    66         /** Shall a detailed history be printed */ 
    67         public static final String PRINT_HISTORY_MODIFIER = "printhistory"; 
    68  
    6959        /** The default name of a workload file */ 
    7060        public static final String DEFAULT_WORKLOAD_FILE_NAME = "workload.swf"; 
    7161 
    7262        public static final String CREATE_XML_SUPPLEMENT_FILES = "createXMLSupplement"; 
    73          
    74         public static final String PROVIDER_LIST_FILE = "in/provider.list"; 
    75          
    76         /** Network topology file path */ 
    77         public static final String NETWORK_TOPOLOGY_FILE_MODIFIER = "networktopologyfilename"; 
     63 
    7864         
    7965        public static final String CREATEDIAGRAMS = "creatediagrams"; 
    80         public static final String CREATEDIAGRAMS_PROCESSORS = CREATEDIAGRAMS +".processors"; 
    81         public static final String CREATEDIAGRAMS_RESERVATIONS = CREATEDIAGRAMS + ".reservations"; 
    82         public static final String CREATEDIAGRAMS_RESOURCES = CREATEDIAGRAMS + ".resources"; 
    83         public static final String CREATEDIAGRAMS_ENERGYUSAGE = CREATEDIAGRAMS + ".energyusage"; 
    84         public static final String CREATEDIAGRAMS_RESOURCES_SCALE = CREATEDIAGRAMS_RESOURCES + ".scale"; 
     66        public static final String CREATEDIAGRAMS_GANTT = CREATEDIAGRAMS +".gantt"; 
    8567        public static final String CREATEDIAGRAMS_TASKS = CREATEDIAGRAMS + ".tasks"; 
    8668        public static final String CREATEDIAGRAMS_TASKSWAITINGTIME = CREATEDIAGRAMS + ".taskswaitingtime"; 
     69        public static final String CREATEDIAGRAMS_UTILIZATION = CREATEDIAGRAMS + ".resutilization"; 
     70        public static final String CREATEDIAGRAMS_ENERGYUSAGE = CREATEDIAGRAMS + ".respowerusage"; 
     71        public static final String CREATEDIAGRAMS_AIRFLOW = CREATEDIAGRAMS + ".resairflow"; 
     72        public static final String CREATEDIAGRAMS_RESOURCES_SCALE = CREATEDIAGRAMS_UTILIZATION + ".scale"; 
     73 
    8774         
    8875        public static final String CREATESTATISTICS = "createstatistics"; 
    8976        public static final String ACCUMULATED_RESOURCES_STATISTICS = CREATESTATISTICS + ".accumulatedresources"; 
    9077        public static final String EXTENDED_TASKS_STATISTICS = CREATESTATISTICS + ".extendedtasks"; 
    91         public static final String GRIDLET_HISTORY_STATISTICS = CREATESTATISTICS + ".gridlethistory"; 
    9278        public static final String JOBS_STATISTICS = CREATESTATISTICS + ".jobs"; 
    9379        public static final String SIMULATION_STATISTICS = CREATESTATISTICS + ".simulation"; 
    94         public static final String FORMAT_STATISTICS_OUTPUT = CREATESTATISTICS + ".formatoutput"; 
    9580         
    9681        /** 
     
    116101        /* =============================================================================================== */ 
    117102         
    118         public String providerListFile = null; 
    119  
    120         /** 
    121          * the full grid scheduling plugin name with package prefix, e.g. 
    122          * simulator.plugin.gridscheduling.raPlugin.RAPlugin (the plugin is loaded 
    123          * using {@link Class#forName(java.lang.String)} and 
    124          * {@link Class#newInstance()} methods) 
    125          */ 
    126         public String gridSchedulingPluginName = null; 
    127  
    128         /** 
    129          * the full forecast finish time plugin name with package prefix, e.g. 
    130          * simulator.plugin.gridscheduling.raPlugin.RAPlugin (the plugin is loaded 
    131          * using {@link Class#forName(java.lang.String)} and 
    132          * {@link Class#newInstance()} methods) 
    133          */ 
    134         public String exectimeestimationplugin = null; 
    135  
    136         /** 
    137          * the full local allocation policy plugin name with package prefix, e.g. 
    138          * simulator.plugin.gridscheduling.raPlugin.RAPlugin (the plugin is loaded 
    139          * using {@link Class#forName(java.lang.String)} and 
    140          * {@link Class#newInstance()} methods) 
    141          */ 
    142         public String localAllocPolicyPluginName = null; 
     103 
    143104 
    144105        /** 
     
    180141        public String inputWorkloadFileName = DEFAULT_WORKLOAD_FILE_NAME; 
    181142 
    182         /** 
    183          * a txt file name with topology description 
    184          */ 
    185         public String networkTopologyFileName = null; 
    186143         
    187144        /** 
     
    199156        public boolean overwriteFiles = false; 
    200157 
    201         /** 
    202          * true if the history files are to be generated (makes the simulation 
    203          * slower) 
    204          */ 
    205         public boolean printHistory = false; 
    206158         
    207159        /** 
     
    210162        public int numberOfSimulations = 1; //default value 
    211163 
    212         public boolean creatediagrams_processors = true; 
    213         public boolean creatediagrams_reservations = true; 
    214         public boolean creatediagrams_resources = true; 
    215         public boolean creatediagrams_energyusage = true; 
    216         public boolean creatediagrams_tasks = true; 
    217         public boolean creatediagrams_taskswaitingtime = true; 
    218         public double     creatediagrams_resources_scale = 1; 
    219          
    220         public boolean createaccumulatedresourcesstatistics = true; 
    221         public boolean createextendedtasksstatistics = true; 
    222         public boolean creategridlethistorystatistics = true; 
     164        public boolean creatediagrams_gantt = false; 
     165        public boolean creatediagrams_tasks = false; 
     166        public boolean creatediagrams_taskswaitingtime = false; 
     167         
     168        public boolean creatediagrams_resutilization = false; 
     169        public boolean creatediagrams_respowerusage = false; 
     170        public boolean creatediagrams_resairflow = false; 
     171        public double  creatediagrams_resources_scale = 1; 
     172 
    223173        public boolean createjobsstatistics = true; 
    224174        public boolean createsimulationstatistics = true; 
    225         public boolean formatstatisticsoutput = false; 
    226          
    227         public static final String ENV_DESC_MODIFIER = "envdesc"; 
    228         public String envDescFileName = null; 
     175         
     176        public String [] resForEnergyChart; 
     177        public String [] resForAirFlowChart; 
     178        public String [] resForUtilizationChart; 
     179         
    229180        /** 
    230181         * An empty constructor. 
     
    257208                        return null; 
    258209                } 
    259  
    260                 try { 
    261                         co.gridSchedulingPluginName = bundle 
    262                                         .getString(GRID_SCHEDULING_PLUGIN_NAME_MODIFIER); 
    263                 } catch(MissingResourceException e){ 
    264                         co.gridSchedulingPluginName = null; 
    265                 } 
    266  
    267                 try { 
    268                         co.exectimeestimationplugin = bundle 
    269                                         .getString(EXEC_TIME_ESTIMATION_PLUGIN_NAME_MODIFIER); 
    270                 } catch(MissingResourceException e){ 
    271                         co.exectimeestimationplugin = null; 
    272                 } 
    273  
    274                 try { 
    275                         co.localAllocPolicyPluginName = bundle 
    276                                         .getString(LOCAL_ALLOC_POLICY_PLUGIN_NAME_MODIFIER); 
    277                 } catch(MissingResourceException e){ 
    278                         co.localAllocPolicyPluginName = null; 
    279                 } 
    280  
    281210                 
    282211                co.resdescFileName = bundle.getString(RESOURCE_DESC_MODIFIER); 
    283                  
    284                 try { 
    285                         co.envDescFileName = bundle.getString(ENV_DESC_MODIFIER); 
    286                 } catch(MissingResourceException e){ 
    287                         co.envDescFileName = null; 
    288                 } 
    289212                 
    290213                try { 
     
    314237                } 
    315238 
    316  
    317                 try { 
    318                         co.networkTopologyFileName = bundle 
    319                                         .getString(NETWORK_TOPOLOGY_FILE_MODIFIER); 
    320                 } catch(MissingResourceException e){ 
    321                         co.networkTopologyFileName = null; 
    322                 } 
    323                  
    324239                if (co.createScenario == false) { 
    325240                        // read scenario 
     
    329244                        } catch (MissingResourceException e) { 
    330245                                co.inputFolder = null; 
    331                         } 
    332                          
    333                         try { 
    334                                 co.inputTar = getSeparatorTerminatedPath(bundle 
    335                                         .getString(READ_SCENARIO_INPUT_TAR)); 
    336                         } catch (MissingResourceException e) { 
    337                                 co.inputTar = null; 
    338246                        } 
    339247                         
     
    357265                        co.createXMLSupplement = false; 
    358266                } 
    359                  
    360                 try { 
    361                         co.printHistory = Boolean.valueOf( 
    362                                         bundle.getString(PRINT_HISTORY_MODIFIER)).booleanValue(); 
    363                 } catch(MissingResourceException e){ 
    364                         co.printHistory = false; 
    365                 } 
    366                  
     267 
    367268                // create diagrams 
    368269                 
     
    372273                                        bundle.getString(CREATEDIAGRAMS)).booleanValue(); 
    373274                } catch(MissingResourceException e){ 
    374                         createDiagrams = true; 
    375                 } 
    376                 try { 
    377                         co.creatediagrams_processors = Boolean.valueOf( 
    378                                         bundle.getString(CREATEDIAGRAMS_PROCESSORS)).booleanValue() && createDiagrams; 
    379                 } catch(MissingResourceException e){ 
    380                         co.creatediagrams_processors = createDiagrams; 
    381                 } 
    382                 try { 
    383                         co.creatediagrams_reservations = Boolean.valueOf( 
    384                                         bundle.getString(CREATEDIAGRAMS_RESERVATIONS)).booleanValue() && createDiagrams; 
    385                 } catch(MissingResourceException e){ 
    386                         co.creatediagrams_reservations = createDiagrams; 
    387                 } 
    388                 try { 
    389                         co.creatediagrams_resources = Boolean.valueOf( 
    390                                         bundle.getString(CREATEDIAGRAMS_RESOURCES)).booleanValue() && createDiagrams; 
    391                 } catch(MissingResourceException e){ 
    392                         co.creatediagrams_resources = createDiagrams; 
     275                        createDiagrams = false; 
     276                } 
     277                try { 
     278                        co.creatediagrams_gantt = Boolean.valueOf( 
     279                                        bundle.getString(CREATEDIAGRAMS_GANTT)).booleanValue(); 
     280                } catch(MissingResourceException e){ 
     281                        co.creatediagrams_gantt = createDiagrams; 
     282                } 
     283 
     284                try { 
     285                        co.resForUtilizationChart = bundle.getString(CREATEDIAGRAMS_UTILIZATION).split(";"); 
     286                        if(co.resForUtilizationChart.length > 0){ 
     287                                co.creatediagrams_resutilization = true; 
     288                        } 
     289                } catch(MissingResourceException e){ 
     290                        co.creatediagrams_resutilization = createDiagrams; 
    393291                } 
    394292                try { 
     
    399297                } 
    400298                try { 
    401                         co.creatediagrams_energyusage = Boolean.valueOf( 
    402                                         bundle.getString(CREATEDIAGRAMS_ENERGYUSAGE)).booleanValue() && createDiagrams; 
    403                 } catch(MissingResourceException e){ 
    404                         co.creatediagrams_energyusage = createDiagrams; 
    405                 } 
     299                        co.resForEnergyChart = bundle.getString(CREATEDIAGRAMS_ENERGYUSAGE).split(";"); 
     300                        if(co.resForEnergyChart.length > 0){ 
     301                                co.creatediagrams_respowerusage = true; 
     302                        } 
     303                } catch(MissingResourceException e){ 
     304                        co.creatediagrams_respowerusage = createDiagrams; 
     305                } 
     306                 
     307                try { 
     308                        co.resForAirFlowChart = bundle.getString(CREATEDIAGRAMS_AIRFLOW).split(";"); 
     309                        if(co.resForAirFlowChart.length > 0){ 
     310                                co.creatediagrams_resairflow = true; 
     311                        } 
     312                } catch(MissingResourceException e){ 
     313                        co.creatediagrams_resairflow = createDiagrams; 
     314                } 
     315                 
    406316                try { 
    407317                        co.creatediagrams_tasks = Boolean.valueOf( 
    408                                         bundle.getString(CREATEDIAGRAMS_TASKS)).booleanValue() && createDiagrams; 
     318                                        bundle.getString(CREATEDIAGRAMS_TASKS)).booleanValue(); 
    409319                } catch(MissingResourceException e){ 
    410320                        co.creatediagrams_tasks = createDiagrams; 
     
    412322                try { 
    413323                        co.creatediagrams_taskswaitingtime = Boolean.valueOf( 
    414                                         bundle.getString(CREATEDIAGRAMS_TASKSWAITINGTIME)).booleanValue() && createDiagrams; 
     324                                        bundle.getString(CREATEDIAGRAMS_TASKSWAITINGTIME)).booleanValue(); 
    415325                } catch(MissingResourceException e){ 
    416326                        co.creatediagrams_taskswaitingtime = createDiagrams; 
    417327                } 
    418                  
    419328                 
    420329                try { 
     
    427336 
    428337                try { 
    429                         co.createaccumulatedresourcesstatistics = Boolean.valueOf( 
    430                                         bundle.getString(ACCUMULATED_RESOURCES_STATISTICS)).booleanValue(); 
    431                 } catch(MissingResourceException e){ 
    432                         co.createaccumulatedresourcesstatistics = true; 
    433                 } 
    434                 try { 
    435                         co.createextendedtasksstatistics = Boolean.valueOf( 
    436                                         bundle.getString(EXTENDED_TASKS_STATISTICS)).booleanValue(); 
    437                 } catch(MissingResourceException e){ 
    438                         co.createextendedtasksstatistics = true; 
    439                 } 
    440                 try { 
    441                         co.creategridlethistorystatistics = Boolean.valueOf( 
    442                                         bundle.getString(GRIDLET_HISTORY_STATISTICS)).booleanValue(); 
    443                 } catch(MissingResourceException e){ 
    444                         co.creategridlethistorystatistics = true; 
    445                 } 
    446                 try { 
    447338                        co.createjobsstatistics = Boolean.valueOf( 
    448339                                        bundle.getString(JOBS_STATISTICS)).booleanValue(); 
     
    456347                        co.createsimulationstatistics = true; 
    457348                } 
    458                 try { 
    459                         co.formatstatisticsoutput = Boolean.valueOf( 
    460                                         bundle.getString(FORMAT_STATISTICS_OUTPUT)).booleanValue(); 
    461                 } catch(MissingResourceException e){ 
    462                         co.formatstatisticsoutput = false; 
    463                 } 
    464                  
     349 
    465350                try { 
    466351                        co.numberOfSimulations = Integer.valueOf(bundle.getString(NUMBER_OF_SIMULATIONS)).intValue(); 
     
    469354                } 
    470355                return co; 
    471         } 
    472  
    473         /** 
    474          * Creates a new configuration object in the CREATE_SCENARIO mode. 
    475          *  
    476          * @param gridSchedulingPluginName 
    477          * @param forecastFinishTimePluginName 
    478          * @param localAllocPolicyPluginName 
    479          * @param resdescFileName 
    480          * @param taskParamFileName 
    481          * @param outputFolder 
    482          * @param outputWorkloadFileName 
    483          * @param overwriteFiles 
    484          * @param printHistory 
    485          */ 
    486         public ConfigurationOptions(String gridSchedulingPluginName, 
    487                         String exectimeestimationplugin, 
    488                         String localAllocPolicyPluginName, String resdescFileName, 
    489                         String taskParamFileName, String outputFolder, 
    490                         String outputWorkloadFileName, boolean overwriteFiles, 
    491                         boolean printHistory) { 
    492                 super(); 
    493                 this.gridSchedulingPluginName = gridSchedulingPluginName; 
    494                 this.exectimeestimationplugin = exectimeestimationplugin; 
    495                 this.localAllocPolicyPluginName = localAllocPolicyPluginName; 
    496                 this.resdescFileName = resdescFileName; 
    497                 this.workloadDescFileName = taskParamFileName; 
    498                 this.outputFolder = getSeparatorTerminatedPath(outputFolder); 
    499                 this.outputWorkloadFileName = outputWorkloadFileName; 
    500                 this.overwriteFiles = overwriteFiles; 
    501                 this.printHistory = printHistory; 
    502  
    503                 // the create mode 
    504                 this.createScenario = true; 
    505         } 
    506  
    507         /** 
    508          * Creates a new configuration object in the READ_SCENARIO mode. 
    509          *  
    510          * @param gridSchedulingPluginName 
    511          * @param forecastFinishTimePluginName 
    512          * @param localAllocPolicyPluginName 
    513          * @param resdescFileName 
    514          * @param inputFolder 
    515          * @param inputWorkloadFileName 
    516          * @param overwriteFiles 
    517          * @param printHistory 
    518          */ 
    519         public ConfigurationOptions(String gridSchedulingPluginName, 
    520                         String exectimeestimationplugin, 
    521                         String localAllocPolicyPluginName, String resdescFileName, 
    522                         String inputFolder, String inputWorkloadFileName, 
    523                         boolean overwriteFiles, boolean printHistory) { 
    524                 super(); 
    525                 this.gridSchedulingPluginName = gridSchedulingPluginName; 
    526                 this.exectimeestimationplugin = exectimeestimationplugin; 
    527                 this.localAllocPolicyPluginName = localAllocPolicyPluginName; 
    528                 this.resdescFileName = resdescFileName; 
    529                 this.inputFolder = getSeparatorTerminatedPath(inputFolder); 
    530                 this.inputWorkloadFileName = inputWorkloadFileName; 
    531                 this.overwriteFiles = overwriteFiles; 
    532                 this.printHistory = printHistory; 
    533                 //FileHandler.loadDataset(new File("iris.data"), 4, ","); 
    534                 // the read mode 
    535                 this.createScenario = false; 
    536356        } 
    537357 
  • DCWoRMS/trunk/build/classes/simulator/DataCenterWorkloadSimulator.java

    r477 r539  
    11package simulator; 
    22 
    3 //import eduni.cloudsim.GSSIM; 
    43import java.io.File; 
    54import java.io.FileReader; 
     
    2625import simulator.reader.ResourceReader; 
    2726import simulator.stats.AccumulatedStatistics; 
    28 import simulator.stats.implementation.GSSimStatistics; 
     27import simulator.stats.implementation.DCWormsStatistics; 
    2928import simulator.utils.LogErrStream; 
    3029import simulator.workload.WorkloadLoader; 
     
    4039 * {@link #main(String[])} method used to invoke the program. This class also 
    4140 * provides second possibility to start the simulator, namely one may use the 
    42  * {@link #performSimulation(ConfigurationOptions, GSSimStatistics)} method. 
     41 * {@link #performSimulation(ConfigurationOptions, DCWormsStatistics)} method. 
    4342 * In this case, the input parameter, describing the simulation options, must be 
    4443 * earlier prepared. The results of the simulation can be acquired using the 
     
    9897         */ 
    9998        public static void main(String[] args) { 
    100                 DataCenterWorkloadSimulator gssim = new DataCenterWorkloadSimulator(); 
    101                 gssim.run(args); 
     99                DataCenterWorkloadSimulator dcworms = new DataCenterWorkloadSimulator(); 
     100                dcworms.run(args); 
    102101        } 
    103102 
     
    117116                                @Override 
    118117                                public String getDescription() { 
    119                                         return "WoRMS experiment file"; 
     118                                        return "DCWoRMS experiment file"; 
    120119                                } 
    121120                        }; 
     
    198197        } 
    199198 
    200         private void runMultiuser(String rootDirPath, DataCenterWorkloadSimulator gssim) { 
     199        private void runMultiuser(String rootDirPath, DataCenterWorkloadSimulator dcworms) { 
    201200                throw new RuntimeException("not supported yet"); 
    202201        } 
     
    269268                rc.setInitList(null); 
    270269                 
    271                 WormsUsers wl = new WormsUsers("Users", 
     270                DCWormsUsers wl = new DCWormsUsers("Users", 
    272271                                rc.getScheduler().get_name(), workload); 
    273272                 
     
    275274                long stopSimulation = System.currentTimeMillis(); 
    276275 
    277                 GSSimStatistics stats = new GSSimStatistics(simulationIdentifier, 
     276                DCWormsStatistics stats = new DCWormsStatistics(simulationIdentifier, 
    278277                                options, wl, statsOutputPath, rc); 
    279278                accumulatedStatistics.add(stats); 
  • DCWoRMS/trunk/build/classes/simulator/GenericUser.java

    r477 r539  
    22 
    33 
    4 import gssim.schedframe.scheduling.utils.JobDescription; 
    5 import gssim.schedframe.scheduling.utils.TaskDescription; 
    64 
    75import java.util.List; 
     6 
     7import dcworms.schedframe.scheduling.utils.JobDescription; 
     8import dcworms.schedframe.scheduling.utils.TaskDescription; 
    89 
    910import schedframe.scheduling.tasks.Job; 
  • DCWoRMS/trunk/build/classes/simulator/reader/ResourceReader.java

    r477 r539  
    1111import java.util.Deque; 
    1212import java.util.HashMap; 
     13import java.util.LinkedHashSet; 
    1314import java.util.LinkedList; 
    1415import java.util.List; 
    1516import java.util.Map; 
     17import java.util.Set; 
    1618 
    1719import org.exolab.castor.types.AnyNode; 
     
    5456        private String globalSchedulingPluginName; 
    5557         
     58        private Set<String> compResLayers; 
     59         
    5660        public ResourceReader(ConfigurationOptions options) throws IOException { 
    5761 
     
    5963                globalSchedulingPluginName = "example.globalplugin.GridFCFSRoundRobinPlugin"; 
    6064                prepareCalendar(); 
     65                compResLayers = new LinkedHashSet<String>(); 
    6166        } 
    6267 
     
    6469                        UnknownParameter { 
    6570 
    66                 //File file = new File("src/test/rewolucja/schemas/example/coolemall/example4.xml"); 
    6771                File file = new File(resDescFileName); 
    68                 //File file = new File("example/tomekp/experiment1/tomExp3.xml"); 
    69                 /*long s =System.currentTimeMillis(); 
    70                 System.out.println("start: "); 
    71                 List<Processor> list = new ArrayList<Processor>(); 
    72                 for(int i =0;i<3000000;i++){ 
    73                         schemas.ComputingResource compResDef = new schemas.ComputingResource(); 
    74                         compResDef.setName("a"+i); 
    75                         compResDef.setClazz("Processor"); 
    76                         CompResourceDescription resDesc = new CompResourceDescription(compResDef); 
    77                         Processor proc = new Processor(resDesc); 
    78                         list.add(proc); 
    79                 } 
    80                 long e = System.currentTimeMillis(); 
    81                 System.out.println("end: "); 
    82                 System.out.println(e-s);*/ 
    8372                Environment env = Environment.unmarshal(new FileReader(file)); 
    8473                 
     
    9786                ResourceController rc = new ResourceController(mainScheduler, computingResources); 
    9887                rc.setInitList(toInit); 
     88                rc.setCompResLayers(compResLayers); 
    9989                return rc; 
    10090        } 
     
    177167 
    178168                List<ComputingResource> mainCompResourceList = new ArrayList<ComputingResource>(); 
    179                  
    180169                Deque<ComputingResourceDescription> toExamine = new ArrayDeque<ComputingResourceDescription>(); 
    181170                Deque<ComputingResource> resStructure = new ArrayDeque<ComputingResource>(); 
     
    192181                        ComputingResource parentResource = resStructure.pop(); 
    193182                        toInit.add(parentResource); 
     183                        compResLayers.add(parentResource.getType().getName()); 
    194184                        List<AbstractResourceDescription> childrenResDesc = parentResDesc.getChildren(); 
    195185                        if (childrenResDesc == null){ 
     
    250240                //TODO - refactor (remove - create scheduler on the basis of resource description) 
    251241                Scheduler mainScheduler = null; 
    252                 if(mainSchedulers.size() == 1 && mainSchedulers.get(0).get_name().equals("grid")){ 
     242                if(mainSchedulers.size() == 1 /*&& mainSchedulers.get(0).get_name().equals("grid")*/){ 
    253243                        mainScheduler = mainSchedulers.get(0); 
    254244                } 
     
    261251                        ManagedResources managedResources = new ManagedResources(mainCompResourceList, new HashMap<ResourceUnitName, List<ResourceUnit>>()); 
    262252                        mainScheduler = ResourceFactory.createScheduler(StandardResourceType.GS, "grid", schedulingPlugin , execTimeEstimationPlugin,  queues, managedResources); 
    263                         /*ManagementSystem ms = new GridBroker("grid", 
    264                                         globalSchedulingPluginName, execTimeEstimationPlugin); 
    265                         mainScheduler = new Scheduler(ms, mainCompResourceList);*/ 
     253 
    266254                        for(Scheduler lr: mainSchedulers){ 
    267255                                mainScheduler.addChild(lr); 
     
    280268                TaskQueueList queues = new TaskQueueList(1); 
    281269                 
    282                 if(schedulerDef.getQueue() != null && schedulerDef.getQueueCount() > 0){ 
    283                         int queueCount = schedulerDef.getQueueCount(); 
     270                if(schedulerDef.getQueues()!= null){ 
     271                        int queueCount = schedulerDef.getQueues().getQueueCount(); 
    284272                        for(int i = 0; i < queueCount; i++){ 
    285                                 schemas.QueueType queueDef = schedulerDef.getQueue(i); 
     273                                schemas.QueueType queueDef = schedulerDef.getQueues().getQueue(i); 
    286274                                TaskQueue queue = new TaskQueue(queueDef.getReservation()); 
    287275                                queue.setName(queueDef.getName()); 
  • DCWoRMS/trunk/build/classes/simulator/stats/AccumulatedStatistics.java

    r477 r539  
    1010import java.util.List; 
    1111 
    12 import simulator.stats.implementation.GSSimStatistics; 
     12import simulator.stats.implementation.DCWormsStatistics; 
    1313import gridsim.Accumulator; 
    1414 
  • DCWoRMS/trunk/build/classes/simulator/stats/implementation/GSSAccumulatorsStats.java

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

    r477 r539  
    11package simulator.stats.implementation; 
    22 
    3 import java.util.Map; 
    4 import java.util.TreeMap; 
    5  
    63import schedframe.resources.ResourceType; 
    7 import schedframe.resources.StandardResourceType; 
    84import simulator.stats.implementation.out.StatsSerializer; 
    95 
    10 /** 
    11  *  
    12  * @author Marcin Krystek 
    13  *  
    14  */ 
    15 public class ResourceUsageStats implements StatsInterface { 
     6public class ResourceUsageStats extends ResourceDynamicStats implements StatsInterface { 
    167 
    17         protected Map<Long, Integer> usage; 
    18         protected String resourceName; 
    19         protected String usageType; 
    20         protected ResourceType resourceType; 
    21         protected double meanUsage; 
    22          
    23         public void setMeanUsage(double meanUsage) { 
    24                 this.meanUsage = meanUsage; 
    25         } 
    26  
    27         private String[] headers = { "resourceName", "timestamp", "usage" }; 
     8        private String[] headers = { "resourceName", "timestamp", "utilization" }; 
    289 
    2910        public ResourceUsageStats(String resourceName, ResourceType resourceType, String usageType) { 
    30                 this.resourceName = resourceName; 
    31                 this.resourceType = resourceType; 
    32                 this.usageType = usageType; 
    33                 this.usage = new TreeMap<Long, Integer>(); 
    34                 this.meanUsage = 0; 
    35         } 
    36  
    37         public double getMeanUsage() { 
    38                 return meanUsage; 
    39         } 
    40  
    41         public String getResourceName() { 
    42                 return this.resourceName; 
    43         } 
    44          
    45         public ResourceType getResourceType() { 
    46                 return resourceType; 
    47         } 
    48          
    49         public String getUsageType() { 
    50                 return this.usageType; 
    51         }        
    52  
    53         public Map<Long, Integer> getUsage() { 
    54                 return this.usage; 
     11                super(resourceName, resourceType, usageType); 
    5512        } 
    5613 
     
    6219                return headers; 
    6320        } 
    64  
    6521} 
  • DCWoRMS/trunk/build/classes/simulator/stats/implementation/TaskStats.java

    r477 r539  
    11package simulator.stats.implementation; 
    22 
    3 import gssim.schedframe.scheduling.Executable; 
    43 
    54import java.util.List; 
     5 
     6import dcworms.schedframe.scheduling.Executable; 
    67 
    78import simulator.stats.implementation.out.StatsSerializer; 
     
    4546 
    4647        public String getUserDN() { 
    47                 return this.task.getUserDn(); 
     48                return this.task.getUserDN(); 
    4849        } 
    4950 
    5051        public String getResName() { 
    51                 String resNames[] = this.task.getAllResourceName(); 
    52                 String resName = ""; 
    53                 for (int i = 0; i < resNames.length; i++) { 
    54                         resName += resNames[i]; 
    55                         if (resNames.length > 1) 
    56                                 resName += " "; 
    57                 } 
     52                String resName = this.task.getSchedulerName(); 
     53 
    5854                return resName; 
    5955        } 
  • DCWoRMS/trunk/build/classes/simulator/stats/implementation/out/StatsSerializer.java

    r477 r539  
    44import simulator.stats.implementation.GSSAccumulatorsStats; 
    55import simulator.stats.implementation.JobStats; 
    6 import simulator.stats.implementation.ResourceEnergyStats; 
     6import simulator.stats.implementation.ResourceAirFlowStats; 
     7import simulator.stats.implementation.ResourcePowerStats; 
    78import simulator.stats.implementation.ResourceStats; 
    89import simulator.stats.implementation.ResourceUsageStats; 
     
    2627        public Object visit(ResourceUsageStats arg); 
    2728         
    28         public Object visit(ResourceEnergyStats arg); 
     29        public Object visit(ResourcePowerStats arg); 
    2930 
     31        public Object visit(ResourceAirFlowStats arg); 
    3032         
    3133        public Object visit(GSSAccumulatorsStats arg); 
  • DCWoRMS/trunk/build/classes/simulator/stats/implementation/out/StringSerializer.java

    r477 r539  
    1111import simulator.stats.implementation.GSSAccumulatorsStats; 
    1212import simulator.stats.implementation.JobStats; 
    13 import simulator.stats.implementation.ResourceEnergyStats; 
     13import simulator.stats.implementation.ResourceAirFlowStats; 
     14import simulator.stats.implementation.ResourcePowerStats; 
    1415import simulator.stats.implementation.ResourceStats; 
    1516import simulator.stats.implementation.ResourceUsageStats; 
     
    258259 
    259260        public Object visit(ResourceUsageStats resourceUsageStats) { 
    260                 Map<Long, Integer> resourceUsage = resourceUsageStats.getUsage(); 
     261                Map<Long, Double> resourceUsage = resourceUsageStats.getHistory(); 
    261262                 
    262263                int mapSize = resourceUsage.size(); 
     
    297298                        buffer.append(resourceUsageStats.getResourceName()); 
    298299                        buffer.append(fieldSeparator); 
    299                         Integer value = resourceUsage.get(timestamp); 
     300                        Double value = resourceUsage.get(timestamp); 
    300301                        buffer.append(timestamp); 
    301302                        buffer.append(fieldSeparator); 
     
    306307 
    307308                } 
    308  
    309                 buffer.append("mean: " + resourceUsageStats.getMeanUsage()); 
    310                 buffer.append(System.getProperty("line.separator")); 
    311                 return buffer.toString(); 
    312         } 
    313  
    314         public Object visit(ResourceEnergyStats resourceEnergyStats) { 
    315                 Map<Long, Double> resourceEnergy = resourceEnergyStats.getEnergy(); 
     309                if(resourceUsage.size() > 0){ 
     310                        buffer.append("mean: " + resourceUsageStats.getMeanValue()); 
     311                        buffer.append(System.getProperty("line.separator"));     
     312                } 
     313                return buffer.toString(); 
     314        } 
     315 
     316        public Object visit(ResourcePowerStats resourceEnergyStats) { 
     317                Map<Long, Double> resourceEnergy = resourceEnergyStats.getHistory(); 
    316318                 
    317319                int mapSize = resourceEnergy.size(); 
     
    361363 
    362364                } 
    363                 buffer.append("mean: "+resourceEnergyStats.getMeanUsage() + " sum: " +resourceEnergyStats.getSumUsage()); 
    364                 buffer.append(System.getProperty("line.separator")); 
     365                 
     366                if(resourceEnergy.size() > 0) { 
     367                        buffer.append("mean: "+resourceEnergyStats.getMeanValue() + " sum: " +resourceEnergyStats.getSumValue()); 
     368                        buffer.append(System.getProperty("line.separator"));     
     369                } 
     370 
     371                return buffer.toString(); 
     372        } 
     373 
     374        public Object visit(ResourceAirFlowStats resourceAirFlowStats) { 
     375                Map<Long, Double> resourceAirFlow = resourceAirFlowStats.getHistory(); 
     376                 
     377                int mapSize = resourceAirFlow.size(); 
     378                /* 
     379                 * FIXME: 
     380                 * Integer.MAX_VALUE = 2147483647. We assume, that each line contains  
     381                 * max 30 signs - this gives max 71582788 lines. If resourceUsage map 
     382                 * contains more elements then we have a problem, because content of 
     383                 * resourceUsage map will not fit in the buffer. 
     384                 * This will need further attention in the future. 
     385                 */ 
     386                int maxSize = (Integer.MAX_VALUE / 30 ) - 1; 
     387                if(mapSize >= maxSize){ 
     388                        log.error("Resource usage data is to long to fit in the buffer."); 
     389                        return null; 
     390                } 
     391                 
     392                int size = 30 * resourceAirFlow.size(); 
     393                 
     394                StringBuffer buffer = null; 
     395 
     396                if(printedHeaders.add(resourceAirFlowStats.getUsageType())) { 
     397                        buffer = new StringBuffer(size + 42); 
     398                        String[] headers = resourceAirFlowStats.getHeaders(); 
     399                        for(int i = 0; i < headers.length; i++) 
     400                        { 
     401                                buffer.append(headers[i]); 
     402                                buffer.append(fieldSeparator); 
     403                        } 
     404                        buffer.append(System.getProperty("line.separator")); 
     405                } else { 
     406                        buffer = new StringBuffer(size); 
     407                } 
     408                 
     409                 
     410                for (Long timestamp : resourceAirFlow.keySet()) { 
     411                         
     412                        buffer.append(resourceAirFlowStats.getResourceName()); 
     413                        buffer.append(fieldSeparator); 
     414                        Double value = resourceAirFlow.get(timestamp); 
     415                        buffer.append(timestamp); 
     416                        buffer.append(fieldSeparator); 
     417                        buffer.append(DataCenterWorkloadSimulator.DFAULT_NUMBER_FORMAT 
     418                                        .format(value)); 
     419                        buffer.append(fieldSeparator); 
     420                        buffer.append(System.getProperty("line.separator")); 
     421 
     422                } 
     423                 
     424                if(resourceAirFlow.size() > 0) { 
     425                        buffer.append("mean: "+resourceAirFlowStats.getMeanValue() + " sum: " +resourceAirFlowStats.getSumValue()); 
     426                        buffer.append(System.getProperty("line.separator"));     
     427                } 
    365428 
    366429                return buffer.toString(); 
  • DCWoRMS/trunk/build/classes/simulator/utils/XsltTransformations.java

    r477 r539  
    11package simulator.utils; 
    22 
    3 import gssim.schedframe.scheduling.utils.JobDescription; 
    4 import gssim.schedframe.scheduling.utils.TaskDescription; 
    53 
    64import java.io.IOException; 
     
    2018import javax.xml.transform.stream.StreamSource; 
    2119import javax.xml.xpath.XPathExpressionException; 
     20 
     21import dcworms.schedframe.scheduling.utils.JobDescription; 
     22import dcworms.schedframe.scheduling.utils.TaskDescription; 
    2223 
    2324/** 
  • DCWoRMS/trunk/build/classes/simulator/workload/WorkloadLoader.java

    r477 r539  
    22 
    33import org.qcg.broker.schemas.jobdesc.QcgJob; 
    4 import gssim.schedframe.scheduling.utils.JobDescription; 
    5 import gssim.schedframe.scheduling.utils.TaskDescription; 
    64 
    75import java.io.IOException; 
     
    2422import org.exolab.castor.xml.MarshalException; 
    2523import org.exolab.castor.xml.ValidationException; 
     24 
     25import dcworms.schedframe.scheduling.utils.JobDescription; 
     26import dcworms.schedframe.scheduling.utils.TaskDescription; 
    2627 
    2728 
  • DCWoRMS/trunk/build/classes/simulator/workload/generator/impl/QcgJobGenerator.java

    r477 r539  
    5858import org.xml.sax.InputSource; 
    5959 
    60 import simulator.WormsConstants; 
     60import simulator.DCWormsConstants; 
    6161import simulator.utils.GSSimXML; 
    6262import simulator.utils.XsltTransformations; 
     
    259259                         
    260260                        //initially - a standard value 
    261                         taskCountToBeGenerated = WormsConstants.DEFAULT_TASK_COUNT_IN_SINGLE_JOB;  
     261                        taskCountToBeGenerated = DCWormsConstants.DEFAULT_TASK_COUNT_IN_SINGLE_JOB;  
    262262                         
    263263                        try { 
Note: See TracChangeset for help on using the changeset viewer.