source: DCWoRMS/trunk/src/schedframe/resources/computing/ResourceFactory.java @ 653

Revision 653, 2.5 KB checked in by wojtekp, 12 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package schedframe.resources.computing;
2
3import schedframe.resources.StandardResourceType;
4import schedframe.resources.computing.description.ComputingResourceDescription;
5import schedframe.scheduling.Scheduler;
6import schedframe.scheduling.manager.resources.ManagedResources;
7import schedframe.scheduling.plugin.SchedulingPlugin;
8import schedframe.scheduling.plugin.estimation.ExecutionTimeEstimationPlugin;
9import schedframe.scheduling.policy.AbstractManagementSystem;
10import schedframe.scheduling.policy.global.GridBroker;
11import schedframe.scheduling.policy.local.LocalManagementSystem;
12import schedframe.scheduling.queue.TaskQueueList;
13import simulator.DCWormsConstants;
14
15
16public class ResourceFactory {
17
18        public static ComputingResource createResource(ComputingResourceDescription resDesc){
19               
20                if (resDesc.getType().equals(StandardResourceType.DataCenter))
21                        return new DataCenter(resDesc);
22                else if (resDesc.getType().equals(StandardResourceType.Rack))
23                        return new Rack(resDesc);
24                else if (resDesc.getType().equals(StandardResourceType.ComputingNode))
25                        return  new ComputingNode(resDesc);
26                else if (resDesc.getType().equals(StandardResourceType.Processor))
27                        return new Processor(resDesc);
28                else if (resDesc.getType().equals(StandardResourceType.Core))
29                        return new Core(resDesc);
30                else
31                        return new ComputingResource(resDesc);
32       
33                /*switch(resDesc.getType()){
34                        case Grid: return new Grid(resDesc);
35                        case DataCenter: return new DataCenter(resDesc);
36                        case ComputingNode: return new ComputingNode(resDesc);
37                        case Processor: return new Processor(resDesc);
38                default:
39                        return new ComputingResource(resDesc);
40                }*/
41        }
42
43        public static Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception{
44                AbstractManagementSystem ms;
45                switch(type){
46                        case GS: {
47                                ms = new GridBroker("grid",
48                                                schedulingPlugin, execTimeEstimationPlugin, queues);
49                                return new Scheduler(ms, type, managedResources);
50                        }
51                        case LS: {
52                                ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM,
53                                                schedulingPlugin, execTimeEstimationPlugin, queues);
54                                return new Scheduler(ms, type, managedResources);
55                        }
56
57                default:{
58                                ms = new LocalManagementSystem(id, DCWormsConstants.MANAGEMENT_SYSTEM,
59                                                schedulingPlugin, execTimeEstimationPlugin, queues);
60                                return new Scheduler(ms, type, managedResources);
61                        }
62                }
63        }
64}
65
Note: See TracBrowser for help on using the repository browser.