diff options
author | Florian Dold <florian.dold@gmail.com> | 2013-10-21 19:13:51 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2013-10-21 19:13:51 +0000 |
commit | 35df3d81f0f5b76b728b3be8ddaa95ecdbbd0e5e (patch) | |
tree | 4dd6f07e063782f39a18fa1031a3f514a8ecc477 /src/main/java/org/gnunet/statistics/Statistics.java | |
parent | 8ceb5e95568a0a5be9ca6fd28a31fe6b07e06f28 (diff) | |
download | gnunet-java-35df3d81f0f5b76b728b3be8ddaa95ecdbbd0e5e.tar.gz gnunet-java-35df3d81f0f5b76b728b3be8ddaa95ecdbbd0e5e.zip |
- use java naming conventions (no underscores in non-capitalized identifiers) consistently
Diffstat (limited to 'src/main/java/org/gnunet/statistics/Statistics.java')
-rw-r--r-- | src/main/java/org/gnunet/statistics/Statistics.java | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/main/java/org/gnunet/statistics/Statistics.java b/src/main/java/org/gnunet/statistics/Statistics.java index 416db0c..d06b627 100644 --- a/src/main/java/org/gnunet/statistics/Statistics.java +++ b/src/main/java/org/gnunet/statistics/Statistics.java | |||
@@ -50,28 +50,28 @@ public class Statistics { | |||
50 | */ | 50 | */ |
51 | private final Client client; | 51 | private final Client client; |
52 | 52 | ||
53 | SequentialRequestContainer<SetRequest> set_requests; | 53 | SequentialRequestContainer<SetRequest> setRequests; |
54 | SequentialRequestContainer<GetRequest> get_requests; | 54 | SequentialRequestContainer<GetRequest> getRequests; |
55 | MatchingRequestContainer<Long,WatchRequest> watch_requests; | 55 | MatchingRequestContainer<Long,WatchRequest> watchRequests; |
56 | 56 | ||
57 | private boolean destroy_requested; | 57 | private boolean destroyRequested; |
58 | 58 | ||
59 | private long wid = 0; | 59 | private long wid = 0; |
60 | 60 | ||
61 | public class StatisticsMessageReceiver extends RunaboutMessageReceiver { | 61 | public class StatisticsMessageReceiver extends RunaboutMessageReceiver { |
62 | public void visit(GetResponseMessage m) { | 62 | public void visit(GetResponseMessage m) { |
63 | GetRequest r = get_requests.getRequest(); | 63 | GetRequest r = getRequests.getRequest(); |
64 | if (r != null) | 64 | if (r != null) |
65 | r.receiver.onReceive(m.subsystemName, m.statisticName, m.value); | 65 | r.receiver.onReceive(m.subsystemName, m.statisticName, m.value); |
66 | } | 66 | } |
67 | 67 | ||
68 | public void visit(GetResponseEndMessage m) { | 68 | public void visit(GetResponseEndMessage m) { |
69 | GetRequest r = get_requests.getRequest(); | 69 | GetRequest r = getRequests.getRequest(); |
70 | if (r != null) | 70 | if (r != null) |
71 | r.receiver.onDone(); | 71 | r.receiver.onDone(); |
72 | //noinspection ConstantConditions | 72 | //noinspection ConstantConditions |
73 | if (get_requests != null) | 73 | if (getRequests != null) |
74 | get_requests.next(); | 74 | getRequests.next(); |
75 | } | 75 | } |
76 | 76 | ||
77 | public void visit(TestMessage m) { | 77 | public void visit(TestMessage m) { |
@@ -80,7 +80,7 @@ public class Statistics { | |||
80 | } | 80 | } |
81 | 81 | ||
82 | public void visit(WatchResponseMessage wrm) { | 82 | public void visit(WatchResponseMessage wrm) { |
83 | WatchRequest r = watch_requests.getRequest((long) wrm.wid); | 83 | WatchRequest r = watchRequests.getRequest((long) wrm.wid); |
84 | if (r != null) { | 84 | if (r != null) { |
85 | r.watcher.onReceive(r.subsystem, r.name, wrm.value); | 85 | r.watcher.onReceive(r.subsystem, r.name, wrm.value); |
86 | } | 86 | } |
@@ -88,11 +88,11 @@ public class Statistics { | |||
88 | 88 | ||
89 | @Override | 89 | @Override |
90 | public void handleError() { | 90 | public void handleError() { |
91 | if (!destroy_requested) { | 91 | if (!destroyRequested) { |
92 | client.reconnect(); | 92 | client.reconnect(); |
93 | get_requests.restart(); | 93 | getRequests.restart(); |
94 | set_requests.restart(); | 94 | setRequests.restart(); |
95 | watch_requests.restart(); | 95 | watchRequests.restart(); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | } | 98 | } |
@@ -100,9 +100,9 @@ public class Statistics { | |||
100 | public Statistics(Configuration cfg) { | 100 | public Statistics(Configuration cfg) { |
101 | client = new Client("statistics", cfg); | 101 | client = new Client("statistics", cfg); |
102 | client.installReceiver(new StatisticsMessageReceiver()); | 102 | client.installReceiver(new StatisticsMessageReceiver()); |
103 | get_requests = new SequentialRequestContainer<GetRequest>(client); | 103 | getRequests = new SequentialRequestContainer<GetRequest>(client); |
104 | set_requests = new SequentialRequestContainer<SetRequest>(client); | 104 | setRequests = new SequentialRequestContainer<SetRequest>(client); |
105 | watch_requests = new MatchingRequestContainer<Long, WatchRequest>(client); | 105 | watchRequests = new MatchingRequestContainer<Long, WatchRequest>(client); |
106 | } | 106 | } |
107 | 107 | ||
108 | /** | 108 | /** |
@@ -118,9 +118,9 @@ public class Statistics { | |||
118 | */ | 118 | */ |
119 | public Cancelable get(RelativeTime timeout, final String subsystem, final String name, | 119 | public Cancelable get(RelativeTime timeout, final String subsystem, final String name, |
120 | final StatisticsReceiver receiver) { | 120 | final StatisticsReceiver receiver) { |
121 | if (destroy_requested) | 121 | if (destroyRequested) |
122 | throw new AssertionError("already destroyed"); | 122 | throw new AssertionError("already destroyed"); |
123 | return get_requests.addRequest(new GetRequest(subsystem, name, receiver)); | 123 | return getRequests.addRequest(new GetRequest(subsystem, name, receiver)); |
124 | } | 124 | } |
125 | 125 | ||
126 | /** | 126 | /** |
@@ -132,9 +132,9 @@ public class Statistics { | |||
132 | * @return a handle to cancel the request | 132 | * @return a handle to cancel the request |
133 | */ | 133 | */ |
134 | public Cancelable set(final String subsystem, final String name, final long value, boolean persist) { | 134 | public Cancelable set(final String subsystem, final String name, final long value, boolean persist) { |
135 | if (destroy_requested) | 135 | if (destroyRequested) |
136 | throw new AssertionError("already destroyed"); | 136 | throw new AssertionError("already destroyed"); |
137 | return set_requests.addRequest(new SetRequest(subsystem, name, value, false, persist)); | 137 | return setRequests.addRequest(new SetRequest(subsystem, name, value, false, persist)); |
138 | } | 138 | } |
139 | 139 | ||
140 | /** | 140 | /** |
@@ -146,9 +146,9 @@ public class Statistics { | |||
146 | * @return a handle to cancel the request | 146 | * @return a handle to cancel the request |
147 | */ | 147 | */ |
148 | public Cancelable update(final String subsystem, final String name, final long delta, boolean persist) { | 148 | public Cancelable update(final String subsystem, final String name, final long delta, boolean persist) { |
149 | if (destroy_requested) | 149 | if (destroyRequested) |
150 | throw new AssertionError("already destroyed"); | 150 | throw new AssertionError("already destroyed"); |
151 | return set_requests.addRequest(new SetRequest(subsystem, name, delta, true, persist)); | 151 | return setRequests.addRequest(new SetRequest(subsystem, name, delta, true, persist)); |
152 | } | 152 | } |
153 | 153 | ||
154 | /** | 154 | /** |
@@ -160,17 +160,17 @@ public class Statistics { | |||
160 | * @return a handle to cancel the request | 160 | * @return a handle to cancel the request |
161 | */ | 161 | */ |
162 | public Cancelable watch(final String subsystem, final String name, StatisticsWatcher watcher) { | 162 | public Cancelable watch(final String subsystem, final String name, StatisticsWatcher watcher) { |
163 | if (destroy_requested) | 163 | if (destroyRequested) |
164 | throw new AssertionError("already destroyed"); | 164 | throw new AssertionError("already destroyed"); |
165 | WatchRequest r = new WatchRequest(subsystem, name, watcher); | 165 | WatchRequest r = new WatchRequest(subsystem, name, watcher); |
166 | return watch_requests.addRequest(wid++, r); | 166 | return watchRequests.addRequest(wid++, r); |
167 | } | 167 | } |
168 | 168 | ||
169 | /** | 169 | /** |
170 | * Destroy handle to the statistics service. Always finishes writing pending values. | 170 | * Destroy handle to the statistics service. Always finishes writing pending values. |
171 | */ | 171 | */ |
172 | public void destroy() { | 172 | public void destroy() { |
173 | destroy_requested = true; | 173 | destroyRequested = true; |
174 | client.send(new TestMessage()); | 174 | client.send(new TestMessage()); |
175 | // wait until the service responds | 175 | // wait until the service responds |
176 | // TODO: or timeout | 176 | // TODO: or timeout |