use of org.opendaylight.mdsal.binding.util.TypedReadWriteTransaction in project netvirt by opendaylight.
the class MergeCommandsAggregator method mergeUpdate.
@SuppressWarnings("illegalcatch")
public <D extends Datastore> void mergeUpdate(InstanceIdentifier<Node> dstPath, DataObjectModification mod, Class<D> datastoreType, TypedReadWriteTransaction<D> transaction, ManagedNewTransactionRunner txRunner) {
BatchedTransaction tx = null;
if (mod == null || mod.getModifiedChildren() == null) {
return;
}
if (!(transaction instanceof BatchedTransaction)) {
return;
} else {
tx = (BatchedTransaction) transaction;
}
final BatchedTransaction transaction1 = tx;
String srcNodeId = transaction1.getSrcNodeId().getValue();
String dstNodeId = dstPath.firstKeyOf(Node.class).getNodeId().getValue();
Collection<DataObjectModification> modifications = mod.getModifiedChildren();
modifications.stream().filter(modification -> skipCopy.negate().test(datastoreType, modification.getDataType())).filter(modification -> commands.get(modification.getDataType()) != null).peek(modification -> LOG.debug("Received {} modification {} copy/delete to {}", datastoreType, modification, dstPath)).forEach(modification -> {
try {
copyModification(dstPath, datastoreType, transaction1, srcNodeId, dstNodeId, modification, txRunner);
} catch (Exception e) {
LOG.error("Failed to copy mod from {} to {} {} {} id {}", srcNodeId, dstNodeId, modification.getDataType().getSimpleName(), modification, modification.getIdentifier(), e);
}
});
}
use of org.opendaylight.mdsal.binding.util.TypedReadWriteTransaction in project netvirt by opendaylight.
the class FloatingIPListener method addOrDelDefaultFibRouteForDnat.
private void addOrDelDefaultFibRouteForDnat(Uint64 dpnId, String routerName, Uint32 routerId, @Nullable TypedReadWriteTransaction<Configuration> confTx, boolean create) throws ExecutionException, InterruptedException {
if (confTx == null) {
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, newTx -> addOrDelDefaultFibRouteForDnat(dpnId, routerName, routerId, newTx, create)), LOG, "Error handling default FIB route for DNAT");
return;
}
// Check if the router to bgp-vpn association is present
Uint32 associatedVpnId = NatConstants.INVALID_ID;
Uuid associatedVpn = NatUtil.getVpnForRouter(dataBroker, routerName);
if (associatedVpn != null) {
associatedVpnId = NatUtil.getVpnId(dataBroker, associatedVpn.getValue());
}
if (create) {
if (associatedVpnId != NatConstants.INVALID_ID) {
LOG.debug("addOrDelDefaultFibRouteForDnat: Install NAT default route on DPN {} for the router {} with " + "vpn-id {}", dpnId, routerName, associatedVpnId);
defaultRouteProgrammer.installDefNATRouteInDPN(dpnId, associatedVpnId, routerId, confTx);
} else {
LOG.debug("addOrDelDefaultFibRouteForDnat: Install NAT default route on DPN {} for the router {} with " + "vpn-id {}", dpnId, routerName, routerId);
defaultRouteProgrammer.installDefNATRouteInDPN(dpnId, routerId, confTx);
}
} else {
if (associatedVpnId != NatConstants.INVALID_ID) {
LOG.debug("addOrDelDefaultFibRouteForDnat: Remove NAT default route on DPN {} for the router {} " + "with vpn-id {}", dpnId, routerName, associatedVpnId);
defaultRouteProgrammer.removeDefNATRouteInDPN(dpnId, associatedVpnId, routerId, confTx);
} else {
LOG.debug("addOrDelDefaultFibRouteForDnat: Remove NAT default route on DPN {} for the router {} " + "with vpn-id {}", dpnId, routerName, routerId);
defaultRouteProgrammer.removeDefNATRouteInDPN(dpnId, routerId, confTx);
}
}
}
Aggregations