Changeset 539 for DCWoRMS/trunk
- Timestamp:
- 10/31/12 13:52:06 (12 years ago)
- Location:
- DCWoRMS/trunk/build/classes
- Files:
-
- 85 added
- 168 edited
Legend:
- Unmodified
- Added
- Removed
-
DCWoRMS/trunk/build/classes/example/energy/BaseEnergyEstimationPlugin.java
r477 r539 31 31 32 32 @Override 33 public double estimate EnergyDissipation(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resourceManager) {33 public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resourceManager) { 34 34 throw new RuntimeException("Not implemented."); 35 35 } … … 44 44 } 45 45 46 public String getName() { 47 return getClass().getName(); 48 } 46 49 } -
DCWoRMS/trunk/build/classes/example/energy/CPUEnergyEstimationPlugin.java
r477 r539 1 1 package example.energy; 2 2 3 import schedframe.resources.ResourceStatus;4 3 import schedframe.resources.computing.ComputingResource; 5 4 import schedframe.resources.computing.Processor; … … 14 13 ComputingResource resource) { 15 14 Processor cpu = (Processor)resource; 16 if(resource.getPowerInterface().getPowerState(). getName().equals(StandardPowerStateName.OFF))15 if(resource.getPowerInterface().getPowerState().equals(StandardPowerStateName.OFF)) 17 16 return 0; 18 if(resource.getStatus() == ResourceStatus.BUSY)17 else { 19 18 try { 20 19 return cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPState()); 21 20 } catch (NoSuchFieldException e) { 22 return 0; 21 try { 22 return cpu.getPowerInterface().getPowerConsumption(StandardPowerStateName.ON); 23 } catch (NoSuchFieldException e1) { 24 } 23 25 } 24 else 25 return 1; 26 return 1; 27 } 28 26 29 } 27 30 28 public String getName() {29 return getClass().getName();30 }31 32 33 31 } -
DCWoRMS/trunk/build/classes/example/energy/ComputingNodeEnergyEstimationPlugin.java
r477 r539 17 17 try{ 18 18 power = power + cpu.getPowerInterface().getRecentPowerUsage().getValue(); 19 } catch (Exception e){20 //power = power + cpu.getPowerInterface().getPowerConsumption(cpu.getPowerInterface().getPowerState());19 } catch (Exception e){ 20 21 21 } 22 22 } 23 24 23 try { 25 power +=node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState());24 power = power + node.getPowerInterface().getPowerConsumption(node.getPowerInterface().getPowerState()); 26 25 } catch (NoSuchFieldException e) { 27 26 } … … 30 29 } 31 30 32 public String getName() {33 return getClass().getName();34 }35 31 36 32 } -
DCWoRMS/trunk/build/classes/example/energy/DataCenterEnergyEstimationPlugin.java
r477 r539 18 18 power += (powerUsage == null ? 0 : powerUsage.getValue()); 19 19 } 20 21 //System.out.println( new DateTime() + "ENERGY CONSUMPT BY: " + resMan.getResourceName() +" IS: " + power); 20 22 21 return power; 23 22 } 24 23 25 public String getName() {26 return getClass().getName();27 }28 29 24 } -
DCWoRMS/trunk/build/classes/example/globalplugin/BaseGlobalPlugin.java
r477 r539 4 4 import schedframe.PluginConfiguration; 5 5 import schedframe.events.scheduling.SchedulingEventType; 6 import schedframe.scheduling. WorkloadUnitListImpl;6 import schedframe.scheduling.TaskList; 7 7 import schedframe.scheduling.manager.resources.ResourceManager; 8 8 import schedframe.scheduling.plugin.SchedulingPluginConfiguration; … … 11 11 import schedframe.scheduling.queue.TaskQueue; 12 12 import schedframe.scheduling.queue.TaskQueueList; 13 import schedframe.scheduling.tasks. WorkloadUnit;13 import schedframe.scheduling.tasks.TaskInterface; 14 14 import schemas.StringValueWithUnit; 15 15 … … 22 22 } 23 23 24 public int place JobsInQueues(WorkloadUnitListImpl newJobs, TaskQueueList queues, ResourceManager resourceManager,24 public int placeTasksInQueues(TaskList newTasks, TaskQueueList queues, ResourceManager resourceManager, 25 25 ModuleList moduleList) { 26 26 … … 28 28 TaskQueue queue = queues.get(0); 29 29 30 for (int i = 0; i < new Jobs.size(); i++) {31 WorkloadUnit<?> task = newJobs.get(i);30 for (int i = 0; i < newTasks.size(); i++) { 31 TaskInterface<?> task = newTasks.get(i); 32 32 queue.add(task); 33 33 } … … 46 46 } 47 47 48 public String getName() { 49 return getClass().getName(); 50 } 48 51 49 52 } -
DCWoRMS/trunk/build/classes/example/globalplugin/GridFCFSLoadBalancingPlugin.java
r477 r539 19 19 import schedframe.scheduling.plugin.grid.ModuleList; 20 20 import schedframe.scheduling.plugin.grid.ResourceDiscovery; 21 import schedframe.scheduling.queue.QueueDescription; 21 22 import schedframe.scheduling.queue.TaskQueue; 22 import schedframe.scheduling.queue.QueueDescription;23 23 import schedframe.scheduling.queue.TaskQueueList; 24 24 import schedframe.scheduling.tasks.TaskInterface; … … 29 29 private Log log = LogFactory.getLog(GridFCFSLoadBalancingPlugin.class); 30 30 31 public SchedulingPlanInterface schedule(SchedulingEvent event,31 public SchedulingPlanInterface<?> schedule(SchedulingEvent event, 32 32 TaskQueueList queues, 33 33 JobRegistry jobRegistry, … … 53 53 54 54 for(int i = 0; i < size; i++) { 55 WorkloadUnit <?>job = q.remove(0);55 WorkloadUnit job = q.remove(0); 56 56 TaskInterface<?> task = (TaskInterface<?>)job; 57 57 … … 74 74 } 75 75 76 public String getName() {77 return getClass().getName();78 }79 80 public void init(Properties properties) {81 // no extra initialization is expected.82 }83 84 76 private int findLeastLoadedResourceIdx(List<SchedulerDescription> availableResources){ 85 86 77 int resourceIdx = -1; 87 78 long minLoad = Long.MAX_VALUE; 79 88 80 for(int i = 0; i < availableResources.size(); i++){ 89 81 SchedulerDescription sd = availableResources.get(i); -
DCWoRMS/trunk/build/classes/example/globalplugin/GridFCFSRandomPlugin.java
r477 r539 53 53 54 54 for(int i = 0; i < size; i++) { 55 WorkloadUnit <?>job = q.remove(0);55 WorkloadUnit job = q.remove(0); 56 56 TaskInterface<?> task = (TaskInterface<?>)job; 57 57 … … 75 75 } 76 76 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 86 77 } -
DCWoRMS/trunk/build/classes/example/globalplugin/GridFCFSRoundRobinPlugin.java
r477 r539 47 47 48 48 for(int i = 0; i < size; i++) { 49 WorkloadUnit <?>job = q.remove(0);49 WorkloadUnit job = q.remove(0); 50 50 TaskInterface<?> task = (TaskInterface<?>)job; 51 51 … … 65 65 allocation.setProcessesCount(1); 66 66 allocation.setProviderName(sd.getProvider().getProviderId()); 67 System.out.println("----" + sd.getProvider().getProviderId());68 67 ScheduledTask scheduledTask = new ScheduledTask(task); 69 68 scheduledTask.setTaskId(task.getId()); … … 76 75 } 77 76 78 public String getName() {79 return getClass().getName();80 }81 82 83 77 } -
DCWoRMS/trunk/build/classes/example/localplugin/FCFSCPUFreqScalingClusterLocalPlugin.java
r477 r539 1 1 package example.localplugin; 2 2 3 import gridsim. Gridlet;3 import gridsim.dcworms.DCWormsTags; 4 4 5 5 import java.util.ArrayList; … … 18 18 import schedframe.resources.units.ResourceUnitName; 19 19 import schedframe.resources.units.StandardResourceUnitName; 20 import schedframe.scheduling.ResourceHistoryItem; 21 import schedframe.scheduling.UsedResourceList; 20 import schedframe.scheduling.UsedResourcesList; 22 21 import schedframe.scheduling.manager.resources.ClusterResourceManager; 23 22 import schedframe.scheduling.manager.resources.ResourceManager; … … 28 27 import schedframe.scheduling.queue.TaskQueue; 29 28 import schedframe.scheduling.queue.TaskQueueList; 30 import schedframe.scheduling.tasks.SubmittedTask;31 29 import schedframe.scheduling.tasks.TaskInterface; 32 30 import schedframe.scheduling.tasks.WorkloadUnit; 31 import dcworms.schedframe.scheduling.Executable; 33 32 34 public class FCFSCPUFreqScalingClusterLocalPlugin extends BaseLocal Plugin {33 public class FCFSCPUFreqScalingClusterLocalPlugin extends BaseLocalSchedulingPlugin { 35 34 36 35 List<Processor> allocatedCPUs; … … 39 38 } 40 39 41 public SchedulingPlanInterface schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,40 public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 42 41 ResourceManager resManager, ModuleList modules) { 43 42 … … 55 54 // check all tasks in queue 56 55 for (int i = 0; i < q.size(); i++) { 57 WorkloadUnit <?>job = q.get(i);56 WorkloadUnit job = q.get(i); 58 57 TaskInterface<?> task = (TaskInterface<?>) job; 59 58 // if status of the tasks in READY 60 if (task.getStatus() == Gridlet.READY) {59 if (task.getStatus() == DCWormsTags.READY) { 61 60 62 61 Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); … … 76 75 case TASK_FINISHED: 77 76 TaskFinishedEvent finEvent = (TaskFinishedEvent) event; 78 SubmittedTask subTask = (SubmittedTask )jobRegistry.getSubmittedTask(finEvent.getJobId(), finEvent.getTaskId());79 UsedResource List<ResourceHistoryItem> usedResourcesList = subTask.getUsedResources();77 Executable exec = (Executable) jobRegistry.getExecutable(finEvent.getJobId(), finEvent.getTaskId()); 78 UsedResourcesList usedResourcesList = exec.getUsedResources(); 80 79 ProcessingElements pes = (ProcessingElements)usedResourcesList.getLast().getResourceUnits().get(StandardResourceUnitName.PE); 81 80 List<Processor> processors = new ArrayList<Processor>(); … … 89 88 case TASK_REQUESTED_TIME_EXPIRED: 90 89 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(); 93 92 pes = (ProcessingElements)usedResourcesList.getLast().getResourceUnits().get(StandardResourceUnitName.PE); 94 93 processors = new ArrayList<Processor>(); … … 98 97 // check all tasks in queue 99 98 for (int i = 0; i < q.size(); i++) { 100 WorkloadUnit <?>job = q.get(i);99 WorkloadUnit job = q.get(i); 101 100 TaskInterface<?> task = (TaskInterface<?>) job; 102 101 // if status of the tasks in READY 103 if (task.getStatus() == Gridlet.READY) {102 if (task.getStatus() == DCWormsTags.READY) { 104 103 105 104 Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); … … 188 187 } 189 188 } 190 191 public String getName() {192 return getClass().getName();193 }194 189 195 190 } -
DCWoRMS/trunk/build/classes/example/localplugin/FCFSClusterLocalPlugin.java
r477 r539 1 1 package example.localplugin; 2 2 3 import gridsim. Gridlet;3 import gridsim.dcworms.DCWormsTags; 4 4 5 5 import java.util.ArrayList; … … 31 31 import schedframe.scheduling.tasks.WorkloadUnit; 32 32 33 public class FCFSClusterLocalPlugin extends BaseLocal Plugin {33 public class FCFSClusterLocalPlugin extends BaseLocalSchedulingPlugin { 34 34 35 35 public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, … … 49 49 50 50 for (int i = 0; i < q.size(); i++) { 51 WorkloadUnit <?>job = q.get(i);51 WorkloadUnit job = q.get(i); 52 52 TaskInterface<?> task = (TaskInterface<?>) job; 53 53 // if status of the tasks in READY 54 if (task.getStatus() == Gridlet.READY) {54 if (task.getStatus() == DCWormsTags.READY) { 55 55 56 56 /****************3 ways to schedule task****************/ 57 57 58 58 /****************1. Choosing particular resources to perform execution****************/ 59 Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution 2(resourceManager, task);59 Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); 60 60 if (choosenResources != null) { 61 61 addToSchedulingPlan(plan, task, choosenResources); … … 80 80 81 81 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(150 82 ClusterResourceManager resourceManager, TaskInterface<?> task) { 151 83 … … 178 110 } 179 111 180 ProcessingElements result = new ProcessingElements( processors.get(0).getParent().getName());112 ProcessingElements result = new ProcessingElements(); 181 113 result.addAll(choosenResources); 182 114 map.put(StandardResourceUnitName.PE, result); … … 204 136 return map; 205 137 } 206 } 138 } else return map; 207 139 } 208 140 } … … 221 153 } 222 154 223 public String getName() {224 return getClass().getName();225 }226 227 155 } -
DCWoRMS/trunk/build/classes/example/localplugin/FCFSConsolidationClusterLocalPlugin.java
r477 r539 1 1 package example.localplugin; 2 2 3 import gridsim. Gridlet;3 import gridsim.dcworms.DCWormsTags; 4 4 5 5 import java.util.ArrayList; … … 30 30 import schedframe.scheduling.tasks.WorkloadUnit; 31 31 32 public class FCFSConsolidationClusterLocalPlugin extends BaseLocal Plugin {32 public class FCFSConsolidationClusterLocalPlugin extends BaseLocalSchedulingPlugin { 33 33 34 34 public FCFSConsolidationClusterLocalPlugin () { 35 35 } 36 36 37 public SchedulingPlanInterface schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,37 public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 38 38 ResourceManager resManager, ModuleList modules) { 39 39 … … 51 51 52 52 for (int i = 0; i < q.size(); i++) { 53 WorkloadUnit <?>job = q.get(i);53 WorkloadUnit job = q.get(i); 54 54 TaskInterface<?> task = (TaskInterface<?>) job; 55 55 // if status of the tasks in READY 56 if (task.getStatus() == Gridlet.READY) {56 if (task.getStatus() == DCWormsTags.READY) { 57 57 58 58 Map<ResourceUnitName, ResourceUnit> choosenResources = null; … … 140 140 return suitableNodes; 141 141 } 142 143 public String getName() {144 return getClass().getName();145 }146 142 147 143 } -
DCWoRMS/trunk/build/classes/example/localplugin/FCFSNodePowerManagementClusterLocalPlugin.java
r477 r539 1 1 package example.localplugin; 2 2 3 import gridsim. Gridlet;3 import gridsim.dcworms.DCWormsTags; 4 4 5 5 import java.util.ArrayList; … … 30 30 import schedframe.scheduling.tasks.WorkloadUnit; 31 31 32 public class FCFSNodePowerManagementClusterLocalPlugin extends BaseLocal Plugin {32 public class FCFSNodePowerManagementClusterLocalPlugin extends BaseLocalSchedulingPlugin { 33 33 34 34 public FCFSNodePowerManagementClusterLocalPlugin () { 35 35 } 36 36 37 public SchedulingPlanInterface schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,37 public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 38 38 ResourceManager resManager, ModuleList modules) { 39 39 40 40 ClusterResourceManager resourceManager = (ClusterResourceManager) resManager; 41 41 SchedulingPlan plan = new SchedulingPlan(); 42 // chose the events types to serve. 43 // Different actions for different events are possible. 42 44 43 switch (event.getType()) { 45 44 case START_TASK_EXECUTION: 46 45 case TASK_FINISHED: 47 // our tasks are placed only in first queue (see 48 // BaseLocalPlugin.placeJobsInQueues() method) 46 49 47 TaskQueue q = queues.get(0); 50 // check all tasks in queue51 48 52 49 for (int i = 0; i < q.size(); i++) { 53 WorkloadUnit <?>job = q.get(i);50 WorkloadUnit job = q.get(i); 54 51 TaskInterface<?> task = (TaskInterface<?>) job; 55 // if status of the tasks in READY 56 if (task.getStatus() == Gridlet.READY) { 52 if (task.getStatus() == DCWormsTags.READY) { 57 53 58 54 Map<ResourceUnitName, ResourceUnit> choosenResources = chooseResourcesForExecution(resourceManager, task); … … 65 61 } 66 62 } 67 68 63 turnOffIdleNodes(resourceManager.getComputingNodes()); 69 70 64 break; 71 65 } … … 151 145 return cpuRequest > 0 ? false : true; 152 146 } 153 154 public String getName() {155 return getClass().getName();156 }157 158 147 159 148 } -
DCWoRMS/trunk/build/classes/example/localplugin/FCFSRandomClusterLocalPlugin.java
r477 r539 1 1 package example.localplugin; 2 2 3 import gridsim. Gridlet;3 import gridsim.dcworms.DCWormsTags; 4 4 5 5 import java.util.List; … … 19 19 import schedframe.scheduling.tasks.WorkloadUnit; 20 20 21 public class FCFSRandomClusterLocalPlugin extends BaseLocal Plugin {21 public class FCFSRandomClusterLocalPlugin extends BaseLocalSchedulingPlugin { 22 22 23 23 private Random rand; … … 41 41 // BaseLocalPlugin.placeJobsInQueues() method) 42 42 TaskQueue q = queues.get(0); 43 43 44 // check all tasks in queue 44 45 45 for (int i = 0; i < q.size(); i++) { 46 WorkloadUnit <?>job = q.get(i);46 WorkloadUnit job = q.get(i); 47 47 TaskInterface<?> task = (TaskInterface<?>) job; 48 48 // 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); 55 52 if (nodeName != null) { 56 53 addToSchedulingPlan(plan, task, nodeName); 57 } */54 } 58 55 } 59 56 } … … 68 65 return nodes.get(nodeIdx).getName(); 69 66 } 70 71 public String getName() {72 return getClass().getName();73 }74 75 67 76 68 } -
DCWoRMS/trunk/build/classes/example/localplugin/FCFS_BFLocalPlugin.java
r477 r539 1 1 package example.localplugin; 2 2 3 import gridsim. Gridlet;3 import gridsim.dcworms.DCWormsTags; 4 4 import schedframe.events.scheduling.SchedulingEvent; 5 5 import schedframe.scheduling.manager.resources.ResourceManager; 6 6 import schedframe.scheduling.manager.tasks.JobRegistry; 7 import schedframe.scheduling.plan.SchedulingPlanInterface;8 7 import schedframe.scheduling.plan.impl.SchedulingPlan; 9 8 import schedframe.scheduling.plugin.grid.ModuleList; … … 13 12 import schedframe.scheduling.tasks.WorkloadUnit; 14 13 15 public class FCFS_BFLocalPlugin extends BaseLocal Plugin {14 public class FCFS_BFLocalPlugin extends BaseLocalSchedulingPlugin { 16 15 17 public SchedulingPlan Interface<?>schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,16 public SchedulingPlan schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry, 18 17 ResourceManager resManager, ModuleList modules) { 19 18 20 19 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. 23 21 switch (event.getType()) { 24 22 case START_TASK_EXECUTION: 25 23 case TASK_FINISHED: 26 //case TIMER:24 27 25 // our tasks are placed only in first queue (see BaseLocalPlugin.placeJobsInQueues() method) 26 TaskQueue q = queues.get(0); 28 27 29 TaskQueue q = queues.get(0);30 28 // check all tasks in queue 31 29 for (int i = 0; i < q.size(); i++) { 32 WorkloadUnit <?>job = q.get(i);30 WorkloadUnit job = q.get(i); 33 31 TaskInterface<?> task = (TaskInterface<?>) job; 34 32 35 33 // if status of the tasks in READY 36 if (task.getStatus() == Gridlet.READY) {34 if (task.getStatus() == DCWormsTags.READY) { 37 35 addToSchedulingPlan(plan, task); 38 36 } … … 43 41 } 44 42 45 public String getName() {46 return getClass().getName();47 }48 49 50 43 } 51 44 -
DCWoRMS/trunk/build/classes/example/timeestimation/DefaultTimeEstimationPlugin.java
r477 r539 1 1 package example.timeestimation; 2 2 3 import gssim.schedframe.scheduling.ExecTask;4 3 5 4 import java.util.Map; 6 5 7 import schedframe.Parameters;8 import schedframe.PluginConfiguration; 6 import dcworms.schedframe.scheduling.ExecTask; 7 9 8 import schedframe.events.scheduling.SchedulingEvent; 10 9 import schedframe.resources.units.PEUnit; … … 16 15 /** 17 16 * 18 * @author Marcin Krystek 17 * @author Marcin Krystek && Wojciech Piatek 19 18 * 20 19 */ 21 public class DefaultTimeEstimationPlugin implements schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin{ 20 21 public class DefaultTimeEstimationPlugin extends BaseTimeEstimationPlugin{ 22 22 23 23 /* 24 24 * This method should return an estimation of time required to execute the task. 25 25 * 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. 27 27 * 28 28 * Example implementation calculate the estimation based on cpu processing power. … … 30 30 * of number of allocated cpus and their speed. 31 31 */ 32 public double execTimeEstimation(SchedulingEvent event, 32 public double execTimeEstimation(SchedulingEvent event, ExecTask task, 33 33 Map<ResourceUnitName, ResourceUnit> allocatedResources, 34 ExecTask task,double completionPercentage) {34 double completionPercentage) { 35 35 36 36 // collect all information necessary to do the calculation … … 43 43 int cnt = peUnit.getUsedAmount(); 44 44 45 double remainingLength = task.getLength() * (1- completionPercentage); 45 // estimate remainingTaskLength 46 double remainingLength = task.getLength() * (1 - completionPercentage/100); 47 46 48 // do the calculation 47 49 double execTime = (remainingLength / (cnt * speed)); … … 57 59 } 58 60 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 70 61 } -
DCWoRMS/trunk/build/classes/org/joda/time/VCMilisProvider.java
r477 r539 39 39 long vc = Math.round(Sim_system.clock()); 40 40 //System.out.println("SIMJAVA TIME: "+Sim_system.clock()); 41 //System.out.println("CLOUD TIME: "+GSSIM.clock());42 41 43 42 // change virtual seconds to milliseconds -
DCWoRMS/trunk/build/classes/schedframe/Property.java
r477 r539 3 3 import java.util.ArrayList; 4 4 5 import schemas.StringValueWithUnit ;5 import schemas.StringValueWithUnitType; 6 6 7 public class Property extends ArrayList<StringValueWithUnit >{7 public class Property extends ArrayList<StringValueWithUnitType>{ 8 8 9 9 /** -
DCWoRMS/trunk/build/classes/schedframe/ResourceController.java
r477 r539 19 19 protected static List<ComputingResource> computingResources; 20 20 protected Deque<Initializable> toInit; 21 protected Set<String> compResLayers; 21 22 22 23 public ResourceController(Scheduler logicalStructure, List<ComputingResource> compResources){ … … 144 145 } 145 146 147 public Set<String> getComputingResourceLayers() { 148 return compResLayers; 149 } 150 151 public void setCompResLayers(Set<String> compResLayers) { 152 this.compResLayers = compResLayers; 153 } 154 155 146 156 } -
DCWoRMS/trunk/build/classes/schedframe/events/TaskEvent.java
r477 r539 7 7 public class TaskEvent { 8 8 9 protected WorkloadUnit <?>task;9 protected WorkloadUnit task; 10 10 protected String resourceName; 11 11 12 public TaskEvent(WorkloadUnit <?>task,12 public TaskEvent(WorkloadUnit task, 13 13 String resourceName) { 14 14 super(); … … 17 17 } 18 18 19 public WorkloadUnit <?>getTask() {19 public WorkloadUnit getTask() { 20 20 return task; 21 21 } -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/ComputingNode.java
r477 r539 10 10 import schedframe.resources.computing.extensions.ExtensionType; 11 11 import schedframe.resources.computing.profiles.energy.EnergyExtension; 12 import schedframe.resources.computing.profiles.energy.power.Power ProfileFactory;12 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 13 13 import schedframe.resources.computing.profiles.energy.power.ui.ComputingNodePowerInterface; 14 14 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; … … 26 26 27 27 //extensionList.add(new EnergyExtension(this, resDesc.getPowerInterface(), resDesc.getEnergyEstimationPlugin())); 28 PowerInterface pi = Power ProfileFactory.createPowerInterface(this, resDesc.getPowerProfile());28 PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 29 29 accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 30 30 } … … 39 39 40 40 public ComputingNodePowerInterface getPowerInterface(){ 41 ComputingNodePowerInterface power Profile = null;41 ComputingNodePowerInterface powerInterface = null; 42 42 if(extensionList.isExtensionAvailable(ExtensionType.ENERGY_EXTENSION)){ 43 43 EnergyExtension ee = (EnergyExtension)extensionList.getExtension(ExtensionType.ENERGY_EXTENSION); 44 power Profile = (ComputingNodePowerInterface)ee.getPowerInterface();44 powerInterface = (ComputingNodePowerInterface)ee.getPowerInterface(); 45 45 } 46 return power Profile;46 return powerInterface; 47 47 } 48 48 -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/ComputingResource.java
r477 r539 2 2 3 3 import gridsim.GridSimTags; 4 import gridsim. gssim.WormsTags;4 import gridsim.dcworms.DCWormsTags; 5 5 6 6 import java.util.ArrayList; … … 28 28 import schedframe.resources.computing.profiles.energy.EnergyEventType; 29 29 import schedframe.resources.computing.profiles.energy.EnergyExtension; 30 import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 30 31 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 31 32 import schedframe.resources.computing.properties.DefaultPropertiesBuilder; … … 68 69 } 69 70 70 //TODO remove if possible (check if all scenarios can be realized - statistics issue) , since it'stemporary method71 //TODO remove if possible (check if all scenarios can be realized - statistics issue), since it's a temporary method 71 72 private void addFakeProcessors() { 72 73 if(getResourceCharacteristic().getResourceUnits().get(StandardResourceUnitName.PE) != null){ … … 145 146 sec.execute(event); 146 147 147 148 148 //old, correctly working method 149 149 /*if (extensionList != null) { … … 157 157 //if(scheduler != null && (parent != null && scheduler != parent.getScheduler())/*scheduler.getResources().contains(this)*/){ 158 158 // 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); 160 160 //} 161 161 //triggerEventUp(event); … … 188 188 } 189 189 190 protected List<? extends ComputingResource> searchDescendants(List<ResourceValidator> validators, boolean cut off) {190 protected List<? extends ComputingResource> searchDescendants(List<ResourceValidator> validators, boolean cutOff) { 191 191 192 192 List<ComputingResource> descendants = new ArrayList<ComputingResource>(); … … 198 198 ComputingResource resource = toExamine.pop(); 199 199 List<ComputingResource> resources = resource.getChildren(); 200 /*if (resources == null)201 continue;*/202 200 int numberOfRes = resources.size(); 203 201 for (int i = 0; i < numberOfRes; i++) { … … 205 203 if (resourceChild.match(validators)) { 206 204 descendants.add(resourceChild); 207 if(cut off == false) {205 if(cutOff == false) { 208 206 toExamine.addLast(resourceChild); 209 207 } … … 243 241 return null; 244 242 } 243 244 public AirThroughputInterface getAirThroughputInterface(){ 245 if (extensionList != null) { 246 for (Extension extension : extensionList) { 247 if (extension.getType() == ExtensionType.ENERGY_EXTENSION) { 248 EnergyExtension ee = (EnergyExtension)extension; 249 return ee.getAirThroughputInterface(); 250 } 251 } 252 } 253 return null; 254 } 245 255 246 256 public Scheduler getScheduler() { … … 257 267 } 258 268 259 class SimpleEventHandler implements EventHandler{269 class ComputingResourceEventHandler implements EventHandler{ 260 270 261 271 public void handleResourceEvent(Event event){ … … 275 285 if(scheduler != null && (parent != null && scheduler != parent.getScheduler())/*scheduler.getResources().contains(this)*/){ 276 286 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); 278 288 } else if(parent != null) 279 289 parent.getEventHandler().handleSchedulingEvent(event); … … 282 292 283 293 public EventHandler getEventHandler(){ 284 return new SimpleEventHandler();294 return new ComputingResourceEventHandler(); 285 295 } 286 296 287 297 public void initiate(){ 298 288 299 ResourceEventCommand rec = new ResourceEventCommand(this); 289 EnergyEvent event = new EnergyEvent(EnergyEventType. POWER_STATE_CHANGED, "Resource controller");300 EnergyEvent event = new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller"); 290 301 event.setReason(EventReason.SIM_INIT); 291 302 rec.execute(event); 303 304 rec = new ResourceEventCommand(this); 305 event = new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller"); 306 event.setReason(EventReason.SIM_INIT); 307 rec.execute(event); 308 292 309 //alternative way 310 //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.AIRFLOW_STATE_CHANGED, "Resource controller")); 293 311 //getEventHandler().handleResourceEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, "Resource controller")); 294 312 } -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/Core.java
r477 r539 3 3 import schedframe.resources.computing.description.ComputingResourceDescription; 4 4 import schedframe.resources.computing.profiles.energy.EnergyExtension; 5 import schedframe.resources.computing.profiles.energy.power.Power ProfileFactory;5 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 6 6 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 7 7 import schedframe.resources.units.CpuSpeed; … … 13 13 public Core (ComputingResourceDescription resDesc) { 14 14 super(resDesc); 15 PowerInterface pi = Power ProfileFactory.createPowerInterface(this, resDesc.getPowerProfile());15 PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 16 16 accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 17 17 } -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/DataCenter.java
r477 r539 3 3 import schedframe.resources.computing.description.ComputingResourceDescription; 4 4 import schedframe.resources.computing.profiles.energy.EnergyExtension; 5 import schedframe.resources.computing.profiles.energy.power.Power ProfileFactory;5 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 6 6 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 7 7 … … 11 11 super(resDesc); 12 12 //extensionList.add(new EnergyExtension(this, resDesc.getPowerInterface(), resDesc.getEnergyEstimationPlugin())); 13 PowerInterface pi = Power ProfileFactory.createPowerInterface(this, resDesc.getPowerProfile());13 PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 14 14 accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 15 15 } -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/Processor.java
r477 r539 8 8 import schedframe.resources.computing.extensions.ExtensionType; 9 9 import schedframe.resources.computing.profiles.energy.EnergyExtension; 10 import schedframe.resources.computing.profiles.energy.power.Power ProfileFactory;10 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 11 11 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 12 12 import schedframe.resources.computing.profiles.energy.power.ui.ProcessorPowerInterface; … … 22 22 super(resDesc); 23 23 //extensionList.add(new EnergyExtension(this, resDesc.getPowerInterface(), resDesc.getEnergyEstimationPlugin())); 24 PowerInterface pi = Power ProfileFactory.createPowerInterface(this, resDesc.getPowerProfile());24 PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 25 25 accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 26 26 } -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/Rack.java
r477 r539 6 6 import schedframe.resources.computing.description.ComputingResourceDescription; 7 7 import schedframe.resources.computing.profiles.energy.EnergyExtension; 8 import schedframe.resources.computing.profiles.energy.power.Power ProfileFactory;8 import schedframe.resources.computing.profiles.energy.power.PowerInterfaceFactory; 9 9 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 10 10 … … 14 14 public Rack (ComputingResourceDescription resDesc) { 15 15 super(resDesc); 16 PowerInterface pi = Power ProfileFactory.createPowerInterface(this, resDesc.getPowerProfile());16 PowerInterface pi = PowerInterfaceFactory.createPowerInterface(this, resDesc.getPowerProfile()); 17 17 accept(new EnergyExtension(pi, resDesc.getPowerProfile())); 18 18 } -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/ResourceFactory.java
r477 r539 11 11 import schedframe.scheduling.policy.local.LocalManagementSystem; 12 12 import schedframe.scheduling.queue.TaskQueueList; 13 import simulator. WormsConstants;13 import simulator.DCWormsConstants; 14 14 15 15 … … 20 20 if (resDesc.getType().equals(StandardResourceType.DataCenter)) 21 21 return new DataCenter(resDesc); 22 else if (resDesc.getType().equals(StandardResourceType.Rack)) 23 return new Rack(resDesc); 22 24 else if (resDesc.getType().equals(StandardResourceType.ComputingNode)) 23 25 return new ComputingNode(resDesc); … … 46 48 } 47 49 case LS: { 48 ms = new LocalManagementSystem(id, WormsConstants.MANAGEMENT_SYSTEM,50 ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, 49 51 schedulingPlugin, execTimeEstimationPlugin, queues); 50 52 return new Scheduler(ms, type, managedResources); … … 52 54 53 55 default:{ 54 ms = new LocalManagementSystem(id, WormsConstants.MANAGEMENT_SYSTEM,56 ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, 55 57 schedulingPlugin, execTimeEstimationPlugin, queues); 56 58 return new Scheduler(ms, type, managedResources); -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/EnergyEventType.java
r477 r539 15 15 FREQUENCY_CHANGED(64), 16 16 VOLTAGE_CHANGED(128), 17 RESOURCE_FAILED(256) 17 18 AIRFLOW_STATE_CHANGED(256), 19 20 RESOURCE_FAILED(512) 18 21 ; 19 22 -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/EnergyExtension.java
r477 r539 11 11 import schedframe.resources.computing.extensions.ExtensionException; 12 12 import schedframe.resources.computing.extensions.ExtensionType; 13 import schedframe.resources.computing.profiles.energy.airthroughput.AirThroughputProfile; 14 import schedframe.resources.computing.profiles.energy.airthroughput.ui.AirThroughputInterface; 13 15 import schedframe.resources.computing.profiles.energy.power.PowerProfile; 14 16 import schedframe.resources.computing.profiles.energy.power.ui.PowerInterface; 15 17 import schedframe.scheduling.manager.tasks.JobRegistryImpl; 16 18 17 public class EnergyExtension implements Extension /*, ResourceVisitor */{19 public class EnergyExtension implements Extension{ 18 20 19 21 private Log log = LogFactory.getLog(EnergyExtension.class); … … 21 23 protected PowerInterface powerInterface; 22 24 protected PowerProfile powerProfile; 23 25 26 protected AirThroughputInterface airFlowInterface; 27 protected AirThroughputProfile airFlowProfile; 28 24 29 protected ComputingResource computingResource; 25 30 … … 29 34 } 30 35 31 @Override 36 public EnergyExtension(PowerInterface powerInterface, PowerProfile powerProfile, 37 AirThroughputInterface airFlowInterface, AirThroughputProfile airFlowProfile) { 38 super(); 39 this.powerInterface = powerInterface; 40 this.powerProfile = powerProfile; 41 this.airFlowInterface = airFlowInterface; 42 this.airFlowProfile = airFlowProfile; 43 } 44 32 45 public boolean supportsEvent(Event event) { 33 46 34 47 if(powerProfile == null || powerProfile.getEnergyEstimationPlugin() == null) 35 48 return false; 36 37 49 if(event.getType().getName().equals(EnergyEventType.POWER_STATE_CHANGED.getName())) 38 50 return true; … … 43 55 else if(event.getType().getName().equals(EnergyEventType.TASK_FINISHED.getName())) 44 56 return true; 57 58 if(airFlowProfile == null) 59 return false; 60 if(event.getType().getName().equals(EnergyEventType.AIRFLOW_STATE_CHANGED.getName())) 61 return true; 62 45 63 else return false; 46 64 47 65 } 48 49 66 50 @Override51 67 public void handleEvent(Event event) { 52 68 EnergyEvent enEvent = (EnergyEvent)event; … … 87 103 //System.out.println(this.resource.getName() + " - ESTIMATED ENERGY:" + power); 88 104 powerProfile.addToPowerUsageHistory(power); 89 105 break; 106 case AIRFLOW_STATE_CHANGED: 107 System.out.println("====="); 108 double airFlow = powerProfile.getEnergyEstimationPlugin().estimateAirThroughput(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 109 airFlowProfile.addToPowerUsageHistory(airFlow); 110 power = powerProfile.getEnergyEstimationPlugin().estimatePowerConsumption(enEvent, new JobRegistryImpl(computingResource.getName()), computingResource); 111 powerProfile.addToPowerUsageHistory(power); 90 112 break; 91 113 } 92 114 } 93 94 @Override 115 95 116 public void init(Properties properties) throws ExtensionException { 96 117 // TODO Auto-generated method stub 97 118 } 98 119 99 @Override100 120 public ExtensionType getType() { 101 121 return ExtensionType.ENERGY_EXTENSION; … … 118 138 } 119 139 140 public AirThroughputInterface getAirThroughputInterface() { 141 return airFlowInterface; 142 } 143 144 public AirThroughputProfile getAirFlowProfile() { 145 return airFlowProfile; 146 } 120 147 121 148 } -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/airthroughput/AirThroughputProfile.java
r477 r539 1 1 package schedframe.resources.computing.profiles.energy.airthroughput; 2 2 3 import java.util.ArrayList; 3 4 import java.util.List; 5 6 import org.joda.time.DateTimeUtils; 4 7 5 8 import schedframe.Parameters; … … 8 11 public class AirThroughputProfile { 9 12 10 AirThroughputEstimationPlugin airThroughputEstimationPlugin; 13 protected List<AirFlowValue> airFlowHistory; 14 15 protected AirThroughputEstimationPlugin airThroughputEstimationPlugin; 11 16 protected List <AirThroughputState> airThroughputStates; 17 protected Parameters parameters; 12 18 13 19 public AirThroughputProfile(AirThroughputEstimationPlugin airThroughputEstimationPlugin, List<AirThroughputState> airThroughputStates) { … … 15 21 this.airThroughputEstimationPlugin = airThroughputEstimationPlugin; 16 22 this.airThroughputStates = airThroughputStates; 23 this.airFlowHistory = new ArrayList<AirFlowValue>(); 17 24 } 18 25 … … 21 28 } 22 29 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; 25 64 } 26 65 } -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/power/PowerProfile.java
r477 r539 19 19 protected Map<String, PState> supportedPStates; 20 20 21 protected Parameters parameters; 22 21 23 22 public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List< schedframe.resources.computing.profiles.energy.power.PowerState> supportedPowerStates) {24 public PowerProfile(EnergyEstimationPlugin energyEstimationPlugin, List<PowerState> powerStates) { 23 25 this.energyEstimationPlugin = energyEstimationPlugin; 24 26 this.powerUsage = new ArrayList<PowerUsage>(); 25 this.supportedPowerStates = supportedPowerStates;27 this.supportedPowerStates = powerStates; 26 28 } 27 29 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) { 29 31 this.energyEstimationPlugin = energyEstimationPlugin; 30 this.supportedPowerStates = supportedPowerStates;32 this.supportedPowerStates = powerStates; 31 33 this.powerUsage = new ArrayList<PowerUsage>(); 32 34 if(pStates.size() > 0) … … 98 100 } 99 101 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; 102 108 } 103 109 110 104 111 } -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/power/PowerUsage.java
r477 r539 1 1 package schedframe.resources.computing.profiles.energy.power; 2 2 3 public class PowerUsage { 3 import schedframe.resources.computing.profiles.energy.MeasurementHistory; 4 4 5 protected long timestamp; 6 protected double value; 5 public class PowerUsage extends MeasurementHistory{ 7 6 8 7 public PowerUsage(long timestamp, double value){ 9 this.timestamp = timestamp; 10 this.value = value; 11 } 12 13 public long getTimestamp() { 14 return timestamp; 15 } 16 17 public double getValue() { 18 return value; 19 } 20 21 public void setValue(double value) { 22 this.value = value; 8 super(timestamp, value); 23 9 } 24 10 -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/power/plugin/EnergyEstimationPlugin.java
r477 r539 10 10 public double estimatePowerConsumption(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 11 11 12 public double estimate EnergyDissipation(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource);12 public double estimateAirThroughput(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); 13 13 14 14 public double estimateTemperature(EnergyEvent event, JobRegistry jobRegistry, ComputingResource resource); -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/power/ui/ComputingNodePowerInterface.java
r477 r539 10 10 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 11 11 12 public class ComputingNodePowerInterface extends AbstractPowerInterface{12 public class ComputingNodePowerInterface extends ComputingResourcePowerInterface{ 13 13 14 14 public static long START_TIME = 600000; … … 28 28 currentPowerState = state; 29 29 ComputingNode computingNode = (ComputingNode) resource; 30 boolean pePowerStateChangeStatus = false; 30 31 if(computingNode.getProcessors() != null) 31 32 { 32 33 for(ComputingResource child:computingNode.getProcessors()){ 33 child.getPowerInterface().setPowerState(state); 34 if(child.getPowerInterface() != null){ 35 pePowerStateChangeStatus = child.getPowerInterface().setPowerState(state); 36 } 34 37 } 35 } else { 38 } 39 40 if(!pePowerStateChangeStatus){ 36 41 computingNode.handleEvent(new EnergyEvent(EnergyEventType.POWER_STATE_CHANGED, computingNode.getName())); 37 42 } 38 43 39 44 if(state == StandardPowerStateName.OFF){ 40 45 computingNode.setStatus(ResourceStatus.UNAVAILABLE); … … 46 51 return true; 47 52 } 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 }*/75 53 76 54 public void turnOn(){ -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/power/ui/DataCenterPowerInterface.java
r477 r539 7 7 import schedframe.resources.computing.profiles.energy.power.StandardPowerStateName; 8 8 9 public class DataCenterPowerInterface extends AbstractPowerInterface{9 public class DataCenterPowerInterface extends ComputingResourcePowerInterface{ 10 10 11 12 13 14 11 public DataCenterPowerInterface(ComputingResource resource, PowerProfile pp){ 15 12 super(resource, pp); -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/power/ui/PowerInterface.java
r477 r539 3 3 import java.util.List; 4 4 5 import schedframe.Parameters; 5 6 import schedframe.resources.computing.profiles.energy.power.PowerState; 6 7 import schedframe.resources.computing.profiles.energy.power.PowerStateName; … … 25 26 List<PowerUsage> getPowerUsageHistory(); 26 27 28 public Parameters getParameters(); 27 29 } -
DCWoRMS/trunk/build/classes/schedframe/resources/computing/profiles/energy/power/ui/ProcessorPowerInterface.java
r477 r539 1 1 package schedframe.resources.computing.profiles.energy.power.ui; 2 3 4 import gridsim.GridSimTags; 5 import gridsim.dcworms.DCWormsTags; 2 6 3 7 import java.util.Map; 4 8 5 import schedframe.events.ResourceEventCommand;6 9 import schedframe.resources.ResourceStatus; 7 10 import schedframe.resources.computing.ComputingResource; 8 import schedframe.resources.computing.Processor;9 11 import schedframe.resources.computing.profiles.energy.EnergyEvent; 10 12 import schedframe.resources.computing.profiles.energy.EnergyEventType; … … 16 18 import schedframe.resources.units.StandardResourceUnitName; 17 19 18 public class ProcessorPowerInterface extends AbstractPowerInterface {20 public class ProcessorPowerInterface extends ComputingResourcePowerInterface { 19 21 20 22 protected PState currentPState; … … 36 38 if(powerState != currentPowerState){ 37 39 currentPowerState = powerState; 38 //Processor cpu = (Processor) resource;39 40 if(powerState == StandardPowerStateName.OFF){ 40 41 resource.setStatus(ResourceStatus.UNAVAILABLE); … … 42 43 resource.setStatus(ResourceStatus.FREE); 43 44 } 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())); 46 46 } 47 47 … … 79 79 80 80 if(newPState != currentPState){ 81 double factor = newPState.getFrequency()/currentPState.getFrequency();81 //double factor = newPState.getFrequency()/currentPState.getFrequency(); 82 82 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()); 85 85 //new ResourceEventCommand(resource).execute(EnergyEventType.FREQUENCY_CHANGED); 86 86 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()); 88 88 return true; 89 89 } -
DCWoRMS/trunk/build/classes/schedframe/resources/units/AbstractResourceUnit.java
r477 r539 78 78 public ResourceUnitProvisioner getProvisioner() { 79 79 return provisioner; 80 80 } 81 82 public Parameters getParameters(){ 83 return null; 81 84 } 82 85 -
DCWoRMS/trunk/build/classes/schedframe/resources/units/ResourceUnit.java
r477 r539 23 23 public void init(Parameters parameters); 24 24 25 public Parameters getParameters(); 26 25 27 public ResourceUnitProvisioner getProvisioner(); 26 28 } -
DCWoRMS/trunk/build/classes/schedframe/scheduling/Cluster.java
r477 r539 13 13 import gridsim.GridSimTags; 14 14 import gridsim.IO_data; 15 import gridsim. gssim.WormsTags;15 import gridsim.dcworms.DCWormsTags; 16 16 17 17 public class Cluster extends Scheduler{ … … 23 23 protected void processOtherRequest(Sim_event ev) { 24 24 switch (ev.get_tag()) { 25 case WormsTags.QUERY_RESOURCE_DESC:25 case DCWormsTags.QUERY_RESOURCE_DESC: 26 26 SchedulerDescription desc = new SchedulerDescription(new LocalSystem(get_name(), null, null)); 27 27 Map<ResourceUnitName, List<ResourceUnit>> units = managementSystem.getResourceManager().getSharedResourceUnits(); … … 30 30 31 31 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); 33 33 break; 34 34 -
DCWoRMS/trunk/build/classes/schedframe/scheduling/GridResourceDiscovery.java
r477 r539 5 5 import gridsim.GridSimTags; 6 6 import gridsim.IO_data; 7 import gridsim. gssim.WormsTags;7 import gridsim.dcworms.DCWormsTags; 8 8 9 9 import java.util.ArrayList; … … 58 58 for(int i = 0; i < resourceList.size(); i++){ 59 59 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); 61 61 } 62 62 63 63 //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); 65 65 Sim_event ev = new Sim_event(); 66 66 … … 80 80 for(int i = 0; i < gridBroker.getChildren().size(); i++){ 81 81 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); 83 83 } 84 84 85 85 //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); 87 87 Sim_event ev = new Sim_event(); 88 88 -
DCWoRMS/trunk/build/classes/schedframe/scheduling/Scheduler.java
r477 r539 8 8 import gridsim.GridSimTags; 9 9 import gridsim.IO_data; 10 import gridsim. gssim.WormsTags;10 import gridsim.dcworms.DCWormsTags; 11 11 12 12 import java.util.ArrayList; … … 28 28 import schedframe.scheduling.manager.resources.ManagedResources; 29 29 import schedframe.scheduling.policy.AbstractManagementSystem; 30 import schedframe.scheduling.queue.QueueDescription; 30 31 import schedframe.scheduling.queue.TaskQueue; 31 import schedframe.scheduling.queue.QueueDescription;32 32 import schedframe.scheduling.tasks.WorkloadUnit; 33 33 … … 117 117 if (obj != null) { 118 118 int delay = (Integer) obj; 119 send(this.get_id(), delay, WormsTags.TIMER);119 send(this.get_id(), delay, DCWormsTags.TIMER); 120 120 } 121 121 } … … 133 133 // managemetnSystem_.setEndSimulation(); 134 134 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 (measure140 .startsWith(GssimConstants.TASKS_QUEUE_LENGTH_MEASURE_NAME)) {141 System.out.println("====="+this.get_name()+";"+stats.average(measure));142 }143 }*/144 135 break; 145 136 } … … 155 146 156 147 case GridSimTags.GRIDLET_SUBMIT: 157 process GSSIMJobSubmit(ev, false);148 processWorkloadUnitSubmit(ev, false); 158 149 break; 159 150 160 151 case GridSimTags.GRIDLET_SUBMIT_ACK: 161 process GSSIMJobSubmit(ev, true);152 processWorkloadUnitSubmit(ev, true); 162 153 break; 163 154 164 155 case GridSimTags.GRIDLET_RETURN: 165 process GSSIMJobReturn(ev);156 processWorkloadUnitReturn(ev); 166 157 break; 167 158 … … 174 165 protected void processOtherRequest(Sim_event ev) { 175 166 switch (ev.get_tag()) { 176 case WormsTags.QUERY_RESOURCE_DESC:167 case DCWormsTags.QUERY_RESOURCE_DESC: 177 168 SchedulerDescription desc = new SchedulerDescription(new LocalSystem(get_name(), null, null)); 178 169 Map<ResourceUnitName, List<ResourceUnit>> units = managementSystem.getResourceManager().getSharedResourceUnits(); … … 181 172 182 173 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); 184 175 break; 185 176 … … 189 180 } 190 181 } 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(); 198 185 managementSystem.notifyReturnedWorkloadUnit(job); 199 186 } 200 187 201 protected void process GSSIMJobSubmit(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(); 203 190 managementSystem.notifySubmittedWorkloadUnit(job, ack); 204 191 } … … 223 210 this.send(this.get_id(), delay, tag, data); 224 211 } 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 }*/230 212 231 213 public Sim_port getOutputPort() { … … 271 253 public List<QueueDescription> getQueuesDescription(){ 272 254 List<QueueDescription> queues = new ArrayList<QueueDescription>(); 273 for(TaskQueue queue: managementSystem.get AccessQueues()){255 for(TaskQueue queue: managementSystem.getQueues()){ 274 256 QueueDescription qd; 275 257 try { -
DCWoRMS/trunk/build/classes/schedframe/scheduling/WorkloadUnitHandler.java
r477 r539 1 1 package schedframe.scheduling; 2 2 3 import schedframe.scheduling.tasks.Job;4 import schedframe.scheduling.tasks. SubmittedTask;3 import dcworms.schedframe.scheduling.ExecTask; 4 import schedframe.scheduling.tasks.JobInterface; 5 5 import schedframe.scheduling.tasks.TaskInterface; 6 import gssim.schedframe.scheduling.ExecTask;7 6 8 public 7 public interface WorkloadUnitHandler{ 9 8 10 public void handleJob(Job job);9 public void handleJob(JobInterface<?> job); 11 10 12 11 public void handleTask(TaskInterface<?> task); 13 12 14 13 public void handleExecutable(ExecTask task); 15 16 public void handleSubmittedTask(SubmittedTask task); 14 17 15 } -
DCWoRMS/trunk/build/classes/schedframe/scheduling/manager/resources/LocalResourceManager.java
r477 r539 13 13 import java.util.Properties; 14 14 import java.util.Set; 15 import java.util.Stack;16 15 17 16 import schedframe.exceptions.ResourceException; … … 175 174 return resourceUnit; 176 175 } 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 }*/188 176 189 177 public List<? extends ComputingResource> filterResources(Properties properties) { … … 242 230 computingResources = (List<ComputingResource>) getResourcesOfType(StandardResourceType.Core); 243 231 } catch (ResourceException e) { 244 throw new RuntimeException(" GSSIMinternal error");232 throw new RuntimeException("DCWorms internal error"); 245 233 } 246 234 PEUnit peUnit = new ProcessingElements(computingResources); … … 253 241 computingResources = (List<ComputingResource>) getResourcesOfType(StandardResourceType.Processor); 254 242 } catch (ResourceException e) { 255 throw new RuntimeException(" GSSIMinternal error");243 throw new RuntimeException("DCWorms internal error"); 256 244 } 257 245 PEUnit peUnit = new ProcessingElements(computingResources); … … 318 306 return false; 319 307 } 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 }*/336 308 337 309 for(ResourceUnitName resUnitName: resources.keySet()){ … … 345 317 public void freeResources(Map<ResourceUnitName, ResourceUnit> resources) { 346 318 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 362 319 for(ResourceUnitName resUnitName: resources.keySet()){ 363 320 ResourceUnit resUnit = resources.get(resUnitName); … … 366 323 } 367 324 368 369 325 } -
DCWoRMS/trunk/build/classes/schedframe/scheduling/manager/tasks/AbstractJobRegistry.java
r477 r539 2 2 3 3 4 import java.util.Map;5 4 import java.util.concurrent.ConcurrentHashMap; 6 5 … … 14 13 15 14 16 public abstract class AbstractJobRegistry /*extends ConcurrentHashMap<String, Job> */implements JobRegistry, Cloneable{15 public abstract class AbstractJobRegistry /*extends ConcurrentHashMap<String, Job>*/ implements JobRegistry, Cloneable{ 17 16 18 17 private static final long serialVersionUID = 8409060063583755824L; 18 19 19 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<?>>(); 23 21 24 22 protected AbstractJobRegistry(){ 25 //log.warn("Methods from JobRegistry interface are not implemented.");26 23 } 27 24 28 25 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); 35 27 return true; 36 28 } … … 38 30 public boolean addTask(TaskInterface<?> task) { 39 31 if(jobs.containsKey(task.getJobId())){ 40 jobs.get(task.getJobId()).add((Task)task);32 getJob(task.getJobId()).add((Task)task); 41 33 return true; 42 34 } else { … … 45 37 } 46 38 47 public Job get(String jobId){39 public JobInterface<?> getJobInfo(String jobId) { 48 40 return jobs.get(jobId); 49 41 } 50 51 public JobInterface<?> getJobInfo(String jobID) {52 return jobs.get(jobID);53 }54 42 55 public TaskInterface<?> getTaskInfo(String jobI D, String taskId) {43 public TaskInterface<?> getTaskInfo(String jobId, String taskId) { 56 44 Task task = null; 57 Job job = jobs.get(jobID);45 Job job = getJob(jobId); 58 46 59 47 if(job == null) … … 63 51 task = job.getTask(taskId); 64 52 } catch (NoSuchFieldException e) { 65 log.error(e.getMessage());66 53 } 67 54 return task; 68 55 } 69 56 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); 73 59 } 74 60 75 public List<TaskInterface<?>> getActiveTasks() {76 log.error("getActiveTasks() not implemented.");77 return null;78 }*/79 80 81 82 83 61 } -
DCWoRMS/trunk/build/classes/schedframe/scheduling/manager/tasks/JobRegistry.java
r477 r539 1 1 package schedframe.scheduling.manager.tasks; 2 2 3 import gssim.schedframe.scheduling.ExecTask;4 3 5 4 import java.util.List; 6 5 6 import dcworms.schedframe.scheduling.ExecTask; 7 8 import schedframe.ExecutablesList; 7 9 import schedframe.scheduling.tasks.JobInterface; 8 10 import schedframe.scheduling.tasks.TaskInterface; … … 11 13 public interface JobRegistry { 12 14 13 //public List<JobInterface<?>> getActiveJobs();14 15 //public List<TaskInterface<?>> getActiveTasks();16 17 15 public JobInterface<?> getJobInfo(String jobId); 18 16 … … 31 29 32 30 33 //public List<SubmittedTask> getSubmittedTasks();31 public ExecutablesList getExecutableTasks(); 34 32 35 public ExecTask get SubmittedTask(String jobId, String taskId);33 public ExecTask getExecutable(String jobId, String taskId); 36 34 37 35 38 public List<? extends TaskInterface<?>> get ReadyTasks(List<JobInterface<?>> jobsList);36 public List<? extends TaskInterface<?>> getAvailableTasks(List<JobInterface<?>> jobsList); 39 37 40 38 } -
DCWoRMS/trunk/build/classes/schedframe/scheduling/manager/tasks/JobRegistryImpl.java
r477 r539 1 1 package schedframe.scheduling.manager.tasks; 2 2 3 import gridsim.Gridlet; 4 import gssim.schedframe.scheduling.ExecTask; 5 import gssim.schedframe.scheduling.Executable; 3 import gridsim.dcworms.DCWormsTags; 6 4 7 5 import java.util.ArrayList; 8 import java.util.Collections;9 import java.util.HashMap;10 6 import java.util.List; 11 import java.util.Map;12 7 13 8 import org.apache.commons.lang.ArrayUtils; 14 9 import org.apache.commons.logging.Log; 15 10 import org.apache.commons.logging.LogFactory; 16 import org.joda.time.DateTime;17 11 import org.qcg.broker.schemas.resreqs.ParentType; 18 12 import org.qcg.broker.schemas.resreqs.types.TaskStatesName; 19 13 14 import dcworms.schedframe.scheduling.ExecTask; 15 20 16 import 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; 17 import schedframe.ExecutablesList; 26 18 import schedframe.scheduling.tasks.JobInterface; 27 import schedframe.scheduling.tasks.SubmittedTask;28 19 import schedframe.scheduling.tasks.Task; 29 import simulator.WormsConstants;30 20 31 21 public class JobRegistryImpl extends AbstractJobRegistry { … … 37 27 private String context; 38 28 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>(); 42 33 43 public JobRegistryImpl(String context _) {44 context = context_;34 public JobRegistryImpl(String context) { 35 this.context = context; 45 36 } 46 37 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); 56 42 } 57 43 return true; … … 60 46 } 61 47 48 public ExecutablesList getExecutableTasks() { 49 return executables; 50 } 62 51 public List<ExecTask> getTasks(int status) { 63 52 List<ExecTask> taskList = new ArrayList<ExecTask>(); 64 synchronized ( submittedTasks) {65 for (ExecTask task: submittedTasks) {53 synchronized (executables) { 54 for (ExecTask task: executables) { 66 55 if (task.getStatus() == status) { 67 //SubmittedTask subTask = (SubmittedTask) task;68 56 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)) { 70 58 taskList.add(task); 71 59 } 72 /*if(subTask.getVisitedResources().contains(context)){73 taskList.add(subTask);74 }*/75 60 } 76 61 } … … 80 65 81 66 public List<ExecTask> getQueuedTasks() { 82 return getTasks( Gridlet.QUEUED);67 return getTasks(DCWormsTags.QUEUED); 83 68 } 84 69 85 70 public List<ExecTask> getRunningTasks() { 86 return getTasks( Gridlet.INEXEC);71 return getTasks(DCWormsTags.INEXEC); 87 72 } 88 73 89 74 public List<ExecTask> getReadyTasks() { 90 return getTasks( Gridlet.READY);75 return getTasks(DCWormsTags.READY); 91 76 } 92 77 93 78 public List<ExecTask> getFinishedTasks() { 94 return getTasks( Gridlet.SUCCESS);79 return getTasks(DCWormsTags.SUCCESS); 95 80 } 96 81 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) { 127 86 return task; 128 87 } … … 131 90 return null; 132 91 } 133 134 92 135 93 @SuppressWarnings("unchecked") 136 public List<Task> get ReadyTasks(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>(); 138 96 List<Task> waitingTasks = new ArrayList<Task>(); 139 97 … … 143 101 } 144 102 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; 283 105 } 284 106 285 107 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){ 294 109 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(); 329 112 330 List<Task> readyTasks = new ArrayList<Task>();331 332 int size = tasks.size();333 113 for(int i = 0; i < size; i++){ 334 114 int parCnt; 335 int previousTask ReadyCnt = 0;115 int previousTaskSucceedCnt = 0; 336 116 Task task = tasks.get(i); 337 117 if(task.getStatus() != (int)BrokerConstants.TASK_STATUS_UNSUBMITTED) … … 341 121 } catch(Exception e){ 342 122 parCnt = 0; 343 //e.printStackTrace();344 123 } 345 if(parCnt == 0) 346 { 347 readyTasks.add(task); 124 if(parCnt == 0){ 125 availableTasks.add(task); 348 126 } 349 else 350 { 127 else { 351 128 for(int j = 0; j < parCnt; j++){ 352 129 ParentType par = task.getDescription().getWorkflow().getParent(j); … … 356 133 } 357 134 } 358 previousTask ReadyCnt++;135 previousTaskSucceedCnt++; 359 136 } 360 137 361 if(previousTask ReadyCnt == parCnt && task.getDescription().getWorkflow().getAnd() != null)362 readyTasks.add(task);363 else if(previousTask ReadyCnt > 0 && task.getDescription().getWorkflow().getOr() != null)364 readyTasks.add(task);365 else if (previousTask ReadyCnt == 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); 367 144 } 368 145 } 369 return readyTasks;146 return availableTasks; 370 147 } 371 148 … … 380 157 return false; 381 158 } 159 382 160 } -
DCWoRMS/trunk/build/classes/schedframe/scheduling/plan/ScheduledTaskInterface.java
r477 r539 4 4 5 5 import schedframe.DescriptionContainer; 6 import schedframe.scheduling.tasks. WorkloadUnit;6 import schedframe.scheduling.tasks.TaskInterface; 7 7 8 8 public interface ScheduledTaskInterface<T> extends DescriptionContainer<T> { … … 190 190 191 191 192 public ArrayList<AllocationInterface > getAllocations();192 public ArrayList<AllocationInterface<?>> getAllocations(); 193 193 194 public WorkloadUnit<?> getTask();194 public TaskInterface<?> getTask(); 195 195 196 196 } -
DCWoRMS/trunk/build/classes/schedframe/scheduling/plan/SchedulingPlanInterface.java
r477 r539 99 99 100 100 101 public ArrayList<ScheduledTaskInterface > getTasks();101 public ArrayList<ScheduledTaskInterface<?>> getTasks(); 102 102 } -
DCWoRMS/trunk/build/classes/schedframe/scheduling/plan/impl/ScheduledTask.java
r477 r539 6 6 import org.exolab.castor.xml.MarshalException; 7 7 import org.exolab.castor.xml.ValidationException; 8 import org.qcg.broker.schemas.schedulingplan.types.AllocationStatus; 8 9 9 10 import schedframe.scheduling.plan.AllocationInterface; 10 11 import schedframe.scheduling.plan.ScheduledTaskInterface; 11 12 import schedframe.scheduling.plan.ScheduledTimeInterface; 12 import schedframe.scheduling.tasks.WorkloadUnit; 13 14 15 import org.qcg.broker.schemas.schedulingplan.types.AllocationStatus; 13 import schedframe.scheduling.tasks.TaskInterface; 16 14 17 15 public class ScheduledTask implements ScheduledTaskInterface<org.qcg.broker.schemas.schedulingplan.Task> { … … 22 20 public ScheduledTask(){ 23 21 t = new org.qcg.broker.schemas.schedulingplan.Task(); 24 allocationList = new ArrayList<AllocationInterface >();22 allocationList = new ArrayList<AllocationInterface<?>>(); 25 23 } 26 24 27 25 public ScheduledTask(org.qcg.broker.schemas.schedulingplan.Task value){ 28 26 t = value; 29 allocationList = new ArrayList<AllocationInterface >();27 allocationList = new ArrayList<AllocationInterface<?>>(); 30 28 } 31 29 … … 178 176 179 177 180 protected WorkloadUnit<?> task;181 protected ArrayList<AllocationInterface > allocationList;178 protected TaskInterface<?> task; 179 protected ArrayList<AllocationInterface<?>> allocationList; 182 180 183 public ScheduledTask( WorkloadUnit<?> task){181 public ScheduledTask(TaskInterface<?> task){ 184 182 this(); 185 183 this.task = task; 186 184 } 187 185 188 public ArrayList<AllocationInterface > getAllocations() {186 public ArrayList<AllocationInterface<?>> getAllocations() { 189 187 return this.allocationList; 190 188 } 191 189 192 public WorkloadUnit<?> getTask(){190 public TaskInterface<?> getTask(){ 193 191 return this.task; 194 192 } -
DCWoRMS/trunk/build/classes/schedframe/scheduling/plan/impl/SchedulingPlan.java
r477 r539 18 18 public SchedulingPlan(){ 19 19 sp = new org.qcg.broker.schemas.schedulingplan.SchedulingPlan(); 20 taskList = new ArrayList<ScheduledTaskInterface >();20 taskList = new ArrayList<ScheduledTaskInterface<?>>(); 21 21 } 22 22 23 23 public SchedulingPlan(org.qcg.broker.schemas.schedulingplan.SchedulingPlan value){ 24 24 sp = value; 25 taskList = new ArrayList<ScheduledTaskInterface >();25 taskList = new ArrayList<ScheduledTaskInterface<?>>(); 26 26 } 27 27 … … 106 106 107 107 108 protected ArrayList<ScheduledTaskInterface > taskList;108 protected ArrayList<ScheduledTaskInterface<?>> taskList; 109 109 110 public ArrayList<ScheduledTaskInterface > getTasks() {110 public ArrayList<ScheduledTaskInterface<?>> getTasks() { 111 111 112 112 return this.taskList; -
DCWoRMS/trunk/build/classes/schedframe/scheduling/plugin/SchedulingPlugin.java
r477 r539 3 3 import schedframe.Plugin; 4 4 import schedframe.events.scheduling.SchedulingEvent; 5 import schedframe.scheduling.WorkloadUnitListImpl; 5 import schedframe.scheduling.TaskList; 6 import schedframe.scheduling.TaskListImpl; 6 7 import schedframe.scheduling.manager.resources.ResourceManager; 7 8 import schedframe.scheduling.manager.tasks.JobRegistry; … … 12 13 public interface SchedulingPlugin extends Plugin{ 13 14 14 public int place JobsInQueues(WorkloadUnitListImpl newJobs,15 public int placeTasksInQueues(TaskList newTasks, 15 16 TaskQueueList queues, 16 17 ResourceManager resourceManager, ModuleList modules); -
DCWoRMS/trunk/build/classes/schedframe/scheduling/plugin/estimation/ExecutionTimeEstimationPlugin.java
r477 r539 1 1 package schedframe.scheduling.plugin.estimation; 2 2 3 import gssim.schedframe.scheduling.ExecTask;4 3 5 import java.util.List;6 4 import java.util.Map; 5 6 import dcworms.schedframe.scheduling.ExecTask; 7 7 8 8 import schedframe.Plugin; … … 32 32 * @return estimated execution time of a task of specified length 33 33 */ 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, 36 35 double completionPercentage); 37 36 -
DCWoRMS/trunk/build/classes/schedframe/scheduling/policy/AbstractManagementSystem.java
r477 r539 8 8 import org.joda.time.DateTimeUtilsExt; 9 9 10 import dcworms.schedframe.scheduling.ExecTask; 11 import dcworms.schedframe.scheduling.Executable; 12 import dcworms.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 13 10 14 import schedframe.PluginConfiguration; 11 15 import schedframe.events.scheduling.SchedulingEventType; 12 import schedframe.resources.units.StandardResourceUnitName;13 16 import schedframe.scheduling.Scheduler; 14 17 import schedframe.scheduling.WorkloadUnitHandler; … … 16 19 import schedframe.scheduling.manager.resources.ResourceManager; 17 20 import schedframe.scheduling.manager.resources.ResourceManagerFactory; 21 import schedframe.scheduling.manager.tasks.JobRegistry; 18 22 import schedframe.scheduling.manager.tasks.JobRegistryImpl; 19 import schedframe.scheduling.manager.tasks.JobRegistry;20 23 import schedframe.scheduling.plan.AllocationInterface; 21 24 import schedframe.scheduling.plan.SchedulingPlanInterface; … … 27 30 import schedframe.scheduling.queue.TaskQueueList; 28 31 import schedframe.scheduling.tasks.Job; 32 import schedframe.scheduling.tasks.TaskInterface; 29 33 import schedframe.scheduling.tasks.WorkloadUnit; 30 import simulator. WormsConstants;34 import simulator.DCWormsConstants; 31 35 import eduni.simjava.Sim_event; 32 36 import gridsim.GridSim; 33 37 import gridsim.GridSimTags; 34 import gridsim.Gridlet;35 38 import 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; 39 import gridsim.dcworms.DCWormsTags; 40 40 41 41 public abstract class AbstractManagementSystem { … … 45 45 protected String name; 46 46 47 protected TaskQueueList queues; 47 48 protected ResourceManager resourceManager; 48 49 protected TaskQueueList queues;50 49 protected JobRegistryImpl jobRegistry; 50 protected ModuleList moduleList; 51 51 52 protected SchedulingPlugin schedulingPlugin; 52 53 53 protected ExecutionTimeEstimationPlugin execTimeEstimationPlugin; 54 54 55 protected ModuleList moduleList; 56 57 protected JobRegistryImpl jobRegistry; 55 protected Scheduler scheduler; 58 56 59 57 … … 67 65 } 68 66 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 69 80 public void processEvent(Sim_event ev) { 70 81 processOtherEvent(ev); … … 81 92 } 82 93 94 83 95 public String getName() { 84 96 return name; 85 }86 87 public PluginConfiguration getSchedulingPluginConfiguration() {88 return schedulingPlugin.getConfiguration();89 97 } 90 98 … … 106 114 return jobRegistry; 107 115 } 116 117 public Scheduler getScheduler() { 118 return scheduler; 119 } 120 121 public PluginConfiguration getSchedulingPluginConfiguration() { 122 return schedulingPlugin.getConfiguration(); 123 } 108 124 109 125 public boolean pluginSupportsEvent(int eventType){ … … 111 127 } 112 128 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 123 141 //POPRAWIC (ale co? bo teraz chyba jest ok) 124 protected void submit WorkloadUnit(WorkloadUnit<?> wu, AllocationInterfaceallocation) {142 protected void submitTask(TaskInterface<?> task, AllocationInterface<?> allocation) { 125 143 String providerName = allocation.getProviderName(); 126 144 if (providerName == null) { 127 145 return; 128 146 } 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) { 167 152 168 153 Executable exec = (Executable) wu; 169 154 if(scheduler.getParent() == null) 170 155 { 171 Job job = jobRegistry.get (exec.getJobId());156 Job job = jobRegistry.getJob(exec.getJobId()); 172 157 173 158 if(job.isFinished()){ 174 159 scheduler.send(job.getSenderId(), GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_RETURN, job); 175 160 return true; 176 }else return true; 161 } 162 else return true; 177 163 } 178 164 … … 183 169 184 170 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 }*/191 171 192 172 long delay = 0; … … 201 181 } 202 182 203 scheduler.sendInternal(Long.valueOf(delay).doubleValue(), WormsTags.TASK_READY_FOR_EXECUTION,183 scheduler.sendInternal(Long.valueOf(delay).doubleValue(), DCWormsTags.TASK_READY_FOR_EXECUTION, 204 184 exec); 205 185 } … … 213 193 if (obj != null) { 214 194 int delay = (Integer) obj; 215 scheduler.sendInternal(delay, WormsTags.TIMER, null);195 scheduler.sendInternal(delay, DCWormsTags.TIMER, null); 216 196 } 217 197 } … … 219 199 } 220 200 221 protected boolean removeFromQueue( WorkloadUnit<?> wu) {201 protected boolean removeFromQueue(TaskInterface<?> task) { 222 202 for(TaskQueue queue : queues){ 223 if(queue.contains( wu)){224 queue.remove( wu);203 if(queue.contains(task)){ 204 queue.remove(task); 225 205 return true; 226 206 } … … 228 208 return false; 229 209 } 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 }261 210 262 211 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); 263 218 264 219 } -
DCWoRMS/trunk/build/classes/schedframe/scheduling/policy/global/GlobalManagementSystem.java
r477 r539 11 11 import org.qcg.broker.schemas.schedulingplan.types.AllocationStatus; 12 12 13 import dcworms.schedframe.scheduling.ExecTask; 14 import dcworms.schedframe.scheduling.Executable; 15 13 16 import qcg.shared.constants.BrokerConstants; 14 15 import schedframe.events.scheduling.EventReason;16 import schedframe.events.scheduling.SchedulingEvent;17 17 import schedframe.events.scheduling.TaskArrivedEvent; 18 import schedframe.events.scheduling.TaskCanceledEvent;19 18 import schedframe.events.scheduling.TimerEvent; 20 import schedframe.scheduling. Scheduler;19 import schedframe.scheduling.TaskListImpl; 21 20 import schedframe.scheduling.WorkloadUnitHandler; 22 import schedframe.scheduling.WorkloadUnitListImpl;23 21 import schedframe.scheduling.plan.AllocationInterface; 24 22 import schedframe.scheduling.plan.ScheduledTaskInterface; … … 31 29 import schedframe.scheduling.tasks.Job; 32 30 import schedframe.scheduling.tasks.JobInterface; 33 import schedframe.scheduling.tasks.SubmittedTask;34 31 import schedframe.scheduling.tasks.Task; 35 32 import schedframe.scheduling.tasks.TaskInterface; 36 33 import schedframe.scheduling.tasks.WorkloadUnit; 37 38 34 import eduni.simjava.Sim_event; 39 35 import gridsim.GridSim; 40 36 import gridsim.GridSimTags; 41 import gridsim.Gridlet;42 37 import gridsim.IO_data; 43 import gridsim.gssim.WormsTags; 44 import gssim.schedframe.scheduling.ExecTask; 45 import gssim.schedframe.scheduling.Executable; 38 import gridsim.dcworms.DCWormsTags; 46 39 47 40 public class GlobalManagementSystem extends AbstractManagementSystem { … … 54 47 super(providerId, entityName, execTimeEstimationPlugin, queues); 55 48 56 /*schedulingPlugin = (GlobalSchedulingPlugin) InstanceFactory.createInstance(57 schedulingPluginClassName,58 GlobalSchedulingPlugin.class);*/59 49 if(schedPlugin == null){ 60 50 throw new Exception("Can not create global scheduling plugin instance"); … … 69 59 switch (tag) { 70 60 71 case WormsTags.TIMER:72 if (pluginSupportsEvent( WormsTags.TIMER)) {61 case DCWormsTags.TIMER: 62 if (pluginSupportsEvent(DCWormsTags.TIMER)) { 73 63 TimerEvent event = new TimerEvent(); 74 SchedulingPlanInterface decision = schedulingPlugin.schedule(event,64 SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 75 65 queues, getJobRegistry(), getResourceManager(), moduleList); 76 66 executeSchedulingPlan(decision); … … 81 71 } 82 72 83 public void notifySubmittedWorkloadUnit(WorkloadUnit <?>wu, boolean ack) {73 public void notifySubmittedWorkloadUnit(WorkloadUnit wu, boolean ack) { 84 74 if (!pluginSupportsEvent(GridSimTags.GRIDLET_SUBMIT)) { 85 75 log.error("Plugin " + schedulingPlugin.getClass() … … 90 80 91 81 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){ 98 94 List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>(); 99 95 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) 134 103 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) { 142 107 Executable exec = (Executable) wu; 143 108 … … 149 114 150 115 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()); 153 118 if(exec.getProcessesId() == null){ 154 119 try { 155 120 task.setStatus(exec.getStatus()); 156 121 } catch (Exception e) { 157 // TODO Auto-generated catch block 158 e.printStackTrace(); 122 159 123 } 160 124 } else { … … 167 131 } 168 132 } 169 } */133 } 170 134 171 135 if(job.isFinished()){ … … 173 137 } 174 138 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); 183 140 } 184 141 … … 189 146 } 190 147 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(); 218 151 for (int i = 0; i < taskSchedulingDecisions.size(); i++) { 219 152 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) { 254 235 255 236 String providerName = allocation.getProviderName(); … … 257 238 return; 258 239 } 259 TaskInterface<?> task = (TaskInterface<?>) job;260 240 removeFromQueue(task); 261 241 262 242 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); 264 244 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 267 247 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 274 250 } 275 251 276 252 class GlobalWorkloadUnitHandler implements WorkloadUnitHandler{ 277 253 278 public void handleJob(Job job){ 279 280 jobRegistry.addJob(job); 254 public void handleJob(JobInterface<?> job){ 281 255 if (log.isInfoEnabled()) 282 256 log.info("Received job " + job.getId() + " at " + new DateTime(DateTimeUtilsExt.currentTimeMillis())); 283 257 284 scheduleReadyTasks(job); 258 jobRegistry.addJob(job); 259 schedule(job); 285 260 } 286 261 … … 292 267 throw new RuntimeException("Not implemented since it isn't expected that tasks are send directly to the global scheduler."); 293 268 } 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 }298 269 } 299 270 … … 301 272 return new GlobalWorkloadUnitHandler(); 302 273 } 303 304 274 305 275 -
DCWoRMS/trunk/build/classes/schedframe/scheduling/policy/global/GridBroker.java
r477 r539 19 19 public class GridBroker extends GlobalManagementSystem { 20 20 21 22 21 private static Log log = LogFactory.getLog(GridBroker.class); 23 22 … … 27 26 public GridBroker(String name, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues) throws Exception { 28 27 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 36 29 otherGridSchedulersIds = new HashSet<Integer>(); 37 38 30 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");44 31 } 45 32 46 33 public void init(Scheduler scheduler, ManagedResources managedResources) { 47 34 super.init(scheduler, managedResources); 48 //this.scheduler = scheduler;49 //this.resourceManager = ResourceManagerFactory.createResourceManager(scheduler, managedResources);50 35 this.moduleList.add((GridResourceDiscovery)resourceManager); 51 36 } … … 57 42 } 58 43 return providerIds; 59 //return GridSim.getGridResourceList();60 44 } 61 45 -
DCWoRMS/trunk/build/classes/schedframe/scheduling/policy/local/LocalManagementSystem.java
r477 r539 1 1 package schedframe.scheduling.policy.local; 2 2 3 import dcworms.schedframe.scheduling.ExecTask; 4 import dcworms.schedframe.scheduling.Executable; 3 5 import eduni.simjava.Sim_event; 4 6 import eduni.simjava.Sim_system; 5 7 import gridsim.Accumulator; 6 8 import gridsim.GridSimTags; 7 import gridsim.Gridlet;8 9 import 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; 10 import gridsim.dcworms.DCWormsTags; 11 import gridsim.dcworms.filter.ExecTaskFilter; 13 12 14 13 import java.util.ArrayList; … … 27 26 import qcg.shared.constants.BrokerConstants; 28 27 import schedframe.ResourceController; 29 import schedframe.events.scheduling.EventReason;30 28 import schedframe.events.scheduling.SchedulingEvent; 31 29 import schedframe.events.scheduling.SchedulingEventType; 32 30 import schedframe.events.scheduling.StartTaskExecutionEvent; 33 import schedframe.events.scheduling.TaskCanceledEvent;34 31 import schedframe.events.scheduling.TaskFinishedEvent; 35 32 import schedframe.events.scheduling.TaskRequestedTimeExpiredEvent; … … 45 42 import schedframe.scheduling.ResourceHistoryItem; 46 43 import schedframe.scheduling.Scheduler; 47 import schedframe.scheduling.UsedResourceList; 44 import schedframe.scheduling.TaskList; 45 import schedframe.scheduling.TaskListImpl; 46 import schedframe.scheduling.UsedResourcesList; 48 47 import schedframe.scheduling.WorkloadUnitHandler; 49 import schedframe.scheduling.WorkloadUnitListImpl;50 48 import schedframe.scheduling.manager.resources.LocalResourceManager; 51 49 import schedframe.scheduling.manager.resources.ManagedResources; … … 63 61 import schedframe.scheduling.tasks.Job; 64 62 import schedframe.scheduling.tasks.JobInterface; 65 import schedframe.scheduling.tasks.SubmittedTask;66 63 import schedframe.scheduling.tasks.Task; 67 64 import schedframe.scheduling.tasks.TaskInterface; 68 65 import schedframe.scheduling.tasks.WorkloadUnit; 69 import simulator. WormsConstants;66 import simulator.DCWormsConstants; 70 67 import simulator.utils.DoubleMath; 71 68 … … 83 80 84 81 super(providerId, entityName, execTimeEstimationPlugin, queues); 85 86 //schedulingPlugin = (LocalSchedulingPlugin) InstanceFactory.createInstance(schedulingPluginClassName, LocalSchedulingPlugin.class);87 82 88 83 if (schedPlugin == null) { … … 90 85 } 91 86 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(); 95 90 } 96 91 97 92 public void init(Scheduler sched, ManagedResources managedResources) { 98 93 super.init(sched, managedResources); 99 //scheduler = sched;100 //resourceManager = ResourceManagerFactory.createResourceManager(scheduler);101 94 double load = 0; 102 95 accTotalLoad.add(load); … … 112 105 switch (tag) { 113 106 114 case WormsTags.TIMER:107 case DCWormsTags.TIMER: 115 108 if (pluginSupportsEvent(tag)) { 116 109 SchedulingEvent event = new SchedulingEvent(SchedulingEventType.TIMER); 117 SchedulingPlanInterface decision = schedulingPlugin.schedule(event,110 SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 118 111 queues, getJobRegistry(), getResourceManager(), moduleList); 119 112 executeSchedulingPlan(decision); 120 113 } 121 114 sendTimerEvent(); 122 123 115 break; 124 116 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); 130 121 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, 133 124 queues, getJobRegistry(), getResourceManager(), moduleList); 134 125 executeSchedulingPlan(decision); … … 139 130 break; 140 131 141 case WormsTags.TASK_EXECUTION_FINISHED:132 case DCWormsTags.TASK_EXECUTION_FINISHED: 142 133 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); 159 146 } 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; 164 158 if (pluginSupportsEvent(tag)) { 165 SchedulingEvent event = new Task FinishedEvent(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, 167 161 queues, getJobRegistry(), getResourceManager(), moduleList); 168 162 executeSchedulingPlan(decision); 169 163 } 170 Job job = jobRegistry.get(task.getJobId());171 if(!job.isFinished()){172 getWorkloadUnitHandler().handleJob(job);173 }174 175 164 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: 188 167 updateProcessingTimes(ev); 189 168 break; 190 169 } 191 170 } 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)) { 196 174 SchedulingEvent event = new SchedulingEvent(SchedulingEventType.TASK_FINISHED); 197 SchedulingPlanInterface decision = schedulingPlugin.schedule(event,175 SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event, 198 176 queues, getJobRegistry(), getResourceManager(), moduleList); 199 177 executeSchedulingPlan(decision); … … 203 181 //} 204 182 } 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(); 238 187 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)); 245 209 } 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 297 212 } 298 213 } 299 214 300 215 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; 304 218 boolean allocationStatus = getAllocationManager().allocateResources(choosenResources); 305 219 if(allocationStatus == false) 306 220 return; 307 221 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 315 223 SchedulingEvent event = new SchedulingEvent(SchedulingEventType.START_TASK_EXECUTION); 316 224 int time = Double.valueOf( 317 execTimeEstimationPlugin.execTimeEstimation(event, choosenResources, task, completionPercentage)).intValue();225 execTimeEstimationPlugin.execTimeEstimation(event, task, choosenResources, exec.getCompletionPercentage())).intValue(); 318 226 log.debug(task.getJobId() + "_" + task.getId() + " starts executing on " + new DateTime() 319 227 + " will finish after " + time); … … 322 230 return; 323 231 324 submittedTask.setEstimatedDuration(time);232 exec.setEstimatedDuration(time); 325 233 DateTime currentTime = new DateTime(); 326 234 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); 335 236 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); 338 247 } 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())); 345 253 346 254 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){ 348 259 ProcessingElements pes = (ProcessingElements) peUnit; 349 260 for (ComputingResource resource : pes) { 350 resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_ FINISHED, submittedTask));261 resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, exec)); 351 262 } 352 263 } else { … … 355 266 resource = ResourceController.getComputingResourceByName(peUnit.getResourceId()); 356 267 } 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 */ 365 273 366 274 /*for(ExecTaskInterface etask : jobRegistry.getRunningTasks()){ … … 371 279 } 372 280 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); 403 287 scheduler.sim_cancel(filter, null); 404 288 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()); 409 291 try { 410 task = job.getTask(exec utable.getTaskId());292 task = job.getTask(exec.getTaskId()); 411 293 } catch (NoSuchFieldException e) { 412 e.printStackTrace();413 } 414 if(exec utable.getProcessesId() == null){415 try { 416 task.setStatus(exec utable.getStatus());294 return; 295 } 296 if(exec.getProcessesId() == null){ 297 try { 298 task.setStatus(exec.getStatus()); 417 299 } catch (Exception e) { 418 300 e.printStackTrace(); … … 422 304 for(int i = 0; i < processesList.size(); i++){ 423 305 AbstractProcesses processes = processesList.get(i); 424 if(processes.getId().equals(exec utable.getProcessesId())){425 processes.setStatus(exec utable.getStatus());306 if(processes.getId().equals(exec.getProcessesId())){ 307 processes.setStatus(exec.getStatus()); 426 308 break; 427 309 } 428 310 } 429 311 } 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 430 335 //sendFinishedWorkloadUnit(executable); 431 336 } … … 441 346 while (iter.hasNext()) { 442 347 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() 446 353 .get(StandardResourceUnitName.PE); 447 448 double load = getMIShare(timeSpan, (PEUnit) unit); 449 subTask.updateGridletFinishedSoFar(load); 354 double load = getMIShare(timeSpan, peUnit); 450 355 addTotalLoad(load); 451 356 } 452 357 } 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 454 376 private double getMIShare(double timeSpan, PEUnit pes) { 455 377 double localLoad; … … 470 392 protected void updateProcessingTimes(Sim_event ev) { 471 393 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(); 475 397 String originResource = ev.get_data().toString(); 476 398 if(!ArrayUtils.contains(visitedResource.toArray(new String[visitedResource.size()]), originResource)){ … … 478 400 } 479 401 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){ 486 408 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); 493 412 scheduler.sim_cancel(filter, null); 494 scheduler.sendInternal(time, WormsTags.TASK_EXECUTION_FINISHED, task); 495 413 scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, execTask); 496 414 } 497 415 } … … 511 429 numberOfPE = numberOfPE + resUnit.getAmount(); 512 430 } 513 //numberOfPE = getResourceManager().getPE().size();514 431 } catch (Exception e) { 515 432 numberOfPE = 1; … … 532 449 ExecTask task) { 533 450 534 ResourceManager resourceManager = this.resourceManager; 451 Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>(); 452 LocalResourceManager resourceManager = getResourceManager(); 535 453 if(resourceName != null){ 536 454 ComputingResource resource = null; … … 540 458 return null; 541 459 } 542 543 460 resourceManager = new LocalResourceManager(resource); 544 461 } 545 Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();546 547 462 548 463 int cpuRequest; … … 553 468 } 554 469 555 //PEUnit processingUnits = null;556 470 if (cpuRequest != 0) { 557 471 558 472 List<ResourceUnit> availableUnits = null; 559 473 try { 560 availableUnits = getResourceManager().getPE();474 availableUnits = resourceManager.getPE(); 561 475 } catch (ResourceException e) { 562 476 return null; 563 477 } 478 564 479 List<ResourceUnit> choosenPEUnits = new ArrayList<ResourceUnit>(); 565 566 480 for (int i = 0; i < availableUnits.size() && cpuRequest > 0; i++) { 567 481 PEUnit peUnit = (PEUnit) availableUnits .get(i); … … 576 490 return null; 577 491 } 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 }*/606 492 map.put(StandardResourceUnitName.PE, choosenPEUnits.get(0)); 607 493 } 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 630 495 return map; 631 496 } 632 633 634 635 public void notifySubmittedWorkloadUnit(WorkloadUnit<?> job, boolean ack) { 497 498 public void notifySubmittedWorkloadUnit(WorkloadUnit wu, boolean ack) { 636 499 updateProcessingProgress(); 637 registerWorkloadUnit( job);638 } 639 640 private void registerWorkloadUnit(WorkloadUnit <?>wu){500 registerWorkloadUnit(wu); 501 } 502 503 private void registerWorkloadUnit(WorkloadUnit wu){ 641 504 if(!wu.isRegistered()){ 642 505 wu.register(jobRegistry); … … 647 510 class LocalWorkloadUnitHandler implements WorkloadUnitHandler{ 648 511 649 public void handleJob(Job job){512 public void handleJob(JobInterface<?> job){ 650 513 651 514 if (log.isInfoEnabled()) … … 654 517 List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>(); 655 518 jobsList.add(job); 656 WorkloadUnitListImpl readyTasks = new WorkloadUnitListImpl();657 for(Task task: jobRegistry.get ReadyTasks(jobsList)){519 TaskListImpl availableTasks = new TaskListImpl(); 520 for(Task task: jobRegistry.getAvailableTasks(jobsList)){ 658 521 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){ 671 535 Executable exec = new Executable(task); 672 exec.setUserID(task.getSenderId());673 exec.setLength(task.getLength());674 536 registerWorkloadUnit(exec); 675 537 } 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); 682 541 registerWorkloadUnit(exec); 683 542 } … … 686 545 687 546 public void handleExecutable(ExecTask task){ 547 688 548 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()); 697 552 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()); 700 557 parentScheduler = parentScheduler.getParent(); 701 558 } 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) { 712 567 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);733 568 } 734 569 } -
DCWoRMS/trunk/build/classes/schedframe/scheduling/queue/TaskQueue.java
r477 r539 1 1 package schedframe.scheduling.queue; 2 2 3 import gridsim.Gridlet; 4 import gssim.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 3 import gridsim.dcworms.DCWormsTags; 5 4 6 5 import org.joda.time.DateTime; 7 6 8 import schedframe.scheduling.tasks.WorkloadUnit;7 import dcworms.schedframe.scheduling.queues.AbstractStatsSupportingQueue; 9 8 10 public class TaskQueue extends AbstractStatsSupportingQueue<WorkloadUnit<?>> implements Queue<WorkloadUnit<?>>{ 9 import schedframe.scheduling.tasks.TaskInterface; 11 10 11 public class TaskQueue extends AbstractStatsSupportingQueue<TaskInterface<?>> implements Queue<TaskInterface<?>>{ 12 12 13 13 private static final long serialVersionUID = 6576299222910508209L; … … 17 17 protected boolean supportReservation; 18 18 19 20 19 public TaskQueue (boolean supportReservation){ 21 name = "Queue";22 priority = 0;20 this.name = "Queue"; 21 this.priority = 0; 23 22 this.supportReservation = supportReservation; 24 25 23 } 26 24 27 public boolean add( WorkloadUnit<?> wu){25 public boolean add(TaskInterface<?> task){ 28 26 try { 29 wu.setStatus(Gridlet.QUEUED);27 task.setStatus(DCWormsTags.QUEUED); 30 28 } catch(Exception e){ 31 29 throw new RuntimeException(e); 32 30 } 33 //updateStats(); 34 return super.add(wu); 31 return super.add(task); 35 32 } 36 33 37 public void add(int pos, WorkloadUnit<?> wu){34 public void add(int pos, TaskInterface<?> task){ 38 35 try { 39 wu.setStatus(Gridlet.QUEUED);36 task.setStatus(DCWormsTags.QUEUED); 40 37 } catch(Exception e){ 41 38 throw new RuntimeException(e); 42 39 } 43 //updateStats(); 44 super.add(pos, wu); 40 super.add(pos, task); 45 41 } 46 42 47 43 public DateTime getArrivalTime(int pos) throws IndexOutOfBoundsException { 48 //return get(pos).getSubmissionTimeToBroker(); 49 return null; 44 return get(pos).getSubmissionTimeToBroker(); 50 45 } 51 46 … … 69 64 return supportReservation; 70 65 } 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 }*/103 66 } -
DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/AbstractProcesses.java
r477 r539 3 3 import schedframe.scheduling.tasks.requirements.ResourceParameterName; 4 4 5 public abstract class AbstractProcesses <T> implements WorkloadUnit<T>{5 public abstract class AbstractProcesses implements WorkloadUnit{ 6 6 7 7 -
DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/Job.java
r477 r539 18 18 import schedframe.scheduling.WorkloadUnitHandler; 19 19 import schedframe.scheduling.manager.tasks.JobRegistryImpl; 20 import schedframe.scheduling.policy.AbstractManagementSystem;21 20 22 21 … … 179 178 } 180 179 181 public int getUserI D(){180 public int getUserId(){ 182 181 return this.senderId; 183 182 } … … 204 203 205 204 List<Task> readyTasks = new ArrayList<Task>(); 206 207 205 int size = tasks.size(); 206 208 207 for(int i = 0; i < size; i++){ 209 208 int parCnt; … … 216 215 } catch(Exception e){ 217 216 parCnt = 0; 218 //e.printStackTrace(); 219 } 220 if(parCnt == 0) 221 { 217 } 218 if(parCnt == 0) { 222 219 readyTasks.add(task); 223 220 } 224 else 225 { 221 else { 226 222 for(int j = 0; j < parCnt; j++){ 227 223 ParentType par = task.getDescription().getWorkflow().getParent(j); -
DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/JobInterface.java
r477 r539 11 11 * 12 12 */ 13 public interface JobInterface<T> extends WorkloadUnit <T> {13 public interface JobInterface<T> extends WorkloadUnit, DescriptionContainer<T> { 14 14 15 15 /** … … 18 18 * @throws NoSuchFieldException if there is no tasks for this job, and job id can not be obtained 19 19 */ 20 public abstract String getId() throws NoSuchFieldException;20 //public abstract String getId() throws NoSuchFieldException; 21 21 22 22 /** … … 44 44 * @return constant which represents current status of this job 45 45 */ 46 public int getStatus();46 //public int getStatus(); 47 47 48 public int getUserID();48 //public int getUserID(); 49 49 } -
DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/Processes.java
r477 r539 1 1 package schedframe.scheduling.tasks; 2 3 import java.util.List;4 2 5 3 import org.qcg.broker.schemas.resreqs.ComputingResourceBaseTypeItem; … … 196 194 } 197 195 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() { 216 202 // TODO Auto-generated method stub 217 203 return 0; 218 204 } 219 205 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 237 207 238 208 @Override -
DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/Task.java
r477 r539 30 30 import schedframe.scheduling.WorkloadUnitHandler; 31 31 import schedframe.scheduling.manager.tasks.JobRegistryImpl; 32 import schedframe.scheduling.policy.AbstractManagementSystem;33 32 import schedframe.scheduling.tasks.requirements.ResourceParameterName; 34 33 … … 38 37 * 39 38 */ 40 public class Task /*extends AbstractTask*/implements TaskInterface<org.qcg.broker.schemas.resreqs.Task> {39 public class Task implements TaskInterface<org.qcg.broker.schemas.resreqs.Task> { 41 40 42 41 protected static Unmarshaller unmarshaller; … … 72 71 private int senderId; 73 72 private long workloadLogWaitTime; 74 //String resPathHistory; 75 73 76 74 public Task(org.qcg.broker.schemas.resreqs.Task task){ 77 75 this.task = task; … … 80 78 this.brokerSubmitTime = null; 81 79 this.duration = null; 82 // this.gridletID_ = (getJobId() + "_" + getId()).hashCode();83 80 prepareTopology(); 84 81 } … … 91 88 this.brokerSubmitTime = null; 92 89 this.duration = null; 93 // this.gridletID_ = (getJobId() + getId()).hashCode();94 90 prepareTopology(); 95 91 } … … 269 265 } 270 266 271 public String getUserD n() {267 public String getUserDN() { 272 268 return this.task.getUserDN(); 273 269 } … … 471 467 }*/ 472 468 469 473 470 @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() { 488 472 // TODO Auto-generated method stub 489 473 return 0; 490 474 } 491 475 492 @Override493 public int getUserID() {494 // TODO Auto-generated method stub495 return 0;496 }497 498 476 public boolean isRegistered() { 499 477 return isRegistered; -
DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/TaskInterface.java
r477 r539 6 6 import org.joda.time.ReadableDuration; 7 7 8 import schedframe.DescriptionContainer; 8 9 import schedframe.scheduling.tasks.requirements.ResourceParameterName; 9 10 … … 14 15 * 15 16 */ 16 public interface TaskInterface<T> extends WorkloadUnit <T> {17 public interface TaskInterface<T> extends WorkloadUnit, DescriptionContainer<T> { 17 18 18 19 /** … … 20 21 * @return task identifier 21 22 */ 22 public abstract String getId();23 //public abstract String getId(); 23 24 24 25 /** … … 33 34 * submitted this task. 34 35 */ 35 public abstract String getUserD n();36 public abstract String getUserDN(); 36 37 37 38 /** … … 87 88 */ 88 89 public long getLength(); 89 90 /** 91 * 92 * @param length measured in instructions. 93 */ 94 public void setLength(long length); 95 90 96 91 /** 97 92 * 98 93 * @return constant which represent current task status 99 94 */ 100 public int getStatus();95 //public int getStatus(); 101 96 102 97 … … 107 102 public List<AbstractProcesses> getProcesses(AbstractProcessesGroup processGroup); 108 103 109 public void setStatus(int status) throws Exception;104 //public void setStatus(int status) throws Exception; 110 105 111 106 public double getCpuCntRequest() throws NoSuchFieldException; … … 114 109 115 110 public long getWorkloadLogWaitTime(); 116 117 //public void addToResPath(String resName); 118 119 //public String getResPath(); 111 120 112 121 113 } -
DCWoRMS/trunk/build/classes/schedframe/scheduling/tasks/WorkloadUnit.java
r477 r539 1 1 package schedframe.scheduling.tasks; 2 2 3 import java.util.List;4 5 import schedframe.DescriptionContainer;6 3 import schedframe.scheduling.WorkloadUnitHandler; 7 4 import schedframe.scheduling.manager.tasks.JobRegistryImpl; 8 import schedframe.scheduling.policy.AbstractManagementSystem;9 5 10 public interface WorkloadUnit <T> extends DescriptionContainer<T>{6 public interface WorkloadUnit { 11 7 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(); 18 9 19 /** 20 * 21 * @return list of tasks which belongs to this job 22 */ 23 public abstract List<? extends TaskInterface<?>> getTask(); 10 public int getUserId(); 24 11 25 /**26 *27 * @param taskId28 * @return task with specified taskId29 * @throws NoSuchFieldException if task with taskId does not exist in this job30 */31 public abstract TaskInterface<?> getTask(String taskId) throws NoSuchFieldException;32 33 /**34 *35 * @return number of tasks in this job36 */37 public abstract int getTaskCount();38 39 /**40 *41 * @return constant which represents current status of this job42 */43 12 public int getStatus(); 44 13 45 14 public void setStatus(int status) throws Exception; 46 15 47 16 public boolean isFinished(); 48 49 public int getUserID(); 50 17 51 18 public boolean isRegistered(); 52 19 -
DCWoRMS/trunk/build/classes/simulator/ConfigurationOptions.java
r477 r539 8 8 import java.util.PropertyResourceBundle; 9 9 import java.util.ResourceBundle; 10 import java.util.logging.FileHandler;11 10 12 11 /** … … 26 25 * ============================================================================================= 27 26 */ 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 34 28 /** The path to the resource description file */ 35 29 public static final String RESOURCE_DESC_MODIFIER = "resdesc"; … … 58 52 public static final String READ_SCENARIO_INPUT_FOLDER = READ_SCENARIO_MODIFIER 59 53 + ".inputfolder"; 60 public static final String READ_SCENARIO_INPUT_TAR = READ_SCENARIO_MODIFIER+ ".tar";61 54 62 55 /** The name of the workload file */ … … 64 57 + ".workloadfilename"; 65 58 66 /** Shall a detailed history be printed */67 public static final String PRINT_HISTORY_MODIFIER = "printhistory";68 69 59 /** The default name of a workload file */ 70 60 public static final String DEFAULT_WORKLOAD_FILE_NAME = "workload.swf"; 71 61 72 62 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 78 64 79 65 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"; 85 67 public static final String CREATEDIAGRAMS_TASKS = CREATEDIAGRAMS + ".tasks"; 86 68 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 87 74 88 75 public static final String CREATESTATISTICS = "createstatistics"; 89 76 public static final String ACCUMULATED_RESOURCES_STATISTICS = CREATESTATISTICS + ".accumulatedresources"; 90 77 public static final String EXTENDED_TASKS_STATISTICS = CREATESTATISTICS + ".extendedtasks"; 91 public static final String GRIDLET_HISTORY_STATISTICS = CREATESTATISTICS + ".gridlethistory";92 78 public static final String JOBS_STATISTICS = CREATESTATISTICS + ".jobs"; 93 79 public static final String SIMULATION_STATISTICS = CREATESTATISTICS + ".simulation"; 94 public static final String FORMAT_STATISTICS_OUTPUT = CREATESTATISTICS + ".formatoutput";95 80 96 81 /** … … 116 101 /* =============================================================================================== */ 117 102 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 143 104 144 105 /** … … 180 141 public String inputWorkloadFileName = DEFAULT_WORKLOAD_FILE_NAME; 181 142 182 /**183 * a txt file name with topology description184 */185 public String networkTopologyFileName = null;186 143 187 144 /** … … 199 156 public boolean overwriteFiles = false; 200 157 201 /**202 * true if the history files are to be generated (makes the simulation203 * slower)204 */205 public boolean printHistory = false;206 158 207 159 /** … … 210 162 public int numberOfSimulations = 1; //default value 211 163 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 223 173 public boolean createjobsstatistics = true; 224 174 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 229 180 /** 230 181 * An empty constructor. … … 257 208 return null; 258 209 } 259 260 try {261 co.gridSchedulingPluginName = bundle262 .getString(GRID_SCHEDULING_PLUGIN_NAME_MODIFIER);263 } catch(MissingResourceException e){264 co.gridSchedulingPluginName = null;265 }266 267 try {268 co.exectimeestimationplugin = bundle269 .getString(EXEC_TIME_ESTIMATION_PLUGIN_NAME_MODIFIER);270 } catch(MissingResourceException e){271 co.exectimeestimationplugin = null;272 }273 274 try {275 co.localAllocPolicyPluginName = bundle276 .getString(LOCAL_ALLOC_POLICY_PLUGIN_NAME_MODIFIER);277 } catch(MissingResourceException e){278 co.localAllocPolicyPluginName = null;279 }280 281 210 282 211 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 }289 212 290 213 try { … … 314 237 } 315 238 316 317 try {318 co.networkTopologyFileName = bundle319 .getString(NETWORK_TOPOLOGY_FILE_MODIFIER);320 } catch(MissingResourceException e){321 co.networkTopologyFileName = null;322 }323 324 239 if (co.createScenario == false) { 325 240 // read scenario … … 329 244 } catch (MissingResourceException e) { 330 245 co.inputFolder = null; 331 }332 333 try {334 co.inputTar = getSeparatorTerminatedPath(bundle335 .getString(READ_SCENARIO_INPUT_TAR));336 } catch (MissingResourceException e) {337 co.inputTar = null;338 246 } 339 247 … … 357 265 co.createXMLSupplement = false; 358 266 } 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 367 268 // create diagrams 368 269 … … 372 273 bundle.getString(CREATEDIAGRAMS)).booleanValue(); 373 274 } 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; 393 291 } 394 292 try { … … 399 297 } 400 298 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 406 316 try { 407 317 co.creatediagrams_tasks = Boolean.valueOf( 408 bundle.getString(CREATEDIAGRAMS_TASKS)).booleanValue() && createDiagrams;318 bundle.getString(CREATEDIAGRAMS_TASKS)).booleanValue(); 409 319 } catch(MissingResourceException e){ 410 320 co.creatediagrams_tasks = createDiagrams; … … 412 322 try { 413 323 co.creatediagrams_taskswaitingtime = Boolean.valueOf( 414 bundle.getString(CREATEDIAGRAMS_TASKSWAITINGTIME)).booleanValue() && createDiagrams;324 bundle.getString(CREATEDIAGRAMS_TASKSWAITINGTIME)).booleanValue(); 415 325 } catch(MissingResourceException e){ 416 326 co.creatediagrams_taskswaitingtime = createDiagrams; 417 327 } 418 419 328 420 329 try { … … 427 336 428 337 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 {447 338 co.createjobsstatistics = Boolean.valueOf( 448 339 bundle.getString(JOBS_STATISTICS)).booleanValue(); … … 456 347 co.createsimulationstatistics = true; 457 348 } 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 465 350 try { 466 351 co.numberOfSimulations = Integer.valueOf(bundle.getString(NUMBER_OF_SIMULATIONS)).intValue(); … … 469 354 } 470 355 return co; 471 }472 473 /**474 * Creates a new configuration object in the CREATE_SCENARIO mode.475 *476 * @param gridSchedulingPluginName477 * @param forecastFinishTimePluginName478 * @param localAllocPolicyPluginName479 * @param resdescFileName480 * @param taskParamFileName481 * @param outputFolder482 * @param outputWorkloadFileName483 * @param overwriteFiles484 * @param printHistory485 */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 mode504 this.createScenario = true;505 }506 507 /**508 * Creates a new configuration object in the READ_SCENARIO mode.509 *510 * @param gridSchedulingPluginName511 * @param forecastFinishTimePluginName512 * @param localAllocPolicyPluginName513 * @param resdescFileName514 * @param inputFolder515 * @param inputWorkloadFileName516 * @param overwriteFiles517 * @param printHistory518 */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 mode535 this.createScenario = false;536 356 } 537 357 -
DCWoRMS/trunk/build/classes/simulator/DataCenterWorkloadSimulator.java
r477 r539 1 1 package simulator; 2 2 3 //import eduni.cloudsim.GSSIM;4 3 import java.io.File; 5 4 import java.io.FileReader; … … 26 25 import simulator.reader.ResourceReader; 27 26 import simulator.stats.AccumulatedStatistics; 28 import simulator.stats.implementation. GSSimStatistics;27 import simulator.stats.implementation.DCWormsStatistics; 29 28 import simulator.utils.LogErrStream; 30 29 import simulator.workload.WorkloadLoader; … … 40 39 * {@link #main(String[])} method used to invoke the program. This class also 41 40 * provides second possibility to start the simulator, namely one may use the 42 * {@link #performSimulation(ConfigurationOptions, GSSimStatistics)} method.41 * {@link #performSimulation(ConfigurationOptions, DCWormsStatistics)} method. 43 42 * In this case, the input parameter, describing the simulation options, must be 44 43 * earlier prepared. The results of the simulation can be acquired using the … … 98 97 */ 99 98 public static void main(String[] args) { 100 DataCenterWorkloadSimulator gssim= new DataCenterWorkloadSimulator();101 gssim.run(args);99 DataCenterWorkloadSimulator dcworms = new DataCenterWorkloadSimulator(); 100 dcworms.run(args); 102 101 } 103 102 … … 117 116 @Override 118 117 public String getDescription() { 119 return " WoRMS experiment file";118 return "DCWoRMS experiment file"; 120 119 } 121 120 }; … … 198 197 } 199 198 200 private void runMultiuser(String rootDirPath, DataCenterWorkloadSimulator gssim) {199 private void runMultiuser(String rootDirPath, DataCenterWorkloadSimulator dcworms) { 201 200 throw new RuntimeException("not supported yet"); 202 201 } … … 269 268 rc.setInitList(null); 270 269 271 WormsUsers wl = newWormsUsers("Users",270 DCWormsUsers wl = new DCWormsUsers("Users", 272 271 rc.getScheduler().get_name(), workload); 273 272 … … 275 274 long stopSimulation = System.currentTimeMillis(); 276 275 277 GSSimStatistics stats = new GSSimStatistics(simulationIdentifier,276 DCWormsStatistics stats = new DCWormsStatistics(simulationIdentifier, 278 277 options, wl, statsOutputPath, rc); 279 278 accumulatedStatistics.add(stats); -
DCWoRMS/trunk/build/classes/simulator/GenericUser.java
r477 r539 2 2 3 3 4 import gssim.schedframe.scheduling.utils.JobDescription;5 import gssim.schedframe.scheduling.utils.TaskDescription;6 4 7 5 import java.util.List; 6 7 import dcworms.schedframe.scheduling.utils.JobDescription; 8 import dcworms.schedframe.scheduling.utils.TaskDescription; 8 9 9 10 import schedframe.scheduling.tasks.Job; -
DCWoRMS/trunk/build/classes/simulator/reader/ResourceReader.java
r477 r539 11 11 import java.util.Deque; 12 12 import java.util.HashMap; 13 import java.util.LinkedHashSet; 13 14 import java.util.LinkedList; 14 15 import java.util.List; 15 16 import java.util.Map; 17 import java.util.Set; 16 18 17 19 import org.exolab.castor.types.AnyNode; … … 54 56 private String globalSchedulingPluginName; 55 57 58 private Set<String> compResLayers; 59 56 60 public ResourceReader(ConfigurationOptions options) throws IOException { 57 61 … … 59 63 globalSchedulingPluginName = "example.globalplugin.GridFCFSRoundRobinPlugin"; 60 64 prepareCalendar(); 65 compResLayers = new LinkedHashSet<String>(); 61 66 } 62 67 … … 64 69 UnknownParameter { 65 70 66 //File file = new File("src/test/rewolucja/schemas/example/coolemall/example4.xml");67 71 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);*/83 72 Environment env = Environment.unmarshal(new FileReader(file)); 84 73 … … 97 86 ResourceController rc = new ResourceController(mainScheduler, computingResources); 98 87 rc.setInitList(toInit); 88 rc.setCompResLayers(compResLayers); 99 89 return rc; 100 90 } … … 177 167 178 168 List<ComputingResource> mainCompResourceList = new ArrayList<ComputingResource>(); 179 180 169 Deque<ComputingResourceDescription> toExamine = new ArrayDeque<ComputingResourceDescription>(); 181 170 Deque<ComputingResource> resStructure = new ArrayDeque<ComputingResource>(); … … 192 181 ComputingResource parentResource = resStructure.pop(); 193 182 toInit.add(parentResource); 183 compResLayers.add(parentResource.getType().getName()); 194 184 List<AbstractResourceDescription> childrenResDesc = parentResDesc.getChildren(); 195 185 if (childrenResDesc == null){ … … 250 240 //TODO - refactor (remove - create scheduler on the basis of resource description) 251 241 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")*/){ 253 243 mainScheduler = mainSchedulers.get(0); 254 244 } … … 261 251 ManagedResources managedResources = new ManagedResources(mainCompResourceList, new HashMap<ResourceUnitName, List<ResourceUnit>>()); 262 252 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 266 254 for(Scheduler lr: mainSchedulers){ 267 255 mainScheduler.addChild(lr); … … 280 268 TaskQueueList queues = new TaskQueueList(1); 281 269 282 if(schedulerDef.getQueue () != null && schedulerDef.getQueueCount() > 0){283 int queueCount = schedulerDef.getQueue Count();270 if(schedulerDef.getQueues()!= null){ 271 int queueCount = schedulerDef.getQueues().getQueueCount(); 284 272 for(int i = 0; i < queueCount; i++){ 285 schemas.QueueType queueDef = schedulerDef.getQueue (i);273 schemas.QueueType queueDef = schedulerDef.getQueues().getQueue(i); 286 274 TaskQueue queue = new TaskQueue(queueDef.getReservation()); 287 275 queue.setName(queueDef.getName()); -
DCWoRMS/trunk/build/classes/simulator/stats/AccumulatedStatistics.java
r477 r539 10 10 import java.util.List; 11 11 12 import simulator.stats.implementation. GSSimStatistics;12 import simulator.stats.implementation.DCWormsStatistics; 13 13 import gridsim.Accumulator; 14 14 -
DCWoRMS/trunk/build/classes/simulator/stats/implementation/GSSAccumulatorsStats.java
r477 r539 10 10 public GSSAccumulator meanQueueLength; 11 11 public GSSAccumulator meanEnergyUsage; 12 public GSSAccumulator meanAirFlow; 12 13 13 14 public GSSAccumulator meanTaskStartTime; … … 29 30 meanReservationLoad = new GSSAccumulator(); 30 31 meanQueueLength = new GSSAccumulator(); 31 meanEnergyUsage = new GSSAccumulator(); 32 meanEnergyUsage = new GSSAccumulator(); 33 meanAirFlow = new GSSAccumulator(); 32 34 33 35 meanTaskStartTime = new GSSAccumulator(); -
DCWoRMS/trunk/build/classes/simulator/stats/implementation/ResourceUsageStats.java
r477 r539 1 1 package simulator.stats.implementation; 2 2 3 import java.util.Map;4 import java.util.TreeMap;5 6 3 import schedframe.resources.ResourceType; 7 import schedframe.resources.StandardResourceType;8 4 import simulator.stats.implementation.out.StatsSerializer; 9 5 10 /** 11 * 12 * @author Marcin Krystek 13 * 14 */ 15 public class ResourceUsageStats implements StatsInterface { 6 public class ResourceUsageStats extends ResourceDynamicStats implements StatsInterface { 16 7 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" }; 28 9 29 10 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); 55 12 } 56 13 … … 62 19 return headers; 63 20 } 64 65 21 } -
DCWoRMS/trunk/build/classes/simulator/stats/implementation/TaskStats.java
r477 r539 1 1 package simulator.stats.implementation; 2 2 3 import gssim.schedframe.scheduling.Executable;4 3 5 4 import java.util.List; 5 6 import dcworms.schedframe.scheduling.Executable; 6 7 7 8 import simulator.stats.implementation.out.StatsSerializer; … … 45 46 46 47 public String getUserDN() { 47 return this.task.getUserD n();48 return this.task.getUserDN(); 48 49 } 49 50 50 51 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 58 54 return resName; 59 55 } -
DCWoRMS/trunk/build/classes/simulator/stats/implementation/out/StatsSerializer.java
r477 r539 4 4 import simulator.stats.implementation.GSSAccumulatorsStats; 5 5 import simulator.stats.implementation.JobStats; 6 import simulator.stats.implementation.ResourceEnergyStats; 6 import simulator.stats.implementation.ResourceAirFlowStats; 7 import simulator.stats.implementation.ResourcePowerStats; 7 8 import simulator.stats.implementation.ResourceStats; 8 9 import simulator.stats.implementation.ResourceUsageStats; … … 26 27 public Object visit(ResourceUsageStats arg); 27 28 28 public Object visit(Resource EnergyStats arg);29 public Object visit(ResourcePowerStats arg); 29 30 31 public Object visit(ResourceAirFlowStats arg); 30 32 31 33 public Object visit(GSSAccumulatorsStats arg); -
DCWoRMS/trunk/build/classes/simulator/stats/implementation/out/StringSerializer.java
r477 r539 11 11 import simulator.stats.implementation.GSSAccumulatorsStats; 12 12 import simulator.stats.implementation.JobStats; 13 import simulator.stats.implementation.ResourceEnergyStats; 13 import simulator.stats.implementation.ResourceAirFlowStats; 14 import simulator.stats.implementation.ResourcePowerStats; 14 15 import simulator.stats.implementation.ResourceStats; 15 16 import simulator.stats.implementation.ResourceUsageStats; … … 258 259 259 260 public Object visit(ResourceUsageStats resourceUsageStats) { 260 Map<Long, Integer> resourceUsage = resourceUsageStats.getUsage();261 Map<Long, Double> resourceUsage = resourceUsageStats.getHistory(); 261 262 262 263 int mapSize = resourceUsage.size(); … … 297 298 buffer.append(resourceUsageStats.getResourceName()); 298 299 buffer.append(fieldSeparator); 299 Integervalue = resourceUsage.get(timestamp);300 Double value = resourceUsage.get(timestamp); 300 301 buffer.append(timestamp); 301 302 buffer.append(fieldSeparator); … … 306 307 307 308 } 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(); 316 318 317 319 int mapSize = resourceEnergy.size(); … … 361 363 362 364 } 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 } 365 428 366 429 return buffer.toString(); -
DCWoRMS/trunk/build/classes/simulator/utils/XsltTransformations.java
r477 r539 1 1 package simulator.utils; 2 2 3 import gssim.schedframe.scheduling.utils.JobDescription;4 import gssim.schedframe.scheduling.utils.TaskDescription;5 3 6 4 import java.io.IOException; … … 20 18 import javax.xml.transform.stream.StreamSource; 21 19 import javax.xml.xpath.XPathExpressionException; 20 21 import dcworms.schedframe.scheduling.utils.JobDescription; 22 import dcworms.schedframe.scheduling.utils.TaskDescription; 22 23 23 24 /** -
DCWoRMS/trunk/build/classes/simulator/workload/WorkloadLoader.java
r477 r539 2 2 3 3 import org.qcg.broker.schemas.jobdesc.QcgJob; 4 import gssim.schedframe.scheduling.utils.JobDescription;5 import gssim.schedframe.scheduling.utils.TaskDescription;6 4 7 5 import java.io.IOException; … … 24 22 import org.exolab.castor.xml.MarshalException; 25 23 import org.exolab.castor.xml.ValidationException; 24 25 import dcworms.schedframe.scheduling.utils.JobDescription; 26 import dcworms.schedframe.scheduling.utils.TaskDescription; 26 27 27 28 -
DCWoRMS/trunk/build/classes/simulator/workload/generator/impl/QcgJobGenerator.java
r477 r539 58 58 import org.xml.sax.InputSource; 59 59 60 import simulator. WormsConstants;60 import simulator.DCWormsConstants; 61 61 import simulator.utils.GSSimXML; 62 62 import simulator.utils.XsltTransformations; … … 259 259 260 260 //initially - a standard value 261 taskCountToBeGenerated = WormsConstants.DEFAULT_TASK_COUNT_IN_SINGLE_JOB;261 taskCountToBeGenerated = DCWormsConstants.DEFAULT_TASK_COUNT_IN_SINGLE_JOB; 262 262 263 263 try {
Note: See TracChangeset
for help on using the changeset viewer.