Convert ManagerListener to non-static HwvtepNodeHACache 44/70344/2
authorTom Pantelis <tompantelis@gmail.com>
Wed, 4 Apr 2018 17:38:47 +0000 (13:38 -0400)
committerSam Hague <shague@redhat.com>
Wed, 4 Apr 2018 20:04:00 +0000 (20:04 +0000)
This one popped up after the original patches to convert to
non-static HwvtepNodeHACache were submitted while ago.

Let's get this patch and the subsequent genius patch that
removes the static version in ASAP to finally put this to bed.

Change-Id: I657aa9d1b2065ac531117fd1236fe44865a8ae1a
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/l2gw/ha/listeners/ManagerListener.java

index 0826ef166200b1e0dba56d0349df936fca8772c6..eb3d05e969ee2267312cb3d7b61bd6f939d03830 100644 (file)
@@ -11,11 +11,10 @@ import java.util.Arrays;
 import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 import javax.inject.Singleton;
-
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase;
-import org.opendaylight.genius.utils.hwvtep.HwvtepHACache;
+import org.opendaylight.genius.utils.hwvtep.HwvtepNodeHACache;
 import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils;
 import org.opendaylight.netvirt.elan.l2gw.ha.HwvtepHAUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
@@ -31,10 +30,12 @@ public final class ManagerListener extends AsyncClusteredDataTreeChangeListenerB
     private static final Logger LOG = LoggerFactory.getLogger(ManagerListener.class);
 
     private final DataBroker dataBroker;
+    private final HwvtepNodeHACache hwvtepNodeHACache;
 
     @Inject
-    public ManagerListener(DataBroker dataBroker) {
+    public ManagerListener(DataBroker dataBroker, HwvtepNodeHACache hwvtepNodeHACache) {
         this.dataBroker = dataBroker;
+        this.hwvtepNodeHACache = hwvtepNodeHACache;
     }
 
     @PostConstruct
@@ -67,7 +68,7 @@ public final class ManagerListener extends AsyncClusteredDataTreeChangeListenerB
                 .filter(otherConfig -> otherConfig.getKey().getOtherConfigKey().contains(HwvtepHAUtil.HA_CHILDREN))
                 .flatMap(otherConfig -> Arrays.stream(otherConfig.getOtherConfigValue().split(",")))
                 .map(HwvtepHAUtil::convertToInstanceIdentifier)
-                .forEach(childIid -> HwvtepHACache.getInstance().addChild(parent, childIid));
+                .forEach(childIid -> hwvtepNodeHACache.addChild(parent, childIid));
         }
     }