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

Revision 477, 2.3 KB checked in by wojtekp, 13 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.WormsConstants;
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.ComputingNode))
23                        return  new ComputingNode(resDesc);
24                else if (resDesc.getType().equals(StandardResourceType.Processor))
25                        return new Processor(resDesc);
26                else
27                        return new ComputingResource(resDesc);
28       
29                /*switch(resDesc.getType()){
30                        case Grid: return new Grid(resDesc);
31                        case DataCenter: return new DataCenter(resDesc);
32                        case ComputingNode: return new ComputingNode(resDesc);
33                        case Processor: return new Processor(resDesc);
34                default:
35                        return new ComputingResource(resDesc);
36                }*/
37        }
38
39        public static Scheduler createScheduler(StandardResourceType type, String id, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues, ManagedResources managedResources) throws Exception{
40                AbstractManagementSystem ms;
41                switch(type){
42                        case GS: {
43                                ms = new GridBroker("grid",
44                                                schedulingPlugin, execTimeEstimationPlugin, queues);
45                                return new Scheduler(ms, type, managedResources);
46                        }
47                        case LS: {
48                                ms = new LocalManagementSystem(id, WormsConstants.MANAGEMENT_SYSTEM,
49                                                schedulingPlugin, execTimeEstimationPlugin, queues);
50                                return new Scheduler(ms, type, managedResources);
51                        }
52
53                default:{
54                                ms = new LocalManagementSystem(id, WormsConstants.MANAGEMENT_SYSTEM,
55                                                schedulingPlugin, execTimeEstimationPlugin, queues);
56                                return new Scheduler(ms, type, managedResources);
57                        }
58                }
59        }
60}
61
Note: See TracBrowser for help on using the repository browser.