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.SingleTransactionDataBroker;
-import org.opendaylight.genius.infra.Datastore;
+import org.opendaylight.genius.infra.Datastore.Configuration;
+import org.opendaylight.genius.infra.Datastore.Operational;
+import org.opendaylight.genius.infra.TypedReadTransaction;
+import org.opendaylight.genius.infra.TypedReadWriteTransaction;
import org.opendaylight.genius.infra.TypedWriteTransaction;
import org.opendaylight.genius.mdsalutil.BucketInfo;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
return MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
}
+ static Optional<VpnInstanceOpDataEntry> getVpnInstanceOpData(TypedReadTransaction<Operational> operTx, String rd)
+ throws ExecutionException, InterruptedException {
+ return operTx.read(getVpnInstanceOpDataIdentifier(rd)).get();
+ }
+
VpnInstanceOpDataEntry getVpnInstance(String rd) {
InstanceIdentifier<VpnInstanceOpDataEntry> id =
InstanceIdentifier.create(VpnInstanceOpData.class)
return localNextHopInfoData.isPresent() ? localNextHopInfoData.get() : null;
}
+ static Prefixes getPrefixToInterface(TypedReadTransaction<Operational> operTx, Long vpnId, String ipPrefix)
+ throws ExecutionException, InterruptedException {
+ return operTx.read(getPrefixToInterfaceIdentifier(vpnId, ipPrefix)).get().orNull();
+ }
+
String getMacAddressFromPrefix(String ifName, String vpnName, String ipPrefix) {
Optional<Adjacency> adjacencyData = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL,
getAdjacencyIdentifierOp(ifName, vpnName, ipPrefix));
}
}
- public void removeVrfTable(String rd, TypedWriteTransaction<Datastore.Configuration> writeConfigTxn) {
+ public void removeVrfTable(String rd, TypedWriteTransaction<Configuration> writeConfigTxn) {
LOG.debug("Removing vrf table for rd {}", rd);
InstanceIdentifier.InstanceIdentifierBuilder<VrfTables> idBuilder =
InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
return "FIB-" + vpnId.toString() + "-" + dpnId.toString() ;
}
- public void updateUsedRdAndVpnToExtraRoute(WriteTransaction writeConfigTxn, WriteTransaction writeOperTxn,
- String tunnelIpRemoved, String primaryRd, String prefix) {
- Optional<VpnInstanceOpDataEntry> optVpnInstance = getVpnInstanceOpData(primaryRd);
+ public void updateUsedRdAndVpnToExtraRoute(TypedReadWriteTransaction<Configuration> confTx,
+ TypedReadWriteTransaction<Operational> operTx, String tunnelIpRemoved, String primaryRd, String prefix)
+ throws ExecutionException, InterruptedException {
+ Optional<VpnInstanceOpDataEntry> optVpnInstance = getVpnInstanceOpData(operTx, primaryRd);
if (!optVpnInstance.isPresent()) {
return;
}
VpnInstanceOpDataEntry vpnInstance = optVpnInstance.get();
String vpnName = vpnInstance.getVpnInstanceName();
long vpnId = vpnInstance.getVpnId();
- List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, prefix);
+ List<String> usedRds = VpnExtraRouteHelper.getUsedRds(confTx, vpnId, prefix);
// To identify the rd to be removed, iterate through the allocated rds for the prefix and check
// which rd is allocated for the particular OVS.
for (String usedRd : usedRds) {
- Optional<Routes> vpnExtraRoutes = VpnExtraRouteHelper
- .getVpnExtraroutes(dataBroker, vpnName, usedRd, prefix);
+ Optional<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getVpnExtraroutes(operTx, vpnName, usedRd, prefix);
if (vpnExtraRoutes.isPresent()) {
// Since all the nexthops under one OVS will be present under one rd, only 1 nexthop is read
// to identify the OVS
String nextHopRemoved = vpnExtraRoutes.get().getNexthopIpList().get(0);
- Prefixes prefixToInterface = getPrefixToInterface(vpnId, getIpPrefix(nextHopRemoved));
+ Prefixes prefixToInterface = getPrefixToInterface(operTx, vpnId, getIpPrefix(nextHopRemoved));
if (prefixToInterface != null && tunnelIpRemoved
.equals(getEndpointIpAddressForDPN(prefixToInterface.getDpnId()))) {
LOG.info("updating data-stores for prefix {} with primaryRd {} for interface {} on vpn {} ",
prefix, primaryRd, prefixToInterface.getVpnInterfaceName(), vpnName);
- writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL,
- FibUtil.getAdjacencyIdentifierOp(prefixToInterface.getVpnInterfaceName(),
+ operTx.delete(FibUtil.getAdjacencyIdentifierOp(prefixToInterface.getVpnInterfaceName(),
vpnName, prefix));
- writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL,
- VpnExtraRouteHelper.getVpnToExtrarouteVrfIdIdentifier(vpnName, usedRd, prefix));
- writeConfigTxn.delete(LogicalDatastoreType.CONFIGURATION,
- VpnExtraRouteHelper.getUsedRdsIdentifier(vpnId, prefix, nextHopRemoved));
+ operTx.delete(VpnExtraRouteHelper.getVpnToExtrarouteVrfIdIdentifier(vpnName, usedRd, prefix));
+ confTx.delete(VpnExtraRouteHelper.getUsedRdsIdentifier(vpnId, prefix, nextHopRemoved));
break;
}
}
}
public static void updateLbGroupInfo(BigInteger dpnId, String destinationIp, String groupIdKey,
- String groupId, WriteTransaction tx) {
+ String groupId, TypedWriteTransaction<Operational> tx) {
InstanceIdentifier<DpnLbNexthops> id = getDpnLbNexthopsIdentifier(dpnId, destinationIp);
DpnLbNexthops dpnToLbNextHop = buildDpnLbNextHops(dpnId, destinationIp, groupIdKey);
- tx.merge(LogicalDatastoreType.OPERATIONAL, id, dpnToLbNextHop);
+ tx.merge(id, dpnToLbNextHop);
InstanceIdentifier<Nexthops> nextHopsId = getNextHopsIdentifier(groupIdKey);
Nexthops nextHopsToGroupId = buildNextHops(dpnId, groupIdKey, groupId);
- tx.merge(LogicalDatastoreType.OPERATIONAL, nextHopsId, nextHopsToGroupId);
+ tx.merge(nextHopsId, nextHopsToGroupId);
}
- public static void removeDpnIdToNextHopInfo(String destinationIp, BigInteger dpnId, WriteTransaction tx) {
- InstanceIdentifier<DpnLbNexthops> id = getDpnLbNexthopsIdentifier(dpnId, destinationIp);
- tx.delete(LogicalDatastoreType.OPERATIONAL, id);
+ public static void removeDpnIdToNextHopInfo(String destinationIp, BigInteger dpnId,
+ TypedWriteTransaction<Operational> tx) {
+ tx.delete(getDpnLbNexthopsIdentifier(dpnId, destinationIp));
}
public static void removeOrUpdateNextHopInfo(BigInteger dpnId, String nextHopKey, String groupId,
- Nexthops nexthops, WriteTransaction tx) {
+ Nexthops nexthops, TypedWriteTransaction<Operational> tx) {
InstanceIdentifier<Nexthops> nextHopsId = getNextHopsIdentifier(nextHopKey);
List<String> targetDeviceIds = nexthops.getTargetDeviceId();
targetDeviceIds.remove(dpnId.toString());
if (targetDeviceIds.isEmpty()) {
- tx.delete(LogicalDatastoreType.OPERATIONAL, nextHopsId);
+ tx.delete(nextHopsId);
} else {
Nexthops nextHopsToGroupId = new NexthopsBuilder().withKey(new NexthopsKey(nextHopKey))
.setNexthopKey(nextHopKey)
.setGroupId(groupId)
.setTargetDeviceId(targetDeviceIds).build();
- tx.put(LogicalDatastoreType.OPERATIONAL, nextHopsId, nextHopsToGroupId);
+ tx.put(nextHopsId, nextHopsToGroupId);
}
}
*/
package org.opendaylight.netvirt.fibmanager;
+import static org.opendaylight.controller.md.sal.binding.api.WriteTransaction.CREATE_MISSING_PARENTS;
+import static org.opendaylight.genius.infra.Datastore.CONFIGURATION;
+import static org.opendaylight.genius.infra.Datastore.OPERATIONAL;
import static org.opendaylight.genius.mdsalutil.NWUtil.isIpv4Address;
import com.google.common.base.Optional;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ExecutionException;
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.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
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.datastoreutils.listeners.DataTreeEventCallbackRegistrar;
+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.RetryingManagedNewTransactionRunner;
+import org.opendaylight.genius.infra.TransactionAdapter;
+import org.opendaylight.genius.infra.TypedReadWriteTransaction;
+import org.opendaylight.genius.infra.TypedWriteTransaction;
import org.opendaylight.genius.mdsalutil.ActionInfo;
import org.opendaylight.genius.mdsalutil.FlowEntity;
import org.opendaylight.genius.mdsalutil.InstructionInfo;
nextHopsRemoved.removeAll(FibHelper.getNextHopListFromRoutePaths(update));
List<ListenableFuture<Void>> futures = new ArrayList<>();
ListenableFuture<Void> configFuture =
- txRunner.callWithNewWriteOnlyTransactionAndSubmit(configTx ->
- futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(operTx ->
- nextHopsRemoved.parallelStream()
- .forEach(nextHopRemoved -> fibUtil.updateUsedRdAndVpnToExtraRoute(
- configTx, operTx, nextHopRemoved, rd, update.getDestPrefix())))));
+ txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, configTx ->
+ futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, operTx ->
+ nextHopsRemoved.parallelStream()
+ .forEach(nextHopRemoved -> {
+ try {
+ fibUtil.updateUsedRdAndVpnToExtraRoute(
+ configTx, operTx, nextHopRemoved, rd, update.getDestPrefix());
+ } catch (ExecutionException | InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }))));
futures.add(configFuture);
Futures.addCallback(configFuture, new FutureCallback<Void>() {
@Override
+ " with elantag {}", rd, vrfEntry.getDestPrefix(), elanTag);
if (vpnToDpnList != null) {
jobCoordinator.enqueueJob(FibUtil.getJobKeyForRdPrefix(rd, vrfEntry.getDestPrefix()),
- () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
- for (final VpnToDpnList curDpn : vpnToDpnList) {
- if (curDpn.getDpnState() == VpnToDpnList.DpnState.Active) {
- installSubnetRouteInFib(curDpn.getDpnId(), elanTag, rd, vpnId, vrfEntry, tx);
- installSubnetBroadcastAddrDropRule(curDpn.getDpnId(), rd, vpnId.longValue(),
+ () -> Collections.singletonList(
+ txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
+ for (final VpnToDpnList curDpn : vpnToDpnList) {
+ if (curDpn.getDpnState() == VpnToDpnList.DpnState.Active) {
+ installSubnetRouteInFib(curDpn.getDpnId(), elanTag, rd, vpnId, vrfEntry, tx);
+ installSubnetBroadcastAddrDropRule(curDpn.getDpnId(), rd, vpnId.longValue(),
vrfEntry, NwConstants.ADD_FLOW, tx);
+ }
}
- }
- })));
+ })));
}
return;
}
final List<BigInteger> localDpnIdList = createLocalFibEntry(vpnInstance.getVpnId(), rd, vrfEntry, etherType);
if (!localDpnIdList.isEmpty() && vpnToDpnList != null) {
jobCoordinator.enqueueJob(FibUtil.getJobKeyForRdPrefix(rd, vrfEntry.getDestPrefix()),
- () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+ () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
synchronized (vpnInstance.getVpnInstanceName().intern()) {
for (VpnToDpnList vpnDpn : vpnToDpnList) {
if (!localDpnIdList.contains(vpnDpn.getDpnId())) {
try {
if (RouteOrigin.BGP.getValue().equals(vrfEntry.getOrigin())) {
bgpRouteVrfEntryHandler.createRemoteFibEntry(vpnDpn.getDpnId(),
- vpnId, vrfTableKey.getRouteDistinguisher(), vrfEntry, tx,
+ vpnId, vrfTableKey.getRouteDistinguisher(), vrfEntry,
+ TransactionAdapter.toWriteTransaction(tx),
txnObjects);
} else {
createRemoteFibEntry(vpnDpn.getDpnId(), vpnInstance.getVpnId(),
}
void installSubnetRouteInFib(final BigInteger dpnId, final long elanTag, final String rd,
- final long vpnId, final VrfEntry vrfEntry, WriteTransaction tx) {
+ final long vpnId, final VrfEntry vrfEntry, TypedWriteTransaction<Configuration> tx) {
if (tx == null) {
- ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+ ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
newTx -> installSubnetRouteInFib(dpnId, elanTag, rd, vpnId, vrfEntry, newTx)), LOG,
"Error installing subnet route in FIB");
return;
instructions.add(new InstructionWriteMetadata(subnetRouteMeta, MetaDataUtil.METADATA_MASK_SUBNET_ROUTE));
instructions.add(new InstructionGotoTable(NwConstants.L3_SUBNET_ROUTE_TABLE));
baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, instructions,
- NwConstants.ADD_FLOW, tx, null);
+ NwConstants.ADD_FLOW, TransactionAdapter.toWriteTransaction(tx), null);
if (vrfEntry.getRoutePaths() != null) {
for (RoutePaths routePath : vrfEntry.getRoutePaths()) {
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
}
private void installSubnetBroadcastAddrDropRule(final BigInteger dpnId, final String rd, final long vpnId,
- final VrfEntry vrfEntry, int addOrRemove, WriteTransaction tx) {
+ final VrfEntry vrfEntry, int addOrRemove, TypedWriteTransaction<Configuration> tx) {
List<MatchInfo> matches = new ArrayList<>();
LOG.debug("SUBNETROUTE: installSubnetBroadcastAddrDropRule: destPrefix {} rd {} vpnId {} dpnId {}",
.child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
if (addOrRemove == NwConstants.ADD_FLOW) {
- tx.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId,flow, true);
+ tx.put(flowInstanceId,flow, true);
} else {
- tx.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
+ tx.delete(flowInstanceId);
}
}
java.util.Optional<Long> optLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
String jobKey = FibUtil.getCreateLocalNextHopJobKey(vpnId, dpnId, vrfEntry.getDestPrefix());
- jobCoordinator.enqueueJob(jobKey, () -> {
- return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+ jobCoordinator.enqueueJob(jobKey,
+ () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, instructions,
- NwConstants.ADD_FLOW, tx, null);
+ NwConstants.ADD_FLOW, TransactionAdapter.toWriteTransaction(tx), null);
if (FibUtil.isBgpVpn(vpnName, rd)) {
optLabel.ifPresent(label -> {
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
}
});
}
- }));
- });
+ })));
return dpnId;
}
LOG.error("localNextHopInfo received is null for prefix {} on rd {} on vpn {}", vrfEntry.getDestPrefix(), rd,
return null;
}
- private boolean deleteLabelRouteInfo(LabelRouteInfo lri, String vpnInstanceName, WriteTransaction tx) {
+ private boolean deleteLabelRouteInfo(LabelRouteInfo lri, String vpnInstanceName,
+ TypedWriteTransaction<Operational> tx) {
if (lri == null) {
return true;
}
if (vpnInstancesList.isEmpty()) {
LOG.debug("deleting LRI instance object for label {}", lri.getLabel());
if (tx != null) {
- tx.delete(LogicalDatastoreType.OPERATIONAL, lriId);
+ tx.delete(lriId);
} else {
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.OPERATIONAL, lriId);
}
}
void makeTunnelTableEntry(BigInteger dpId, long label, long groupId/*String egressInterfaceName*/,
- WriteTransaction tx) {
+ TypedWriteTransaction<Configuration> tx) {
List<ActionInfo> actionsInfos = Collections.singletonList(new ActionGroup(groupId));
createTerminatingServiceActions(dpId, (int) label, actionsInfos, tx);
}
public void createTerminatingServiceActions(BigInteger destDpId, int label, List<ActionInfo> actionsInfos,
- WriteTransaction tx) {
+ TypedWriteTransaction<Configuration> tx) {
List<MatchInfo> mkMatches = new ArrayList<>();
LOG.debug("create terminatingServiceAction on DpnId = {} and serviceId = {} and actions = {}",
.child(Node.class, nodeDpn.key()).augmentation(FlowCapableNode.class)
.child(Table.class, new TableKey(terminatingServiceTableFlowEntity.getTableId()))
.child(Flow.class, flowKey).build();
- tx.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flowbld.build(),
- WriteTransaction.CREATE_MISSING_PARENTS);
+ tx.put(flowInstanceId, flowbld.build(), CREATE_MISSING_PARENTS);
}
- private void removeTunnelTableEntry(BigInteger dpId, long label, WriteTransaction tx) {
+ private void removeTunnelTableEntry(BigInteger dpId, long label, TypedWriteTransaction<Configuration> tx) {
FlowEntity flowEntity;
LOG.debug("remove terminatingServiceActions called with DpnId = {} and label = {}", dpId, label);
List<MatchInfo> mkMatches = new ArrayList<>();
.child(Node.class, nodeDpn.key()).augmentation(FlowCapableNode.class)
.child(Table.class, new TableKey(flowEntity.getTableId())).child(Flow.class, flowKey).build();
- tx.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
+ tx.delete(flowInstanceId);
LOG.debug("Terminating service Entry for dpID {} : label : {} removed successfully", dpId, label);
}
vrfEntry.getDestPrefix(), vpnName, rd);
return returnLocalDpnId;
}
- String vpnRd = (!usedRds.isEmpty()) ? usedRds.get(0) : rd;
+ String vpnRd = !usedRds.isEmpty() ? usedRds.get(0) : rd;
//Is this fib route an extra route? If yes, get the nexthop which would be an adjacency
//in the vpn
Optional<Routes> extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker,
}
jobCoordinator.enqueueJob(FibUtil.getCreateLocalNextHopJobKey(vpnId, dpnId, vrfEntry.getDestPrefix()),
- () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+ () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, null,
- NwConstants.DEL_FLOW, tx, null);
+ NwConstants.DEL_FLOW, TransactionAdapter.toWriteTransaction(tx), null);
if (FibUtil.isBgpVpn(vpnName, rd)) {
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
FibUtil.getLabelFromRoutePaths(vrfEntry).ifPresent(label -> {
}
private void createRemoteFibEntry(final BigInteger remoteDpnId, final long vpnId, String rd,
- final VrfEntry vrfEntry, WriteTransaction tx) {
+ final VrfEntry vrfEntry, TypedWriteTransaction<Configuration> tx) {
if (tx == null) {
- ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(newTx -> {
- createRemoteFibEntry(remoteDpnId, vpnId, rd, vrfEntry, newTx);
- }), LOG, "Error creating remote FIB entry");
+ ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+ newTx -> createRemoteFibEntry(remoteDpnId, vpnId, rd, vrfEntry, newTx)), LOG,
+ "Error creating remote FIB entry");
return;
}
Collections.singletonList(new ActionGroup(groupId));
instructions.add(new InstructionApplyActions(actionInfos));
baseVrfEntryHandler.makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, instructions,
- NwConstants.ADD_FLOW, tx, null);
+ NwConstants.ADD_FLOW, TransactionAdapter.toWriteTransaction(tx), null);
} else {
- baseVrfEntryHandler.programRemoteFib(remoteDpnId, vpnId, vrfEntry, tx, rd, adjacencyResults, null);
+ baseVrfEntryHandler.programRemoteFib(remoteDpnId, vpnId, vrfEntry,
+ TransactionAdapter.toWriteTransaction(tx), rd, adjacencyResults, null);
}
LOG.debug("Successfully added FIB entry for prefix {} in vpnId {}", vrfEntry.getDestPrefix(), vpnId);
public List<ListenableFuture<Void>> call() {
// If another renderer(for eg : CSS) needs to be supported, check can be performed here
// to call the respective helpers.
- return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+ return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, tx -> {
//First Cleanup LabelRouteInfo
//TODO(KIRAN) : Move the below block when addressing iRT/eRT for L3VPN Over VxLan
LOG.debug("cleanupVpnInterfaceWorker: rd {} prefix {}", rd, prefixInfo.getIpAddress());
String vpnName = null;
if (Prefixes.PrefixCue.PhysNetFunc.equals(prefixInfo.getPrefixCue())) {
- /*Get vpnId for rd = networkId since op vpnInterface will be pointing to rd = networkId
- * */
+ // Get vpnId for rd = networkId since op vpnInterface will be pointing to rd = networkId
Optional<String> vpnNameOpt = fibUtil.getVpnNameFromRd(vrfEntry.getParentVpnRd());
if (vpnNameOpt.isPresent()) {
vpnId = fibUtil.getVpnId(vpnNameOpt.get());
}
if (optVpnName.isPresent()) {
vpnName = optVpnName.get();
- Optional<VpnInterfaceOpDataEntry> opVpnInterface = MDSALUtil
- .read(dataBroker, LogicalDatastoreType.OPERATIONAL,
- fibUtil.getVpnInterfaceOpDataEntryIdentifier(ifName, vpnName));
+ Optional<VpnInterfaceOpDataEntry> opVpnInterface = tx
+ .read(FibUtil.getVpnInterfaceOpDataEntryIdentifier(ifName, vpnName)).get();
if (opVpnInterface.isPresent()) {
long associatedVpnId = fibUtil.getVpnId(vpnName);
if (vpnId != associatedVpnId) {
//Only one used Rd present in case of removal event
String usedRd = usedRds.get(0);
if (optVpnName.isPresent()) {
- tx.delete(LogicalDatastoreType.OPERATIONAL,
- baseVrfEntryHandler.getVpnToExtrarouteIdentifier(vpnName, usedRd,
+ tx.delete(BaseVrfEntryHandler.getVpnToExtrarouteIdentifier(vpnName, usedRd,
vrfEntry.getDestPrefix()));
- tx.delete(LogicalDatastoreType.CONFIGURATION,
- VpnExtraRouteHelper.getUsedRdsIdentifier(vpnId, vrfEntry.getDestPrefix()));
+ txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, configTx ->
+ configTx.delete(VpnExtraRouteHelper.getUsedRdsIdentifier(vpnId, vrfEntry.getDestPrefix())));
}
}
handleAdjacencyAndVpnOpInterfaceDeletion(vrfEntry, ifName, vpnName, tx);
* @param ifName - Interface name from VRFentry
* @param vpnName - VPN name of corresponding VRF
* @param tx - ReadWrite Tx
- * @throws ReadFailedException - Exception thrown in case of read failed
*/
private void handleAdjacencyAndVpnOpInterfaceDeletion(VrfEntry vrfEntry, String ifName, String vpnName,
- ReadWriteTransaction tx) throws ReadFailedException {
+ TypedReadWriteTransaction<Operational> tx)
+ throws ExecutionException, InterruptedException {
InstanceIdentifier<Adjacency> adjacencyIid =
FibUtil.getAdjacencyIdentifierOp(ifName, vpnName, vrfEntry.getDestPrefix());
- Optional<Adjacency> adjacencyOptional = tx.read(LogicalDatastoreType.OPERATIONAL, adjacencyIid).checkedGet();
+ Optional<Adjacency> adjacencyOptional = tx.read(adjacencyIid).get();
if (adjacencyOptional.isPresent()) {
if (adjacencyOptional.get().getAdjacencyType() != Adjacency.AdjacencyType.PrimaryAdjacency) {
- tx.delete(LogicalDatastoreType.OPERATIONAL,
- FibUtil.getAdjacencyIdentifierOp(ifName, vpnName, vrfEntry.getDestPrefix()));
+ tx.delete(FibUtil.getAdjacencyIdentifierOp(ifName, vpnName, vrfEntry.getDestPrefix()));
} else {
- tx.merge(LogicalDatastoreType.OPERATIONAL, adjacencyIid,
+ tx.merge(adjacencyIid,
new AdjacencyBuilder(adjacencyOptional.get()).setMarkedForDeletion(true).build());
}
}
- Optional<AdjacenciesOp> optAdjacencies =
- tx.read(LogicalDatastoreType.OPERATIONAL,
- FibUtil.getAdjListPathOp(ifName, vpnName)).checkedGet();
+ Optional<AdjacenciesOp> optAdjacencies = tx.read(FibUtil.getAdjListPathOp(ifName, vpnName)).get();
if (!optAdjacencies.isPresent() || optAdjacencies.get().getAdjacency() == null) {
return;
&& adjacency.isMarkedForDeletion()
)) {
LOG.info("Clean up vpn interface {} to vpn {} list.", ifName, vpnName);
- tx.delete(LogicalDatastoreType.OPERATIONAL,
- FibUtil.getVpnInterfaceOpDataEntryIdentifier(ifName, vpnName));
+ tx.delete(FibUtil.getVpnInterfaceOpDataEntryIdentifier(ifName, vpnName));
}
}
+ " with elantag {}", rd, vrfEntry.getDestPrefix(), elanTag);
if (vpnToDpnList != null) {
jobCoordinator.enqueueJob(FibUtil.getJobKeyForRdPrefix(rd, vrfEntry.getDestPrefix()),
- () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
- for (final VpnToDpnList curDpn : vpnToDpnList) {
-
- baseVrfEntryHandler.makeConnectedRoute(curDpn.getDpnId(), vpnInstance.getVpnId(), vrfEntry,
- vrfTableKey.getRouteDistinguisher(), null, NwConstants.DEL_FLOW, tx, null);
- if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
- optionalLabel.ifPresent(label -> makeLFibTableEntry(curDpn.getDpnId(), label, null,
+ () -> Collections.singletonList(
+ txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
+ for (final VpnToDpnList curDpn : vpnToDpnList) {
+
+ baseVrfEntryHandler.makeConnectedRoute(curDpn.getDpnId(), vpnInstance.getVpnId(),
+ vrfEntry, vrfTableKey.getRouteDistinguisher(), null, NwConstants.DEL_FLOW,
+ TransactionAdapter.toWriteTransaction(tx), null);
+ if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
+ optionalLabel.ifPresent(label -> makeLFibTableEntry(curDpn.getDpnId(), label, null,
DEFAULT_FIB_FLOW_PRIORITY, NwConstants.DEL_FLOW, tx));
- }
+ }
- installSubnetBroadcastAddrDropRule(curDpn.getDpnId(), rd, vpnInstance.getVpnId(),
+ installSubnetBroadcastAddrDropRule(curDpn.getDpnId(), rd, vpnInstance.getVpnId(),
vrfEntry, NwConstants.DEL_FLOW, tx);
- }
- })));
+ }
+ })));
}
optionalLabel.ifPresent(label -> {
synchronized (label.toString().intern()) {
}
jobCoordinator.enqueueJob(jobKey,
- () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+ () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
if (localDpnIdList.size() <= 0) {
for (VpnToDpnList curDpn : vpnToDpnList) {
baseVrfEntryHandler.deleteRemoteRoute(BigInteger.ZERO, curDpn.getDpnId(),
- vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, tx);
+ vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional,
+ TransactionAdapter.toWriteTransaction(tx));
}
} else {
for (BigInteger localDpnId : localDpnIdList) {
for (VpnToDpnList curDpn : vpnToDpnList) {
if (!curDpn.getDpnId().equals(localDpnId)) {
baseVrfEntryHandler.deleteRemoteRoute(localDpnId, curDpn.getDpnId(),
- vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, tx);
+ vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional,
+ TransactionAdapter.toWriteTransaction(tx));
}
}
}
}
private void makeLFibTableEntry(BigInteger dpId, long label, List<InstructionInfo> instructions, int priority,
- int addOrRemove, WriteTransaction tx) {
+ int addOrRemove, TypedWriteTransaction<Configuration> tx) {
if (tx == null) {
- ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
+ ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
newTx -> makeLFibTableEntry(dpId, label, instructions, priority, addOrRemove, newTx)), LOG,
"Error making LFIB table entry");
return;
.child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
if (addOrRemove == NwConstants.ADD_FLOW) {
- tx.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow, WriteTransaction.CREATE_MISSING_PARENTS);
+ tx.put(flowInstanceId, flow, CREATE_MISSING_PARENTS);
} else {
- tx.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
+ tx.delete(flowInstanceId);
}
LOG.debug("LFIB Entry for dpID {} : label : {} instructions {} : key {} {} successfully",
return futures;
}
synchronized (vpnInstance.getVpnInstanceName().intern()) {
- futures.add(retryingTxRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
+ futures.add(retryingTxRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> {
for (final VrfEntry vrfEntry : vrfTable.get().getVrfEntry()) {
SubnetRoute subnetRoute = vrfEntry.augmentation(SubnetRoute.class);
if (subnetRoute != null) {
if (RouteOrigin.BGP.getValue().equals(vrfEntry.getOrigin())) {
List<SubTransaction> txnObjects = new ArrayList<>();
bgpRouteVrfEntryHandler.createRemoteFibEntry(dpnId, vpnId,
- vrfTable.get().getRouteDistinguisher(), vrfEntry, tx, txnObjects);
+ vrfTable.get().getRouteDistinguisher(), vrfEntry,
+ TransactionAdapter.toWriteTransaction(tx), txnObjects);
} else {
createRemoteFibEntry(dpnId, vpnId, vrfTable.get().getRouteDistinguisher(),
vrfEntry, tx);
final Optional<VrfTables> vrfTable = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
if (vrfTable.isPresent()) {
jobCoordinator.enqueueJob(FibUtil.getJobKeyForVpnIdDpnId(vpnId, dpnId),
- () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+ () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
synchronized (vpnInstance.getVpnInstanceName().intern()) {
vrfTable.get().getVrfEntry().stream()
- .filter(vrfEntry -> RouteOrigin.BGP == RouteOrigin.value(vrfEntry.getOrigin()))
- .forEach(bgpRouteVrfEntryHandler.getConsumerForCreatingRemoteFib(dpnId, vpnId,
- rd, remoteNextHopIp, vrfTable, tx, txnObjects));
+ .filter(vrfEntry -> RouteOrigin.BGP == RouteOrigin.value(vrfEntry.getOrigin()))
+ .forEach(bgpRouteVrfEntryHandler.getConsumerForCreatingRemoteFib(dpnId, vpnId,
+ rd, remoteNextHopIp, vrfTable, TransactionAdapter.toWriteTransaction(tx), txnObjects));
}
})));
}
}
jobCoordinator.enqueueJob(FibUtil.getJobKeyForVpnIdDpnId(vpnId, localDpnId),
- () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+ () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
synchronized (vpnInstance.getVpnInstanceName().intern()) {
VrfTablesKey vrfTablesKey = new VrfTablesKey(rd);
VrfEntry vrfEntry = getVrfEntry(dataBroker, rd, destPrefix);
usedRds.get(0), vrfEntry.getDestPrefix());
}
baseVrfEntryHandler.deleteRemoteRoute(null, localDpnId, vpnId, vrfTablesKey, modVrfEntry,
- extraRouteOptional, tx);
+ extraRouteOptional, TransactionAdapter.toWriteTransaction(tx));
}
}
})));
List<ListenableFuture<Void>> futures = new ArrayList<>();
if (vrfTable.isPresent()) {
synchronized (vpnInstance.getVpnInstanceName().intern()) {
- futures.add(retryingTxRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+ futures.add(retryingTxRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
String vpnName = fibUtil.getVpnNameFromId(vpnInstance.getVpnId());
for (final VrfEntry vrfEntry : vrfTable.get().getVrfEntry()) {
/* Handle subnet routes here */
LOG.trace("SUBNETROUTE: cleanUpDpnForVpn: Cleaning subnetroute {} on dpn {}"
+ " for vpn {}", vrfEntry.getDestPrefix(), dpnId, rd);
baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, null,
- NwConstants.DEL_FLOW, tx, null);
+ NwConstants.DEL_FLOW, TransactionAdapter.toWriteTransaction(tx), null);
List<RoutePaths> routePaths = vrfEntry.getRoutePaths();
if (routePaths != null) {
for (RoutePaths routePath : routePaths) {
}
if (RouteOrigin.BGP.getValue().equals(vrfEntry.getOrigin())) {
bgpRouteVrfEntryHandler.deleteRemoteRoute(null, dpnId, vpnId,
- vrfTable.get().key(), vrfEntry, extraRouteOptional, tx, txnObjects);
+ vrfTable.get().key(), vrfEntry, extraRouteOptional,
+ TransactionAdapter.toWriteTransaction(tx), txnObjects);
} else {
if (subnetRoute == null || !fibUtil
.isInterfacePresentInDpn(vrfEntry.getParentVpnRd(), dpnId)) {
baseVrfEntryHandler.deleteRemoteRoute(null, dpnId, vpnId,
- vrfTable.get().key(), vrfEntry, extraRouteOptional, tx);
+ vrfTable.get().key(), vrfEntry, extraRouteOptional,
+ TransactionAdapter.toWriteTransaction(tx));
}
}
}
jobCoordinator.enqueueJob(FibUtil.getJobKeyForVpnIdDpnId(vpnId, dpnId),
() -> {
synchronized (vpnInstance.getVpnInstanceName().intern()) {
- return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(
- tx -> vrfTable.get().getVrfEntry().stream()
+ return Collections.singletonList(
+ txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION,
+ tx -> vrfTable.get().getVrfEntry().stream()
.filter(vrfEntry -> RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.BGP)
.forEach(bgpRouteVrfEntryHandler.getConsumerForDeletingRemoteFib(dpnId, vpnId,
- remoteNextHopIp, vrfTable, tx, txnObjects))));
+ remoteNextHopIp, vrfTable, TransactionAdapter.toWriteTransaction(tx),
+ txnObjects))));
}
});
}
optLabel.ifPresent(label -> {
LOG.trace("Removing flow in FIB table for interVpnLink {}", interVpnLinkName);
- ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
+ ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
for (BigInteger dpId : targetDpns) {
LOG.debug("Removing flow: VrfEntry=[prefix={} label={}] dpn {} for InterVpnLink {} in LFIB",
vrfEntry.getDestPrefix(), label, dpId, interVpnLinkName);