Thomas Vachuska
Committed by Gerrit Code Review

Adding multi-instance support for flow stats.

Change-Id: I428c5a7cb58f4f9773a125fc94fb368ed846cb0d
...@@ -61,6 +61,22 @@ public final class DefaultPortStatistics implements PortStatistics { ...@@ -61,6 +61,22 @@ public final class DefaultPortStatistics implements PortStatistics {
61 this.durationNano = durationNano; 61 this.durationNano = durationNano;
62 } 62 }
63 63
64 + // Constructor for serializer
65 + private DefaultPortStatistics() {
66 + this.deviceId = null;
67 + this.port = 0;
68 + this.packetsReceived = 0;
69 + this.packetsSent = 0;
70 + this.bytesReceived = 0;
71 + this.bytesSent = 0;
72 + this.packetsRxDropped = 0;
73 + this.packetsTxDropped = 0;
74 + this.packetsRxErrors = 0;
75 + this.packetsTxErrors = 0;
76 + this.durationSec = 0;
77 + this.durationNano = 0;
78 + }
79 +
64 /** 80 /**
65 * Creates a builder for DefaultPortStatistics object. 81 * Creates a builder for DefaultPortStatistics object.
66 * 82 *
......
...@@ -50,6 +50,7 @@ import org.onosproject.net.OduCltPort; ...@@ -50,6 +50,7 @@ import org.onosproject.net.OduCltPort;
50 import org.onosproject.net.OmsPort; 50 import org.onosproject.net.OmsPort;
51 import org.onosproject.net.Port; 51 import org.onosproject.net.Port;
52 import org.onosproject.net.PortNumber; 52 import org.onosproject.net.PortNumber;
53 +import org.onosproject.net.device.DefaultPortStatistics;
53 import org.onosproject.net.device.DeviceClockService; 54 import org.onosproject.net.device.DeviceClockService;
54 import org.onosproject.net.device.DeviceDescription; 55 import org.onosproject.net.device.DeviceDescription;
55 import org.onosproject.net.device.DeviceEvent; 56 import org.onosproject.net.device.DeviceEvent;
...@@ -68,8 +69,16 @@ import org.onosproject.store.cluster.messaging.ClusterMessage; ...@@ -68,8 +69,16 @@ import org.onosproject.store.cluster.messaging.ClusterMessage;
68 import org.onosproject.store.cluster.messaging.ClusterMessageHandler; 69 import org.onosproject.store.cluster.messaging.ClusterMessageHandler;
69 import org.onosproject.store.cluster.messaging.MessageSubject; 70 import org.onosproject.store.cluster.messaging.MessageSubject;
70 import org.onosproject.store.impl.Timestamped; 71 import org.onosproject.store.impl.Timestamped;
72 +import org.onosproject.store.serializers.KryoNamespaces;
71 import org.onosproject.store.serializers.KryoSerializer; 73 import org.onosproject.store.serializers.KryoSerializer;
72 import org.onosproject.store.serializers.custom.DistributedStoreSerializers; 74 import org.onosproject.store.serializers.custom.DistributedStoreSerializers;
75 +import org.onosproject.store.service.EventuallyConsistentMap;
76 +import org.onosproject.store.service.EventuallyConsistentMapEvent;
77 +import org.onosproject.store.service.EventuallyConsistentMapListener;
78 +import org.onosproject.store.service.MultiValuedTimestamp;
79 +import org.onosproject.store.service.StorageService;
80 +import org.onosproject.store.service.WallClockTimestamp;
81 +import org.onosproject.store.service.WallclockClockManager;
73 import org.slf4j.Logger; 82 import org.slf4j.Logger;
74 83
75 import java.io.IOException; 84 import java.io.IOException;
...@@ -102,6 +111,7 @@ import static org.onosproject.net.DefaultAnnotations.merge; ...@@ -102,6 +111,7 @@ import static org.onosproject.net.DefaultAnnotations.merge;
102 import static org.onosproject.net.device.DeviceEvent.Type.*; 111 import static org.onosproject.net.device.DeviceEvent.Type.*;
103 import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_REMOVED; 112 import static org.onosproject.net.device.DeviceEvent.Type.DEVICE_REMOVED;
104 import static org.onosproject.store.device.impl.GossipDeviceStoreMessageSubjects.*; 113 import static org.onosproject.store.device.impl.GossipDeviceStoreMessageSubjects.*;
114 +import static org.onosproject.store.service.EventuallyConsistentMapEvent.Type.PUT;
105 import static org.slf4j.LoggerFactory.getLogger; 115 import static org.slf4j.LoggerFactory.getLogger;
106 116
107 /** 117 /**
...@@ -123,13 +133,15 @@ public class GossipDeviceStore ...@@ -123,13 +133,15 @@ public class GossipDeviceStore
123 // innerMap is used to lock a Device, thus instance should never be replaced. 133 // innerMap is used to lock a Device, thus instance should never be replaced.
124 // collection of Description given from various providers 134 // collection of Description given from various providers
125 private final ConcurrentMap<DeviceId, Map<ProviderId, DeviceDescriptions>> 135 private final ConcurrentMap<DeviceId, Map<ProviderId, DeviceDescriptions>>
126 - deviceDescs = Maps.newConcurrentMap(); 136 + deviceDescs = Maps.newConcurrentMap();
127 137
128 // cache of Device and Ports generated by compositing descriptions from providers 138 // cache of Device and Ports generated by compositing descriptions from providers
129 private final ConcurrentMap<DeviceId, Device> devices = Maps.newConcurrentMap(); 139 private final ConcurrentMap<DeviceId, Device> devices = Maps.newConcurrentMap();
130 private final ConcurrentMap<DeviceId, ConcurrentMap<PortNumber, Port>> devicePorts = Maps.newConcurrentMap(); 140 private final ConcurrentMap<DeviceId, ConcurrentMap<PortNumber, Port>> devicePorts = Maps.newConcurrentMap();
131 - private final ConcurrentMap<DeviceId, ConcurrentMap<PortNumber, PortStatistics>> 141 +
132 - devicePortStats = Maps.newConcurrentMap(); 142 + private EventuallyConsistentMap<DeviceId, Map<PortNumber, PortStatistics>> devicePortStats;
143 + private final EventuallyConsistentMapListener<DeviceId, Map<PortNumber, PortStatistics>>
144 + portStatsListener = new InternalPortStatsListener();
133 145
134 // to be updated under Device lock 146 // to be updated under Device lock
135 private final Map<DeviceId, Timestamp> offline = Maps.newHashMap(); 147 private final Map<DeviceId, Timestamp> offline = Maps.newHashMap();
...@@ -142,6 +154,9 @@ public class GossipDeviceStore ...@@ -142,6 +154,9 @@ public class GossipDeviceStore
142 protected DeviceClockService deviceClockService; 154 protected DeviceClockService deviceClockService;
143 155
144 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 156 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
157 + protected StorageService storageService;
158 +
159 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
145 protected ClusterCommunicationService clusterCommunicator; 160 protected ClusterCommunicationService clusterCommunicator;
146 161
147 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 162 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
...@@ -182,10 +197,8 @@ public class GossipDeviceStore ...@@ -182,10 +197,8 @@ public class GossipDeviceStore
182 private long initialDelaySec = 5; 197 private long initialDelaySec = 5;
183 private long periodSec = 5; 198 private long periodSec = 5;
184 199
185 -
186 @Activate 200 @Activate
187 public void activate() { 201 public void activate() {
188 -
189 executor = Executors.newCachedThreadPool(groupedThreads("onos/device", "fg-%d")); 202 executor = Executors.newCachedThreadPool(groupedThreads("onos/device", "fg-%d"));
190 203
191 backgroundExecutor = 204 backgroundExecutor =
...@@ -198,8 +211,8 @@ public class GossipDeviceStore ...@@ -198,8 +211,8 @@ public class GossipDeviceStore
198 new InternalDeviceOfflineEventListener(), 211 new InternalDeviceOfflineEventListener(),
199 executor); 212 executor);
200 clusterCommunicator.addSubscriber(DEVICE_REMOVE_REQ, 213 clusterCommunicator.addSubscriber(DEVICE_REMOVE_REQ,
201 - new InternalRemoveRequestListener(), 214 + new InternalRemoveRequestListener(),
202 - executor); 215 + executor);
203 clusterCommunicator.addSubscriber( 216 clusterCommunicator.addSubscriber(
204 GossipDeviceStoreMessageSubjects.DEVICE_REMOVED, new InternalDeviceRemovedEventListener(), executor); 217 GossipDeviceStoreMessageSubjects.DEVICE_REMOVED, new InternalDeviceRemovedEventListener(), executor);
205 clusterCommunicator.addSubscriber( 218 clusterCommunicator.addSubscriber(
...@@ -217,8 +230,24 @@ public class GossipDeviceStore ...@@ -217,8 +230,24 @@ public class GossipDeviceStore
217 230
218 // start anti-entropy thread 231 // start anti-entropy thread
219 backgroundExecutor.scheduleAtFixedRate(new SendAdvertisementTask(), 232 backgroundExecutor.scheduleAtFixedRate(new SendAdvertisementTask(),
220 - initialDelaySec, periodSec, TimeUnit.SECONDS); 233 + initialDelaySec, periodSec, TimeUnit.SECONDS);
221 - 234 +
235 + // Create a distributed map for port stats.
236 + KryoNamespace.Builder deviceDataSerializer = KryoNamespace.newBuilder()
237 + .register(KryoNamespaces.API)
238 + .register(DefaultPortStatistics.class)
239 + .register(DeviceId.class)
240 + .register(MultiValuedTimestamp.class)
241 + .register(WallClockTimestamp.class);
242 +
243 + devicePortStats = storageService.<DeviceId, Map<PortNumber, PortStatistics>>eventuallyConsistentMapBuilder()
244 + .withName("port-stats")
245 + .withSerializer(deviceDataSerializer)
246 + .withAntiEntropyPeriod(5, TimeUnit.SECONDS)
247 + .withClockService(new WallclockClockManager<>())
248 + .withTombstonesDisabled()
249 + .build();
250 + devicePortStats.addListener(portStatsListener);
222 log.info("Started"); 251 log.info("Started");
223 } 252 }
224 253
...@@ -272,8 +301,8 @@ public class GossipDeviceStore ...@@ -272,8 +301,8 @@ public class GossipDeviceStore
272 301
273 @Override 302 @Override
274 public synchronized DeviceEvent createOrUpdateDevice(ProviderId providerId, 303 public synchronized DeviceEvent createOrUpdateDevice(ProviderId providerId,
275 - DeviceId deviceId, 304 + DeviceId deviceId,
276 - DeviceDescription deviceDescription) { 305 + DeviceDescription deviceDescription) {
277 NodeId localNode = clusterService.getLocalNode().id(); 306 NodeId localNode = clusterService.getLocalNode().id();
278 NodeId deviceNode = mastershipService.getMasterFor(deviceId); 307 NodeId deviceNode = mastershipService.getMasterFor(deviceId);
279 308
...@@ -294,7 +323,7 @@ public class GossipDeviceStore ...@@ -294,7 +323,7 @@ public class GossipDeviceStore
294 323
295 if (deviceEvent != null) { 324 if (deviceEvent != null) {
296 log.info("Notifying peers of a device update topology event for providerId: {} and deviceId: {}", 325 log.info("Notifying peers of a device update topology event for providerId: {} and deviceId: {}",
297 - providerId, deviceId); 326 + providerId, deviceId);
298 notifyPeers(new InternalDeviceEvent(providerId, deviceId, mergedDesc)); 327 notifyPeers(new InternalDeviceEvent(providerId, deviceId, mergedDesc));
299 } 328 }
300 329
...@@ -324,12 +353,12 @@ public class GossipDeviceStore ...@@ -324,12 +353,12 @@ public class GossipDeviceStore
324 } 353 }
325 354
326 private DeviceEvent createOrUpdateDeviceInternal(ProviderId providerId, 355 private DeviceEvent createOrUpdateDeviceInternal(ProviderId providerId,
327 - DeviceId deviceId, 356 + DeviceId deviceId,
328 - Timestamped<DeviceDescription> deltaDesc) { 357 + Timestamped<DeviceDescription> deltaDesc) {
329 358
330 // Collection of DeviceDescriptions for a Device 359 // Collection of DeviceDescriptions for a Device
331 Map<ProviderId, DeviceDescriptions> device 360 Map<ProviderId, DeviceDescriptions> device
332 - = getOrCreateDeviceDescriptionsMap(deviceId); 361 + = getOrCreateDeviceDescriptionsMap(deviceId);
333 362
334 synchronized (device) { 363 synchronized (device) {
335 // locking per device 364 // locking per device
...@@ -345,7 +374,7 @@ public class GossipDeviceStore ...@@ -345,7 +374,7 @@ public class GossipDeviceStore
345 final Device newDevice; 374 final Device newDevice;
346 375
347 if (deltaDesc == descs.getDeviceDesc() || 376 if (deltaDesc == descs.getDeviceDesc() ||
348 - deltaDesc.isNewer(descs.getDeviceDesc())) { 377 + deltaDesc.isNewer(descs.getDeviceDesc())) {
349 // on new device or valid update 378 // on new device or valid update
350 descs.putDeviceDesc(deltaDesc); 379 descs.putDeviceDesc(deltaDesc);
351 newDevice = composeDevice(deviceId, device); 380 newDevice = composeDevice(deviceId, device);
...@@ -371,8 +400,8 @@ public class GossipDeviceStore ...@@ -371,8 +400,8 @@ public class GossipDeviceStore
371 // update composed device cache 400 // update composed device cache
372 Device oldDevice = devices.putIfAbsent(newDevice.id(), newDevice); 401 Device oldDevice = devices.putIfAbsent(newDevice.id(), newDevice);
373 verify(oldDevice == null, 402 verify(oldDevice == null,
374 - "Unexpected Device in cache. PID:%s [old=%s, new=%s]", 403 + "Unexpected Device in cache. PID:%s [old=%s, new=%s]",
375 - providerId, oldDevice, newDevice); 404 + providerId, oldDevice, newDevice);
376 405
377 if (!providerId.isAncillary()) { 406 if (!providerId.isAncillary()) {
378 markOnline(newDevice.id(), timestamp); 407 markOnline(newDevice.id(), timestamp);
...@@ -401,8 +430,8 @@ public class GossipDeviceStore ...@@ -401,8 +430,8 @@ public class GossipDeviceStore
401 boolean replaced = devices.replace(newDevice.id(), oldDevice, newDevice); 430 boolean replaced = devices.replace(newDevice.id(), oldDevice, newDevice);
402 if (!replaced) { 431 if (!replaced) {
403 verify(replaced, 432 verify(replaced,
404 - "Replacing devices cache failed. PID:%s [expected:%s, found:%s, new=%s]", 433 + "Replacing devices cache failed. PID:%s [expected:%s, found:%s, new=%s]",
405 - providerId, oldDevice, devices.get(newDevice.id()) 434 + providerId, oldDevice, devices.get(newDevice.id())
406 , newDevice); 435 , newDevice);
407 } 436 }
408 if (!providerId.isAncillary()) { 437 if (!providerId.isAncillary()) {
...@@ -424,7 +453,7 @@ public class GossipDeviceStore ...@@ -424,7 +453,7 @@ public class GossipDeviceStore
424 final DeviceEvent event = markOfflineInternal(deviceId, timestamp); 453 final DeviceEvent event = markOfflineInternal(deviceId, timestamp);
425 if (event != null) { 454 if (event != null) {
426 log.info("Notifying peers of a device offline topology event for deviceId: {} {}", 455 log.info("Notifying peers of a device offline topology event for deviceId: {} {}",
427 - deviceId, timestamp); 456 + deviceId, timestamp);
428 notifyPeers(new InternalDeviceOfflineEvent(deviceId, timestamp)); 457 notifyPeers(new InternalDeviceOfflineEvent(deviceId, timestamp));
429 } 458 }
430 return event; 459 return event;
...@@ -433,7 +462,7 @@ public class GossipDeviceStore ...@@ -433,7 +462,7 @@ public class GossipDeviceStore
433 private DeviceEvent markOfflineInternal(DeviceId deviceId, Timestamp timestamp) { 462 private DeviceEvent markOfflineInternal(DeviceId deviceId, Timestamp timestamp) {
434 463
435 Map<ProviderId, DeviceDescriptions> providerDescs 464 Map<ProviderId, DeviceDescriptions> providerDescs
436 - = getOrCreateDeviceDescriptionsMap(deviceId); 465 + = getOrCreateDeviceDescriptionsMap(deviceId);
437 466
438 // locking device 467 // locking device
439 synchronized (providerDescs) { 468 synchronized (providerDescs) {
...@@ -465,7 +494,7 @@ public class GossipDeviceStore ...@@ -465,7 +494,7 @@ public class GossipDeviceStore
465 * Marks the device as available if the given timestamp is not outdated, 494 * Marks the device as available if the given timestamp is not outdated,
466 * compared to the time the device has been marked offline. 495 * compared to the time the device has been marked offline.
467 * 496 *
468 - * @param deviceId identifier of the device 497 + * @param deviceId identifier of the device
469 * @param timestamp of the event triggering this change. 498 * @param timestamp of the event triggering this change.
470 * @return true if availability change request was accepted and changed the state 499 * @return true if availability change request was accepted and changed the state
471 */ 500 */
...@@ -475,7 +504,7 @@ public class GossipDeviceStore ...@@ -475,7 +504,7 @@ public class GossipDeviceStore
475 // the latest offline request Timestamp 504 // the latest offline request Timestamp
476 Timestamp offlineTimestamp = offline.get(deviceId); 505 Timestamp offlineTimestamp = offline.get(deviceId);
477 if (offlineTimestamp == null || 506 if (offlineTimestamp == null ||
478 - offlineTimestamp.compareTo(timestamp) < 0) { 507 + offlineTimestamp.compareTo(timestamp) < 0) {
479 508
480 offline.remove(deviceId); 509 offline.remove(deviceId);
481 return availableDevices.add(deviceId); 510 return availableDevices.add(deviceId);
...@@ -485,8 +514,8 @@ public class GossipDeviceStore ...@@ -485,8 +514,8 @@ public class GossipDeviceStore
485 514
486 @Override 515 @Override
487 public synchronized List<DeviceEvent> updatePorts(ProviderId providerId, 516 public synchronized List<DeviceEvent> updatePorts(ProviderId providerId,
488 - DeviceId deviceId, 517 + DeviceId deviceId,
489 - List<PortDescription> portDescriptions) { 518 + List<PortDescription> portDescriptions) {
490 519
491 NodeId localNode = clusterService.getLocalNode().id(); 520 NodeId localNode = clusterService.getLocalNode().id();
492 // TODO: It might be negligible, but this will have negative impact to topology discovery performance, 521 // TODO: It might be negligible, but this will have negative impact to topology discovery performance,
...@@ -544,7 +573,7 @@ public class GossipDeviceStore ...@@ -544,7 +573,7 @@ public class GossipDeviceStore
544 573
545 if (!deviceEvents.isEmpty()) { 574 if (!deviceEvents.isEmpty()) {
546 log.info("Notifying peers of a ports update topology event for providerId: {} and deviceId: {}", 575 log.info("Notifying peers of a ports update topology event for providerId: {} and deviceId: {}",
547 - providerId, deviceId); 576 + providerId, deviceId);
548 notifyPeers(new InternalPortEvent(providerId, deviceId, merged)); 577 notifyPeers(new InternalPortEvent(providerId, deviceId, merged));
549 } 578 }
550 579
...@@ -572,8 +601,8 @@ public class GossipDeviceStore ...@@ -572,8 +601,8 @@ public class GossipDeviceStore
572 } 601 }
573 602
574 private List<DeviceEvent> updatePortsInternal(ProviderId providerId, 603 private List<DeviceEvent> updatePortsInternal(ProviderId providerId,
575 - DeviceId deviceId, 604 + DeviceId deviceId,
576 - Timestamped<List<PortDescription>> portDescriptions) { 605 + Timestamped<List<PortDescription>> portDescriptions) {
577 606
578 Device device = devices.get(deviceId); 607 Device device = devices.get(deviceId);
579 checkArgument(device != null, DEVICE_NOT_FOUND, deviceId); 608 checkArgument(device != null, DEVICE_NOT_FOUND, deviceId);
...@@ -592,8 +621,8 @@ public class GossipDeviceStore ...@@ -592,8 +621,8 @@ public class GossipDeviceStore
592 DeviceDescriptions descs = descsMap.get(providerId); 621 DeviceDescriptions descs = descsMap.get(providerId);
593 // every provider must provide DeviceDescription. 622 // every provider must provide DeviceDescription.
594 checkArgument(descs != null, 623 checkArgument(descs != null,
595 - "Device description for Device ID %s from Provider %s was not found", 624 + "Device description for Device ID %s from Provider %s was not found",
596 - deviceId, providerId); 625 + deviceId, providerId);
597 626
598 Map<PortNumber, Port> ports = getPortMap(deviceId); 627 Map<PortNumber, Port> ports = getPortMap(deviceId);
599 628
...@@ -611,11 +640,11 @@ public class GossipDeviceStore ...@@ -611,11 +640,11 @@ public class GossipDeviceStore
611 640
612 final Timestamped<PortDescription> existingPortDesc = descs.getPortDesc(number); 641 final Timestamped<PortDescription> existingPortDesc = descs.getPortDesc(number);
613 if (existingPortDesc == null || 642 if (existingPortDesc == null ||
614 - newTimestamp.compareTo(existingPortDesc.timestamp()) >= 0) { 643 + newTimestamp.compareTo(existingPortDesc.timestamp()) >= 0) {
615 // on new port or valid update 644 // on new port or valid update
616 // update description 645 // update description
617 descs.putPortDesc(new Timestamped<>(portDescription, 646 descs.putPortDesc(new Timestamped<>(portDescription,
618 - portDescriptions.timestamp())); 647 + portDescriptions.timestamp()));
619 newPort = composePort(device, number, descsMap); 648 newPort = composePort(device, number, descsMap);
620 } else { 649 } else {
621 // outdated event, ignored. 650 // outdated event, ignored.
...@@ -680,7 +709,7 @@ public class GossipDeviceStore ...@@ -680,7 +709,7 @@ public class GossipDeviceStore
680 // exist, it creates and registers a new one. 709 // exist, it creates and registers a new one.
681 private ConcurrentMap<PortNumber, Port> getPortMap(DeviceId deviceId) { 710 private ConcurrentMap<PortNumber, Port> getPortMap(DeviceId deviceId) {
682 return createIfAbsentUnchecked(devicePorts, deviceId, 711 return createIfAbsentUnchecked(devicePorts, deviceId,
683 - NewConcurrentHashMap.<PortNumber, Port>ifNeeded()); 712 + NewConcurrentHashMap.<PortNumber, Port>ifNeeded());
684 } 713 }
685 714
686 private Map<ProviderId, DeviceDescriptions> getOrCreateDeviceDescriptionsMap( 715 private Map<ProviderId, DeviceDescriptions> getOrCreateDeviceDescriptionsMap(
...@@ -702,7 +731,6 @@ public class GossipDeviceStore ...@@ -702,7 +731,6 @@ public class GossipDeviceStore
702 private DeviceDescriptions getOrCreateProviderDeviceDescriptions( 731 private DeviceDescriptions getOrCreateProviderDeviceDescriptions(
703 Map<ProviderId, DeviceDescriptions> device, 732 Map<ProviderId, DeviceDescriptions> device,
704 ProviderId providerId, Timestamped<DeviceDescription> deltaDesc) { 733 ProviderId providerId, Timestamped<DeviceDescription> deltaDesc) {
705 -
706 synchronized (device) { 734 synchronized (device) {
707 DeviceDescriptions r = device.get(providerId); 735 DeviceDescriptions r = device.get(providerId);
708 if (r == null) { 736 if (r == null) {
...@@ -728,26 +756,25 @@ public class GossipDeviceStore ...@@ -728,26 +756,25 @@ public class GossipDeviceStore
728 return null; 756 return null;
729 } 757 }
730 final Timestamped<PortDescription> deltaDesc 758 final Timestamped<PortDescription> deltaDesc
731 - = new Timestamped<>(portDescription, newTimestamp); 759 + = new Timestamped<>(portDescription, newTimestamp);
732 final DeviceEvent event; 760 final DeviceEvent event;
733 final Timestamped<PortDescription> mergedDesc; 761 final Timestamped<PortDescription> mergedDesc;
734 final Map<ProviderId, DeviceDescriptions> device = getOrCreateDeviceDescriptionsMap(deviceId); 762 final Map<ProviderId, DeviceDescriptions> device = getOrCreateDeviceDescriptionsMap(deviceId);
735 synchronized (device) { 763 synchronized (device) {
736 event = updatePortStatusInternal(providerId, deviceId, deltaDesc); 764 event = updatePortStatusInternal(providerId, deviceId, deltaDesc);
737 mergedDesc = device.get(providerId) 765 mergedDesc = device.get(providerId)
738 - .getPortDesc(portDescription.portNumber()); 766 + .getPortDesc(portDescription.portNumber());
739 } 767 }
740 if (event != null) { 768 if (event != null) {
741 log.info("Notifying peers of a port status update topology event for providerId: {} and deviceId: {}", 769 log.info("Notifying peers of a port status update topology event for providerId: {} and deviceId: {}",
742 - providerId, deviceId); 770 + providerId, deviceId);
743 notifyPeers(new InternalPortStatusEvent(providerId, deviceId, mergedDesc)); 771 notifyPeers(new InternalPortStatusEvent(providerId, deviceId, mergedDesc));
744 } 772 }
745 return event; 773 return event;
746 } 774 }
747 775
748 private DeviceEvent updatePortStatusInternal(ProviderId providerId, DeviceId deviceId, 776 private DeviceEvent updatePortStatusInternal(ProviderId providerId, DeviceId deviceId,
749 - Timestamped<PortDescription> deltaDesc) { 777 + Timestamped<PortDescription> deltaDesc) {
750 -
751 Device device = devices.get(deviceId); 778 Device device = devices.get(deviceId);
752 checkArgument(device != null, DEVICE_NOT_FOUND, deviceId); 779 checkArgument(device != null, DEVICE_NOT_FOUND, deviceId);
753 780
...@@ -764,8 +791,8 @@ public class GossipDeviceStore ...@@ -764,8 +791,8 @@ public class GossipDeviceStore
764 DeviceDescriptions descs = descsMap.get(providerId); 791 DeviceDescriptions descs = descsMap.get(providerId);
765 // assuming all providers must to give DeviceDescription 792 // assuming all providers must to give DeviceDescription
766 verify(descs != null, 793 verify(descs != null,
767 - "Device description for Device ID %s from Provider %s was not found", 794 + "Device description for Device ID %s from Provider %s was not found",
768 - deviceId, providerId); 795 + deviceId, providerId);
769 796
770 ConcurrentMap<PortNumber, Port> ports = getPortMap(deviceId); 797 ConcurrentMap<PortNumber, Port> ports = getPortMap(deviceId);
771 final PortNumber number = deltaDesc.value().portNumber(); 798 final PortNumber number = deltaDesc.value().portNumber();
...@@ -774,7 +801,7 @@ public class GossipDeviceStore ...@@ -774,7 +801,7 @@ public class GossipDeviceStore
774 801
775 final Timestamped<PortDescription> existingPortDesc = descs.getPortDesc(number); 802 final Timestamped<PortDescription> existingPortDesc = descs.getPortDesc(number);
776 if (existingPortDesc == null || 803 if (existingPortDesc == null ||
777 - deltaDesc.isNewer(existingPortDesc)) { 804 + deltaDesc.isNewer(existingPortDesc)) {
778 // on new port or valid update 805 // on new port or valid update
779 // update description 806 // update description
780 descs.putPortDesc(deltaDesc); 807 descs.putPortDesc(deltaDesc);
...@@ -805,24 +832,21 @@ public class GossipDeviceStore ...@@ -805,24 +832,21 @@ public class GossipDeviceStore
805 @Override 832 @Override
806 public DeviceEvent updatePortStatistics(ProviderId providerId, DeviceId deviceId, 833 public DeviceEvent updatePortStatistics(ProviderId providerId, DeviceId deviceId,
807 Collection<PortStatistics> portStats) { 834 Collection<PortStatistics> portStats) {
808 - 835 + Map<PortNumber, PortStatistics> statsMap = devicePortStats.get(deviceId);
809 - ConcurrentMap<PortNumber, PortStatistics> statsMap = devicePortStats.get(deviceId);
810 if (statsMap == null) { 836 if (statsMap == null) {
811 - statsMap = Maps.newConcurrentMap(); 837 + statsMap = Maps.newHashMap();
812 - devicePortStats.put(deviceId, statsMap);
813 } 838 }
814 839
815 - for (PortStatistics stat: portStats) { 840 + for (PortStatistics stat : portStats) {
816 PortNumber portNumber = PortNumber.portNumber(stat.port()); 841 PortNumber portNumber = PortNumber.portNumber(stat.port());
817 statsMap.put(portNumber, stat); 842 statsMap.put(portNumber, stat);
818 } 843 }
819 - 844 + devicePortStats.put(deviceId, statsMap);
820 - return new DeviceEvent(PORT_STATS_UPDATED, devices.get(deviceId), null); 845 + return null; // new DeviceEvent(PORT_STATS_UPDATED, devices.get(deviceId), null);
821 } 846 }
822 847
823 @Override 848 @Override
824 public List<PortStatistics> getPortStatistics(DeviceId deviceId) { 849 public List<PortStatistics> getPortStatistics(DeviceId deviceId) {
825 -
826 Map<PortNumber, PortStatistics> portStats = devicePortStats.get(deviceId); 850 Map<PortNumber, PortStatistics> portStats = devicePortStats.get(deviceId);
827 if (portStats == null) { 851 if (portStats == null) {
828 return Collections.emptyList(); 852 return Collections.emptyList();
...@@ -865,7 +889,7 @@ public class GossipDeviceStore ...@@ -865,7 +889,7 @@ public class GossipDeviceStore
865 889
866 if (!myId.equals(master)) { 890 if (!myId.equals(master)) {
867 log.debug("{} has control of {}, forwarding remove request", 891 log.debug("{} has control of {}, forwarding remove request",
868 - master, deviceId); 892 + master, deviceId);
869 893
870 // TODO check unicast return value 894 // TODO check unicast return value
871 clusterCommunicator.unicast(deviceId, DEVICE_REMOVE_REQ, SERIALIZER::encode, master); 895 clusterCommunicator.unicast(deviceId, DEVICE_REMOVE_REQ, SERIALIZER::encode, master);
...@@ -874,7 +898,7 @@ public class GossipDeviceStore ...@@ -874,7 +898,7 @@ public class GossipDeviceStore
874 */ 898 */
875 899
876 // event will be triggered after master processes it. 900 // event will be triggered after master processes it.
877 - return null; 901 + return null;
878 } 902 }
879 903
880 // I have control.. 904 // I have control..
...@@ -883,7 +907,7 @@ public class GossipDeviceStore ...@@ -883,7 +907,7 @@ public class GossipDeviceStore
883 DeviceEvent event = removeDeviceInternal(deviceId, timestamp); 907 DeviceEvent event = removeDeviceInternal(deviceId, timestamp);
884 if (event != null) { 908 if (event != null) {
885 log.debug("Notifying peers of a device removed topology event for deviceId: {}", 909 log.debug("Notifying peers of a device removed topology event for deviceId: {}",
886 - deviceId); 910 + deviceId);
887 notifyPeers(new InternalDeviceRemovedEvent(deviceId, timestamp)); 911 notifyPeers(new InternalDeviceRemovedEvent(deviceId, timestamp));
888 } 912 }
889 if (relinquishAtEnd) { 913 if (relinquishAtEnd) {
...@@ -917,7 +941,7 @@ public class GossipDeviceStore ...@@ -917,7 +941,7 @@ public class GossipDeviceStore
917 markOfflineInternal(deviceId, timestamp); 941 markOfflineInternal(deviceId, timestamp);
918 descs.clear(); 942 descs.clear();
919 return device == null ? null : 943 return device == null ? null :
920 - new DeviceEvent(DEVICE_REMOVED, device, null); 944 + new DeviceEvent(DEVICE_REMOVED, device, null);
921 } 945 }
922 } 946 }
923 947
...@@ -925,14 +949,14 @@ public class GossipDeviceStore ...@@ -925,14 +949,14 @@ public class GossipDeviceStore
925 * Checks if given timestamp is superseded by removal request 949 * Checks if given timestamp is superseded by removal request
926 * with more recent timestamp. 950 * with more recent timestamp.
927 * 951 *
928 - * @param deviceId identifier of a device 952 + * @param deviceId identifier of a device
929 * @param timestampToCheck timestamp of an event to check 953 * @param timestampToCheck timestamp of an event to check
930 * @return true if device is already removed 954 * @return true if device is already removed
931 */ 955 */
932 private boolean isDeviceRemoved(DeviceId deviceId, Timestamp timestampToCheck) { 956 private boolean isDeviceRemoved(DeviceId deviceId, Timestamp timestampToCheck) {
933 Timestamp removalTimestamp = removalRequest.get(deviceId); 957 Timestamp removalTimestamp = removalRequest.get(deviceId);
934 if (removalTimestamp != null && 958 if (removalTimestamp != null &&
935 - removalTimestamp.compareTo(timestampToCheck) >= 0) { 959 + removalTimestamp.compareTo(timestampToCheck) >= 0) {
936 // removalRequest is more recent 960 // removalRequest is more recent
937 return true; 961 return true;
938 } 962 }
...@@ -942,12 +966,12 @@ public class GossipDeviceStore ...@@ -942,12 +966,12 @@ public class GossipDeviceStore
942 /** 966 /**
943 * Returns a Device, merging description given from multiple Providers. 967 * Returns a Device, merging description given from multiple Providers.
944 * 968 *
945 - * @param deviceId device identifier 969 + * @param deviceId device identifier
946 * @param providerDescs Collection of Descriptions from multiple providers 970 * @param providerDescs Collection of Descriptions from multiple providers
947 * @return Device instance 971 * @return Device instance
948 */ 972 */
949 private Device composeDevice(DeviceId deviceId, 973 private Device composeDevice(DeviceId deviceId,
950 - Map<ProviderId, DeviceDescriptions> providerDescs) { 974 + Map<ProviderId, DeviceDescriptions> providerDescs) {
951 975
952 checkArgument(!providerDescs.isEmpty(), "No device descriptions supplied"); 976 checkArgument(!providerDescs.isEmpty(), "No device descriptions supplied");
953 977
...@@ -978,21 +1002,21 @@ public class GossipDeviceStore ...@@ -978,21 +1002,21 @@ public class GossipDeviceStore
978 annotations = merge(annotations, e.getValue().getDeviceDesc().value().annotations()); 1002 annotations = merge(annotations, e.getValue().getDeviceDesc().value().annotations());
979 } 1003 }
980 1004
981 - return new DefaultDevice(primary, deviceId , type, manufacturer, 1005 + return new DefaultDevice(primary, deviceId, type, manufacturer,
982 - hwVersion, swVersion, serialNumber, 1006 + hwVersion, swVersion, serialNumber,
983 - chassisId, annotations); 1007 + chassisId, annotations);
984 } 1008 }
985 1009
986 /** 1010 /**
987 * Returns a Port, merging description given from multiple Providers. 1011 * Returns a Port, merging description given from multiple Providers.
988 * 1012 *
989 - * @param device device the port is on 1013 + * @param device device the port is on
990 - * @param number port number 1014 + * @param number port number
991 * @param descsMap Collection of Descriptions from multiple providers 1015 * @param descsMap Collection of Descriptions from multiple providers
992 * @return Port instance 1016 * @return Port instance
993 */ 1017 */
994 private Port composePort(Device device, PortNumber number, 1018 private Port composePort(Device device, PortNumber number,
995 - Map<ProviderId, DeviceDescriptions> descsMap) { 1019 + Map<ProviderId, DeviceDescriptions> descsMap) {
996 1020
997 ProviderId primary = pickPrimaryPID(descsMap); 1021 ProviderId primary = pickPrimaryPID(descsMap);
998 DeviceDescriptions primDescs = descsMap.get(primary); 1022 DeviceDescriptions primDescs = descsMap.get(primary);
...@@ -1028,12 +1052,12 @@ public class GossipDeviceStore ...@@ -1028,12 +1052,12 @@ public class GossipDeviceStore
1028 case OMS: 1052 case OMS:
1029 OmsPortDescription omsPortDesc = (OmsPortDescription) otherPortDesc.value(); 1053 OmsPortDescription omsPortDesc = (OmsPortDescription) otherPortDesc.value();
1030 updated = new OmsPort(device, number, isEnabled, omsPortDesc.minFrequency(), 1054 updated = new OmsPort(device, number, isEnabled, omsPortDesc.minFrequency(),
1031 - omsPortDesc.maxFrequency(), omsPortDesc.grid(), annotations); 1055 + omsPortDesc.maxFrequency(), omsPortDesc.grid(), annotations);
1032 break; 1056 break;
1033 case OCH: 1057 case OCH:
1034 OchPortDescription ochPortDesc = (OchPortDescription) otherPortDesc.value(); 1058 OchPortDescription ochPortDesc = (OchPortDescription) otherPortDesc.value();
1035 updated = new OchPort(device, number, isEnabled, ochPortDesc.signalType(), 1059 updated = new OchPort(device, number, isEnabled, ochPortDesc.signalType(),
1036 - ochPortDesc.isTunable(), ochPortDesc.lambda(), annotations); 1060 + ochPortDesc.isTunable(), ochPortDesc.lambda(), annotations);
1037 break; 1061 break;
1038 case ODUCLT: 1062 case ODUCLT:
1039 OduCltPortDescription oduCltPortDesc = (OduCltPortDescription) otherPortDesc.value(); 1063 OduCltPortDescription oduCltPortDesc = (OduCltPortDescription) otherPortDesc.value();
...@@ -1073,7 +1097,7 @@ public class GossipDeviceStore ...@@ -1073,7 +1097,7 @@ public class GossipDeviceStore
1073 } 1097 }
1074 1098
1075 private DeviceDescriptions getPrimaryDescriptions( 1099 private DeviceDescriptions getPrimaryDescriptions(
1076 - Map<ProviderId, DeviceDescriptions> providerDescs) { 1100 + Map<ProviderId, DeviceDescriptions> providerDescs) {
1077 ProviderId pid = pickPrimaryPID(providerDescs); 1101 ProviderId pid = pickPrimaryPID(providerDescs);
1078 return providerDescs.get(pid); 1102 return providerDescs.get(pid);
1079 } 1103 }
...@@ -1174,14 +1198,14 @@ public class GossipDeviceStore ...@@ -1174,14 +1198,14 @@ public class GossipDeviceStore
1174 final DeviceDescriptions descs = prov.getValue(); 1198 final DeviceDescriptions descs = prov.getValue();
1175 1199
1176 adDevices.put(new DeviceFragmentId(deviceId, provId), 1200 adDevices.put(new DeviceFragmentId(deviceId, provId),
1177 - descs.getDeviceDesc().timestamp()); 1201 + descs.getDeviceDesc().timestamp());
1178 1202
1179 for (Entry<PortNumber, Timestamped<PortDescription>> 1203 for (Entry<PortNumber, Timestamped<PortDescription>>
1180 portDesc : descs.getPortDescs().entrySet()) { 1204 portDesc : descs.getPortDescs().entrySet()) {
1181 1205
1182 final PortNumber number = portDesc.getKey(); 1206 final PortNumber number = portDesc.getKey();
1183 adPorts.put(new PortFragmentId(deviceId, provId, number), 1207 adPorts.put(new PortFragmentId(deviceId, provId, number),
1184 - portDesc.getValue().timestamp()); 1208 + portDesc.getValue().timestamp());
1185 } 1209 }
1186 } 1210 }
1187 } 1211 }
...@@ -1192,7 +1216,7 @@ public class GossipDeviceStore ...@@ -1192,7 +1216,7 @@ public class GossipDeviceStore
1192 1216
1193 /** 1217 /**
1194 * Responds to anti-entropy advertisement message. 1218 * Responds to anti-entropy advertisement message.
1195 - * <P> 1219 + * <p/>
1196 * Notify sender about out-dated information using regular replication message. 1220 * Notify sender about out-dated information using regular replication message.
1197 * Send back advertisement to sender if not in sync. 1221 * Send back advertisement to sender if not in sync.
1198 * 1222 *
...@@ -1269,7 +1293,7 @@ public class GossipDeviceStore ...@@ -1269,7 +1293,7 @@ public class GossipDeviceStore
1269 // find latest and update 1293 // find latest and update
1270 final Timestamp providerLatest = lDeviceDescs.getLatestTimestamp(); 1294 final Timestamp providerLatest = lDeviceDescs.getLatestTimestamp();
1271 if (localLatest == null || 1295 if (localLatest == null ||
1272 - providerLatest.compareTo(localLatest) > 0) { 1296 + providerLatest.compareTo(localLatest) > 0) {
1273 localLatest = providerLatest; 1297 localLatest = providerLatest;
1274 } 1298 }
1275 } // end local provider loop 1299 } // end local provider loop
...@@ -1277,7 +1301,7 @@ public class GossipDeviceStore ...@@ -1277,7 +1301,7 @@ public class GossipDeviceStore
1277 // checking if remote timestamp is more recent. 1301 // checking if remote timestamp is more recent.
1278 Timestamp rOffline = offlineAds.get(deviceId); 1302 Timestamp rOffline = offlineAds.get(deviceId);
1279 if (rOffline != null && 1303 if (rOffline != null &&
1280 - rOffline.compareTo(localLatest) > 0) { 1304 + rOffline.compareTo(localLatest) > 0) {
1281 // remote offline timestamp suggests that the 1305 // remote offline timestamp suggests that the
1282 // device is off-line 1306 // device is off-line
1283 markOfflineInternal(deviceId, rOffline); 1307 markOfflineInternal(deviceId, rOffline);
...@@ -1386,7 +1410,6 @@ public class GossipDeviceStore ...@@ -1386,7 +1410,6 @@ public class GossipDeviceStore
1386 implements ClusterMessageHandler { 1410 implements ClusterMessageHandler {
1387 @Override 1411 @Override
1388 public void handle(ClusterMessage message) { 1412 public void handle(ClusterMessage message) {
1389 -
1390 log.debug("Received device update event from peer: {}", message.sender()); 1413 log.debug("Received device update event from peer: {}", message.sender());
1391 InternalDeviceEvent event = SERIALIZER.decode(message.payload()); 1414 InternalDeviceEvent event = SERIALIZER.decode(message.payload());
1392 1415
...@@ -1406,7 +1429,6 @@ public class GossipDeviceStore ...@@ -1406,7 +1429,6 @@ public class GossipDeviceStore
1406 implements ClusterMessageHandler { 1429 implements ClusterMessageHandler {
1407 @Override 1430 @Override
1408 public void handle(ClusterMessage message) { 1431 public void handle(ClusterMessage message) {
1409 -
1410 log.debug("Received device offline event from peer: {}", message.sender()); 1432 log.debug("Received device offline event from peer: {}", message.sender());
1411 InternalDeviceOfflineEvent event = SERIALIZER.decode(message.payload()); 1433 InternalDeviceOfflineEvent event = SERIALIZER.decode(message.payload());
1412 1434
...@@ -1440,7 +1462,6 @@ public class GossipDeviceStore ...@@ -1440,7 +1462,6 @@ public class GossipDeviceStore
1440 implements ClusterMessageHandler { 1462 implements ClusterMessageHandler {
1441 @Override 1463 @Override
1442 public void handle(ClusterMessage message) { 1464 public void handle(ClusterMessage message) {
1443 -
1444 log.debug("Received device removed event from peer: {}", message.sender()); 1465 log.debug("Received device removed event from peer: {}", message.sender());
1445 InternalDeviceRemovedEvent event = SERIALIZER.decode(message.payload()); 1466 InternalDeviceRemovedEvent event = SERIALIZER.decode(message.payload());
1446 1467
...@@ -1508,8 +1529,7 @@ public class GossipDeviceStore ...@@ -1508,8 +1529,7 @@ public class GossipDeviceStore
1508 } 1529 }
1509 1530
1510 private final class InternalDeviceAdvertisementListener 1531 private final class InternalDeviceAdvertisementListener
1511 - implements ClusterMessageHandler { 1532 + implements ClusterMessageHandler {
1512 -
1513 @Override 1533 @Override
1514 public void handle(ClusterMessage message) { 1534 public void handle(ClusterMessage message) {
1515 log.trace("Received Device Anti-Entropy advertisement from peer: {}", message.sender()); 1535 log.trace("Received Device Anti-Entropy advertisement from peer: {}", message.sender());
...@@ -1526,7 +1546,6 @@ public class GossipDeviceStore ...@@ -1526,7 +1546,6 @@ public class GossipDeviceStore
1526 implements ClusterMessageHandler { 1546 implements ClusterMessageHandler {
1527 @Override 1547 @Override
1528 public void handle(ClusterMessage message) { 1548 public void handle(ClusterMessage message) {
1529 -
1530 log.debug("Received injected device event from peer: {}", message.sender()); 1549 log.debug("Received injected device event from peer: {}", message.sender());
1531 DeviceInjectedEvent event = SERIALIZER.decode(message.payload()); 1550 DeviceInjectedEvent event = SERIALIZER.decode(message.payload());
1532 1551
...@@ -1551,7 +1570,6 @@ public class GossipDeviceStore ...@@ -1551,7 +1570,6 @@ public class GossipDeviceStore
1551 implements ClusterMessageHandler { 1570 implements ClusterMessageHandler {
1552 @Override 1571 @Override
1553 public void handle(ClusterMessage message) { 1572 public void handle(ClusterMessage message) {
1554 -
1555 log.debug("Received injected port event from peer: {}", message.sender()); 1573 log.debug("Received injected port event from peer: {}", message.sender());
1556 PortInjectedEvent event = SERIALIZER.decode(message.payload()); 1574 PortInjectedEvent event = SERIALIZER.decode(message.payload());
1557 1575
...@@ -1571,4 +1589,17 @@ public class GossipDeviceStore ...@@ -1571,4 +1589,17 @@ public class GossipDeviceStore
1571 } 1589 }
1572 } 1590 }
1573 } 1591 }
1592 +
1593 + private class InternalPortStatsListener
1594 + implements EventuallyConsistentMapListener<DeviceId, Map<PortNumber, PortStatistics>> {
1595 + @Override
1596 + public void event(EventuallyConsistentMapEvent<DeviceId, Map<PortNumber, PortStatistics>> event) {
1597 + if (event.type() == PUT) {
1598 + Device device = devices.get(event.key());
1599 + if (device != null) {
1600 + delegate.notify(new DeviceEvent(PORT_STATS_UPDATED, device));
1601 + }
1602 + }
1603 + }
1604 + }
1574 } 1605 }
......
...@@ -55,6 +55,7 @@ import org.onosproject.store.cluster.messaging.ClusterCommunicationService; ...@@ -55,6 +55,7 @@ import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
55 import org.onosproject.store.cluster.messaging.ClusterMessage; 55 import org.onosproject.store.cluster.messaging.ClusterMessage;
56 import org.onosproject.store.cluster.messaging.ClusterMessageHandler; 56 import org.onosproject.store.cluster.messaging.ClusterMessageHandler;
57 import org.onosproject.store.cluster.messaging.MessageSubject; 57 import org.onosproject.store.cluster.messaging.MessageSubject;
58 +import org.onosproject.store.consistent.impl.DatabaseManager;
58 59
59 import java.io.IOException; 60 import java.io.IOException;
60 import java.util.Arrays; 61 import java.util.Arrays;
...@@ -157,7 +158,7 @@ public class GossipDeviceStoreTest { ...@@ -157,7 +158,7 @@ public class GossipDeviceStoreTest {
157 158
158 clusterCommunicator = createNiceMock(ClusterCommunicationService.class); 159 clusterCommunicator = createNiceMock(ClusterCommunicationService.class);
159 clusterCommunicator.addSubscriber(anyObject(MessageSubject.class), 160 clusterCommunicator.addSubscriber(anyObject(MessageSubject.class),
160 - anyObject(ClusterMessageHandler.class), anyObject(ExecutorService.class)); 161 + anyObject(ClusterMessageHandler.class), anyObject(ExecutorService.class));
161 expectLastCall().anyTimes(); 162 expectLastCall().anyTimes();
162 replay(clusterCommunicator); 163 replay(clusterCommunicator);
163 ClusterService clusterService = new TestClusterService(); 164 ClusterService clusterService = new TestClusterService();
...@@ -165,6 +166,10 @@ public class GossipDeviceStoreTest { ...@@ -165,6 +166,10 @@ public class GossipDeviceStoreTest {
165 testGossipDeviceStore = new TestGossipDeviceStore(deviceClockService, clusterService, clusterCommunicator); 166 testGossipDeviceStore = new TestGossipDeviceStore(deviceClockService, clusterService, clusterCommunicator);
166 testGossipDeviceStore.mastershipService = new TestMastershipService(); 167 testGossipDeviceStore.mastershipService = new TestMastershipService();
167 168
169 + TestDatabaseManager testDatabaseManager = new TestDatabaseManager();
170 + testDatabaseManager.init(clusterService, clusterCommunicator);
171 + testGossipDeviceStore.storageService = testDatabaseManager;
172 +
168 gossipDeviceStore = testGossipDeviceStore; 173 gossipDeviceStore = testGossipDeviceStore;
169 gossipDeviceStore.activate(); 174 gossipDeviceStore.activate();
170 deviceStore = gossipDeviceStore; 175 deviceStore = gossipDeviceStore;
...@@ -885,4 +890,12 @@ public class GossipDeviceStoreTest { ...@@ -885,4 +890,12 @@ public class GossipDeviceStoreTest {
885 nodeStates.put(NID2, ACTIVE); 890 nodeStates.put(NID2, ACTIVE);
886 } 891 }
887 } 892 }
893 +
894 + private class TestDatabaseManager extends DatabaseManager {
895 + void init(ClusterService clusterService,
896 + ClusterCommunicationService clusterCommunicator) {
897 + this.clusterService = clusterService;
898 + this.clusterCommunicator = clusterCommunicator;
899 + }
900 + }
888 } 901 }
......
...@@ -71,9 +71,11 @@ import org.onosproject.net.Port; ...@@ -71,9 +71,11 @@ import org.onosproject.net.Port;
71 import org.onosproject.net.PortNumber; 71 import org.onosproject.net.PortNumber;
72 import org.onosproject.net.device.DefaultDeviceDescription; 72 import org.onosproject.net.device.DefaultDeviceDescription;
73 import org.onosproject.net.device.DefaultPortDescription; 73 import org.onosproject.net.device.DefaultPortDescription;
74 +import org.onosproject.net.device.DefaultPortStatistics;
74 import org.onosproject.net.device.OchPortDescription; 75 import org.onosproject.net.device.OchPortDescription;
75 import org.onosproject.net.device.OduCltPortDescription; 76 import org.onosproject.net.device.OduCltPortDescription;
76 import org.onosproject.net.device.OmsPortDescription; 77 import org.onosproject.net.device.OmsPortDescription;
78 +import org.onosproject.net.device.PortStatistics;
77 import org.onosproject.net.flow.CompletedBatchOperation; 79 import org.onosproject.net.flow.CompletedBatchOperation;
78 import org.onosproject.net.flow.DefaultFlowEntry; 80 import org.onosproject.net.flow.DefaultFlowEntry;
79 import org.onosproject.net.flow.DefaultFlowRule; 81 import org.onosproject.net.flow.DefaultFlowRule;
...@@ -380,7 +382,9 @@ public final class KryoNamespaces { ...@@ -380,7 +382,9 @@ public final class KryoNamespaces {
380 IntentOperation.class, 382 IntentOperation.class,
381 FlowRuleExtPayLoad.class, 383 FlowRuleExtPayLoad.class,
382 Frequency.class, 384 Frequency.class,
383 - DefaultAnnotations.class 385 + DefaultAnnotations.class,
386 + PortStatistics.class,
387 + DefaultPortStatistics.class
384 ) 388 )
385 .register(new DefaultApplicationIdSerializer(), DefaultApplicationId.class) 389 .register(new DefaultApplicationIdSerializer(), DefaultApplicationId.class)
386 .register(new URISerializer(), URI.class) 390 .register(new URISerializer(), URI.class)
......
...@@ -14,7 +14,7 @@ cut -c7- $aux | cut -d\ -f1 | sort > $aux.1 ...@@ -14,7 +14,7 @@ cut -c7- $aux | cut -d\ -f1 | sort > $aux.1
14 14
15 # Normalize the expected apps 15 # Normalize the expected apps
16 apps=${ONOS_APPS:-drivers,openflow} 16 apps=${ONOS_APPS:-drivers,openflow}
17 -(for app in ${apps/,/ }; do echo org.onosproject.$app; done) | sort > $aux.2 17 +(for app in ${apps//,/ }; do echo org.onosproject.$app; done) | sort > $aux.2
18 18
19 # Check for differences 19 # Check for differences
20 diff $aux.1 $aux.2 20 diff $aux.1 $aux.2
......
1 +# Madan's ProxMox ONOS instances 1,2,3 & ONOS mininet box
2 +
3 +export ONOS_NIC="10.128.4.*"
4 +export OC1="10.128.4.2"
5 +export OC2="10.128.4.3"
6 +export OC3="10.128.4.4"
7 +export OCN="10.128.4.5"
1 -# Office ProxMox ONOS instances 1,2,3 & ONOS mininet box 1 +# Tom's ProxMox ONOS instances 1,2,3 & ONOS mininet box
2 2
3 -export ONOS_NIC=10.128.11.* 3 +export ONOS_NIC="10.128.11.*"
4 export OC1="10.128.11.1" 4 export OC1="10.128.11.1"
5 export OC2="10.128.11.2" 5 export OC2="10.128.11.2"
6 export OC3="10.128.11.3" 6 export OC3="10.128.11.3"
......
...@@ -850,7 +850,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler { ...@@ -850,7 +850,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
850 if (load != null) { 850 if (load != null) {
851 this.hasTraffic = hasTraffic || load.rate() > threshold; 851 this.hasTraffic = hasTraffic || load.rate() > threshold;
852 this.bytes += load.latest(); 852 this.bytes += load.latest();
853 - this.rate = load.rate(); 853 + this.rate += load.rate();
854 } 854 }
855 } 855 }
856 856
......