1 | package schedframe.scheduling.policy.global; |
---|
2 | |
---|
3 | import java.util.ArrayList; |
---|
4 | import java.util.HashSet; |
---|
5 | import java.util.List; |
---|
6 | import java.util.Set; |
---|
7 | |
---|
8 | import org.apache.commons.logging.Log; |
---|
9 | import org.apache.commons.logging.LogFactory; |
---|
10 | |
---|
11 | import schedframe.scheduling.GridResourceDiscovery; |
---|
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.plugin.grid.ModuleListImpl; |
---|
17 | import schedframe.scheduling.queue.TaskQueueList; |
---|
18 | |
---|
19 | public class GridBroker extends GlobalManagementSystem { |
---|
20 | |
---|
21 | |
---|
22 | private static Log log = LogFactory.getLog(GridBroker.class); |
---|
23 | |
---|
24 | protected Set<Integer> otherGridSchedulersIds; |
---|
25 | |
---|
26 | |
---|
27 | public GridBroker(String name, SchedulingPlugin schedulingPlugin, ExecutionTimeEstimationPlugin execTimeEstimationPlugin, TaskQueueList queues) throws Exception { |
---|
28 | super(name, "BROKER", schedulingPlugin, execTimeEstimationPlugin, queues); |
---|
29 | |
---|
30 | //make use of plug-in interface |
---|
31 | |
---|
32 | //Properties prop = new Properties(); |
---|
33 | //prop.put("plugin.name", name); |
---|
34 | //prop.put("plugin.utils.timeoperations", "gssim.scheduling.plugin.local.GssimTimeOperations"); |
---|
35 | //schedulingPlugin.init(prop); |
---|
36 | otherGridSchedulersIds = new HashSet<Integer>(); |
---|
37 | |
---|
38 | moduleList = new ModuleListImpl(2); |
---|
39 | //this.moduleList.add(new GridResourceDiscovery(this.getScheduler())); |
---|
40 | //moduleList.add(new GridReservationManagerNew(this)); |
---|
41 | |
---|
42 | if(log.isDebugEnabled()) |
---|
43 | log.debug(name + ": Creating a broker interface object"); |
---|
44 | } |
---|
45 | |
---|
46 | public void init(Scheduler scheduler, ManagedResources managedResources) { |
---|
47 | super.init(scheduler, managedResources); |
---|
48 | //this.scheduler = scheduler; |
---|
49 | //this.resourceManager = ResourceManagerFactory.createResourceManager(scheduler, managedResources); |
---|
50 | this.moduleList.add((GridResourceDiscovery)resourceManager); |
---|
51 | } |
---|
52 | |
---|
53 | public List<Integer> getMyGridResources() { |
---|
54 | List<Integer> providerIds = new ArrayList<Integer>(); |
---|
55 | for(Scheduler sched: scheduler.getChildren()){ |
---|
56 | providerIds.add(sched.get_id()); |
---|
57 | } |
---|
58 | return providerIds; |
---|
59 | //return GridSim.getGridResourceList(); |
---|
60 | } |
---|
61 | |
---|
62 | public void addOtherGridSchedulerId(int id){ |
---|
63 | otherGridSchedulersIds.add(id); |
---|
64 | } |
---|
65 | |
---|
66 | |
---|
67 | } |
---|