From e0eb5ce4d0d34bef99aa42fbe7150a0582d97a7c Mon Sep 17 00:00:00 2001 From: Frank Wang Date: Fri, 1 Jul 2016 18:21:25 +0800 Subject: [PATCH] [ONOS-4789]some services don't remove listener in deactive function Change-Id: I74c3f4eb14edcd93d06a8838a4205df381c7f678 --- .../store/device/impl/GossipDeviceStore.java | 19 +++++++++++++++++++ .../impl/DistributedFlowObjectiveStore.java | 1 + .../group/impl/DistributedGroupStore.java | 6 ++++-- .../store/intent/impl/GossipIntentStore.java | 12 ++++++++++-- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java index acc8ff4d4c..49c8534b7e 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java +++ b/core/store/dist/src/main/java/org/onosproject/store/device/impl/GossipDeviceStore.java @@ -257,6 +257,7 @@ public class GossipDeviceStore @Deactivate public void deactivate() { + devicePortStats.removeListener(portStatsListener); devicePortStats.destroy(); devicePortDeltaStats.destroy(); executor.shutdownNow(); @@ -274,6 +275,24 @@ public class GossipDeviceStore devices.clear(); devicePorts.clear(); availableDevices.clear(); + clusterCommunicator.removeSubscriber( + GossipDeviceStoreMessageSubjects.DEVICE_UPDATE); + clusterCommunicator.removeSubscriber( + GossipDeviceStoreMessageSubjects.DEVICE_OFFLINE); + clusterCommunicator.removeSubscriber( + GossipDeviceStoreMessageSubjects.DEVICE_REMOVE_REQ); + clusterCommunicator.removeSubscriber( + GossipDeviceStoreMessageSubjects.DEVICE_REMOVED); + clusterCommunicator.removeSubscriber( + GossipDeviceStoreMessageSubjects.PORT_UPDATE); + clusterCommunicator.removeSubscriber( + GossipDeviceStoreMessageSubjects.PORT_STATUS_UPDATE); + clusterCommunicator.removeSubscriber( + GossipDeviceStoreMessageSubjects.DEVICE_ADVERTISE); + clusterCommunicator.removeSubscriber( + GossipDeviceStoreMessageSubjects.DEVICE_INJECTED); + clusterCommunicator.removeSubscriber( + GossipDeviceStoreMessageSubjects.PORT_INJECTED); log.info("Stopped"); } diff --git a/core/store/dist/src/main/java/org/onosproject/store/flowobjective/impl/DistributedFlowObjectiveStore.java b/core/store/dist/src/main/java/org/onosproject/store/flowobjective/impl/DistributedFlowObjectiveStore.java index 263e93a728..48a1dcc2a8 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/flowobjective/impl/DistributedFlowObjectiveStore.java +++ b/core/store/dist/src/main/java/org/onosproject/store/flowobjective/impl/DistributedFlowObjectiveStore.java @@ -90,6 +90,7 @@ public class DistributedFlowObjectiveStore @Deactivate public void deactivate() { + nextGroups.removeListener(mapListener); tpool.shutdown(); log.info("Stopped"); } diff --git a/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java b/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java index dc8ac58454..29cd8e0f4c 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java +++ b/core/store/dist/src/main/java/org/onosproject/store/group/impl/DistributedGroupStore.java @@ -135,11 +135,12 @@ public class DistributedGroupStore groupEntriesById = new ConcurrentHashMap<>(); private ConsistentMap auditPendingReqQueue = null; + private MapEventListener + mapListener = new GroupStoreKeyMapListener(); private final ConcurrentMap> extraneousGroupEntriesById = new ConcurrentHashMap<>(); private ExecutorService messageHandlingExecutor; private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 1; - private final HashMap deviceAuditStatus = new HashMap<>(); private final AtomicInteger groupIdGen = new AtomicInteger(); @@ -198,7 +199,7 @@ public class DistributedGroupStore .withName("onos-group-store-keymap") .withSerializer(serializer) .build(); - groupStoreEntriesByKey.addListener(new GroupStoreKeyMapListener()); + groupStoreEntriesByKey.addListener(mapListener); log.debug("Current size of groupstorekeymap:{}", groupStoreEntriesByKey.size()); @@ -216,6 +217,7 @@ public class DistributedGroupStore @Deactivate public void deactivate() { + groupStoreEntriesByKey.removeListener(mapListener); cfgService.unregisterProperties(getClass(), false); clusterCommunicator.removeSubscriber(GroupStoreMessageSubjects.REMOTE_GROUP_OP_REQUEST); log.info("Stopped"); diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java index 3c42346d89..57a86e4668 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java +++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/GossipIntentStore.java @@ -86,6 +86,12 @@ public class GossipIntentStore private final AtomicLong sequenceNumber = new AtomicLong(0); + private EventuallyConsistentMapListener + mapCurrentListener = new InternalCurrentListener(); + + private EventuallyConsistentMapListener + mapPendingListener = new InternalPendingListener(); + @Activate public void activate() { KryoNamespace.Builder intentSerializer = KryoNamespace.newBuilder() @@ -111,14 +117,16 @@ public class GossipIntentStore .withPeerUpdateFunction((key, intentData) -> getPeerNodes(key, intentData)) .build(); - currentMap.addListener(new InternalCurrentListener()); - pendingMap.addListener(new InternalPendingListener()); + currentMap.addListener(mapCurrentListener); + pendingMap.addListener(mapPendingListener); log.info("Started"); } @Deactivate public void deactivate() { + currentMap.removeListener(mapCurrentListener); + pendingMap.removeListener(mapPendingListener); currentMap.destroy(); pendingMap.destroy();