Search in sources :

Example 71 with WriteTransaction

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

the class PolicyRouteGroupProgrammer method programPolicyClassifierGroups.

public void programPolicyClassifierGroups(String policyClassifier, BigInteger dpId, List<TunnelInterface> tunnelInterfaces, int addOrRemove) {
    if (tunnelInterfaces == null) {
        LOG.debug("No tunnel interfaces found for policy classifier {} DPN {}", policyClassifier, dpId);
        return;
    }
    coordinator.enqueueJob(policyClassifier, () -> {
        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
        tunnelInterfaces.forEach(tunnelInterface -> {
            BigInteger remoteDpId = tunnelInterface.getRemoteDpId();
            programPolicyClassifierGroups(policyClassifier, Collections.singletonList(dpId), remoteDpId, tx, addOrRemove);
        });
        return Collections.singletonList(tx.submit());
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) BigInteger(java.math.BigInteger)

Example 72 with WriteTransaction

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

the class PolicyNodeListener method add.

@Override
protected void add(InstanceIdentifier<FlowCapableNode> key, FlowCapableNode flowCapableNode) {
    BigInteger dpId = MDSALUtil.getDpnIdFromNodeName(key.firstKeyOf(Node.class).getId());
    WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
    createTableMissFlow(dpId, NwConstants.EGRESS_POLICY_CLASSIFIER_TABLE, NwConstants.EGRESS_POLICY_CLASSIFIER_COOKIE, tx);
    createTableMissFlow(dpId, NwConstants.EGRESS_POLICY_ROUTING_TABLE, NwConstants.EGRESS_POLICY_ROUTING_COOKIE, tx);
    tx.submit();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) BigInteger(java.math.BigInteger)

Example 73 with WriteTransaction

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

the class EventSourceTopology method deleteData.

private <T extends DataObject> void deleteData(final LogicalDatastoreType store, final InstanceIdentifier<T> path) {
    final WriteTransaction tx = getDataBroker().newWriteOnlyTransaction();
    tx.delete(OPERATIONAL, path);
    Futures.addCallback(tx.submit(), new FutureCallback<Void>() {

        @Override
        public void onSuccess(final Void result) {
            LOG.trace("Data has deleted from datastore {} {}", store, path);
        }

        @Override
        public void onFailure(final Throwable ex) {
            LOG.error("Can not delete data from datastore [store: {}] [path: {}] [exception: {}]", store, path, ex);
        }
    }, MoreExecutors.directExecutor());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction)

Example 74 with WriteTransaction

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

the class EventSourceTopology method putData.

private <T extends DataObject> void putData(final LogicalDatastoreType store, final InstanceIdentifier<T> path, final T data) {
    final WriteTransaction tx = getDataBroker().newWriteOnlyTransaction();
    tx.put(store, path, data, true);
    Futures.addCallback(tx.submit(), new FutureCallback<Void>() {

        @Override
        public void onSuccess(final Void result) {
            LOG.trace("Data has put into datastore {} {}", store, path);
        }

        @Override
        public void onFailure(final Throwable ex) {
            LOG.error("Can not put data into datastore [store: {}] [path: {}] [exception: {}]", store, path, ex);
        }
    }, MoreExecutors.directExecutor());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction)

Example 75 with WriteTransaction

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

the class DsbenchmarkProvider method setTestOperData.

private void setTestOperData(final ExecStatus sts, final long tstCompl) {
    TestStatus status = new TestStatusBuilder().setExecStatus(sts).setTestsCompleted(tstCompl).build();
    WriteTransaction tx = simpleTxDataBroker.newWriteOnlyTransaction();
    tx.put(LogicalDatastoreType.OPERATIONAL, TEST_STATUS_IID, status);
    try {
        tx.submit().checkedGet();
    } catch (final TransactionCommitFailedException e) {
        throw new IllegalStateException(e);
    }
    LOG.debug("DataStore test oper status populated: {}", status);
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) TestStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestStatus) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) TestStatusBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestStatusBuilder)

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