aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/gnunet/statistics
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/gnunet/statistics')
-rw-r--r--src/main/java/org/gnunet/statistics/Statistics.java27
-rw-r--r--src/main/java/org/gnunet/statistics/StatisticsReceiver.java21
-rw-r--r--src/main/java/org/gnunet/statistics/StatisticsWatcher.java10
3 files changed, 52 insertions, 6 deletions
diff --git a/src/main/java/org/gnunet/statistics/Statistics.java b/src/main/java/org/gnunet/statistics/Statistics.java
index d8b8f3e..d642962 100644
--- a/src/main/java/org/gnunet/statistics/Statistics.java
+++ b/src/main/java/org/gnunet/statistics/Statistics.java
@@ -131,6 +131,11 @@ public class Statistics {
131 } 131 }
132 } 132 }
133 133
134 /**
135 * Create a connection to the statistics service.
136 *
137 * @param cfg configuration to use
138 */
134 public Statistics(Configuration cfg) { 139 public Statistics(Configuration cfg) {
135 client = new Client("statistics", cfg); 140 client = new Client("statistics", cfg);
136 client.installReceiver(new StatisticsMessageReceiver()); 141 client.installReceiver(new StatisticsMessageReceiver());
@@ -139,9 +144,7 @@ public class Statistics {
139 } 144 }
140 145
141 /** 146 /**
142 * Retrieve values from statistics. 147 * Retrieve a statistics value of a subsystem.
143 * Only one instance of this getRequestIdentifier may be active simultaneously.
144 * Upon cancellation
145 * 148 *
146 * @param timeout time after we give up and call receiver.onTimeout 149 * @param timeout time after we give up and call receiver.onTimeout
147 * @param subsystem the subsystem of interest 150 * @param subsystem the subsystem of interest
@@ -164,6 +167,19 @@ public class Statistics {
164 } 167 }
165 168
166 /** 169 /**
170 * Retrieve all statistics value of a subsystem.
171 *
172 * @param timeout time after we give up and call receiver.onTimeout
173 * @param subsystem the subsystem of interest
174 * @param receiver callback
175 * @return handle to onCancel the getRequestIdentifier
176 */
177 public Cancelable get(RelativeTime timeout, final String subsystem,
178 final StatisticsReceiver receiver) {
179 return get(timeout, subsystem, "", receiver);
180 }
181
182 /**
167 * Sets a statistics value asynchronously. 183 * Sets a statistics value asynchronously.
168 * 184 *
169 * @param name name of the entry 185 * @param name name of the entry
@@ -226,9 +242,10 @@ public class Statistics {
226 } 242 }
227 243
228 /** 244 /**
229 * Destroy handle to the statistics service. Always finishes writing pending values. 245 * Destroy handle to the statistics service.
230 * 246 *
231 * @param syncFirst Wait until the statistics service has received all our updates. 247 * @param syncFirst If true, wait until the statistics service has received all our updates.
248 * If false, pending updates may be lost.
232 */ 249 */
233 public void destroy(boolean syncFirst) { 250 public void destroy(boolean syncFirst) {
234 if (destroyRequested) 251 if (destroyRequested)
diff --git a/src/main/java/org/gnunet/statistics/StatisticsReceiver.java b/src/main/java/org/gnunet/statistics/StatisticsReceiver.java
index 0c25acc..d30a93e 100644
--- a/src/main/java/org/gnunet/statistics/StatisticsReceiver.java
+++ b/src/main/java/org/gnunet/statistics/StatisticsReceiver.java
@@ -21,9 +21,28 @@
21package org.gnunet.statistics; 21package org.gnunet.statistics;
22 22
23 23
24 24/**
25 * Handler for statistics results.
26 */
25public interface StatisticsReceiver { 27public interface StatisticsReceiver {
28 /**
29 * Called when having received a statistics value from the service.
30 *
31 * @param subsystem subsystem of the value
32 * @param name name of the value
33 * @param value the value
34 */
26 public void onReceive(String subsystem, String name, long value); 35 public void onReceive(String subsystem, String name, long value);
36
37 /**
38 * Called when a statistics request times out. Never called
39 * for watchers.
40 */
27 public void onTimeout(); 41 public void onTimeout();
42
43 /**
44 * Called when all values for the request have been received.
45 * Never called for watchers.
46 */
28 public void onDone(); 47 public void onDone();
29} 48}
diff --git a/src/main/java/org/gnunet/statistics/StatisticsWatcher.java b/src/main/java/org/gnunet/statistics/StatisticsWatcher.java
index 11328b7..5fdd6bc 100644
--- a/src/main/java/org/gnunet/statistics/StatisticsWatcher.java
+++ b/src/main/java/org/gnunet/statistics/StatisticsWatcher.java
@@ -1,5 +1,15 @@
1package org.gnunet.statistics; 1package org.gnunet.statistics;
2 2
3/**
4 * Listener for statistics changes.
5 */
3public interface StatisticsWatcher { 6public interface StatisticsWatcher {
7 /**
8 * Called when receiving a change notification for a statistics value.
9 *
10 * @param subsystem subsystem of the value that changed
11 * @param name name of the value that changed
12 * @param value new value
13 */
4 public void onReceive(String subsystem, String name, long value); 14 public void onReceive(String subsystem, String name, long value);
5} 15}