Search in sources :

Example 36 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class EvpnVrfEntryHandler method checkDeleteLocalEvpnFLows.

private List<BigInteger> checkDeleteLocalEvpnFLows(long vpnId, String rd, VrfEntry vrfEntry, VpnNexthop localNextHopInfo) {
    List<BigInteger> returnLocalDpnId = new ArrayList<>();
    if (localNextHopInfo == null) {
    // Handle extra routes and imported routes
    } else {
        final BigInteger dpnId = localNextHopInfo.getDpnId();
        jobCoordinator.enqueueJob("FIB-" + rd + "-" + vrfEntry.getDestPrefix(), () -> {
            WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
            makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, null, NwConstants.DEL_FLOW, tx, null);
            List<ListenableFuture<Void>> futures = new ArrayList<>();
            futures.add(tx.submit());
            return futures;
        });
        // TODO: verify below adjacency call need to be optimized (?)
        deleteLocalAdjacency(dpnId, vpnId, vrfEntry.getDestPrefix(), vrfEntry.getDestPrefix());
        returnLocalDpnId.add(dpnId);
    }
    return returnLocalDpnId;
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 37 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class TestUtil method updateNode.

static void updateNode(LogicalDatastoreType datastoreType, InstanceIdentifier<Node> id, Node node, DataBroker dataBroker) throws Exception {
    WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
    transaction.merge(datastoreType, id, node, WriteTransaction.CREATE_MISSING_PARENTS);
    transaction.submit();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)

Example 38 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class VpnUtil method syncWrite.

public static <T extends DataObject> void syncWrite(DataBroker broker, LogicalDatastoreType datastoreType, InstanceIdentifier<T> path, T data) {
    WriteTransaction tx = broker.newWriteOnlyTransaction();
    tx.put(datastoreType, path, data, WriteTransaction.CREATE_MISSING_PARENTS);
    try {
        tx.submit().get();
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("syncWrite: Error writing to datastore (path, data) : ({}, {})", path, data);
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ExecutionException(java.util.concurrent.ExecutionException)

Example 39 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class VpnUtil method removeVrfEntries.

public static void removeVrfEntries(DataBroker broker, String rd, List<VrfEntry> vrfEntries) {
    InstanceIdentifier<VrfTables> vpnVrfTableIid = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).build();
    WriteTransaction tx = broker.newWriteOnlyTransaction();
    for (VrfEntry vrfEntry : vrfEntries) {
        tx.delete(LogicalDatastoreType.CONFIGURATION, vpnVrfTableIid.child(VrfEntry.class, vrfEntry.getKey()));
    }
    tx.submit();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) VrfTablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey) VrfEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry) VrfTables(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables)

Example 40 with WriteTransaction

use of org.opendaylight.controller.md.sal.binding.api.WriteTransaction in project netvirt by opendaylight.

the class VpnUtil method asyncUpdate.

public static <T extends DataObject> void asyncUpdate(DataBroker broker, LogicalDatastoreType datastoreType, InstanceIdentifier<T> path, T data, FutureCallback<Void> callback) {
    WriteTransaction tx = broker.newWriteOnlyTransaction();
    tx.merge(datastoreType, path, data, true);
    Futures.addCallback(tx.submit(), callback, MoreExecutors.directExecutor());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction)

Aggregations

WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)320 ArrayList (java.util.ArrayList)74 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)60 BigInteger (java.math.BigInteger)43 Test (org.junit.Test)38 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)37 ExecutionException (java.util.concurrent.ExecutionException)33 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)28 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)25 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)23 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)23 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)22 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)19 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)17 List (java.util.List)16 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)16 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)16 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)15 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)14 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)14