1 | package simulator.stats.implementation; |
---|
2 | |
---|
3 | import gssim.schedframe.scheduling.Executable; |
---|
4 | |
---|
5 | import java.util.List; |
---|
6 | |
---|
7 | import simulator.stats.implementation.out.StatsSerializer; |
---|
8 | |
---|
9 | /** |
---|
10 | * |
---|
11 | * @author Marcin Krystek |
---|
12 | * |
---|
13 | */ |
---|
14 | public class TaskStats implements StatsInterface { |
---|
15 | protected List<String> processorsName; |
---|
16 | protected double reservationStartDate; |
---|
17 | protected double reservationFinishDate; |
---|
18 | |
---|
19 | protected Executable task; |
---|
20 | protected long startSimulationTimeSek; |
---|
21 | |
---|
22 | private String headers[] = { "JobID", "TaskID", "UserDN", "ResName", "CpuCnt", |
---|
23 | "ExecStartDate", "ExecFinishDate", "ExecEndDate", "GB_SubDate", |
---|
24 | "LB_SubDate", "CompletionTime", "ExecStartTime", |
---|
25 | "ExecutionTime", "ReadyTime", "StartTime", "FlowTime", |
---|
26 | "WaitingTime", "GQ_WaitingTime", "Lateness", "Tardiness", |
---|
27 | "ReservStartDate", "ReservFinishDate", "ProcessorName", "Energy"}; |
---|
28 | |
---|
29 | public TaskStats(Executable task, long startSimulationTime) { |
---|
30 | this.task = task; |
---|
31 | this.startSimulationTimeSek = startSimulationTime / 1000; |
---|
32 | } |
---|
33 | |
---|
34 | public Object serialize(StatsSerializer serializer) { |
---|
35 | return serializer.visit(this); |
---|
36 | } |
---|
37 | |
---|
38 | public String getJobID() { |
---|
39 | return this.task.getJobId(); |
---|
40 | } |
---|
41 | |
---|
42 | public String getTaskID() { |
---|
43 | return this.task.getId(); |
---|
44 | } |
---|
45 | |
---|
46 | public String getUserDN() { |
---|
47 | return this.task.getUserDN(); |
---|
48 | } |
---|
49 | |
---|
50 | public String getResName() { |
---|
51 | String resName = this.task.getSchedulerName(); |
---|
52 | |
---|
53 | return resName; |
---|
54 | } |
---|
55 | |
---|
56 | public long getCpuCnt() { |
---|
57 | long cpuCnt = -1; |
---|
58 | try { |
---|
59 | cpuCnt = Double.valueOf(task.getCpuCntRequest()).longValue(); |
---|
60 | } catch (NoSuchFieldException e) { |
---|
61 | } |
---|
62 | |
---|
63 | return cpuCnt; |
---|
64 | } |
---|
65 | |
---|
66 | public double getExecStartDate() { |
---|
67 | return task.getExecStartTime(); |
---|
68 | } |
---|
69 | |
---|
70 | public double getExecFinishDate() { |
---|
71 | return task.getFinishTime(); |
---|
72 | } |
---|
73 | |
---|
74 | public double getExecEndDate() { |
---|
75 | double ret = -1; |
---|
76 | try { |
---|
77 | ret = task.getExecutionEndTime().getMillis() / 1000; |
---|
78 | } catch (NoSuchFieldException e) { |
---|
79 | ret = task.getFinishTime(); |
---|
80 | } |
---|
81 | return ret; |
---|
82 | } |
---|
83 | |
---|
84 | public double getGB_SubDate() { |
---|
85 | return task.getSubmissionTimeToBroker().getMillis() / 1000; |
---|
86 | } |
---|
87 | |
---|
88 | public double getLB_SubDate() { |
---|
89 | return task.getSubmissionTime(); |
---|
90 | } |
---|
91 | |
---|
92 | public double getCompletionTime() { |
---|
93 | return task.getFinishTime() - startSimulationTimeSek; |
---|
94 | } |
---|
95 | |
---|
96 | public double getExecutionTime() { |
---|
97 | return task.getFinishTime() - task.getExecStartTime(); |
---|
98 | } |
---|
99 | |
---|
100 | public double getExecStartTime() { |
---|
101 | return task.getExecStartTime() - startSimulationTimeSek; |
---|
102 | } |
---|
103 | |
---|
104 | public double getReadyTime() { |
---|
105 | double readyTime = 0; |
---|
106 | |
---|
107 | try { |
---|
108 | readyTime = task.getExecutionStartTime().getMillis() / 1000 |
---|
109 | - startSimulationTimeSek; |
---|
110 | } catch (Exception ex) { |
---|
111 | readyTime = task.getSubmissionTimeToBroker().getMillis()/1000 - startSimulationTimeSek; |
---|
112 | } |
---|
113 | |
---|
114 | return readyTime; |
---|
115 | } |
---|
116 | |
---|
117 | public double getStartTime() { |
---|
118 | return task.getExecStartTime() |
---|
119 | - task.getSubmissionTimeToBroker().getMillis() / 1000; |
---|
120 | } |
---|
121 | |
---|
122 | public double getFlowTime() { |
---|
123 | return getCompletionTime() - getReadyTime(); |
---|
124 | } |
---|
125 | |
---|
126 | public double getWaitingTime() { |
---|
127 | return task.getWaitingTime(); |
---|
128 | } |
---|
129 | |
---|
130 | public double getGQ_WaitingTime() { |
---|
131 | return task.getSubmissionTime() |
---|
132 | - task.getSubmissionTimeToBroker().getMillis() / 1000; |
---|
133 | } |
---|
134 | |
---|
135 | public double getLateness() { |
---|
136 | double execEndDate = getExecEndDate(); |
---|
137 | double lateness = 0; |
---|
138 | if (execEndDate != -1) { |
---|
139 | lateness = task.getFinishTime() - execEndDate; |
---|
140 | } |
---|
141 | return lateness; |
---|
142 | } |
---|
143 | |
---|
144 | public double getTardiness() { |
---|
145 | return Math.max(getLateness(), 0.0); |
---|
146 | } |
---|
147 | |
---|
148 | public void setProcessorsName(List<String> value) { |
---|
149 | this.processorsName = value; |
---|
150 | } |
---|
151 | |
---|
152 | public void setReservationStartDate(double value) { |
---|
153 | this.reservationStartDate = value; |
---|
154 | } |
---|
155 | |
---|
156 | public void setReservationFinishDate(double value) { |
---|
157 | this.reservationFinishDate = value; |
---|
158 | } |
---|
159 | |
---|
160 | public List<String> getProcessorsName() { |
---|
161 | return processorsName; |
---|
162 | } |
---|
163 | |
---|
164 | public double getReservationStartDate() { |
---|
165 | return reservationStartDate; |
---|
166 | } |
---|
167 | |
---|
168 | public double getReservationFinishDate() { |
---|
169 | return reservationFinishDate; |
---|
170 | } |
---|
171 | |
---|
172 | public String[] getHeaders() { |
---|
173 | return headers; |
---|
174 | } |
---|
175 | |
---|
176 | } |
---|