1 | package simulator.stats.implementation; |
---|
2 | |
---|
3 | import gridsim.gssim.resource.AbstractComputingResource; |
---|
4 | |
---|
5 | import java.util.HashMap; |
---|
6 | import java.util.Map; |
---|
7 | |
---|
8 | import simulator.stats.implementation.out.StatsSerializer; |
---|
9 | |
---|
10 | public class ResourceStats implements StatsInterface { |
---|
11 | |
---|
12 | // raw resource statistic |
---|
13 | protected String resourceName; |
---|
14 | protected int cpucnt; |
---|
15 | protected int cpuspeed; |
---|
16 | protected int memory; |
---|
17 | protected double queueLength; |
---|
18 | protected Map<String, Double> processorsLoad; |
---|
19 | protected Map<String, Double> processorsReservationLoad; |
---|
20 | |
---|
21 | private String[] headers = { "resourceName", "memory", "cpu", "cpu_speed", |
---|
22 | "queue_length", "cpu_load", "reservation_load" }; |
---|
23 | |
---|
24 | public ResourceStats(AbstractComputingResource gridResource) { |
---|
25 | this.resourceName = gridResource.getResourceCharacteristics() |
---|
26 | .getResourceName(); |
---|
27 | init(); |
---|
28 | for (int cpu = 0; cpu < gridResource.getResourceCharacteristics() |
---|
29 | .getNumPE(); cpu++) { |
---|
30 | String processorName = cpu + "@" + this.resourceName; |
---|
31 | processorsLoad.put(processorName, (double) 0); |
---|
32 | processorsReservationLoad.put(processorName, (double) 0); |
---|
33 | } |
---|
34 | } |
---|
35 | |
---|
36 | public void init() { |
---|
37 | this.cpucnt = 0; |
---|
38 | this.cpuspeed = 0; |
---|
39 | this.memory = 0; |
---|
40 | this.queueLength = 0; |
---|
41 | this.processorsLoad = new HashMap<String, Double>(); |
---|
42 | this.processorsReservationLoad = new HashMap<String, Double>(); |
---|
43 | } |
---|
44 | |
---|
45 | public double getQueueLength() { |
---|
46 | return queueLength; |
---|
47 | } |
---|
48 | |
---|
49 | public void setQueueLength(double queueLength) { |
---|
50 | this.queueLength = queueLength; |
---|
51 | } |
---|
52 | |
---|
53 | public Map<String, Double> getPELoad() { |
---|
54 | return processorsLoad; |
---|
55 | } |
---|
56 | |
---|
57 | public Map<String, Double> getProcessorsReservationLoad() { |
---|
58 | return processorsReservationLoad; |
---|
59 | } |
---|
60 | |
---|
61 | public String getResourceName() { |
---|
62 | return resourceName; |
---|
63 | } |
---|
64 | |
---|
65 | public int getCpucnt() { |
---|
66 | return cpucnt; |
---|
67 | } |
---|
68 | |
---|
69 | public int getCpuspeed() { |
---|
70 | return cpuspeed; |
---|
71 | } |
---|
72 | |
---|
73 | public int getMemory() { |
---|
74 | return memory; |
---|
75 | } |
---|
76 | |
---|
77 | public Object serialize(StatsSerializer serializer) { |
---|
78 | return serializer.visit(this); |
---|
79 | } |
---|
80 | |
---|
81 | public String[] getHeaders() { |
---|
82 | return headers; |
---|
83 | } |
---|
84 | |
---|
85 | } |
---|