1 | package test.rewolucja.resources.utils; |
---|
2 | |
---|
3 | import eduni.simjava.Sim_event; |
---|
4 | import eduni.simjava.Sim_port; |
---|
5 | import eduni.simjava.Sim_system; |
---|
6 | import gridsim.GridSimTags; |
---|
7 | import gridsim.gssim.GssimTags; |
---|
8 | import gridsim.gssim.network.ExtendedGridSimCore; |
---|
9 | import test.rewolucja.resources.logical.base.LogicalResource; |
---|
10 | import test.rewolucja.resources.physical.base.ComputingResource; |
---|
11 | |
---|
12 | public class ResourceController extends ExtendedGridSimCore{ |
---|
13 | |
---|
14 | public LogicalResource getLogicalStructure() { |
---|
15 | return logicalStructure; |
---|
16 | } |
---|
17 | |
---|
18 | public ComputingResource getResources() { |
---|
19 | return resources; |
---|
20 | } |
---|
21 | |
---|
22 | protected LogicalResource logicalStructure; |
---|
23 | protected ComputingResource resources; |
---|
24 | |
---|
25 | public ResourceController(String name, LogicalResource logicalStructure, ComputingResource resources) throws Exception { |
---|
26 | super(name); |
---|
27 | this.logicalStructure = logicalStructure; |
---|
28 | this.resources = resources; |
---|
29 | // TODO Auto-generated constructor stub |
---|
30 | } |
---|
31 | |
---|
32 | public void body() { |
---|
33 | |
---|
34 | // Process events until END_OF_SIMULATION is received from the |
---|
35 | // GridSimShutdown Entity |
---|
36 | Sim_event ev = new Sim_event(); |
---|
37 | sim_get_next(ev); |
---|
38 | // boolean run = true; |
---|
39 | |
---|
40 | while (Sim_system.running()) { |
---|
41 | // sim_get_next(ev); |
---|
42 | // if the simulation finishes then exit the loop |
---|
43 | if (ev.get_tag() == GridSimTags.END_OF_SIMULATION) { |
---|
44 | // managemetnSystem_.setEndSimulation(); |
---|
45 | break; |
---|
46 | } |
---|
47 | |
---|
48 | // process the received event |
---|
49 | processRequest(ev); |
---|
50 | sim_get_next(ev); |
---|
51 | } |
---|
52 | |
---|
53 | } |
---|
54 | |
---|
55 | protected void processRequest(Sim_event ev) { |
---|
56 | switch (ev.get_tag()) { |
---|
57 | |
---|
58 | case GridSimTags.GRIDLET_SUBMIT: |
---|
59 | break; |
---|
60 | |
---|
61 | default: |
---|
62 | break; |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|
66 | public void send(String entityName, double delay, int gridSimTag, Object data){ |
---|
67 | super.send(entityName, delay, gridSimTag, data); |
---|
68 | } |
---|
69 | |
---|
70 | public void send(int entityID, double delay, int gridSimTag){ |
---|
71 | super.send(entityID, delay, gridSimTag); |
---|
72 | } |
---|
73 | |
---|
74 | public void send(int entityID, double delay, int gridSimTag, Object data){ |
---|
75 | super.send(entityID, delay, gridSimTag, data); |
---|
76 | } |
---|
77 | |
---|
78 | public void send(Sim_port destPort, double delay, int gridSimTag, Object data) { |
---|
79 | super.send(destPort, delay, gridSimTag, data); |
---|
80 | } |
---|
81 | |
---|
82 | public void sendInternal(double delay, int gridSimTag, Object data) { |
---|
83 | this.send(this.get_id(), delay, gridSimTag, data); |
---|
84 | } |
---|
85 | |
---|
86 | public void notifLogicalResources(){ |
---|
87 | for(LogicalResource lr : logicalStructure.getChildren()){ |
---|
88 | send(lr.get_name(), 0.0, GssimTags.UPDATE); |
---|
89 | } |
---|
90 | } |
---|
91 | |
---|
92 | } |
---|