01: package net.javacoding.jspider.api.event.monitor;
02:
03: /**
04: * $Id: SchedulerMonitorEvent.java,v 1.4 2003/04/03 15:57:14 vanrogu Exp $
05: */
06: public class SchedulerMonitorEvent extends MonitorEvent {
07:
08: protected int jobCount;
09: protected int spiderJobsCount;
10: protected int thinkerJobsCount;
11: protected int jobsDone;
12: protected int spiderJobsDone;
13: protected int thinkerJobsDone;
14: protected int blockedCount;
15: protected int assignedCount;
16:
17: public SchedulerMonitorEvent(int jobCount, int spiderJobsCount,
18: int thinkerJobsCount, int jobsDone, int spiderJobsDone,
19: int thinkerJobsDone, int blockedCount, int assignedCount) {
20: this .jobCount = jobCount;
21: this .spiderJobsCount = spiderJobsCount;
22: this .thinkerJobsCount = thinkerJobsCount;
23: this .jobsDone = jobsDone;
24: this .spiderJobsDone = spiderJobsDone;
25: this .thinkerJobsDone = thinkerJobsDone;
26: this .blockedCount = blockedCount;
27: this .assignedCount = assignedCount;
28: }
29:
30: public String toString() {
31: int pctDone = 0;
32: if (getJobCount() != 0) {
33: pctDone = ((getJobsDone() * 100) / getJobCount());
34: }
35: int spidersPctDone = 0;
36: if (getSpiderJobsCount() != 0) {
37: spidersPctDone = ((getSpiderJobsDone() * 100) / getSpiderJobsCount());
38: }
39: int thinkersPctDone = 0;
40: if (getThinkerJobsCount() != 0) {
41: thinkersPctDone = ((getThinkerJobsDone() * 100) / getThinkerJobsCount());
42: }
43: return "Job monitor: " + pctDone + "% (" + getJobsDone() + "/"
44: + getJobCount() + ") [S:" + spidersPctDone + "% ("
45: + getSpiderJobsDone() + "/" + getSpiderJobsCount()
46: + ") | T:" + thinkersPctDone + "% ("
47: + getThinkerJobsDone() + "/" + getThinkerJobsCount()
48: + ")] [blocked:" + blockedCount + "] [assigned:"
49: + assignedCount + "]";
50: }
51:
52: public String getComment() {
53: return toString();
54: }
55:
56: public int getJobCount() {
57: return jobCount;
58: }
59:
60: public int getSpiderJobsCount() {
61: return spiderJobsCount;
62: }
63:
64: public int getThinkerJobsCount() {
65: return thinkerJobsCount;
66: }
67:
68: public int getJobsDone() {
69: return jobsDone;
70: }
71:
72: public int getSpiderJobsDone() {
73: return spiderJobsDone;
74: }
75:
76: public int getThinkerJobsDone() {
77: return thinkerJobsDone;
78: }
79:
80: public int getBlockedCount() {
81: return blockedCount;
82: }
83:
84: public int getAssignedCount() {
85: return assignedCount;
86: }
87:
88: }
|