[1207] | 1 | package schedframe.resources.computing; |
---|
| 2 | |
---|
| 3 | import schedframe.resources.StandardResourceType; |
---|
| 4 | import schedframe.resources.computing.description.ComputingResourceDescription; |
---|
| 5 | import schedframe.scheduling.Scheduler; |
---|
| 6 | import schedframe.scheduling.manager.resources.ManagedResources; |
---|
| 7 | import schedframe.scheduling.plugin.SchedulingPlugin; |
---|
| 8 | import schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin; |
---|
| 9 | import schedframe.scheduling.policy.AbstractManagementSystem; |
---|
| 10 | import schedframe.scheduling.policy.global.GridBroker; |
---|
| 11 | import schedframe.scheduling.policy.local.LocalManagementSystem; |
---|
| 12 | import schedframe.scheduling.queue.TaskQueueList; |
---|
| 13 | import simulator.DCWormsConstants; |
---|
| 14 | |
---|
| 15 | public class StandardResourceFactory implements ResourceFactory { |
---|
| 16 | |
---|
| 17 | public ComputingResource createComputingResource(ComputingResourceDescription resDesc){ |
---|
| 18 | |
---|
| 19 | if (resDesc.getType().equals(StandardResourceType.DataCenter)) |
---|
| 20 | return new DataCenter(resDesc); |
---|
| 21 | else if (resDesc.getType().equals(StandardResourceType.Rack)) |
---|
| 22 | return new Rack(resDesc); |
---|
| 23 | else if (resDesc.getType().equals(StandardResourceType.Node)) |
---|
[1247] | 24 | return new Node(resDesc); |
---|
[1207] | 25 | else if (resDesc.getType().equals(StandardResourceType.Processor)) |
---|
| 26 | return new Processor(resDesc); |
---|
| 27 | else if (resDesc.getType().equals(StandardResourceType.Core)) |
---|
| 28 | return new Core(resDesc); |
---|
| 29 | else |
---|
| 30 | return new ComputingResource(resDesc); |
---|
[1247] | 31 | |
---|
[1207] | 32 | } |
---|
| 33 | |
---|
| 34 | public Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception{ |
---|
| 35 | AbstractManagementSystem ms; |
---|
| 36 | switch(type){ |
---|
| 37 | case GS: { |
---|
| 38 | ms = new GridBroker("grid", |
---|
| 39 | schedulingPlugin, execTimeEstimationPlugin, queues); |
---|
| 40 | return new Scheduler(ms, type, managedResources); |
---|
| 41 | } |
---|
| 42 | case LS: { |
---|
| 43 | ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, |
---|
| 44 | schedulingPlugin, execTimeEstimationPlugin, queues); |
---|
| 45 | return new Scheduler(ms, type, managedResources); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | default:{ |
---|
| 49 | ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, |
---|
| 50 | schedulingPlugin, execTimeEstimationPlugin, queues); |
---|
| 51 | return new Scheduler(ms, type, managedResources); |
---|
| 52 | } |
---|
| 53 | } |
---|
| 54 | } |
---|
| 55 | } |
---|