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