* Most of the txRunners are converted to use DS constrained txns.
* Excluded methods are below
- Same tx used for both config and operational
- Methods where blocking calls are used.
JIRA: NETVIRT-1339
Change-Id: I78c40439c486a95d74b063886d3be49b0a999a28
Signed-off-by: eceghkl <manu.b@ericsson.com>
*/
package org.opendaylight.netvirt.elan.evpn.utils;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
import com.google.common.base.Optional;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.MoreExecutors;
}
public void bindElanServiceToExternalTunnel(String elanName, String interfaceName) {
- ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+ ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
int instructionKey = 0;
LOG.trace("Binding external interface {} elan {}", interfaceName, elanName);
List<Instruction> instructions = new ArrayList<>();
ElanUtils.getElanServiceName(elanName, interfaceName), elanServiceIndex,
NwConstants.ELAN_SERVICE_INDEX, NwConstants.COOKIE_ELAN_INGRESS_TABLE, instructions);
InstanceIdentifier<BoundServices> bindServiceId = ElanUtils.buildServiceId(interfaceName, elanServiceIndex);
- if (!tx.read(LogicalDatastoreType.CONFIGURATION, bindServiceId).checkedGet().isPresent()) {
- tx.put(LogicalDatastoreType.CONFIGURATION, bindServiceId, serviceInfo,
- WriteTransaction.CREATE_MISSING_PARENTS);
+ if (!tx.read(bindServiceId).get().isPresent()) {
+ tx.put(bindServiceId, serviceInfo, WriteTransaction.CREATE_MISSING_PARENTS);
}
}), LOG, "Error binding an ELAN service to an external tunnel");
}
public void unbindElanServiceFromExternalTunnel(String elanName, String interfaceName) {
- ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+ ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
LOG.trace("UnBinding external interface {} elan {}", interfaceManager, elanName);
short elanServiceIndex =
ServiceIndex.getIndex(NwConstants.ELAN_SERVICE_NAME, NwConstants.ELAN_SERVICE_INDEX);
InstanceIdentifier<BoundServices> bindServiceId = ElanUtils.buildServiceId(interfaceName, elanServiceIndex);
- if (tx.read(LogicalDatastoreType.CONFIGURATION, bindServiceId).checkedGet().isPresent()) {
- tx.delete(LogicalDatastoreType.CONFIGURATION, bindServiceId);
+ if (tx.read(bindServiceId).get().isPresent()) {
+ tx.delete(bindServiceId);
}
}), LOG, "Error binding an ELAN service to an external tunnel");
}
*/
package org.opendaylight.netvirt.elan.internal;
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
+
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
@Override
protected void add(InstanceIdentifier<ExternalTeps> iid, ExternalTeps tep) {
- JdkFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
- tx.put(LogicalDatastoreType.OPERATIONAL, iid, tep, true);
+ JdkFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx -> {
+ tx.put(iid, tep, true);
}), LOG, "Failed to update operational external teps {}", iid);
}
@Override
protected void remove(InstanceIdentifier<ExternalTeps> iid, ExternalTeps tep) {
- JdkFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
- tx.delete(LogicalDatastoreType.OPERATIONAL, iid);
+ JdkFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx -> {
+ tx.delete(iid);
}), LOG, "Failed to update operational external teps {}", iid);
}
*/
package org.opendaylight.netvirt.elan.internal;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
import static org.opendaylight.netvirt.elan.utils.ElanUtils.isVxlanNetworkOrVxlanSegment;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ListenableFuture;
+
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
+
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
+
import org.apache.commons.lang3.StringUtils;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
+import org.opendaylight.genius.infra.Datastore.Configuration;
import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.genius.itm.globals.ITMConstants;
interfaceInfo, String interfaceName, boolean isLastElanInterface) {
String elanName = elanInfo.getElanInstanceName();
List<ListenableFuture<Void>> futures = new ArrayList<>();
- futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(flowTx -> {
+ futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, flowTx -> {
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(interfaceTx -> {
InstanceIdentifier<ElanInterfaceMac> elanInterfaceId = ElanUtils
.getElanInterfaceMacEntriesOperationalDataPath(interfaceName);
}
public void removeFilterEqualsTable(ElanInstance elanInfo, InterfaceInfo interfaceInfo,
- WriteTransaction deleteFlowGroupTx) {
+ TypedReadWriteTransaction<Configuration> flowTx) {
int ifTag = interfaceInfo.getInterfaceTag();
Flow flow = MDSALUtil.buildFlow(NwConstants.ELAN_FILTER_EQUALS_TABLE,
getFlowRef(NwConstants.ELAN_FILTER_EQUALS_TABLE, ifTag, "group"));
- mdsalManager.removeFlowToTx(interfaceInfo.getDpId(), flow, deleteFlowGroupTx);
+ mdsalManager.removeFlow(flowTx, interfaceInfo.getDpId(), flow);
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.ELAN_FILTER_EQUALS_TABLE,
getFlowRef(NwConstants.ELAN_FILTER_EQUALS_TABLE, ifTag, "drop"), 10, elanInfo.getElanInstanceName(), 0,
0, ElanConstants.COOKIE_ELAN_FILTER_EQUALS.add(BigInteger.valueOf(ifTag)),
getMatchesForFilterEqualsLPortTag(ifTag), MDSALUtil.buildInstructionsDrop());
- mdsalManager.removeFlowToTx(interfaceInfo.getDpId(), flowEntity, deleteFlowGroupTx);
+ mdsalManager.removeFlow(flowTx, interfaceInfo.getDpId(), flowEntity);
}
private List<Bucket> getRemoteBCGroupBucketInfos(ElanInstance elanInfo, int bucketKeyStart,
*/
package org.opendaylight.netvirt.elan.internal;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
+
import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
+
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Callable;
+
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.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
+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.TransactionAdapter;
+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.infrautils.jobcoordinator.JobCoordinator;
return Collections.emptyList();
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
- futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(interfaceTx -> futures.add(
- txRunner.callWithNewWriteOnlyTransactionAndSubmit(
- flowTx -> addMacEntryToDsAndSetupFlows(elanInterface.get().getElanInstanceName(),
- interfaceTx, flowTx, ElanConstants.STATIC_MAC_TIMEOUT)))));
+ futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, interfaceTx ->
+ futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, flowTx ->
+ addMacEntryToDsAndSetupFlows(elanInterface.get().getElanInstanceName(), interfaceTx,
+ flowTx, ElanConstants.STATIC_MAC_TIMEOUT)))));
return futures;
}
- private void addMacEntryToDsAndSetupFlows(String elanName, WriteTransaction interfaceTx,
- WriteTransaction flowTx, int macTimeOut) throws ElanException {
+ private void addMacEntryToDsAndSetupFlows(String elanName, TypedWriteTransaction<Operational> interfaceTx,
+ TypedWriteTransaction<Configuration> flowTx, int macTimeOut) throws ElanException {
LOG.trace("Adding mac address {} and interface name {} to ElanInterfaceForwardingEntries and "
+ "ElanForwardingTables DS", macAddress, interfaceName);
BigInteger timeStamp = new BigInteger(String.valueOf(System.currentTimeMillis()));
.setIsStaticAddress(false).build();
InstanceIdentifier<MacEntry> macEntryId = ElanUtils
.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress);
- interfaceTx.put(LogicalDatastoreType.OPERATIONAL, macEntryId, macEntry);
+ interfaceTx.put(macEntryId, macEntry);
InstanceIdentifier<MacEntry> elanMacEntryId =
ElanUtils.getMacEntryOperationalDataPath(elanName, physAddress);
- interfaceTx.put(LogicalDatastoreType.OPERATIONAL, elanMacEntryId, macEntry);
+ interfaceTx.put(elanMacEntryId, macEntry);
ElanInstance elanInstance = elanInstanceCache.get(elanName).orNull();
elanUtils.setupMacFlows(elanInstance, interfaceManager.getInterfaceInfo(interfaceName), macTimeOut,
- macAddress, true, flowTx);
+ macAddress, true, TransactionAdapter.toWriteTransaction(flowTx));
}
}
return Collections.emptyList();
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
- futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(interfaceTx -> futures.add(
- txRunner.callWithNewWriteOnlyTransactionAndSubmit(
- flowTx -> deleteMacEntryFromDsAndRemoveFlows(elanInterface.get().getElanInstanceName(),
- interfaceTx, flowTx)))));
+ futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, interfaceTx ->
+ futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, flowTx ->
+ deleteMacEntryFromDsAndRemoveFlows(elanInterface.get().getElanInstanceName(),
+ interfaceTx, flowTx)))));
return futures;
}
- private void deleteMacEntryFromDsAndRemoveFlows(String elanName, WriteTransaction interfaceTx,
- WriteTransaction flowTx) {
+ private void deleteMacEntryFromDsAndRemoveFlows(String elanName,
+ TypedWriteTransaction<Operational> interfaceTx, TypedReadWriteTransaction<Configuration> flowTx) {
LOG.trace("Deleting mac address {} and interface name {} from ElanInterfaceForwardingEntries "
+ "and ElanForwardingTables DS", macAddress, interfaceName);
PhysAddress physAddress = new PhysAddress(macAddress);
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
if (macEntry != null && interfaceInfo != null) {
elanUtils.deleteMacFlows(elanInstanceCache.get(elanName).orNull(), interfaceInfo, macEntry, flowTx);
- interfaceTx.delete(LogicalDatastoreType.OPERATIONAL,
+ interfaceTx.delete(
ElanUtils.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress));
- interfaceTx.delete(LogicalDatastoreType.OPERATIONAL,
+ interfaceTx.delete(
ElanUtils.getMacEntryOperationalDataPath(elanName, physAddress));
}
}
*/
package org.opendaylight.netvirt.elan.internal;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+
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.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
+import org.opendaylight.genius.infra.Datastore.Configuration;
import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.genius.infra.TypedWriteTransaction;
import org.opendaylight.genius.mdsalutil.ActionInfo;
import org.opendaylight.genius.mdsalutil.BucketInfo;
import org.opendaylight.genius.mdsalutil.FlowEntity;
private void createArpDefaultFlowsForArpCheckTable(BigInteger dpId) {
jobCoordinator.enqueueJob("ARP_CHECK_TABLE-" + dpId.toString(),
- () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+ () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
LOG.debug("Received notification to install Arp Check Default entries for dpn {} ", dpId);
createArpRequestMatchFlows(dpId, tx);
createArpResponseMatchFlows(dpId, tx);
Collections.singletonList(new InstructionGotoTable(NwConstants.ELAN_BASE_TABLE))));
}
- private void createArpRequestMatchFlows(BigInteger dpId, WriteTransaction writeFlowTx) {
+ private void createArpRequestMatchFlows(BigInteger dpId, TypedWriteTransaction<Configuration> tx) {
long arpRequestGroupId = ArpResponderUtil.retrieveStandardArpResponderGroupId(idManagerService);
List<BucketInfo> buckets = ArpResponderUtil.getDefaultBucketInfos(NwConstants.ARP_RESPONDER_TABLE);
new ActionNxResubmit(NwConstants.ARP_LEARN_TABLE_2),
new ActionNxResubmit(NwConstants.ELAN_BASE_TABLE)));
LOG.trace("Invoking MDSAL to install Arp Rquest Match Flow for table {}", NwConstants.ARP_CHECK_TABLE);
- mdsalManager.addFlowToTx(arpReqArpCheckTbl, writeFlowTx);
+ mdsalManager.addFlow(tx, arpReqArpCheckTbl);
}
- private void createArpResponseMatchFlows(BigInteger dpId, WriteTransaction writeFlowTx) {
+ private void createArpResponseMatchFlows(BigInteger dpId, TypedWriteTransaction<Configuration> tx) {
FlowEntity arpRepArpCheckTbl = ArpResponderUtil.createArpDefaultFlow(dpId, NwConstants.ARP_CHECK_TABLE,
NwConstants.ARP_REPLY, () -> Arrays.asList(MatchEthernetType.ARP, MatchArpOp.REPLY), () ->
Arrays.asList(new ActionNxResubmit(NwConstants.ARP_LEARN_TABLE_1),
new ActionNxResubmit(NwConstants.ARP_LEARN_TABLE_2),
new ActionNxResubmit(NwConstants.ELAN_BASE_TABLE)));
LOG.trace("Invoking MDSAL to install Arp Reply Match Flow for Table {} ", NwConstants.ARP_CHECK_TABLE);
- mdsalManager.addFlowToTx(arpRepArpCheckTbl, writeFlowTx);
+ mdsalManager.addFlow(tx, arpRepArpCheckTbl);
}
- private void createArpPuntAndLearnFlow(BigInteger dpId, WriteTransaction writeFlowTx) {
+ private void createArpPuntAndLearnFlow(BigInteger dpId, TypedWriteTransaction<Configuration> tx) {
LOG.debug("adding arp punt and learn entry in table {}", NwConstants.ARP_LEARN_TABLE_1);
List<MatchInfo> matches = new ArrayList<>();
FlowEntity flow = MDSALUtil.buildFlowEntity(dpId, NwConstants.ARP_LEARN_TABLE_1, flowid,
NwConstants.TABLE_MISS_PRIORITY, "arp punt/learn flow", 0,
0, cookie, matches, instructions);
- mdsalManager.addFlowToTx(flow, writeFlowTx);
+ mdsalManager.addFlow(tx, flow);
}
- private void addGarpLearnMatchFlow(BigInteger dpId, WriteTransaction writeFlowTx) {
+ private void addGarpLearnMatchFlow(BigInteger dpId, TypedWriteTransaction<Configuration> tx) {
List<ActionInfo> actions = new ArrayList<>();
List<MatchInfoBase> matches = new ArrayList<>();
FlowEntity garpFlow = MDSALUtil.buildFlowEntity(dpId, NwConstants.ELAN_BASE_TABLE, flowid,
NwConstants.DEFAULT_ARP_FLOW_PRIORITY, "GARP learn match flow", 0, 0,
ElanConstants.COOKIE_ELAN_BASE_SMAC, matches, instructions);
- mdsalManager.addFlowToTx(garpFlow, writeFlowTx);
+ mdsalManager.addFlow(tx, garpFlow);
}
- private void addArpLearnMatchFlow(BigInteger dpId, WriteTransaction writeFlowTx) {
+ private void addArpLearnMatchFlow(BigInteger dpId, TypedWriteTransaction<Configuration> tx) {
List<ActionInfo> actions = new ArrayList<>();
List<MatchInfoBase> matches = new ArrayList<>();
FlowEntity arpFlow = MDSALUtil.buildFlowEntity(dpId, NwConstants.ELAN_BASE_TABLE, flowid,
NwConstants.DEFAULT_ARP_FLOW_PRIORITY, "ARP learn match flow", 0, 0,
ElanConstants.COOKIE_ELAN_BASE_SMAC, matches, instructions);
- mdsalManager.addFlowToTx(arpFlow, writeFlowTx);
+ mdsalManager.addFlow(tx, arpFlow);
}
}
*/
package org.opendaylight.netvirt.elan.internal;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
+
import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
+
import java.math.BigInteger;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.List;
+
import javax.inject.Inject;
import javax.inject.Singleton;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.genius.infra.TransactionAdapter;
import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
import org.opendaylight.genius.mdsalutil.MetaDataUtil;
MacEntry oldMacEntry, MacEntry newMacEntry,
final boolean isVlanOrFlatProviderIface) {
jobCoordinator.enqueueJob(ElanUtils.getElanMacKey(elanTag, macAddress),
- () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+ () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, tx -> {
if (oldMacEntry != null && oldMacEntry.getInterface().equals(interfaceName)) {
// This should never occur because of ovs temporary mac learning
elanManagerCounters.unknownSmacPktinForwardingEntriesRemoved();
InstanceIdentifier<MacEntry> macEntryId = ElanUtils
.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName,
physAddress);
- tx.delete(LogicalDatastoreType.OPERATIONAL, macEntryId);
+ tx.delete(macEntryId);
} else {
// New FEs flood their packets on all interfaces. This can lead
// to many contradicting packet_ins. Ignore all packets received
if (!isVlanOrFlatProviderIface && oldMacEntry == null) {
InstanceIdentifier<MacEntry> elanMacEntryId =
ElanUtils.getMacEntryOperationalDataPath(elanName, physAddress);
- tx.put(LogicalDatastoreType.OPERATIONAL, elanMacEntryId, newMacEntry,
- WriteTransaction.CREATE_MISSING_PARENTS);
+ tx.put(elanMacEntryId, newMacEntry, WriteTransaction.CREATE_MISSING_PARENTS);
}
})));
}
elanL2GatewayUtils.scheduleAddDpnMacInExtDevices(elanInstance.getElanInstanceName(), dpId,
Collections.singletonList(physAddress));
elanManagerCounters.unknownSmacPktinLearned();
- return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
- elanUtils.setupMacFlows(elanInstance, interfaceInfo, elanInstance.getMacTimeout(),
- macAddress, !isVlanOrFlatProviderIface, tx);
- InstanceIdentifier<MacEntry> macEntryId =
+ List<ListenableFuture<Void>> futures = new ArrayList<>();
+ futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
+ futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, operTx -> {
+ elanUtils.setupMacFlows(elanInstance, interfaceInfo, elanInstance.getMacTimeout(),
+ macAddress, !isVlanOrFlatProviderIface, TransactionAdapter.toWriteTransaction(tx));
+ InstanceIdentifier<MacEntry> macEntryId =
ElanUtils.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, physAddress);
- tx.put(LogicalDatastoreType.OPERATIONAL, macEntryId, newMacEntry,
- WriteTransaction.CREATE_MISSING_PARENTS);
+ operTx.put(macEntryId, newMacEntry, WriteTransaction.CREATE_MISSING_PARENTS);
+ }));
}));
+ return futures;
});
}
macEntry.getMacAddress(), macEntry.getInterface());
return;
}
- ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+ ListenableFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION,
tx -> elanUtils.deleteMacFlows(elanInfo, oldInterfaceLport, macEntry, tx)), LOG,
"Error deleting invalid MAC entry");
elanL2GatewayUtils.removeMacsFromElanExternalDevices(elanInfo,
*/
package org.opendaylight.netvirt.elan.internal;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
+
import com.google.common.base.Optional;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
String elanInstanceName = elanTagInfo.getName();
LOG.info("Deleting the Mac-Entry:{} present on ElanInstance:{}", macEntry, elanInstanceName);
if (macEntry != null && interfaceInfo != null) {
- ListenableFuture<Void> result = txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+ ListenableFuture<Void> result = txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION,
tx -> elanUtils.deleteMacFlows(elanInstanceCache.get(elanInstanceName).orNull(),
interfaceInfo, macEntry, tx));
elanFutures.add(result);
Optional<MacEntry> existingInterfaceMacEntry = ElanUtils.read(broker,
LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInterface);
if (existingInterfaceMacEntry.isPresent()) {
- ListenableFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
- tx.delete(LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInterface);
- MacEntry macEntryInElanInstance = elanUtils.getMacEntryForElanInstance(elanInstanceName,
+ ListenableFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL,
+ tx -> {
+ tx.delete(macEntryIdForElanInterface);
+ MacEntry macEntryInElanInstance = elanUtils.getMacEntryForElanInstance(elanInstanceName,
physAddress).orNull();
- if (macEntryInElanInstance != null
+ if (macEntryInElanInstance != null
&& macEntryInElanInstance.getInterface().equals(interfaceName)) {
- InstanceIdentifier<MacEntry> macEntryIdForElanInstance = ElanUtils
+ InstanceIdentifier<MacEntry> macEntryIdForElanInstance = ElanUtils
.getMacEntryOperationalDataPath(elanInstanceName, physAddress);
- tx.delete(LogicalDatastoreType.OPERATIONAL, macEntryIdForElanInstance);
- }
- });
+ tx.delete(macEntryIdForElanInstance);
+ }
+ });
elanFutures.add(future);
addCallBack(future, srcMacAddress);
}
*/
package org.opendaylight.netvirt.elan.l2gw.listeners;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Collections;
import java.util.List;
if (connections.isEmpty()) {
return Collections.emptyList();
}
- ListenableFuture<Void> future = txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
- for (L2gatewayConnection connection : connections) {
- InstanceIdentifier<L2gatewayConnection> iid =
- InstanceIdentifier.create(Neutron.class).child(
- L2gatewayConnections.class).child(
- L2gatewayConnection.class, connection.key());
- tx.delete(LogicalDatastoreType.CONFIGURATION, iid);
- }
- });
+ ListenableFuture<Void> future = txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION,
+ tx -> {
+ for (L2gatewayConnection connection : connections) {
+ InstanceIdentifier<L2gatewayConnection> iid =
+ InstanceIdentifier.create(Neutron.class).child(
+ L2gatewayConnections.class).child(
+ L2gatewayConnection.class, connection.key());
+ tx.delete(iid);
+ }
+ });
ListenableFutures.addErrorLogging(future, LOG,
"Failed to delete associate L2 gateway connection while deleting network");
return Collections.singletonList(future);
package org.opendaylight.netvirt.elan.l2gw.listeners;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
import com.google.common.base.Optional;
import java.util.Collections;
import java.util.HashSet;
PhysicalSwitchAugmentation phySwitchAdded) {
if (phySwitchAdded.getTunnelIps() != null) {
ListenableFutures.addErrorLogging(
- txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
- Optional<PhysicalSwitchAugmentation> existingSwitch = tx.read(
- LogicalDatastoreType.CONFIGURATION, identifier).checkedGet();
+ txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
+ Optional<PhysicalSwitchAugmentation> existingSwitch = tx.read(identifier).get();
PhysicalSwitchAugmentationBuilder psBuilder = new PhysicalSwitchAugmentationBuilder();
if (existingSwitch.isPresent()) {
psBuilder = new PhysicalSwitchAugmentationBuilder(existingSwitch.get());
}
psBuilder.setTunnelIps(phySwitchAdded.getTunnelIps());
- tx.put(LogicalDatastoreType.CONFIGURATION, identifier, psBuilder.build(), true);
+ tx.put(identifier, psBuilder.build(), true);
LOG.trace("Updating config tunnel ips {}", identifier);
}), LOG, "Failed to update the config tunnel ips {}", identifier);
}
*/
package org.opendaylight.netvirt.elan.l2gw.listeners;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.Collections;
private List<ListenableFuture<Void>> handlePortDeleted(InstanceIdentifier<TerminationPoint> identifier) {
InstanceIdentifier<Node> psNodeIid = identifier.firstIdentifierOf(Node.class);
- return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(
- tx -> tx.read(LogicalDatastoreType.CONFIGURATION, psNodeIid).checkedGet().toJavaUtil().ifPresent(
- node -> tx.delete(LogicalDatastoreType.CONFIGURATION, identifier))));
+ return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION,
+ tx -> tx.read(psNodeIid).get().toJavaUtil().ifPresent(
+ node -> tx.delete(identifier))));
}
private List<VlanBindings> getVlanBindings(List<L2gatewayConnection> l2GwConns, NodeId hwvtepNodeId, String psName,
package org.opendaylight.netvirt.elan.l2gw.utils;
import static java.util.Collections.emptyList;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
import static org.opendaylight.netvirt.elan.utils.ElanUtils.isVxlanNetworkOrVxlanSegment;
import com.google.common.util.concurrent.ListenableFuture;
*/
public ListenableFuture<Void> handleMcastForElanL2GwDeviceAdd(String elanName, L2GatewayDevice device) {
InstanceIdentifier<ExternalTeps> tepPath = buildExternalTepPath(elanName, device.getTunnelIp());
- JdkFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
- tx.put(LogicalDatastoreType.CONFIGURATION, tepPath, buildExternalTeps(device));
+ JdkFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
+ tx.put(tepPath, buildExternalTeps(device));
}), LOG, "Failed to write to config external tep {}", tepPath);
return updateMcastMacsForAllElanDevices(elanName, device, true/* updateThisDevice */);
}
*/
package org.opendaylight.netvirt.elan.l2gw.utils;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.FutureCallback;
return;
}
JdkFutures.addErrorLogging(
- new ManagedNewTransactionRunnerImpl(dataBroker).callWithNewReadWriteTransactionAndSubmit(tx -> {
- optionalElan.get().getElanInstance().stream()
+ new ManagedNewTransactionRunnerImpl(dataBroker).callWithNewReadWriteTransactionAndSubmit(CONFIGURATION,
+ tx -> {
+ optionalElan.get().getElanInstance().stream()
.flatMap(elan -> elan.getExternalTeps().stream()
.map(externalTep -> ElanL2GatewayMulticastUtils.buildExternalTepPath(
elan.getElanInstanceName(), externalTep.getTepIp())))
.filter(externalTepIid -> Objects.equals(
deviceVteps.getIpAddress(), externalTepIid.firstKeyOf(ExternalTeps.class).getTepIp()))
.peek(externalTepIid -> LOG.info("Deleting stale external tep {}", externalTepIid))
- .forEach(externalTepIid -> tx.delete(LogicalDatastoreType.CONFIGURATION, externalTepIid));
- }), LOG, "Failed to delete stale external teps {}", deviceVteps);
+ .forEach(externalTepIid -> tx.delete(externalTepIid));
+ }), LOG, "Failed to delete stale external teps {}", deviceVteps);
Thread.sleep(10000);//TODO remove the sleep currently it waits for interfacemgr to finish the cleanup
} catch (ReadFailedException | InterruptedException e) {
LOG.error("Failed to delete stale l2gw tep {}", deviceVteps, e);
*/
package org.opendaylight.netvirt.elan.recovery.impl;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
import java.util.concurrent.ExecutionException;
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.infra.ManagedNewTransactionRunner;
import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
import org.opendaylight.genius.utils.clustering.EntityOwnershipUtils;
.getElanInterfaceConfigurationDataPathId(entityId);
try {
LOG.trace("deleting elan interface {}", entityId);
- txRunner.callWithNewWriteOnlyTransactionAndSubmit(
- tx -> tx.delete(LogicalDatastoreType.CONFIGURATION, elanInterfaceId)).get();
+ txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+ tx -> tx.delete(elanInterfaceId)).get();
LOG.trace("recreating elan interface {}, {}", entityId, elanInterface);
- txRunner.callWithNewWriteOnlyTransactionAndSubmit(
- tx -> tx.put(LogicalDatastoreType.CONFIGURATION, elanInterfaceId, elanInterface)).get();
+ txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+ tx -> tx.put(elanInterfaceId, elanInterface)).get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Service recovery failed for elan interface {}", entityId, e);
}
*/
package org.opendaylight.netvirt.elan.utils;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
import com.google.common.base.Optional;
import com.google.common.util.concurrent.ListenableFuture;
+
import java.util.ArrayList;
import java.util.List;
+
import javax.inject.Inject;
import javax.inject.Singleton;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
createElanInterfaceForwardingTablesList(interfaceName, macEntry, tx);
}
- public void deleteElanInterfaceForwardingTablesList(String interfaceName, MacEntry mac, WriteTransaction tx) {
+ public void deleteElanInterfaceForwardingTablesList(String interfaceName, MacEntry mac,
+ WriteTransaction interfaceTx) {
InstanceIdentifier<MacEntry> existingMacEntryId = ElanUtils
.getInterfaceMacEntriesIdentifierOperationalDataPath(interfaceName, mac.getMacAddress());
MacEntry existingInterfaceMacEntry = elanUtils
.getInterfaceMacEntriesOperationalDataPathFromId(existingMacEntryId);
if (existingInterfaceMacEntry != null) {
- tx.delete(LogicalDatastoreType.OPERATIONAL, existingMacEntryId);
+ interfaceTx.delete(LogicalDatastoreType.OPERATIONAL, existingMacEntryId);
}
}
.getMacEntryOperationalDataPath(elanInfo.getElanInstanceName(), macEntry.getMacAddress());
interfaceTx.delete(LogicalDatastoreType.OPERATIONAL, macEntryId);
deleteElanInterfaceForwardingTablesList(interfaceInfo.getInterfaceName(), macEntry, interfaceTx);
- futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(flowTx -> {
+ futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, flowTx -> {
elanUtils.deleteMacFlows(elanInfo, interfaceInfo, macEntry, flowTx);
}));
}));
*/
package org.opendaylight.netvirt.elan.utils;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+
import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.inject.Singleton;
+
import org.apache.commons.lang3.StringUtils;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.genius.infra.Datastore.Configuration;
import org.opendaylight.genius.infra.ManagedNewTransactionRunner;
import org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl;
+import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
import org.opendaylight.genius.interfacemanager.globals.InterfaceServiceUtil;
import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
}
public void deleteMacFlows(@Nullable ElanInstance elanInfo, @Nullable InterfaceInfo interfaceInfo,
- MacEntry macEntry, WriteTransaction deleteFlowGroupTx) {
+ MacEntry macEntry, TypedReadWriteTransaction<Configuration> flowTx) {
if (elanInfo == null || interfaceInfo == null) {
return;
}
String macAddress = macEntry.getMacAddress().getValue();
synchronized (getElanMacDPNKey(elanInfo.getElanTag(), macAddress, interfaceInfo.getDpId())) {
- deleteMacFlows(elanInfo, interfaceInfo, macAddress, /* alsoDeleteSMAC */ true, deleteFlowGroupTx);
+ deleteMacFlows(elanInfo, interfaceInfo, macAddress, /* alsoDeleteSMAC */ true, flowTx);
}
}
public void deleteMacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress,
- boolean deleteSmac, WriteTransaction deleteFlowGroupTx) {
+ boolean deleteSmac, TypedReadWriteTransaction<Configuration> flowTx) {
String elanInstanceName = elanInfo.getElanInstanceName();
List<DpnInterfaces> remoteFEs = getInvolvedDpnsInElan(elanInstanceName);
BigInteger srcdpId = interfaceInfo.getDpId();
Long elanTag = elanInfo.getElanTag();
BigInteger dstDpId = dpnInterface.getDpId();
if (executeDeleteMacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, elanInstanceName, srcdpId,
- elanTag, dstDpId, deleteFlowGroupTx)) {
+ elanTag, dstDpId, flowTx)) {
isFlowsRemovedInSrcDpn = true;
}
executeEtreeDeleteMacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, elanInstanceName, srcdpId,
- elanTag, dstDpId, deleteFlowGroupTx);
+ elanTag, dstDpId, flowTx);
}
if (!isFlowsRemovedInSrcDpn) {
- deleteSmacAndDmacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, deleteFlowGroupTx);
+ deleteSmacAndDmacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, flowTx);
}
}
private void executeEtreeDeleteMacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress,
boolean deleteSmac, String elanInstanceName, BigInteger srcdpId, Long elanTag, BigInteger dstDpId,
- WriteTransaction deleteFlowGroupTx) {
+ TypedReadWriteTransaction<Configuration> flowTx) {
EtreeLeafTagName etreeLeafTag = elanEtreeUtils.getEtreeLeafTagByElanTag(elanTag);
if (etreeLeafTag != null) {
executeDeleteMacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, elanInstanceName, srcdpId,
- etreeLeafTag.getEtreeLeafTag().getValue(), dstDpId, deleteFlowGroupTx);
+ etreeLeafTag.getEtreeLeafTag().getValue(), dstDpId, flowTx);
}
}
private boolean executeDeleteMacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress,
boolean deleteSmac, String elanInstanceName, BigInteger srcdpId, Long elanTag, BigInteger dstDpId,
- WriteTransaction deleteFlowGroupTx) {
+ TypedReadWriteTransaction<Configuration> flowTx) {
boolean isFlowsRemovedInSrcDpn = false;
if (dstDpId.equals(srcdpId)) {
isFlowsRemovedInSrcDpn = true;
- deleteSmacAndDmacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, deleteFlowGroupTx);
+ deleteSmacAndDmacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, flowTx);
} else if (isDpnPresent(dstDpId)) {
mdsalManager
- .removeFlowToTx(dstDpId,
+ .removeFlow(flowTx, dstDpId,
MDSALUtil.buildFlow(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(
- NwConstants.ELAN_DMAC_TABLE, dstDpId, srcdpId, macAddress, elanTag)),
- deleteFlowGroupTx);
+ NwConstants.ELAN_DMAC_TABLE, dstDpId, srcdpId, macAddress, elanTag)));
LOG.debug("Dmac flow entry deleted for elan:{}, logical interface port:{} and mac address:{} on dpn:{}",
elanInstanceName, interfaceInfo.getPortName(), macAddress, dstDpId);
}
}
private void deleteSmacAndDmacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress,
- boolean deleteSmac, WriteTransaction deleteFlowGroupTx) {
+ boolean deleteSmac, TypedReadWriteTransaction<Configuration> flowTx) {
String elanInstanceName = elanInfo.getElanInstanceName();
long ifTag = interfaceInfo.getInterfaceTag();
BigInteger srcdpId = interfaceInfo.getDpId();
Long elanTag = elanInfo.getElanTag();
if (deleteSmac) {
mdsalManager
- .removeFlowToTx(srcdpId,
+ .removeFlow(flowTx, srcdpId,
MDSALUtil.buildFlow(NwConstants.ELAN_SMAC_TABLE, getKnownDynamicmacFlowRef(
- NwConstants.ELAN_SMAC_TABLE, srcdpId, ifTag, macAddress, elanTag)),
- deleteFlowGroupTx);
+ NwConstants.ELAN_SMAC_TABLE, srcdpId, ifTag, macAddress, elanTag)));
}
- mdsalManager.removeFlowToTx(srcdpId,
+ mdsalManager.removeFlow(flowTx, srcdpId,
MDSALUtil.buildFlow(NwConstants.ELAN_DMAC_TABLE,
- getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, srcdpId, ifTag, macAddress, elanTag)),
- deleteFlowGroupTx);
+ getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, srcdpId, ifTag, macAddress, elanTag)));
LOG.debug("All the required flows deleted for elan:{}, logical Interface port:{} and MAC address:{} on dpn:{}",
elanInstanceName, interfaceInfo.getPortName(), macAddress, srcdpId);
}
public void addDmacRedirectToDispatcherFlows(Long elanTag, String displayName,
String macAddress, List<BigInteger> dpnIds) {
for (BigInteger dpId : dpnIds) {
- ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
- tx -> mdsalManager.addFlowToTx(
- buildDmacRedirectToDispatcherFlow(dpId, macAddress, displayName, elanTag), tx)), LOG,
+ ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+ tx -> mdsalManager.addFlow(tx, buildDmacRedirectToDispatcherFlow(dpId, macAddress, displayName,
+ elanTag))), LOG,
"Error adding DMAC redirect to dispatcher flows");
}
}