X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=elanmanager%2Fimpl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetvirt%2Felan%2Finternal%2FElanInterfaceManager.java;h=8643b3b92533e405a7dac027f49f25f298eace0f;hb=refs%2Fchanges%2F77%2F92077%2F4;hp=4d12f379e814b4d349128f831eeca5ae41157218;hpb=cf1ea9172b94fc17e45391b62bf4ca24ac5c5fe0;p=netvirt.git diff --git a/elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanInterfaceManager.java b/elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanInterfaceManager.java index 4d12f379e8..8643b3b925 100644 --- a/elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanInterfaceManager.java +++ b/elanmanager/impl/src/main/java/org/opendaylight/netvirt/elan/internal/ElanInterfaceManager.java @@ -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> removeElanInterface(ElanInstance elanInfo, String interfaceName, + public List> 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> futures = new ArrayList<>(); + List> 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> removeEntriesForElanInterface(ElanInstance elanInfo, InterfaceInfo + List> removeEntriesForElanInterface(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String interfaceName, boolean isLastElanInterface) { String elanName = elanInfo.getElanInstanceName(); EVENT_LOGGER.debug("ELAN-InterfaceEntries, REMOVE {} Instance {}", interfaceName, elanName); - List> futures = new ArrayList<>(); + List> futures = new ArrayList<>(); futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, flowTx -> { futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, interfaceTx -> { InstanceIdentifier elanInterfaceId = ElanUtils @@ -438,7 +438,8 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener existingMacEntries = existingElanInterfaceMac.get().getMacEntry(); + Map existingMacEntries = + existingElanInterfaceMac.get().nonnullMacEntry(); if (existingMacEntries != null) { List macAddresses = new ArrayList<>(); for (MacEntry macEntry : existingMacEntries.values()) { @@ -468,7 +469,7 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener macEntries = existingElanInterfaceMac.get().getMacEntry(); + Map 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(macs.getMacEntry().values())) { + for (MacEntry mac : new ArrayList(macs.nonnullMacEntry().values())) { removeTheMacFlowInTheDPN(dpId, elanTag, mac, confTx); removeEtreeMacFlowInTheDPN(dpId, elanTag, mac, confTx); } @@ -583,9 +584,9 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener originalStaticMacEntries = new ArrayList(original - .getStaticMacEntries().values()); + .nonnullStaticMacEntries().values()); List updatedStaticMacEntries = new ArrayList(update - .getStaticMacEntries().values()); + .nonnullStaticMacEntries().values()); List deletedEntries = ElanUtils.diffOf(originalStaticMacEntries, updatedStaticMacEntries); List updatedEntries = ElanUtils.diffOf(updatedStaticMacEntries, originalStaticMacEntries); @@ -663,9 +664,9 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener> handleunprocessedElanInterfaces(ElanInstance elanInstance) { + List> handleunprocessedElanInterfaces(ElanInstance elanInstance) { LOG.trace("Handling unprocessed elan interfaces for elan instance {}", elanInstance.getElanInstanceName()); - List> futures = new ArrayList<>(); + List> futures = new ArrayList<>(); Queue elanInterfaces = unProcessedElanInterfaces.get(elanInstance.getElanInstanceName()); if (elanInterfaces == null || elanInterfaces.isEmpty()) { return futures; @@ -687,7 +688,7 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener dpnInterfaceLists = null; if (elanDpnInterfacesList != null) { - dpnInterfaceLists = new ArrayList(elanDpnInterfacesList.getDpnInterfaces().values()); + dpnInterfaceLists = new ArrayList(elanDpnInterfacesList.nonnullDpnInterfaces().values()); } if (dpnInterfaceLists != null && !dpnInterfaceLists.isEmpty()) { Uint64 dstDpId = interfaceInfo.getDpId(); @@ -731,7 +732,7 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener> addElanInterface(ElanInterface elanInterface, + List> 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> futures = new ArrayList<>(); + List> 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> setupEntriesForElanInterface(ElanInstance elanInstance, + List> setupEntriesForElanInterface(ElanInstance elanInstance, ElanInterface elanInterface, InterfaceInfo interfaceInfo, boolean isFirstInterfaceInDpn) { String elanInstanceName = elanInstance.getElanInstanceName(); String interfaceName = elanInterface.getName(); - List> futures = new ArrayList<>(); + List> 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 staticMacEntriesList = elanInterface.getStaticMacEntries(); + Map staticMacEntriesMap = + elanInterface.nonnullStaticMacEntries(); List staticMacAddresses = Lists.newArrayList(); - - if (ElanUtils.isNotEmpty(staticMacEntriesList.values())) { - for (StaticMacEntries staticMacEntry : staticMacEntriesList.values()) { + if (ElanUtils.isNotEmpty(staticMacEntriesMap.values())) { + for (StaticMacEntries staticMacEntry : staticMacEntriesMap.values()) { InstanceIdentifier macId = getMacEntryOperationalDataPath(elanInstanceName, staticMacEntry.getMacAddress()); Optional existingMacEntry = ElanUtils.read(broker, @@ -901,7 +901,7 @@ public class ElanInterfaceManager extends AbstractAsyncDataTreeChangeListener> installDMacAddressTables(ElanInstance elanInfo, InterfaceInfo interfaceInfo, + public List> installDMacAddressTables(ElanInstance elanInfo, InterfaceInfo interfaceInfo, Uint64 dstDpId) { String interfaceName = interfaceInfo.getInterfaceName(); ElanInterfaceMac elanInterfaceMac = elanUtils.getElanInterfaceMacByInterfaceName(interfaceName); if (elanInterfaceMac != null && elanInterfaceMac.getMacEntry() != null) { - Map macEntries = elanInterfaceMac.getMacEntry(); + Map 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 dpnInterfaces = elanDpns.getDpnInterfaces(); + Map dpnInterfaces = elanDpns.nonnullDpnInterfaces(); if (dpnInterfaces == null) { continue; }