Committed by
Gerrit Code Review
Fix for multiple metrics issues
Change-Id: Ie534d5130278df504eda99e30df1eb2c3e7a43da
Showing
1 changed file
with
10 additions
and
7 deletions
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.store.cluster.messaging.impl; | 16 | package org.onosproject.store.cluster.messaging.impl; |
17 | 17 | ||
18 | +import com.google.common.base.Throwables; | ||
18 | import org.apache.felix.scr.annotations.Activate; | 19 | import org.apache.felix.scr.annotations.Activate; |
19 | import org.apache.felix.scr.annotations.Component; | 20 | import org.apache.felix.scr.annotations.Component; |
20 | import org.apache.felix.scr.annotations.Deactivate; | 21 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -68,6 +69,7 @@ public class ClusterCommunicationManager | ... | @@ -68,6 +69,7 @@ public class ClusterCommunicationManager |
68 | private static final String DESERIALIZING = "deserialization"; | 69 | private static final String DESERIALIZING = "deserialization"; |
69 | private static final String NODE_PREFIX = "node:"; | 70 | private static final String NODE_PREFIX = "node:"; |
70 | private static final String ROUND_TRIP_SUFFIX = ".rtt"; | 71 | private static final String ROUND_TRIP_SUFFIX = ".rtt"; |
72 | + private static final String ONE_WAY_SUFFIX = ".oneway"; | ||
71 | 73 | ||
72 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 74 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
73 | private ClusterService clusterService; | 75 | private ClusterService clusterService; |
... | @@ -168,16 +170,17 @@ public class ClusterCommunicationManager | ... | @@ -168,16 +170,17 @@ public class ClusterCommunicationManager |
168 | ControllerNode node = clusterService.getNode(toNodeId); | 170 | ControllerNode node = clusterService.getNode(toNodeId); |
169 | checkArgument(node != null, "Unknown nodeId: %s", toNodeId); | 171 | checkArgument(node != null, "Unknown nodeId: %s", toNodeId); |
170 | Endpoint nodeEp = new Endpoint(node.ip(), node.tcpPort()); | 172 | Endpoint nodeEp = new Endpoint(node.ip(), node.tcpPort()); |
171 | - return messagingService.sendAsync(nodeEp, subject.value(), payload); | 173 | + MeteringAgent.Context context = subjectMeteringAgent.startTimer(subject.toString() + ONE_WAY_SUFFIX); |
174 | + return messagingService.sendAsync(nodeEp, subject.value(), payload).whenComplete((r, e) -> context.stop(e)); | ||
172 | } | 175 | } |
173 | 176 | ||
174 | private CompletableFuture<byte[]> sendAndReceive(MessageSubject subject, byte[] payload, NodeId toNodeId) { | 177 | private CompletableFuture<byte[]> sendAndReceive(MessageSubject subject, byte[] payload, NodeId toNodeId) { |
175 | ControllerNode node = clusterService.getNode(toNodeId); | 178 | ControllerNode node = clusterService.getNode(toNodeId); |
176 | checkArgument(node != null, "Unknown nodeId: %s", toNodeId); | 179 | checkArgument(node != null, "Unknown nodeId: %s", toNodeId); |
177 | Endpoint nodeEp = new Endpoint(node.ip(), node.tcpPort()); | 180 | Endpoint nodeEp = new Endpoint(node.ip(), node.tcpPort()); |
178 | - final MeteringAgent.Context epContext = endpointMeteringAgent. | 181 | + MeteringAgent.Context epContext = endpointMeteringAgent. |
179 | startTimer(NODE_PREFIX + toNodeId.toString() + ROUND_TRIP_SUFFIX); | 182 | startTimer(NODE_PREFIX + toNodeId.toString() + ROUND_TRIP_SUFFIX); |
180 | - final MeteringAgent.Context subjectContext = subjectMeteringAgent. | 183 | + MeteringAgent.Context subjectContext = subjectMeteringAgent. |
181 | startTimer(subject.toString() + ROUND_TRIP_SUFFIX); | 184 | startTimer(subject.toString() + ROUND_TRIP_SUFFIX); |
182 | return messagingService.sendAndReceive(nodeEp, subject.value(), payload). | 185 | return messagingService.sendAndReceive(nodeEp, subject.value(), payload). |
183 | whenComplete((bytes, throwable) -> { | 186 | whenComplete((bytes, throwable) -> { |
... | @@ -261,12 +264,12 @@ public class ClusterCommunicationManager | ... | @@ -261,12 +264,12 @@ public class ClusterCommunicationManager |
261 | B result = null; | 264 | B result = null; |
262 | try { | 265 | try { |
263 | result = timedFunction.apply(a); | 266 | result = timedFunction.apply(a); |
264 | - } catch (Exception e) { | ||
265 | - context.stop(e); | ||
266 | - throw new RuntimeException(e); | ||
267 | - } finally { | ||
268 | context.stop(null); | 267 | context.stop(null); |
269 | return result; | 268 | return result; |
269 | + } catch (Exception e) { | ||
270 | + context.stop(e); | ||
271 | + Throwables.propagate(e); | ||
272 | + return null; | ||
270 | } | 273 | } |
271 | } | 274 | } |
272 | }; | 275 | }; | ... | ... |
-
Please register or login to post a comment