Committed by
Gerrit Code Review
[ONOS-4789]some services don't remove listener in deactive function
Change-Id: I74c3f4eb14edcd93d06a8838a4205df381c7f678
Showing
4 changed files
with
34 additions
and
4 deletions
| ... | @@ -257,6 +257,7 @@ public class GossipDeviceStore | ... | @@ -257,6 +257,7 @@ public class GossipDeviceStore |
| 257 | 257 | ||
| 258 | @Deactivate | 258 | @Deactivate |
| 259 | public void deactivate() { | 259 | public void deactivate() { |
| 260 | + devicePortStats.removeListener(portStatsListener); | ||
| 260 | devicePortStats.destroy(); | 261 | devicePortStats.destroy(); |
| 261 | devicePortDeltaStats.destroy(); | 262 | devicePortDeltaStats.destroy(); |
| 262 | executor.shutdownNow(); | 263 | executor.shutdownNow(); |
| ... | @@ -274,6 +275,24 @@ public class GossipDeviceStore | ... | @@ -274,6 +275,24 @@ public class GossipDeviceStore |
| 274 | devices.clear(); | 275 | devices.clear(); |
| 275 | devicePorts.clear(); | 276 | devicePorts.clear(); |
| 276 | availableDevices.clear(); | 277 | availableDevices.clear(); |
| 278 | + clusterCommunicator.removeSubscriber( | ||
| 279 | + GossipDeviceStoreMessageSubjects.DEVICE_UPDATE); | ||
| 280 | + clusterCommunicator.removeSubscriber( | ||
| 281 | + GossipDeviceStoreMessageSubjects.DEVICE_OFFLINE); | ||
| 282 | + clusterCommunicator.removeSubscriber( | ||
| 283 | + GossipDeviceStoreMessageSubjects.DEVICE_REMOVE_REQ); | ||
| 284 | + clusterCommunicator.removeSubscriber( | ||
| 285 | + GossipDeviceStoreMessageSubjects.DEVICE_REMOVED); | ||
| 286 | + clusterCommunicator.removeSubscriber( | ||
| 287 | + GossipDeviceStoreMessageSubjects.PORT_UPDATE); | ||
| 288 | + clusterCommunicator.removeSubscriber( | ||
| 289 | + GossipDeviceStoreMessageSubjects.PORT_STATUS_UPDATE); | ||
| 290 | + clusterCommunicator.removeSubscriber( | ||
| 291 | + GossipDeviceStoreMessageSubjects.DEVICE_ADVERTISE); | ||
| 292 | + clusterCommunicator.removeSubscriber( | ||
| 293 | + GossipDeviceStoreMessageSubjects.DEVICE_INJECTED); | ||
| 294 | + clusterCommunicator.removeSubscriber( | ||
| 295 | + GossipDeviceStoreMessageSubjects.PORT_INJECTED); | ||
| 277 | log.info("Stopped"); | 296 | log.info("Stopped"); |
| 278 | } | 297 | } |
| 279 | 298 | ... | ... |
| ... | @@ -90,6 +90,7 @@ public class DistributedFlowObjectiveStore | ... | @@ -90,6 +90,7 @@ public class DistributedFlowObjectiveStore |
| 90 | 90 | ||
| 91 | @Deactivate | 91 | @Deactivate |
| 92 | public void deactivate() { | 92 | public void deactivate() { |
| 93 | + nextGroups.removeListener(mapListener); | ||
| 93 | tpool.shutdown(); | 94 | tpool.shutdown(); |
| 94 | log.info("Stopped"); | 95 | log.info("Stopped"); |
| 95 | } | 96 | } | ... | ... |
| ... | @@ -135,11 +135,12 @@ public class DistributedGroupStore | ... | @@ -135,11 +135,12 @@ public class DistributedGroupStore |
| 135 | groupEntriesById = new ConcurrentHashMap<>(); | 135 | groupEntriesById = new ConcurrentHashMap<>(); |
| 136 | private ConsistentMap<GroupStoreKeyMapKey, | 136 | private ConsistentMap<GroupStoreKeyMapKey, |
| 137 | StoredGroupEntry> auditPendingReqQueue = null; | 137 | StoredGroupEntry> auditPendingReqQueue = null; |
| 138 | + private MapEventListener<GroupStoreKeyMapKey, StoredGroupEntry> | ||
| 139 | + mapListener = new GroupStoreKeyMapListener(); | ||
| 138 | private final ConcurrentMap<DeviceId, ConcurrentMap<GroupId, Group>> | 140 | private final ConcurrentMap<DeviceId, ConcurrentMap<GroupId, Group>> |
| 139 | extraneousGroupEntriesById = new ConcurrentHashMap<>(); | 141 | extraneousGroupEntriesById = new ConcurrentHashMap<>(); |
| 140 | private ExecutorService messageHandlingExecutor; | 142 | private ExecutorService messageHandlingExecutor; |
| 141 | private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 1; | 143 | private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 1; |
| 142 | - | ||
| 143 | private final HashMap<DeviceId, Boolean> deviceAuditStatus = new HashMap<>(); | 144 | private final HashMap<DeviceId, Boolean> deviceAuditStatus = new HashMap<>(); |
| 144 | 145 | ||
| 145 | private final AtomicInteger groupIdGen = new AtomicInteger(); | 146 | private final AtomicInteger groupIdGen = new AtomicInteger(); |
| ... | @@ -198,7 +199,7 @@ public class DistributedGroupStore | ... | @@ -198,7 +199,7 @@ public class DistributedGroupStore |
| 198 | .withName("onos-group-store-keymap") | 199 | .withName("onos-group-store-keymap") |
| 199 | .withSerializer(serializer) | 200 | .withSerializer(serializer) |
| 200 | .build(); | 201 | .build(); |
| 201 | - groupStoreEntriesByKey.addListener(new GroupStoreKeyMapListener()); | 202 | + groupStoreEntriesByKey.addListener(mapListener); |
| 202 | log.debug("Current size of groupstorekeymap:{}", | 203 | log.debug("Current size of groupstorekeymap:{}", |
| 203 | groupStoreEntriesByKey.size()); | 204 | groupStoreEntriesByKey.size()); |
| 204 | 205 | ||
| ... | @@ -216,6 +217,7 @@ public class DistributedGroupStore | ... | @@ -216,6 +217,7 @@ public class DistributedGroupStore |
| 216 | 217 | ||
| 217 | @Deactivate | 218 | @Deactivate |
| 218 | public void deactivate() { | 219 | public void deactivate() { |
| 220 | + groupStoreEntriesByKey.removeListener(mapListener); | ||
| 219 | cfgService.unregisterProperties(getClass(), false); | 221 | cfgService.unregisterProperties(getClass(), false); |
| 220 | clusterCommunicator.removeSubscriber(GroupStoreMessageSubjects.REMOTE_GROUP_OP_REQUEST); | 222 | clusterCommunicator.removeSubscriber(GroupStoreMessageSubjects.REMOTE_GROUP_OP_REQUEST); |
| 221 | log.info("Stopped"); | 223 | log.info("Stopped"); | ... | ... |
| ... | @@ -86,6 +86,12 @@ public class GossipIntentStore | ... | @@ -86,6 +86,12 @@ public class GossipIntentStore |
| 86 | 86 | ||
| 87 | private final AtomicLong sequenceNumber = new AtomicLong(0); | 87 | private final AtomicLong sequenceNumber = new AtomicLong(0); |
| 88 | 88 | ||
| 89 | + private EventuallyConsistentMapListener<Key, IntentData> | ||
| 90 | + mapCurrentListener = new InternalCurrentListener(); | ||
| 91 | + | ||
| 92 | + private EventuallyConsistentMapListener<Key, IntentData> | ||
| 93 | + mapPendingListener = new InternalPendingListener(); | ||
| 94 | + | ||
| 89 | @Activate | 95 | @Activate |
| 90 | public void activate() { | 96 | public void activate() { |
| 91 | KryoNamespace.Builder intentSerializer = KryoNamespace.newBuilder() | 97 | KryoNamespace.Builder intentSerializer = KryoNamespace.newBuilder() |
| ... | @@ -111,14 +117,16 @@ public class GossipIntentStore | ... | @@ -111,14 +117,16 @@ public class GossipIntentStore |
| 111 | .withPeerUpdateFunction((key, intentData) -> getPeerNodes(key, intentData)) | 117 | .withPeerUpdateFunction((key, intentData) -> getPeerNodes(key, intentData)) |
| 112 | .build(); | 118 | .build(); |
| 113 | 119 | ||
| 114 | - currentMap.addListener(new InternalCurrentListener()); | 120 | + currentMap.addListener(mapCurrentListener); |
| 115 | - pendingMap.addListener(new InternalPendingListener()); | 121 | + pendingMap.addListener(mapPendingListener); |
| 116 | 122 | ||
| 117 | log.info("Started"); | 123 | log.info("Started"); |
| 118 | } | 124 | } |
| 119 | 125 | ||
| 120 | @Deactivate | 126 | @Deactivate |
| 121 | public void deactivate() { | 127 | public void deactivate() { |
| 128 | + currentMap.removeListener(mapCurrentListener); | ||
| 129 | + pendingMap.removeListener(mapPendingListener); | ||
| 122 | currentMap.destroy(); | 130 | currentMap.destroy(); |
| 123 | pendingMap.destroy(); | 131 | pendingMap.destroy(); |
| 124 | 132 | ... | ... |
-
Please register or login to post a comment