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;
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;
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;
}
@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);
}
}
- 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
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()) {
} 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();
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);
}
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);
}), 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;
.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();
}
@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");
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);
}
@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,
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,
}
// 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()) {
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;
}