Migrate elanmanager to use LoggingFutures
[netvirt.git] / elanmanager / impl / src / main / java / org / opendaylight / netvirt / elan / l2gw / utils / StaleVlanBindingsCleaner.java
index 95f54369d14a453f7c4dcacc5afff653f48c5b41..ea8e50cbf22a7a1ed15fe82826987352583d5127 100644 (file)
@@ -7,7 +7,7 @@
  */
 package org.opendaylight.netvirt.elan.l2gw.utils;
 
-import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -29,7 +29,7 @@ import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
 import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
 import org.opendaylight.genius.mdsalutil.MDSALUtil;
 import org.opendaylight.genius.utils.hwvtep.HwvtepSouthboundUtils;
-import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
+import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
 import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
 import org.opendaylight.netvirt.elan.utils.Scheduler;
 import org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayCache;
@@ -108,9 +108,10 @@ public class StaleVlanBindingsCleaner {
                 () -> {
                     L2GatewayDevice l2GwDevice = l2GatewayCache.get(deviceName);
                     NodeId globalNodeId = globalNodeIid.firstKeyOf(Node.class).getNodeId();
-                    Node configNode = MDSALUtil.read(broker, CONFIGURATION, globalNodeIid)
+                    Node configNode = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, globalNodeIid)
                             .or(defaultNode(globalNodeId));
-                    Node configPsNode = MDSALUtil.read(broker, CONFIGURATION, psNodeIid).or(defaultNode(psNodeId));
+                    Node configPsNode =
+                        MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, psNodeIid).or(defaultNode(psNodeId));
                     cleanupStaleLogicalSwitches(l2GwDevice, configNode, configPsNode);
                     cleanupTasks.remove(psNodeIid.firstKeyOf(Node.class).getNodeId());
                 }, getCleanupDelay(), TimeUnit.SECONDS);
@@ -186,11 +187,10 @@ public class StaleVlanBindingsCleaner {
                                       final String staleLogicalSwitch) {
 
         LOG.trace("CleanupStaleBindings for logical switch {}", staleLogicalSwitch);
-        ListenableFutures.addErrorLogging(
-            txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+        LoggingFutures.addErrorLogging(
+            txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
                 if (vlans.containsKey(staleLogicalSwitch)) {
-                    vlans.get(staleLogicalSwitch)
-                            .forEach((vlanIid) -> tx.delete(LogicalDatastoreType.CONFIGURATION, vlanIid));
+                    vlans.get(staleLogicalSwitch).forEach((vlanIid) -> tx.delete(vlanIid));
                 }
             }),
             LOG, "Failed to delete stale vlan bindings from node {}", globalNodeId);