1
2
3
4
5
6
7 package org.astrogrid.status;
8
9 /***
10 * Basic status information for a service. Particular astrogrid components might
11 * extend this to contain other information.
12 *
13 * A bean so that it can be used to return status information from SOAP web services
14 *
15 * This object holds historic information about a service's status at a particular
16 * time
17 *
18 * <p>
19 * @author M Hill
20 */
21
22 import java.io.Serializable;
23 import java.util.Date;
24
25
26 public class ServiceStatusSnapshot implements Serializable
27 {
28 Date timestamp = new Date();
29 long free = -1;
30 long max = -1;
31 long total = -1;
32
33 long numClosedTasks = -1;
34 long numTasks = -1;
35
36 ServiceStatusSnapshot previous = null;
37
38 /*** Creates an empty snapshot for bean de/serialising */
39 public ServiceStatusSnapshot() {
40 }
41
42 /*** Creates a snapshot of the current situation
43 public ServiceStatusSnapshot(long tasksRunning, long tasksRun) {
44 timestamp = new Date();
45 free = Runtime.getRuntime().freeMemory();
46 max = Runtime.getRuntime().maxMemory();
47 total = Runtime.getRuntime().totalMemory();
48 this.numTasks = tasksRunning;
49 this.numClosedTasks = tasksRun;
50 }
51
52 /** Creates a snapshot of the current situation with a link to the previous one.
53 public ServiceStatusSnapshot(long tasksRunning, long tasksRun, ServiceStatusSnapshot givenPrevious) {
54 this(tasksRunning, tasksRun);
55 this.previous = givenPrevious;
56 }
57
58 /** Creates a snapshot of the given ServiceStatus */
59
60 /*** Propperty setter */
61 public void setNumClosedTasks(long numClosedTasks) {
62 this.numClosedTasks = numClosedTasks;
63 }
64
65 public long getNumClosedTasks() {
66 return numClosedTasks;
67 }
68
69 public void setNumTasks(long numTasks) { this.numTasks = numTasks; }
70
71 public long getNumTasks() { return numTasks; }
72
73 public void setFreeMemory(long free) { this.free = free; }
74
75 public void setMaxMemory(long max) { this.max = max; }
76
77 public void setTotalMemory(long total) { this.total = total; }
78
79 public void setPrevious(ServiceStatusSnapshot previous) {
80 this.previous = previous;
81 }
82
83 public ServiceStatusSnapshot getPrevious() {
84 return previous;
85 }
86
87 public void setTimestamp(Date timestamp) { this.timestamp = timestamp; }
88
89 public Date getTimestamp() { return timestamp; }
90
91 public long getFreeMemory() { return free; }
92
93 public long getMaxMemory() { return max; }
94
95 public long getTotalMemory() { return total; }
96
97 }
98
99
100
101
102
103
104