1 | package simulator.stats.implementation.out; |
---|
2 | |
---|
3 | import java.util.List; |
---|
4 | import java.util.Map; |
---|
5 | |
---|
6 | import org.apache.commons.logging.Log; |
---|
7 | import org.apache.commons.logging.LogFactory; |
---|
8 | |
---|
9 | import simulator.GridSchedulingSimulator; |
---|
10 | import simulator.stats.implementation.AccumulatedResourceStats; |
---|
11 | import simulator.stats.implementation.GSSAccumulatorsStats; |
---|
12 | import simulator.stats.implementation.JobStats; |
---|
13 | import simulator.stats.implementation.LinkStats; |
---|
14 | import simulator.stats.implementation.NetworkReservationStats; |
---|
15 | import simulator.stats.implementation.ResourceStats; |
---|
16 | import simulator.stats.implementation.ResourceUsageStats; |
---|
17 | import simulator.stats.implementation.TaskStats; |
---|
18 | |
---|
19 | /** |
---|
20 | * |
---|
21 | * @author Marcin Krystek, Jarek Szymczak |
---|
22 | * |
---|
23 | * This serializer needs correct implementation. Now it works as simple |
---|
24 | * StringSerializer. |
---|
25 | * |
---|
26 | */ |
---|
27 | |
---|
28 | public class FormatedStringSerializer extends AbstractStringSerializer { |
---|
29 | |
---|
30 | private Log log = LogFactory.getLog(FormatedStringSerializer.class); |
---|
31 | |
---|
32 | private String fieldSeparator = "; "; |
---|
33 | |
---|
34 | public String visit(TaskStats taskStats) { |
---|
35 | |
---|
36 | StringBuffer buffer = null; |
---|
37 | |
---|
38 | if(printedHeaders.add("taskStats")) { |
---|
39 | buffer = new StringBuffer(520); |
---|
40 | String[] headers = taskStats.getHeaders(); |
---|
41 | if (headers.length == 23) { |
---|
42 | |
---|
43 | buffer.append(String.format("%5s", headers[0])); |
---|
44 | buffer.append(fieldSeparator); |
---|
45 | buffer.append(String.format("%7s", headers[1])); |
---|
46 | buffer.append(fieldSeparator); |
---|
47 | buffer.append(String.format("%7s", headers[2])); |
---|
48 | buffer.append(fieldSeparator); |
---|
49 | buffer.append(String.format("%14s", headers[3])); |
---|
50 | buffer.append(fieldSeparator); |
---|
51 | buffer.append(String.format("%7s", headers[4])); |
---|
52 | buffer.append(fieldSeparator); |
---|
53 | buffer.append(String.format("%14s", headers[5])); |
---|
54 | buffer.append(fieldSeparator); |
---|
55 | buffer.append(String.format("%15s", headers[6])); |
---|
56 | buffer.append(fieldSeparator); |
---|
57 | buffer.append(String.format("%13s", headers[7])); |
---|
58 | buffer.append(fieldSeparator); |
---|
59 | buffer.append(String.format("%13s", headers[8])); |
---|
60 | buffer.append(fieldSeparator); |
---|
61 | buffer.append(String.format("%13s", headers[9])); |
---|
62 | buffer.append(fieldSeparator); |
---|
63 | |
---|
64 | if (this.useExtended) { |
---|
65 | buffer.append(String.format("%15s", headers[10])); |
---|
66 | buffer.append(fieldSeparator); |
---|
67 | buffer.append(String.format("%14s", headers[11])); |
---|
68 | buffer.append(fieldSeparator); |
---|
69 | buffer.append(String.format("%14s", headers[12])); |
---|
70 | buffer.append(fieldSeparator); |
---|
71 | buffer.append(String.format("%10s", headers[13])); |
---|
72 | buffer.append(fieldSeparator); |
---|
73 | buffer.append(String.format("%10s", headers[14])); |
---|
74 | buffer.append(fieldSeparator); |
---|
75 | buffer.append(String.format("%9s", headers[15])); |
---|
76 | buffer.append(fieldSeparator); |
---|
77 | buffer.append(String.format("%12s", headers[16])); |
---|
78 | buffer.append(fieldSeparator); |
---|
79 | buffer.append(String.format("%15s", headers[17])); |
---|
80 | buffer.append(fieldSeparator); |
---|
81 | buffer.append(String.format("%9s", headers[18])); |
---|
82 | buffer.append(fieldSeparator); |
---|
83 | buffer.append(String.format("%10s", headers[19])); |
---|
84 | buffer.append(fieldSeparator); |
---|
85 | buffer.append(String.format("%16s", headers[20])); |
---|
86 | buffer.append(fieldSeparator); |
---|
87 | buffer.append(String.format("%17s", headers[21])); |
---|
88 | buffer.append(fieldSeparator); |
---|
89 | buffer.append(String.format("%-17s", headers[22])); |
---|
90 | buffer.append(fieldSeparator); |
---|
91 | } |
---|
92 | |
---|
93 | } else { |
---|
94 | buffer.append(headers.toString()); |
---|
95 | } |
---|
96 | buffer.append(System.getProperty("line.separator")); |
---|
97 | } else { |
---|
98 | buffer = new StringBuffer(260); |
---|
99 | } |
---|
100 | |
---|
101 | buffer.append(String.format("%5s", taskStats.getJobID())); |
---|
102 | buffer.append(fieldSeparator); |
---|
103 | buffer.append(String.format("%7s", taskStats.getTaskID())); |
---|
104 | buffer.append(fieldSeparator); |
---|
105 | buffer.append(String.format("%7s", taskStats.getUserDN())); |
---|
106 | buffer.append(fieldSeparator); |
---|
107 | buffer.append(String.format("%14s", taskStats.getResName())); |
---|
108 | buffer.append(fieldSeparator); |
---|
109 | buffer.append(String.format("%7d", taskStats.getCpuCnt())); |
---|
110 | buffer.append(fieldSeparator); |
---|
111 | buffer.append(String.format("%14d", |
---|
112 | Double.valueOf(taskStats.getExecStartDate()).longValue())); |
---|
113 | buffer.append(fieldSeparator); |
---|
114 | buffer.append(String.format("%15d", |
---|
115 | Double.valueOf(taskStats.getExecFinishDate()).longValue())); |
---|
116 | buffer.append(fieldSeparator); |
---|
117 | buffer.append(String.format("%13d", |
---|
118 | Double.valueOf(taskStats.getExecEndDate()).longValue())); |
---|
119 | buffer.append(fieldSeparator); |
---|
120 | buffer.append(String.format("%13d", |
---|
121 | Double.valueOf(taskStats.getGB_SubDate()).longValue())); |
---|
122 | buffer.append(fieldSeparator); |
---|
123 | buffer.append(String.format("%13d", |
---|
124 | Double.valueOf(taskStats.getLB_SubDate()).longValue())); |
---|
125 | buffer.append(fieldSeparator); |
---|
126 | |
---|
127 | if (this.useExtended) { |
---|
128 | buffer.append(String.format("%15d", |
---|
129 | Double.valueOf(taskStats.getCompletionTime()).longValue())); |
---|
130 | buffer.append(fieldSeparator); |
---|
131 | buffer.append(String.format("%14d", |
---|
132 | Double.valueOf(taskStats.getExecStartTime()).longValue())); |
---|
133 | buffer.append(fieldSeparator); |
---|
134 | buffer.append(String.format("%14d", |
---|
135 | Double.valueOf(taskStats.getExecutionTime()).longValue())); |
---|
136 | buffer.append(fieldSeparator); |
---|
137 | buffer.append(String.format("%10d", |
---|
138 | Double.valueOf(taskStats.getReadyTime()).longValue())); |
---|
139 | buffer.append(fieldSeparator); |
---|
140 | buffer.append(String.format("%10d", |
---|
141 | Double.valueOf(taskStats.getStartTime()).longValue())); |
---|
142 | buffer.append(fieldSeparator); |
---|
143 | buffer.append(String.format("%9d", |
---|
144 | Double.valueOf(taskStats.getFlowTime()).longValue())); |
---|
145 | buffer.append(fieldSeparator); |
---|
146 | buffer.append(String.format("%12d", |
---|
147 | Double.valueOf(taskStats.getWaitingTime()).longValue())); |
---|
148 | buffer.append(fieldSeparator); |
---|
149 | buffer.append(String.format("%15d", |
---|
150 | Double.valueOf(taskStats.getGQ_WaitingTime()).longValue())); |
---|
151 | buffer.append(fieldSeparator); |
---|
152 | buffer.append(String.format("%9d", |
---|
153 | Double.valueOf(taskStats.getLateness()).longValue())); |
---|
154 | buffer.append(fieldSeparator); |
---|
155 | buffer.append(String.format("%10d", |
---|
156 | Double.valueOf(taskStats.getTardiness()).longValue())); |
---|
157 | buffer.append(fieldSeparator); |
---|
158 | buffer.append(String.format("%16d", |
---|
159 | Double.valueOf(taskStats.getReservationStartDate()) |
---|
160 | .longValue())); |
---|
161 | buffer.append(fieldSeparator); |
---|
162 | buffer.append(String.format("%17d", |
---|
163 | Double.valueOf(taskStats.getReservationFinishDate()) |
---|
164 | .longValue())); |
---|
165 | buffer.append(fieldSeparator); |
---|
166 | buffer.append(String.format("%-17s", taskStats.getProcessorsName())); |
---|
167 | buffer.append(fieldSeparator); |
---|
168 | |
---|
169 | } |
---|
170 | |
---|
171 | return buffer.toString(); |
---|
172 | } |
---|
173 | |
---|
174 | public String visit(JobStats jobStats) { |
---|
175 | |
---|
176 | StringBuffer buffer = null; |
---|
177 | |
---|
178 | if(printedHeaders.add("jobStats")) { |
---|
179 | buffer = new StringBuffer(200); |
---|
180 | String[] headers = jobStats.getHeaders(); |
---|
181 | if (headers.length == 10) { |
---|
182 | |
---|
183 | buffer.append(String.format("%5s", headers[0])); |
---|
184 | buffer.append(fieldSeparator); |
---|
185 | buffer.append(String.format("%23s", headers[1])); |
---|
186 | buffer.append(fieldSeparator); |
---|
187 | buffer.append(String.format("%22s", headers[2])); |
---|
188 | buffer.append(fieldSeparator); |
---|
189 | buffer.append(String.format("%18s", headers[3])); |
---|
190 | buffer.append(fieldSeparator); |
---|
191 | buffer.append(String.format("%17s", headers[4])); |
---|
192 | buffer.append(fieldSeparator); |
---|
193 | buffer.append(String.format("%20s", headers[5])); |
---|
194 | buffer.append(fieldSeparator); |
---|
195 | buffer.append(String.format("%23s", headers[6])); |
---|
196 | buffer.append(fieldSeparator); |
---|
197 | buffer.append(String.format("%9s", headers[7])); |
---|
198 | buffer.append(fieldSeparator); |
---|
199 | buffer.append(String.format("%10s", headers[8])); |
---|
200 | buffer.append(fieldSeparator); |
---|
201 | buffer.append(String.format("%9s", headers[9])); |
---|
202 | buffer.append(fieldSeparator); |
---|
203 | |
---|
204 | } else { |
---|
205 | buffer.append(headers.toString()); |
---|
206 | } |
---|
207 | buffer.append(System.getProperty("line.separator")); |
---|
208 | } else { |
---|
209 | buffer = new StringBuffer(100); |
---|
210 | } |
---|
211 | |
---|
212 | buffer.append(String.format("%5s", jobStats.getJobID())); |
---|
213 | buffer.append(fieldSeparator); |
---|
214 | buffer.append(String.format("%23s", defaultNumberFormat.format(jobStats |
---|
215 | .getMeanTaskCompletionTime().getMean()))); |
---|
216 | buffer.append(fieldSeparator); |
---|
217 | buffer.append(String.format("%22s", defaultNumberFormat.format(jobStats |
---|
218 | .getMeanTaskExecutionTime().getMean()))); |
---|
219 | buffer.append(fieldSeparator); |
---|
220 | buffer.append(String.format("%18s", defaultNumberFormat.format(jobStats |
---|
221 | .getMeanTaskStartTime().getMean()))); |
---|
222 | buffer.append(fieldSeparator); |
---|
223 | buffer.append(String.format("%17s", defaultNumberFormat.format(jobStats |
---|
224 | .getMeanTaskFlowTime().getMean()))); |
---|
225 | buffer.append(fieldSeparator); |
---|
226 | buffer.append(String.format("%20s", defaultNumberFormat.format(jobStats |
---|
227 | .getMeanTaskWaitingTime().getMean()))); |
---|
228 | buffer.append(fieldSeparator); |
---|
229 | buffer.append(String.format("%23s", defaultNumberFormat.format(jobStats |
---|
230 | .getMeanTaskGQ_WaitingTime().getMean()))); |
---|
231 | buffer.append(fieldSeparator); |
---|
232 | buffer.append(String.format("%9s", |
---|
233 | defaultNumberFormat.format(jobStats.getTardiness().getMean()))); |
---|
234 | buffer.append(fieldSeparator); |
---|
235 | buffer.append(String.format("%10s", |
---|
236 | defaultNumberFormat.format(jobStats.getLateness().getMean()))); |
---|
237 | buffer.append(fieldSeparator); |
---|
238 | buffer.append(String.format("%9s", |
---|
239 | defaultNumberFormat.format(jobStats.getMakespan().getMean()))); |
---|
240 | buffer.append(fieldSeparator); |
---|
241 | |
---|
242 | return buffer.toString(); |
---|
243 | } |
---|
244 | |
---|
245 | public String visit(ResourceStats resourceStats) { |
---|
246 | |
---|
247 | StringBuffer buffer = null; |
---|
248 | |
---|
249 | if(printedHeaders.add("resourceStats")) { |
---|
250 | buffer = new StringBuffer(600); |
---|
251 | String[] headers = resourceStats.getHeaders(); |
---|
252 | if (headers.length == 7) { |
---|
253 | |
---|
254 | buffer.append(String.format("%-20s", headers[0])); |
---|
255 | buffer.append(fieldSeparator); |
---|
256 | buffer.append(String.format("%6s", headers[1])); |
---|
257 | buffer.append(fieldSeparator); |
---|
258 | buffer.append(String.format("%3s", headers[2])); |
---|
259 | buffer.append(fieldSeparator); |
---|
260 | buffer.append(String.format("%9s", headers[3])); |
---|
261 | buffer.append(fieldSeparator); |
---|
262 | buffer.append(String.format("%12s", headers[4])); |
---|
263 | buffer.append(fieldSeparator); |
---|
264 | buffer.append(String.format("%-120s", headers[5])); |
---|
265 | buffer.append(fieldSeparator); |
---|
266 | buffer.append(String.format("%-120s", headers[6])); |
---|
267 | buffer.append(fieldSeparator); |
---|
268 | } else { |
---|
269 | buffer.append(headers.toString()); |
---|
270 | } |
---|
271 | buffer.append(System.getProperty("line.separator")); |
---|
272 | } else { |
---|
273 | buffer = new StringBuffer(300); |
---|
274 | } |
---|
275 | |
---|
276 | buffer.append(String.format("%-20s", resourceStats.getResourceName())); |
---|
277 | buffer.append(fieldSeparator); |
---|
278 | |
---|
279 | buffer.append(String.format("%6d", resourceStats.getMemory())); |
---|
280 | buffer.append(fieldSeparator); |
---|
281 | |
---|
282 | buffer.append(String.format("%3d", resourceStats.getCpucnt())); |
---|
283 | buffer.append(fieldSeparator); |
---|
284 | |
---|
285 | buffer.append(String.format("%9d", resourceStats.getCpuspeed())); |
---|
286 | buffer.append(fieldSeparator); |
---|
287 | |
---|
288 | buffer.append(String.format("%-12s", |
---|
289 | GridSchedulingSimulator.DFAULT_NUMBER_FORMAT |
---|
290 | .format(resourceStats.getQueueLength()))); |
---|
291 | buffer.append(fieldSeparator); |
---|
292 | |
---|
293 | StringBuffer tempBuffer = new StringBuffer(); |
---|
294 | |
---|
295 | Map<String, Double> processorsLoad = resourceStats.getProcessorsLoad(); |
---|
296 | for (String processorName : processorsLoad.keySet()) { |
---|
297 | |
---|
298 | Double load = processorsLoad.get(processorName); |
---|
299 | tempBuffer.append(String.format("%-12s", processorName)); |
---|
300 | tempBuffer.append(" "); |
---|
301 | tempBuffer.append(String.format("%-5s", GridSchedulingSimulator.DFAULT_NUMBER_FORMAT |
---|
302 | .format(load))); |
---|
303 | tempBuffer.append(": "); |
---|
304 | |
---|
305 | } |
---|
306 | buffer.append(String.format("%-120s", tempBuffer.toString())); |
---|
307 | buffer.append(fieldSeparator); |
---|
308 | |
---|
309 | tempBuffer = new StringBuffer(); |
---|
310 | |
---|
311 | Map<String, Double> processorsReservationLoad = resourceStats |
---|
312 | .getProcessorsReservationLoad(); |
---|
313 | for (String processorName : processorsReservationLoad.keySet()) { |
---|
314 | |
---|
315 | Double reservationLoad = processorsReservationLoad |
---|
316 | .get(processorName); |
---|
317 | tempBuffer.append(String.format("%-12s", processorName)); |
---|
318 | tempBuffer.append(" "); |
---|
319 | tempBuffer.append(String.format("%-5s", GridSchedulingSimulator.DFAULT_NUMBER_FORMAT |
---|
320 | .format(reservationLoad))); |
---|
321 | tempBuffer.append(": "); |
---|
322 | } |
---|
323 | buffer.append(String.format("%-120s", tempBuffer.toString())); |
---|
324 | buffer.append(fieldSeparator); |
---|
325 | return buffer.toString(); |
---|
326 | } |
---|
327 | |
---|
328 | public String visit(AccumulatedResourceStats accResStats) { |
---|
329 | |
---|
330 | StringBuffer buffer = null; |
---|
331 | |
---|
332 | if(printedHeaders.add("accResStats")) { |
---|
333 | buffer = new StringBuffer(340); |
---|
334 | String[] headers = accResStats.getHeaders(); |
---|
335 | if (headers.length == 9) { |
---|
336 | |
---|
337 | buffer.append(String.format("%-27s", headers[0])); |
---|
338 | buffer.append(fieldSeparator); |
---|
339 | buffer.append(String.format("%-27s", headers[1])); |
---|
340 | buffer.append(fieldSeparator); |
---|
341 | buffer.append(String.format("%16s", headers[2])); |
---|
342 | buffer.append(fieldSeparator); |
---|
343 | buffer.append(String.format("%16s", headers[3])); |
---|
344 | buffer.append(fieldSeparator); |
---|
345 | buffer.append(String.format("%16s", headers[4])); |
---|
346 | buffer.append(fieldSeparator); |
---|
347 | buffer.append(String.format("%16s", headers[5])); |
---|
348 | buffer.append(fieldSeparator); |
---|
349 | buffer.append(String.format("%16s", headers[6])); |
---|
350 | buffer.append(fieldSeparator); |
---|
351 | buffer.append(String.format("%16s", headers[7])); |
---|
352 | buffer.append(fieldSeparator); |
---|
353 | buffer.append(String.format("%16s", headers[8])); |
---|
354 | buffer.append(fieldSeparator); |
---|
355 | } else { |
---|
356 | buffer.append(headers.toString()); |
---|
357 | } |
---|
358 | buffer.append(System.getProperty("line.separator")); |
---|
359 | } else { |
---|
360 | buffer = new StringBuffer(170); |
---|
361 | } |
---|
362 | |
---|
363 | buffer.append(String.format("%-27s", accResStats.getResourceName())); |
---|
364 | buffer.append(fieldSeparator); |
---|
365 | buffer.append(String.format("%-27s", "load")); |
---|
366 | buffer.append(accResStats.getResourceLoad().toFormatedString()); |
---|
367 | buffer.append(System.getProperty("line.separator")); |
---|
368 | buffer.append(String.format("%-27s", accResStats.getResourceName())); |
---|
369 | buffer.append(fieldSeparator); |
---|
370 | buffer.append(String.format("%-27s", "reservationload")); |
---|
371 | buffer.append(accResStats.getResourceReservationLoad() |
---|
372 | .toFormatedString()); |
---|
373 | buffer.append(System.getProperty("line.separator")); |
---|
374 | |
---|
375 | return buffer.toString(); |
---|
376 | } |
---|
377 | |
---|
378 | public Object visit(ResourceUsageStats resourceUsageStats) { |
---|
379 | Map<Long, Integer> resourceUsage = resourceUsageStats.getUsage(); |
---|
380 | |
---|
381 | int mapSize = resourceUsage.size(); |
---|
382 | /* |
---|
383 | * FIXME: Integer.MAX_VALUE = 2147483647. We assume, that each line |
---|
384 | * contains max 30 signs - this gives max 71582788 lines. If |
---|
385 | * resourceUsage map contains more elements then we have a problem, |
---|
386 | * because content of resourceUsage map will not fit in the buffer. This |
---|
387 | * will need further attention in the future. |
---|
388 | */ |
---|
389 | int maxSize = (Integer.MAX_VALUE / 30) - 1; |
---|
390 | if (mapSize >= maxSize) { |
---|
391 | log.error("Resource usage data is to long to fit in the buffer."); |
---|
392 | return null; |
---|
393 | } |
---|
394 | |
---|
395 | int size = 30 * resourceUsage.size(); |
---|
396 | |
---|
397 | StringBuffer buffer = null; |
---|
398 | |
---|
399 | if(printedHeaders.add(resourceUsageStats.getResourceType())) { |
---|
400 | buffer = new StringBuffer(size + 42); |
---|
401 | String[] headers = resourceUsageStats.getHeaders(); |
---|
402 | if (headers.length == 3) { |
---|
403 | |
---|
404 | buffer.append(String.format("%-20s", headers[0])); |
---|
405 | buffer.append(fieldSeparator); |
---|
406 | buffer.append(String.format("%15s", headers[1])); |
---|
407 | buffer.append(fieldSeparator); |
---|
408 | buffer.append(String.format("%5s", headers[2])); |
---|
409 | buffer.append(fieldSeparator); |
---|
410 | |
---|
411 | } else { |
---|
412 | buffer.append(headers.toString()); |
---|
413 | } |
---|
414 | buffer.append(System.getProperty("line.separator")); |
---|
415 | } else { |
---|
416 | buffer = new StringBuffer(size); |
---|
417 | } |
---|
418 | |
---|
419 | for (Long timestamp : resourceUsage.keySet()) { |
---|
420 | |
---|
421 | buffer.append(String.format("%-20s", |
---|
422 | resourceUsageStats.getResourceName())); |
---|
423 | buffer.append(fieldSeparator); |
---|
424 | Integer value = resourceUsage.get(timestamp); |
---|
425 | buffer.append(String.format("%15d", timestamp)); |
---|
426 | buffer.append(fieldSeparator); |
---|
427 | buffer.append(String.format("%5s", |
---|
428 | GridSchedulingSimulator.DFAULT_NUMBER_FORMAT.format(value))); |
---|
429 | buffer.append(fieldSeparator); |
---|
430 | buffer.append(System.getProperty("line.separator")); |
---|
431 | |
---|
432 | } |
---|
433 | |
---|
434 | return buffer.toString(); |
---|
435 | } |
---|
436 | |
---|
437 | |
---|
438 | public Object visit(LinkStats linkStats) { |
---|
439 | |
---|
440 | StringBuffer buffer = null; |
---|
441 | |
---|
442 | if(printedHeaders.add("linkStats")) { |
---|
443 | buffer = new StringBuffer(600); |
---|
444 | String[] headers = linkStats.getHeaders(); |
---|
445 | if (headers.length == 6) { |
---|
446 | |
---|
447 | buffer.append(String.format("%-27s", headers[0])); |
---|
448 | buffer.append(fieldSeparator); |
---|
449 | buffer.append(String.format("%18s", headers[1])); |
---|
450 | buffer.append(fieldSeparator); |
---|
451 | buffer.append(String.format("%10s", headers[2])); |
---|
452 | buffer.append(fieldSeparator); |
---|
453 | buffer.append(String.format("%35s", headers[3])); |
---|
454 | buffer.append(fieldSeparator); |
---|
455 | buffer.append(String.format("%10s", headers[4])); |
---|
456 | buffer.append(fieldSeparator); |
---|
457 | buffer.append(String.format("%18s", headers[5])); |
---|
458 | buffer.append(fieldSeparator); |
---|
459 | } else { |
---|
460 | buffer.append(headers.toString()); |
---|
461 | } |
---|
462 | buffer.append(System.getProperty("line.separator")); |
---|
463 | } else { |
---|
464 | buffer = new StringBuffer(300); |
---|
465 | } |
---|
466 | |
---|
467 | buffer.append(String.format("%-27s", linkStats.getLinkName())); |
---|
468 | buffer.append(fieldSeparator); |
---|
469 | buffer.append(String.format("%18s", |
---|
470 | GridSchedulingSimulator.NETWORK_NUMBER_FORMAT.format(linkStats |
---|
471 | .getStartBaduRate()))); |
---|
472 | buffer.append(fieldSeparator); |
---|
473 | buffer.append(String.format("%10s", |
---|
474 | GridSchedulingSimulator.NETWORK_NUMBER_FORMAT.format(linkStats |
---|
475 | .getDelay()))); |
---|
476 | buffer.append(fieldSeparator); |
---|
477 | buffer.append(String.format("%35s", |
---|
478 | GridSchedulingSimulator.NETWORK_NUMBER_FORMAT.format(linkStats |
---|
479 | .getFlowsSize()))); |
---|
480 | buffer.append(fieldSeparator); |
---|
481 | buffer.append(String.format("%10s", |
---|
482 | GridSchedulingSimulator.NETWORK_NUMBER_FORMAT.format(linkStats |
---|
483 | .getLoad()))); |
---|
484 | buffer.append(fieldSeparator); |
---|
485 | buffer.append(String.format("%18s", |
---|
486 | GridSchedulingSimulator.NETWORK_NUMBER_FORMAT.format(linkStats |
---|
487 | .getReservationLoad()))); |
---|
488 | buffer.append(fieldSeparator); |
---|
489 | |
---|
490 | return buffer.toString(); |
---|
491 | } |
---|
492 | |
---|
493 | |
---|
494 | public Object visit(NetworkReservationStats resStats) { |
---|
495 | |
---|
496 | resStats.getHeaders(); |
---|
497 | |
---|
498 | List<String> route = resStats.getRoute(); |
---|
499 | // 20 signs for link name, 80 for string representation of numerical |
---|
500 | // values |
---|
501 | int size = route.size() * 20 + 80; |
---|
502 | |
---|
503 | StringBuffer buffer = null; |
---|
504 | |
---|
505 | if(printedHeaders.add("resStats")) { |
---|
506 | buffer = new StringBuffer(size*2); |
---|
507 | String[] headers = resStats.getHeaders(); |
---|
508 | if (headers.length == 8) { |
---|
509 | |
---|
510 | buffer.append(String.format("%15s", headers[0])); |
---|
511 | buffer.append(fieldSeparator); |
---|
512 | buffer.append(String.format("%-100s", headers[1])); |
---|
513 | buffer.append(fieldSeparator); |
---|
514 | buffer.append(String.format("%32s", headers[2])); |
---|
515 | buffer.append(fieldSeparator); |
---|
516 | buffer.append(String.format("%31s", headers[3])); |
---|
517 | buffer.append(fieldSeparator); |
---|
518 | buffer.append(String.format("%16s", headers[4])); |
---|
519 | buffer.append(fieldSeparator); |
---|
520 | buffer.append(String.format("%35s",headers[5])); |
---|
521 | buffer.append(fieldSeparator); |
---|
522 | buffer.append(String.format("%10s",headers[6])); |
---|
523 | buffer.append(fieldSeparator); |
---|
524 | buffer.append(String.format("%9s", headers[7])); |
---|
525 | buffer.append(fieldSeparator); |
---|
526 | } else { |
---|
527 | buffer.append(headers.toString()); |
---|
528 | } |
---|
529 | buffer.append(System.getProperty("line.separator")); |
---|
530 | } else { |
---|
531 | buffer = new StringBuffer(300); |
---|
532 | } |
---|
533 | |
---|
534 | buffer.append(String.format("%15s", resStats.getReservationID())); |
---|
535 | buffer.append(fieldSeparator); |
---|
536 | buffer.append(String.format("%-100s", route)); |
---|
537 | buffer.append(fieldSeparator); |
---|
538 | buffer.append(String.format("%32s", resStats.getStartTime())); |
---|
539 | buffer.append(fieldSeparator); |
---|
540 | buffer.append(String.format("%31s", resStats.getEndTime())); |
---|
541 | buffer.append(fieldSeparator); |
---|
542 | buffer.append(String.format("%16s", resStats.getBandwidth())); |
---|
543 | buffer.append(fieldSeparator); |
---|
544 | buffer.append(String.format("%35s", |
---|
545 | GridSchedulingSimulator.NETWORK_NUMBER_FORMAT.format(resStats |
---|
546 | .getFlowsSize()))); |
---|
547 | buffer.append(fieldSeparator); |
---|
548 | buffer.append(String.format("%10s", |
---|
549 | GridSchedulingSimulator.NETWORK_NUMBER_FORMAT.format(resStats |
---|
550 | .getLoad()))); |
---|
551 | buffer.append(fieldSeparator); |
---|
552 | buffer.append(String.format("%9s", resStats.getStatus())); |
---|
553 | buffer.append(fieldSeparator); |
---|
554 | |
---|
555 | return buffer.toString(); |
---|
556 | } |
---|
557 | |
---|
558 | |
---|
559 | public Object visit(GSSAccumulatorsStats accStats) { |
---|
560 | |
---|
561 | StringBuffer buffer = null; |
---|
562 | |
---|
563 | if(printedHeaders.add("accStats")) { |
---|
564 | buffer = new StringBuffer(2800); |
---|
565 | String[] headers = accStats.getHeaders(); |
---|
566 | if (headers.length == 8) { |
---|
567 | |
---|
568 | buffer.append(String.format("%-26s", headers[0])); |
---|
569 | buffer.append(fieldSeparator); |
---|
570 | buffer.append(String.format("%16s", headers[1])); |
---|
571 | buffer.append(fieldSeparator); |
---|
572 | buffer.append(String.format("%16s", headers[2])); |
---|
573 | buffer.append(fieldSeparator); |
---|
574 | buffer.append(String.format("%16s", headers[3])); |
---|
575 | buffer.append(fieldSeparator); |
---|
576 | buffer.append(String.format("%16s", headers[4])); |
---|
577 | buffer.append(fieldSeparator); |
---|
578 | buffer.append(String.format("%16s", headers[5])); |
---|
579 | buffer.append(fieldSeparator); |
---|
580 | buffer.append(String.format("%16s", headers[6])); |
---|
581 | buffer.append(fieldSeparator); |
---|
582 | buffer.append(String.format("%16s", headers[7])); |
---|
583 | buffer.append(fieldSeparator); |
---|
584 | } else { |
---|
585 | buffer.append(headers.toString()); |
---|
586 | } |
---|
587 | buffer.append(System.getProperty("line.separator")); |
---|
588 | } else { |
---|
589 | buffer = new StringBuffer(1400); |
---|
590 | } |
---|
591 | |
---|
592 | buffer.append(String.format("%-26s", "Delayed tasks")); |
---|
593 | buffer.append(accStats.delayedTasks.toFormatedString()); |
---|
594 | buffer.append(System.getProperty("line.separator")); |
---|
595 | buffer.append(String.format("%-26s", "Failed requests (tasks)")); |
---|
596 | buffer.append(accStats.failedRequests.toFormatedString()); |
---|
597 | buffer.append(System.getProperty("line.separator")); |
---|
598 | buffer.append(String.format("%-26s", "Makespan")); |
---|
599 | buffer.append(accStats.makespan.toFormatedString()); |
---|
600 | buffer.append(System.getProperty("line.separator")); |
---|
601 | buffer.append(String.format("%-26s", "Resources queue length")); |
---|
602 | buffer.append(accStats.meanQueueLength.toFormatedString()); |
---|
603 | buffer.append(System.getProperty("line.separator")); |
---|
604 | buffer.append(String.format("%-26s", "Resources total load")); |
---|
605 | buffer.append(accStats.meanTotalLoad.toFormatedString()); |
---|
606 | buffer.append(System.getProperty("line.separator")); |
---|
607 | buffer.append(String.format("%-26s", "Resources reservation load")); |
---|
608 | buffer.append(accStats.meanReservationLoad.toFormatedString()); |
---|
609 | buffer.append(System.getProperty("line.separator")); |
---|
610 | buffer.append(String.format("%-26s", "Energy usage")); |
---|
611 | buffer.append(accStats.meanEnergyUsage.toFormatedString()); |
---|
612 | buffer.append(System.getProperty("line.separator")); |
---|
613 | buffer.append(String.format("%-26s", "Task completion time")); |
---|
614 | buffer.append(accStats.meanTaskCompletionTime.toFormatedString()); |
---|
615 | buffer.append(System.getProperty("line.separator")); |
---|
616 | buffer.append(String.format("%-26s", "Task execution time")); |
---|
617 | buffer.append(accStats.meanTaskExecutionTime.toFormatedString()); |
---|
618 | buffer.append(System.getProperty("line.separator")); |
---|
619 | buffer.append(String.format("%-26s", "Task start time")); |
---|
620 | buffer.append(accStats.meanTaskStartTime.toFormatedString()); |
---|
621 | buffer.append(System.getProperty("line.separator")); |
---|
622 | buffer.append(String.format("%-26s", "Task flow time")); |
---|
623 | buffer.append(accStats.meanTaskFlowTime.toFormatedString()); |
---|
624 | buffer.append(System.getProperty("line.separator")); |
---|
625 | buffer.append(String.format("%-26s", "Task waiting time")); |
---|
626 | buffer.append(accStats.meanTaskWaitingTime.toFormatedString()); |
---|
627 | buffer.append(System.getProperty("line.separator")); |
---|
628 | buffer.append(String.format("%-26s", "Task lateness")); |
---|
629 | buffer.append(accStats.lateness.toFormatedString()); |
---|
630 | buffer.append(System.getProperty("line.separator")); |
---|
631 | buffer.append(String.format("%-26s", "Task tardiness")); |
---|
632 | buffer.append(accStats.tardiness.toFormatedString()); |
---|
633 | |
---|
634 | return buffer.toString(); |
---|
635 | |
---|
636 | } |
---|
637 | |
---|
638 | } |
---|