Committed by
Gerrit Code Review
Setting up monitoring of cluster communcation service
Change-Id: I771b23db6920b26b592abc5d5156e9d77cde4f00
Showing
10 changed files
with
113 additions
and
9 deletions
1 | /* | 1 | /* |
2 | - * Copyright 2015 Open Networking Laboratory | 2 | + * Copyright 2016 Open Networking Laboratory |
3 | * | 3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.store.primitives.impl; | 16 | +package org.onosproject.utils; |
17 | 17 | ||
18 | import com.codahale.metrics.Counter; | 18 | import com.codahale.metrics.Counter; |
19 | import com.codahale.metrics.Timer; | 19 | import com.codahale.metrics.Timer; | ... | ... |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +/** | ||
18 | + * Miscellaneous common facilities used for construction of various core and | ||
19 | + * app subsystems. | ||
20 | + */ | ||
21 | +package org.onosproject.utils; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -31,6 +31,7 @@ import org.onosproject.store.cluster.messaging.ClusterMessageHandler; | ... | @@ -31,6 +31,7 @@ import org.onosproject.store.cluster.messaging.ClusterMessageHandler; |
31 | import org.onosproject.store.cluster.messaging.Endpoint; | 31 | import org.onosproject.store.cluster.messaging.Endpoint; |
32 | import org.onosproject.store.cluster.messaging.MessageSubject; | 32 | import org.onosproject.store.cluster.messaging.MessageSubject; |
33 | import org.onosproject.store.cluster.messaging.MessagingService; | 33 | import org.onosproject.store.cluster.messaging.MessagingService; |
34 | +import org.onosproject.utils.MeteringAgent; | ||
34 | import org.slf4j.Logger; | 35 | import org.slf4j.Logger; |
35 | import org.slf4j.LoggerFactory; | 36 | import org.slf4j.LoggerFactory; |
36 | 37 | ||
... | @@ -47,6 +48,7 @@ import java.util.function.Function; | ... | @@ -47,6 +48,7 @@ import java.util.function.Function; |
47 | import java.util.stream.Collectors; | 48 | import java.util.stream.Collectors; |
48 | 49 | ||
49 | import static com.google.common.base.Preconditions.checkArgument; | 50 | import static com.google.common.base.Preconditions.checkArgument; |
51 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
50 | 52 | ||
51 | @Component(immediate = true) | 53 | @Component(immediate = true) |
52 | @Service | 54 | @Service |
... | @@ -55,6 +57,18 @@ public class ClusterCommunicationManager | ... | @@ -55,6 +57,18 @@ public class ClusterCommunicationManager |
55 | 57 | ||
56 | private final Logger log = LoggerFactory.getLogger(getClass()); | 58 | private final Logger log = LoggerFactory.getLogger(getClass()); |
57 | 59 | ||
60 | + private final MeteringAgent subjectMeteringAgent = new MeteringAgent(PRIMITIVE_NAME, SUBJECT_PREFIX, true); | ||
61 | + private final MeteringAgent endpointMeteringAgent = new MeteringAgent(PRIMITIVE_NAME, ENDPOINT_PREFIX, true); | ||
62 | + | ||
63 | + private static final String PRIMITIVE_NAME = "clusterCommunication"; | ||
64 | + private static final String SUBJECT_PREFIX = "subject"; | ||
65 | + private static final String ENDPOINT_PREFIX = "endpoint"; | ||
66 | + | ||
67 | + private static final String SERIALIZING = "serialization"; | ||
68 | + private static final String DESERIALIZING = "deserialization"; | ||
69 | + private static final String NODE_PREFIX = "node:"; | ||
70 | + private static final String ROUND_TRIP_SUFFIX = ".rtt"; | ||
71 | + | ||
58 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 72 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
59 | private ClusterService clusterService; | 73 | private ClusterService clusterService; |
60 | 74 | ||
... | @@ -110,7 +124,8 @@ public class ClusterCommunicationManager | ... | @@ -110,7 +124,8 @@ public class ClusterCommunicationManager |
110 | byte[] payload = new ClusterMessage( | 124 | byte[] payload = new ClusterMessage( |
111 | localNodeId, | 125 | localNodeId, |
112 | subject, | 126 | subject, |
113 | - encoder.apply(message)).getBytes(); | 127 | + timeFunction(encoder, subjectMeteringAgent, SERIALIZING).apply(message) |
128 | + ).getBytes(); | ||
114 | return doUnicast(subject, payload, toNodeId); | 129 | return doUnicast(subject, payload, toNodeId); |
115 | } catch (Exception e) { | 130 | } catch (Exception e) { |
116 | return Tools.exceptionalFuture(e); | 131 | return Tools.exceptionalFuture(e); |
... | @@ -125,7 +140,8 @@ public class ClusterCommunicationManager | ... | @@ -125,7 +140,8 @@ public class ClusterCommunicationManager |
125 | byte[] payload = new ClusterMessage( | 140 | byte[] payload = new ClusterMessage( |
126 | localNodeId, | 141 | localNodeId, |
127 | subject, | 142 | subject, |
128 | - encoder.apply(message)).getBytes(); | 143 | + timeFunction(encoder, subjectMeteringAgent, SERIALIZING).apply(message)) |
144 | + .getBytes(); | ||
129 | nodes.forEach(nodeId -> doUnicast(subject, payload, nodeId)); | 145 | nodes.forEach(nodeId -> doUnicast(subject, payload, nodeId)); |
130 | } | 146 | } |
131 | 147 | ||
... | @@ -139,8 +155,10 @@ public class ClusterCommunicationManager | ... | @@ -139,8 +155,10 @@ public class ClusterCommunicationManager |
139 | ClusterMessage envelope = new ClusterMessage( | 155 | ClusterMessage envelope = new ClusterMessage( |
140 | clusterService.getLocalNode().id(), | 156 | clusterService.getLocalNode().id(), |
141 | subject, | 157 | subject, |
142 | - encoder.apply(message)); | 158 | + timeFunction(encoder, subjectMeteringAgent, SERIALIZING). |
143 | - return sendAndReceive(subject, envelope.getBytes(), toNodeId).thenApply(decoder); | 159 | + apply(message)); |
160 | + return sendAndReceive(subject, envelope.getBytes(), toNodeId). | ||
161 | + thenApply(bytes -> timeFunction(decoder, subjectMeteringAgent, DESERIALIZING).apply(bytes)); | ||
144 | } catch (Exception e) { | 162 | } catch (Exception e) { |
145 | return Tools.exceptionalFuture(e); | 163 | return Tools.exceptionalFuture(e); |
146 | } | 164 | } |
... | @@ -157,7 +175,15 @@ public class ClusterCommunicationManager | ... | @@ -157,7 +175,15 @@ public class ClusterCommunicationManager |
157 | ControllerNode node = clusterService.getNode(toNodeId); | 175 | ControllerNode node = clusterService.getNode(toNodeId); |
158 | checkArgument(node != null, "Unknown nodeId: %s", toNodeId); | 176 | checkArgument(node != null, "Unknown nodeId: %s", toNodeId); |
159 | Endpoint nodeEp = new Endpoint(node.ip(), node.tcpPort()); | 177 | Endpoint nodeEp = new Endpoint(node.ip(), node.tcpPort()); |
160 | - return messagingService.sendAndReceive(nodeEp, subject.value(), payload); | 178 | + final MeteringAgent.Context epContext = endpointMeteringAgent. |
179 | + startTimer(NODE_PREFIX + toNodeId.toString() + ROUND_TRIP_SUFFIX); | ||
180 | + final MeteringAgent.Context subjectContext = subjectMeteringAgent. | ||
181 | + startTimer(subject.toString() + ROUND_TRIP_SUFFIX); | ||
182 | + return messagingService.sendAndReceive(nodeEp, subject.value(), payload). | ||
183 | + whenComplete((bytes, throwable) -> { | ||
184 | + subjectContext.stop(throwable); | ||
185 | + epContext.stop(throwable); | ||
186 | + }); | ||
161 | } | 187 | } |
162 | 188 | ||
163 | @Override | 189 | @Override |
... | @@ -213,6 +239,40 @@ public class ClusterCommunicationManager | ... | @@ -213,6 +239,40 @@ public class ClusterCommunicationManager |
213 | executor); | 239 | executor); |
214 | } | 240 | } |
215 | 241 | ||
242 | + /** | ||
243 | + * Performs the timed function, returning the value it would while timing the operation. | ||
244 | + * | ||
245 | + * @param timedFunction the function to be timed | ||
246 | + * @param meter the metering agent to be used to time the function | ||
247 | + * @param opName the opname to be used when starting the meter | ||
248 | + * @param <A> The param type of the function | ||
249 | + * @param <B> The return type of the function | ||
250 | + * @return the value returned by the timed function | ||
251 | + */ | ||
252 | + private <A, B> Function<A, B> timeFunction(Function<A, B> timedFunction, | ||
253 | + MeteringAgent meter, String opName) { | ||
254 | + checkNotNull(timedFunction); | ||
255 | + checkNotNull(meter); | ||
256 | + checkNotNull(opName); | ||
257 | + return new Function<A, B>() { | ||
258 | + @Override | ||
259 | + public B apply(A a) { | ||
260 | + final MeteringAgent.Context context = meter.startTimer(opName); | ||
261 | + B result = null; | ||
262 | + try { | ||
263 | + result = timedFunction.apply(a); | ||
264 | + } catch (Exception e) { | ||
265 | + context.stop(e); | ||
266 | + throw new RuntimeException(e); | ||
267 | + } finally { | ||
268 | + context.stop(null); | ||
269 | + return result; | ||
270 | + } | ||
271 | + } | ||
272 | + }; | ||
273 | + } | ||
274 | + | ||
275 | + | ||
216 | private class InternalClusterMessageHandler implements BiFunction<Endpoint, byte[], byte[]> { | 276 | private class InternalClusterMessageHandler implements BiFunction<Endpoint, byte[], byte[]> { |
217 | private ClusterMessageHandler handler; | 277 | private ClusterMessageHandler handler; |
218 | 278 | ||
... | @@ -243,7 +303,9 @@ public class ClusterCommunicationManager | ... | @@ -243,7 +303,9 @@ public class ClusterCommunicationManager |
243 | 303 | ||
244 | @Override | 304 | @Override |
245 | public CompletableFuture<byte[]> apply(Endpoint sender, byte[] bytes) { | 305 | public CompletableFuture<byte[]> apply(Endpoint sender, byte[] bytes) { |
246 | - return handler.apply(decoder.apply(ClusterMessage.fromBytes(bytes).payload())).thenApply(encoder); | 306 | + return handler.apply(timeFunction(decoder, subjectMeteringAgent, DESERIALIZING). |
307 | + apply(ClusterMessage.fromBytes(bytes).payload())). | ||
308 | + thenApply(m -> timeFunction(encoder, subjectMeteringAgent, SERIALIZING).apply(m)); | ||
247 | } | 309 | } |
248 | } | 310 | } |
249 | 311 | ||
... | @@ -258,7 +320,8 @@ public class ClusterCommunicationManager | ... | @@ -258,7 +320,8 @@ public class ClusterCommunicationManager |
258 | 320 | ||
259 | @Override | 321 | @Override |
260 | public void accept(Endpoint sender, byte[] bytes) { | 322 | public void accept(Endpoint sender, byte[] bytes) { |
261 | - consumer.accept(decoder.apply(ClusterMessage.fromBytes(bytes).payload())); | 323 | + consumer.accept(timeFunction(decoder, subjectMeteringAgent, DESERIALIZING). |
324 | + apply(ClusterMessage.fromBytes(bytes).payload())); | ||
262 | } | 325 | } |
263 | } | 326 | } |
264 | } | 327 | } | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | package org.onosproject.store.primitives.impl; | 16 | package org.onosproject.store.primitives.impl; |
17 | 17 | ||
18 | import org.onosproject.store.service.AsyncAtomicCounter; | 18 | import org.onosproject.store.service.AsyncAtomicCounter; |
19 | +import org.onosproject.utils.MeteringAgent; | ||
19 | 20 | ||
20 | import java.util.concurrent.CompletableFuture; | 21 | import java.util.concurrent.CompletableFuture; |
21 | 22 | ... | ... |
... | @@ -32,6 +32,7 @@ import org.onosproject.store.service.Versioned; | ... | @@ -32,6 +32,7 @@ import org.onosproject.store.service.Versioned; |
32 | 32 | ||
33 | import com.google.common.base.Throwables; | 33 | import com.google.common.base.Throwables; |
34 | import com.google.common.collect.Maps; | 34 | import com.google.common.collect.Maps; |
35 | +import org.onosproject.utils.MeteringAgent; | ||
35 | 36 | ||
36 | 37 | ||
37 | public class DefaultAsyncAtomicValue<V> implements AsyncAtomicValue<V> { | 38 | public class DefaultAsyncAtomicValue<V> implements AsyncAtomicValue<V> { | ... | ... |
... | @@ -47,6 +47,7 @@ import org.onosproject.store.service.MapEvent; | ... | @@ -47,6 +47,7 @@ import org.onosproject.store.service.MapEvent; |
47 | import org.onosproject.store.service.MapEventListener; | 47 | import org.onosproject.store.service.MapEventListener; |
48 | import org.onosproject.store.service.Serializer; | 48 | import org.onosproject.store.service.Serializer; |
49 | import org.onosproject.store.service.Versioned; | 49 | import org.onosproject.store.service.Versioned; |
50 | +import org.onosproject.utils.MeteringAgent; | ||
50 | import org.slf4j.Logger; | 51 | import org.slf4j.Logger; |
51 | 52 | ||
52 | import com.google.common.cache.CacheBuilder; | 53 | import com.google.common.cache.CacheBuilder; | ... | ... |
... | @@ -33,6 +33,7 @@ import org.onosproject.store.service.SetEventListener; | ... | @@ -33,6 +33,7 @@ import org.onosproject.store.service.SetEventListener; |
33 | import com.google.common.collect.ImmutableSet; | 33 | import com.google.common.collect.ImmutableSet; |
34 | import com.google.common.collect.Maps; | 34 | import com.google.common.collect.Maps; |
35 | import com.google.common.collect.Sets; | 35 | import com.google.common.collect.Sets; |
36 | +import org.onosproject.utils.MeteringAgent; | ||
36 | 37 | ||
37 | /** | 38 | /** |
38 | * Implementation of {@link AsyncDistributedSet}. | 39 | * Implementation of {@link AsyncDistributedSet}. | ... | ... |
... | @@ -22,6 +22,7 @@ import org.onlab.util.SharedExecutors; | ... | @@ -22,6 +22,7 @@ import org.onlab.util.SharedExecutors; |
22 | import org.onosproject.store.service.DistributedPrimitive; | 22 | import org.onosproject.store.service.DistributedPrimitive; |
23 | import org.onosproject.store.service.DistributedQueue; | 23 | import org.onosproject.store.service.DistributedQueue; |
24 | import org.onosproject.store.service.Serializer; | 24 | import org.onosproject.store.service.Serializer; |
25 | +import org.onosproject.utils.MeteringAgent; | ||
25 | 26 | ||
26 | import java.util.List; | 27 | import java.util.List; |
27 | import java.util.Set; | 28 | import java.util.Set; | ... | ... |
... | @@ -32,6 +32,7 @@ import org.onosproject.store.service.Versioned; | ... | @@ -32,6 +32,7 @@ import org.onosproject.store.service.Versioned; |
32 | 32 | ||
33 | import com.google.common.base.Throwables; | 33 | import com.google.common.base.Throwables; |
34 | import com.google.common.collect.Maps; | 34 | import com.google.common.collect.Maps; |
35 | +import org.onosproject.utils.MeteringAgent; | ||
35 | 36 | ||
36 | /** | 37 | /** |
37 | * {@link AsyncConsistentMap} that meters all its operations. | 38 | * {@link AsyncConsistentMap} that meters all its operations. | ... | ... |
tools/test/cells/virtual
0 → 100644
1 | +# Local VirtualBox-based ONOS instances 1,2 & ONOS mininet box | ||
2 | + | ||
3 | +export ONOS_NIC=192.168.56.* | ||
4 | +export OC1="192.168.56.101" | ||
5 | +export OC2="192.168.56.102" | ||
6 | +export OC3="192.168.56.103" | ||
7 | +export OCN="192.168.56.100" | ||
8 | + | ||
9 | +export ONOS_USE_SSH=true | ||
10 | +export ONOS_APPS="drivers,openflow,fwd,proxyarp,mobility" | ||
11 | + | ||
12 | +export ONOS_USER=sdn | ||
13 | +export ONOS_WEB_PASS=sdnrocks | ||
14 | +export ONOS_WEB_USER=onos | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment