1 | package test.rewolucja.scheduling.implementation; |
---|
2 | |
---|
3 | import java.util.ArrayList; |
---|
4 | import java.util.HashSet; |
---|
5 | import java.util.List; |
---|
6 | import java.util.Properties; |
---|
7 | import java.util.Set; |
---|
8 | |
---|
9 | import org.apache.commons.logging.Log; |
---|
10 | import org.apache.commons.logging.LogFactory; |
---|
11 | |
---|
12 | import schedframe.scheduling.plugin.estimation.ExecTimeEstimationPlugin; |
---|
13 | import schedframe.scheduling.plugin.grid.ModuleListImpl; |
---|
14 | import test.rewolucja.reservation.GridReservationManagerNew; |
---|
15 | import test.rewolucja.resources.description.ExecResourceDescription; |
---|
16 | import test.rewolucja.resources.logical.base.LogicalResource; |
---|
17 | import test.rewolucja.resources.manager.factory.ResourceManagerFactory; |
---|
18 | import test.rewolucja.scheduling.GridResourceDiscovery; |
---|
19 | |
---|
20 | public class GridBroker extends GlobalManagementSystem { |
---|
21 | |
---|
22 | |
---|
23 | private static Log log = LogFactory.getLog(GridBroker.class); |
---|
24 | |
---|
25 | protected Set<Integer> otherGridSchedulersIds; |
---|
26 | |
---|
27 | |
---|
28 | public GridBroker(String name, String schedulingPluginClassName, ExecTimeEstimationPlugin execTimeEstimationPlugin, ExecResourceDescription arc) throws Exception { |
---|
29 | super(name, "BROKER", schedulingPluginClassName, execTimeEstimationPlugin, arc); |
---|
30 | |
---|
31 | //make use of plug-in interface |
---|
32 | |
---|
33 | Properties prop = new Properties(); |
---|
34 | prop.put("plugin.name", name); |
---|
35 | prop.put("plugin.utils.timeoperations", "gssim.scheduling.plugin.local.GssimTimeOperations"); |
---|
36 | schedulingPlugin.init(prop); |
---|
37 | otherGridSchedulersIds = new HashSet<Integer>(); |
---|
38 | |
---|
39 | moduleList = new ModuleListImpl(2); |
---|
40 | //this.moduleList.add(new GridResourceDiscovery(this.getLogicalResource())); |
---|
41 | moduleList.add(new GridReservationManagerNew(this)); |
---|
42 | |
---|
43 | if(log.isDebugEnabled()) |
---|
44 | log.debug(name + ": Creating a broker interface object"); |
---|
45 | } |
---|
46 | |
---|
47 | public void init(LogicalResource logRes) { |
---|
48 | logicalResource = logRes; |
---|
49 | resourceManager = ResourceManagerFactory.createResourceManager(logicalResource); |
---|
50 | moduleList.add((GridResourceDiscovery)resourceManager); |
---|
51 | } |
---|
52 | |
---|
53 | public List<Integer> getMyGridResources() { |
---|
54 | List<Integer> providerIds = new ArrayList<Integer>(); |
---|
55 | for(LogicalResource logRes : logicalResource.getChildren()){ |
---|
56 | providerIds.add(logRes.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 | } |
---|