Frank Wang
Committed by Gerrit Code Review

[ONOS-4789]some services don't remove listener in deactive function

Change-Id: I74c3f4eb14edcd93d06a8838a4205df381c7f678
......@@ -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");
}
......
......@@ -90,6 +90,7 @@ public class DistributedFlowObjectiveStore
@Deactivate
public void deactivate() {
nextGroups.removeListener(mapListener);
tpool.shutdown();
log.info("Stopped");
}
......
......@@ -135,11 +135,12 @@ public class DistributedGroupStore
groupEntriesById = new ConcurrentHashMap<>();
private ConsistentMap<GroupStoreKeyMapKey,
StoredGroupEntry> auditPendingReqQueue = null;
private MapEventListener<GroupStoreKeyMapKey, StoredGroupEntry>
mapListener = new GroupStoreKeyMapListener();
private final ConcurrentMap<DeviceId, ConcurrentMap<GroupId, Group>>
extraneousGroupEntriesById = new ConcurrentHashMap<>();
private ExecutorService messageHandlingExecutor;
private static final int MESSAGE_HANDLER_THREAD_POOL_SIZE = 1;
private final HashMap<DeviceId, Boolean> 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");
......
......@@ -86,6 +86,12 @@ public class GossipIntentStore
private final AtomicLong sequenceNumber = new AtomicLong(0);
private EventuallyConsistentMapListener<Key, IntentData>
mapCurrentListener = new InternalCurrentListener();
private EventuallyConsistentMapListener<Key, IntentData>
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();
......