[477] | 1 | package schedframe.resources.computing; |
---|
| 2 | |
---|
| 3 | import schedframe.resources.StandardResourceType; |
---|
[789] | 4 | import schedframe.resources.UserResourceType; |
---|
[477] | 5 | import schedframe.resources.computing.description.ComputingResourceDescription; |
---|
[789] | 6 | import schedframe.resources.computing.recs.ComputeBox1; |
---|
| 7 | import schedframe.resources.computing.recs.Node; |
---|
| 8 | import schedframe.resources.computing.recs.NodeGroup; |
---|
[477] | 9 | import schedframe.scheduling.Scheduler; |
---|
| 10 | import schedframe.scheduling.manager.resources.ManagedResources; |
---|
| 11 | import schedframe.scheduling.plugin.SchedulingPlugin; |
---|
| 12 | import schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin; |
---|
| 13 | import schedframe.scheduling.policy.AbstractManagementSystem; |
---|
| 14 | import schedframe.scheduling.policy.global.GridBroker; |
---|
| 15 | import schedframe.scheduling.policy.local.LocalManagementSystem; |
---|
| 16 | import schedframe.scheduling.queue.TaskQueueList; |
---|
[481] | 17 | import simulator.DCWormsConstants; |
---|
[477] | 18 | |
---|
| 19 | |
---|
| 20 | public class ResourceFactory { |
---|
| 21 | |
---|
| 22 | public static ComputingResource createResource(ComputingResourceDescription resDesc){ |
---|
| 23 | |
---|
| 24 | if (resDesc.getType().equals(StandardResourceType.DataCenter)) |
---|
| 25 | return new DataCenter(resDesc); |
---|
[495] | 26 | else if (resDesc.getType().equals(StandardResourceType.Rack)) |
---|
[653] | 27 | return new Rack(resDesc); |
---|
[477] | 28 | else if (resDesc.getType().equals(StandardResourceType.ComputingNode)) |
---|
[789] | 29 | return new ComputingNode(resDesc); |
---|
[477] | 30 | else if (resDesc.getType().equals(StandardResourceType.Processor)) |
---|
| 31 | return new Processor(resDesc); |
---|
[653] | 32 | else if (resDesc.getType().equals(StandardResourceType.Core)) |
---|
| 33 | return new Core(resDesc); |
---|
[789] | 34 | else if (resDesc.getType().getName().equals(new UserResourceType("ComputeBox1").getName())) |
---|
| 35 | return new ComputeBox1(resDesc); |
---|
| 36 | else if (resDesc.getType().getName().equals(new UserResourceType("NodeGroup").getName())) |
---|
| 37 | return new NodeGroup(resDesc); |
---|
| 38 | else if (resDesc.getType().getName().equals(new UserResourceType("Node").getName())) |
---|
| 39 | return new Node(resDesc); |
---|
[477] | 40 | else |
---|
| 41 | return new ComputingResource(resDesc); |
---|
| 42 | |
---|
| 43 | /*switch(resDesc.getType()){ |
---|
| 44 | case Grid: return new Grid(resDesc); |
---|
| 45 | case DataCenter: return new DataCenter(resDesc); |
---|
| 46 | case ComputingNode: return new ComputingNode(resDesc); |
---|
| 47 | case Processor: return new Processor(resDesc); |
---|
| 48 | default: |
---|
| 49 | return new ComputingResource(resDesc); |
---|
| 50 | }*/ |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | public static Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception{ |
---|
| 54 | AbstractManagementSystem ms; |
---|
| 55 | switch(type){ |
---|
| 56 | case GS: { |
---|
| 57 | ms = new GridBroker("grid", |
---|
| 58 | schedulingPlugin, execTimeEstimationPlugin, queues); |
---|
| 59 | return new Scheduler(ms, type, managedResources); |
---|
| 60 | } |
---|
| 61 | case LS: { |
---|
[481] | 62 | ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, |
---|
[477] | 63 | schedulingPlugin, execTimeEstimationPlugin, queues); |
---|
| 64 | return new Scheduler(ms, type, managedResources); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | default:{ |
---|
[481] | 68 | ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM, |
---|
[477] | 69 | schedulingPlugin, execTimeEstimationPlugin, queues); |
---|
| 70 | return new Scheduler(ms, type, managedResources); |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | |
---|