diff options
Diffstat (limited to 'src/main/java/org/gnunet/statistics/SetRequest.java')
-rw-r--r-- | src/main/java/org/gnunet/statistics/SetRequest.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/main/java/org/gnunet/statistics/SetRequest.java b/src/main/java/org/gnunet/statistics/SetRequest.java new file mode 100644 index 0000000..4aa4a82 --- /dev/null +++ b/src/main/java/org/gnunet/statistics/SetRequest.java | |||
@@ -0,0 +1,48 @@ | |||
1 | package org.gnunet.statistics; | ||
2 | |||
3 | import org.gnunet.mq.Envelope; | ||
4 | import org.gnunet.mq.MessageQueue; | ||
5 | import org.gnunet.requests.RequestContainer; | ||
6 | import org.gnunet.util.RelativeTime; | ||
7 | |||
8 | |||
9 | public class SetRequest extends RequestContainer.Request { | ||
10 | /** | ||
11 | * Time after we give up on setting values in statistics | ||
12 | */ | ||
13 | private static final RelativeTime SET_TIMEOUT = RelativeTime.SECOND.multiply(10); | ||
14 | |||
15 | private final static int SETFLAG_RELATIVE = 1; | ||
16 | private final static int SETFLAG_PERSIST = 2; | ||
17 | private final String subsystem; | ||
18 | private final String name; | ||
19 | private final boolean persist; | ||
20 | private final long value; | ||
21 | private final boolean relative; | ||
22 | |||
23 | public SetRequest(String subsystem, String name, long value, boolean relative, boolean persist) { | ||
24 | this.subsystem = subsystem; | ||
25 | this.name = name; | ||
26 | this.persist = persist; | ||
27 | this.value = value; | ||
28 | this.relative = relative; | ||
29 | |||
30 | } | ||
31 | |||
32 | @Override | ||
33 | public Envelope assembleRequest() { | ||
34 | SetMessage m = new SetMessage(); | ||
35 | m.statisticName = name; | ||
36 | m.subsystemName = subsystem; | ||
37 | m.value = value; | ||
38 | if (relative) | ||
39 | m.flags |= SETFLAG_RELATIVE; | ||
40 | if (persist) | ||
41 | m.flags |= SETFLAG_PERSIST; | ||
42 | return new Envelope(m); | ||
43 | } | ||
44 | |||
45 | public void cancel() { | ||
46 | //To change body of implemented methods use File | Settings | File Templates. | ||
47 | } | ||
48 | } | ||