Remove GENIUS UTIL references in Elanmanager Module
[netvirt.git] / elanmanager / impl / src / main / java / org / opendaylight / netvirt / elan / internal / ElanInterfaceManager.java
index 4d12f379e814b4d349128f831eeca5ae41157218..8643b3b92533e405a7dac027f49f25f298eace0f 100644 (file)
@@ -8,9 +8,9 @@
 package org.opendaylight.netvirt.elan.internal;
 
 import static java.util.Collections.emptyList;
-import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
-import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
 import static org.opendaylight.infrautils.utils.concurrent.LoggingFutures.addErrorLogging;
+import static org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION;
+import static org.opendaylight.mdsal.binding.util.Datastore.OPERATIONAL;
 import static org.opendaylight.netvirt.elan.utils.ElanUtils.isVxlanNetworkOrVxlanSegment;
 
 import com.google.common.base.Preconditions;
@@ -36,12 +36,6 @@ import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 import org.apache.commons.lang3.StringUtils;
-import org.opendaylight.genius.infra.Datastore.Configuration;
-import org.opendaylight.genius.infra.Datastore.Operational;
-import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
-import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
-import org.opendaylight.genius.infra.TypedReadWriteTransaction;
-import org.opendaylight.genius.infra.TypedWriteTransaction;
 import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
 import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
 import org.opendaylight.genius.itm.globals.ITMConstants;
@@ -71,6 +65,12 @@ import org.opendaylight.infrautils.utils.concurrent.Executors;
 import org.opendaylight.infrautils.utils.concurrent.LoggingFutures;
 import org.opendaylight.infrautils.utils.concurrent.NamedSimpleReentrantLock.Acquired;
 import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.util.Datastore.Configuration;
+import org.opendaylight.mdsal.binding.util.Datastore.Operational;
+import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner;
+import org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.mdsal.binding.util.TypedReadWriteTransaction;
+import org.opendaylight.mdsal.binding.util.TypedWriteTransaction;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.netvirt.elan.cache.ElanInstanceCache;
 import org.opendaylight.netvirt.elan.cache.ElanInterfaceCache;
@@ -278,13 +278,13 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener<El
     }
 
     @SuppressWarnings("checkstyle:ForbidCertainMethod")
-    public List<ListenableFuture<Void>> removeElanInterface(ElanInstance elanInfo, String interfaceName,
+    public List<ListenableFuture<?>> removeElanInterface(ElanInstance elanInfo, String interfaceName,
             InterfaceInfo interfaceInfo) {
         String elanName = elanInfo.getElanInstanceName();
         EVENT_LOGGER.debug("ELAN-InterfaceState, REMOVE {} Instance {}", interfaceName, elanName);
         Uint32 elanTag = elanInfo.getElanTag();
         // We use two transaction so we don't suffer on multiple shards (interfaces and flows)
-        List<ListenableFuture<Void>> futures = new ArrayList<>();
+        List<ListenableFuture<?>> futures = new ArrayList<>();
         RemoveElanInterfaceHolder holder = new RemoveElanInterfaceHolder();
         futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, interfaceTx -> {
             Elan elanState = removeElanStateForInterface(elanInfo, interfaceName, interfaceTx);
@@ -425,11 +425,11 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener<El
         }
     }
 
-    List<ListenableFuture<Void>> removeEntriesForElanInterface(ElanInstance elanInfo, InterfaceInfo
+    List<ListenableFuture<?>> removeEntriesForElanInterface(ElanInstance elanInfo, InterfaceInfo
             interfaceInfo, String interfaceName, boolean isLastElanInterface) {
         String elanName = elanInfo.getElanInstanceName();
         EVENT_LOGGER.debug("ELAN-InterfaceEntries, REMOVE {} Instance {}", interfaceName, elanName);
-        List<ListenableFuture<Void>> futures = new ArrayList<>();
+        List<ListenableFuture<?>> futures = new ArrayList<>();
         futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, flowTx -> {
             futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, interfaceTx -> {
                 InstanceIdentifier<ElanInterfaceMac> elanInterfaceId = ElanUtils
@@ -438,7 +438,8 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener<El
                 LOG.debug("Removing the Interface:{} from elan:{}", interfaceName, elanName);
                 if (interfaceInfo != null) {
                     if (existingElanInterfaceMac.isPresent()) {
-                        Map<MacEntryKey, MacEntry> existingMacEntries = existingElanInterfaceMac.get().getMacEntry();
+                        Map<MacEntryKey, MacEntry> existingMacEntries =
+                            existingElanInterfaceMac.get().nonnullMacEntry();
                         if (existingMacEntries != null) {
                             List<PhysAddress> macAddresses = new ArrayList<>();
                             for (MacEntry macEntry : existingMacEntries.values()) {
@@ -468,7 +469,7 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener<El
                 } else if (existingElanInterfaceMac.isPresent()) {
                     // Interface does not exist in ConfigDS, so lets remove everything
                     // about that interface related to Elan
-                    Map<MacEntryKey, MacEntry> macEntries = existingElanInterfaceMac.get().getMacEntry();
+                    Map<MacEntryKey, MacEntry> macEntries = existingElanInterfaceMac.get().nonnullMacEntry();
                     if (macEntries != null) {
                         for (MacEntry macEntry : macEntries.values()) {
                             PhysAddress macAddress = macEntry.getMacAddress();
@@ -530,7 +531,7 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener<El
                         if (macs == null || macs.getMacEntry() == null) {
                             continue;
                         }
-                        for (MacEntry mac : new ArrayList<MacEntry>(macs.getMacEntry().values())) {
+                        for (MacEntry mac : new ArrayList<MacEntry>(macs.nonnullMacEntry().values())) {
                             removeTheMacFlowInTheDPN(dpId, elanTag, mac, confTx);
                             removeEtreeMacFlowInTheDPN(dpId, elanTag, mac, confTx);
                         }
@@ -583,9 +584,9 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener<El
         EVENT_LOGGER.debug("ELAN-Interface, UPDATE {} Instance {}", original.getName(), elanName);
 
         List<StaticMacEntries> originalStaticMacEntries = new ArrayList<StaticMacEntries>(original
-                .getStaticMacEntries().values());
+                .nonnullStaticMacEntries().values());
         List<StaticMacEntries> updatedStaticMacEntries = new ArrayList<StaticMacEntries>(update
-                .getStaticMacEntries().values());
+                .nonnullStaticMacEntries().values());
         List<StaticMacEntries> deletedEntries = ElanUtils.diffOf(originalStaticMacEntries, updatedStaticMacEntries);
         List<StaticMacEntries> updatedEntries = ElanUtils.diffOf(updatedStaticMacEntries, originalStaticMacEntries);
 
@@ -663,9 +664,9 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener<El
         }), LOG, "Error processing added ELAN interface");
     }
 
-    List<ListenableFuture<Void>> handleunprocessedElanInterfaces(ElanInstance elanInstance) {
+    List<ListenableFuture<?>> handleunprocessedElanInterfaces(ElanInstance elanInstance) {
         LOG.trace("Handling unprocessed elan interfaces for elan instance {}", elanInstance.getElanInstanceName());
-        List<ListenableFuture<Void>> futures = new ArrayList<>();
+        List<ListenableFuture<?>> futures = new ArrayList<>();
         Queue<ElanInterface> elanInterfaces = unProcessedElanInterfaces.get(elanInstance.getElanInstanceName());
         if (elanInterfaces == null || elanInterfaces.isEmpty()) {
             return futures;
@@ -687,7 +688,7 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener<El
                 .getElanDpnInterfacesList(elanInstance.getElanInstanceName());
         List<DpnInterfaces> dpnInterfaceLists = null;
         if (elanDpnInterfacesList != null) {
-            dpnInterfaceLists = new ArrayList<DpnInterfaces>(elanDpnInterfacesList.getDpnInterfaces().values());
+            dpnInterfaceLists = new ArrayList<DpnInterfaces>(elanDpnInterfacesList.nonnullDpnInterfaces().values());
         }
         if (dpnInterfaceLists != null && !dpnInterfaceLists.isEmpty()) {
             Uint64 dstDpId = interfaceInfo.getDpId();
@@ -731,7 +732,7 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener<El
     }
 
     @SuppressWarnings("checkstyle:ForbidCertainMethod")
-    List<ListenableFuture<Void>> addElanInterface(ElanInterface elanInterface,
+    List<ListenableFuture<?>> addElanInterface(ElanInterface elanInterface,
             InterfaceInfo interfaceInfo, ElanInstance elanInstance) {
         Preconditions.checkNotNull(elanInstance, "elanInstance cannot be null");
         Preconditions.checkNotNull(interfaceInfo, "interfaceInfo cannot be null");
@@ -742,7 +743,7 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener<El
         LOG.trace("Adding elan interface: interface name {} , instance name {}", interfaceName, elanInstanceName);
         EVENT_LOGGER.debug("ELAN-InterfaceState, ADD {} Instance {}", interfaceName, elanInstanceName);
 
-        List<ListenableFuture<Void>> futures = new ArrayList<>();
+        List<ListenableFuture<?>> futures = new ArrayList<>();
         AddElanInterfaceHolder holder = new AddElanInterfaceHolder();
         futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, operTx -> {
             Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
@@ -853,23 +854,22 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener<El
     }
 
     @SuppressWarnings("checkstyle:ForbidCertainMethod")
-    List<ListenableFuture<Void>> setupEntriesForElanInterface(ElanInstance elanInstance,
+    List<ListenableFuture<?>> setupEntriesForElanInterface(ElanInstance elanInstance,
             ElanInterface elanInterface, InterfaceInfo interfaceInfo, boolean isFirstInterfaceInDpn) {
         String elanInstanceName = elanInstance.getElanInstanceName();
         String interfaceName = elanInterface.getName();
-        List<ListenableFuture<Void>> futures = new ArrayList<>();
+        List<ListenableFuture<?>> futures = new ArrayList<>();
         Uint64 dpId = interfaceInfo.getDpId();
         boolean isInterfaceOperational = isOperational(interfaceInfo);
         futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, confTx -> {
             futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, operTx -> {
                 installEntriesForElanInterface(elanInstance, elanInterface, interfaceInfo,
                     isFirstInterfaceInDpn, confTx);
-
-                Map<StaticMacEntriesKey, StaticMacEntries> staticMacEntriesList = elanInterface.getStaticMacEntries();
+                Map<StaticMacEntriesKey, StaticMacEntries> staticMacEntriesMap =
+                    elanInterface.nonnullStaticMacEntries();
                 List<PhysAddress> staticMacAddresses = Lists.newArrayList();
-
-                if (ElanUtils.isNotEmpty(staticMacEntriesList.values())) {
-                    for (StaticMacEntries staticMacEntry : staticMacEntriesList.values()) {
+                if (ElanUtils.isNotEmpty(staticMacEntriesMap.values())) {
+                    for (StaticMacEntries staticMacEntry : staticMacEntriesMap.values()) {
                         InstanceIdentifier<MacEntry> macId = getMacEntryOperationalDataPath(elanInstanceName,
                             staticMacEntry.getMacAddress());
                         Optional<MacEntry> existingMacEntry = ElanUtils.read(broker,
@@ -901,7 +901,7 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener<El
                     if (isInterfaceOperational) {
                         // Add MAC in TOR's remote MACs via OVSDB. Outside of the loop
                         // on purpose.
-                        for (StaticMacEntries staticMacEntry : staticMacEntriesList.values()) {
+                        for (StaticMacEntries staticMacEntry : staticMacEntriesMap.values()) {
                             staticMacAddresses.add(staticMacEntry.getMacAddress());
                         }
                         elanL2GatewayUtils.scheduleAddDpnMacInExtDevices(elanInstance.getElanInstanceName(), dpId,
@@ -1144,12 +1144,12 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener<El
     }
 
     // Install DMAC entry on dst DPN
-    public List<ListenableFuture<Void>> installDMacAddressTables(ElanInstance elanInfo, InterfaceInfo interfaceInfo,
+    public List<ListenableFuture<?>> installDMacAddressTables(ElanInstance elanInfo, InterfaceInfo interfaceInfo,
             Uint64 dstDpId) {
         String interfaceName = interfaceInfo.getInterfaceName();
         ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(interfaceName);
         if (elanInterfaceMac != null && elanInterfaceMac.getMacEntry() != null) {
-            Map<MacEntryKey, MacEntry> macEntries = elanInterfaceMac.getMacEntry();
+            Map<MacEntryKey, MacEntry> macEntries = elanInterfaceMac.nonnullMacEntry();
             return Collections.singletonList(ElanUtils.waitForTransactionToComplete(
                 txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
                     for (MacEntry macEntry : macEntries.values()) {
@@ -1620,7 +1620,7 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener<El
                 LOG.debug("Ignoring internal tunnel state event for Flat/Vlan elan {}", elanName);
                 continue;
             }
-            Map<DpnInterfacesKey, DpnInterfaces> dpnInterfaces = elanDpns.getDpnInterfaces();
+            Map<DpnInterfacesKey, DpnInterfaces> dpnInterfaces = elanDpns.nonnullDpnInterfaces();
             if (dpnInterfaces == null) {
                 continue;
             }