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