Search in sources :

Example 26 with TransactionCommitFailedException

use of org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException in project controller by opendaylight.

the class DsbenchmarkProvider method cleanupTestStore.

private void cleanupTestStore() {
    TestExec data = new TestExecBuilder().setOuterList(Collections.<OuterList>emptyList()).build();
    WriteTransaction tx = simpleTxDataBroker.newWriteOnlyTransaction();
    tx.put(LogicalDatastoreType.CONFIGURATION, TEST_EXEC_IID, data);
    try {
        tx.submit().checkedGet();
        LOG.debug("DataStore config test data cleaned up");
    } catch (final TransactionCommitFailedException e) {
        LOG.info("Failed to cleanup DataStore configtest data");
        throw new IllegalStateException(e);
    }
    tx = simpleTxDataBroker.newWriteOnlyTransaction();
    tx.put(LogicalDatastoreType.OPERATIONAL, TEST_EXEC_IID, data);
    try {
        tx.submit().checkedGet();
        LOG.debug("DataStore operational test data cleaned up");
    } catch (final TransactionCommitFailedException e) {
        LOG.info("Failed to cleanup DataStore operational test data");
        throw new IllegalStateException(e);
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) TestExecBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExecBuilder) OuterList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList) TestExec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec)

Example 27 with TransactionCommitFailedException

use of org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException in project controller by opendaylight.

the class SimpletxBaWrite method executeList.

@Override
public void executeList() {
    final LogicalDatastoreType dsType = getDataStoreType();
    WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
    long writeCnt = 0;
    for (OuterList element : this.list) {
        InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class).child(OuterList.class, element.getKey());
        if (oper == StartTestInput.Operation.PUT) {
            tx.put(dsType, iid, element);
        } else {
            tx.merge(dsType, iid, element);
        }
        writeCnt++;
        if (writeCnt == writesPerTx) {
            try {
                tx.submit().checkedGet();
                txOk++;
            } catch (final TransactionCommitFailedException e) {
                LOG.error("Transaction failed: {}", e);
                txError++;
            }
            tx = dataBroker.newWriteOnlyTransaction();
            writeCnt = 0;
        }
    }
    if (writeCnt != 0) {
        try {
            tx.submit().checkedGet();
        } catch (final TransactionCommitFailedException e) {
            LOG.error("Transaction failed: {}", e);
        }
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) OuterList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList) TestExec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)

Example 28 with TransactionCommitFailedException

use of org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException in project controller by opendaylight.

the class TxchainBaWrite method executeList.

@Override
public void executeList() {
    final BindingTransactionChain chain = bindingDataBroker.createTransactionChain(this);
    final LogicalDatastoreType dsType = getDataStoreType();
    WriteTransaction tx = chain.newWriteOnlyTransaction();
    int txSubmitted = 0;
    int writeCnt = 0;
    for (OuterList element : this.list) {
        InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class).child(OuterList.class, element.getKey());
        if (oper == StartTestInput.Operation.PUT) {
            tx.put(dsType, iid, element);
        } else {
            tx.merge(dsType, iid, element);
        }
        writeCnt++;
        if (writeCnt == writesPerTx) {
            txSubmitted++;
            Futures.addCallback(tx.submit(), new FutureCallback<Void>() {

                @Override
                public void onSuccess(final Void result) {
                    txOk++;
                }

                @Override
                public void onFailure(final Throwable t) {
                    LOG.error("Transaction failed, {}", t);
                    txError++;
                }
            });
            tx = chain.newWriteOnlyTransaction();
            writeCnt = 0;
        }
    }
    // We need to empty the transaction chain before closing it
    try {
        txSubmitted++;
        tx.submit().checkedGet();
        txOk++;
    } catch (final TransactionCommitFailedException e) {
        LOG.error("Transaction failed", e);
        txError++;
    }
    try {
        chain.close();
    } catch (final IllegalStateException e) {
        LOG.error("Transaction close failed,", e);
    }
    LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError));
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) BindingTransactionChain(org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain) OuterList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) TestExec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)

Example 29 with TransactionCommitFailedException

use of org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException in project controller by opendaylight.

the class TxchainDomWrite method executeList.

@Override
public void executeList() {
    final LogicalDatastoreType dsType = getDataStoreType();
    final YangInstanceIdentifier pid = YangInstanceIdentifier.builder().node(TestExec.QNAME).node(OuterList.QNAME).build();
    final DOMTransactionChain chain = domDataBroker.createTransactionChain(this);
    DOMDataWriteTransaction tx = chain.newWriteOnlyTransaction();
    int txSubmitted = 0;
    int writeCnt = 0;
    for (MapEntryNode element : this.list) {
        YangInstanceIdentifier yid = pid.node(new NodeIdentifierWithPredicates(OuterList.QNAME, element.getIdentifier().getKeyValues()));
        if (oper == StartTestInput.Operation.PUT) {
            tx.put(dsType, yid, element);
        } else {
            tx.merge(dsType, yid, element);
        }
        writeCnt++;
        // Start performing the operation; submit the transaction at every n-th operation
        if (writeCnt == writesPerTx) {
            txSubmitted++;
            Futures.addCallback(tx.submit(), new FutureCallback<Void>() {

                @Override
                public void onSuccess(final Void result) {
                    txOk++;
                }

                @Override
                public void onFailure(final Throwable t) {
                    LOG.error("Transaction failed, {}", t);
                    txError++;
                }
            });
            tx = chain.newWriteOnlyTransaction();
            writeCnt = 0;
        }
    }
    try {
        txSubmitted++;
        tx.submit().checkedGet();
        txOk++;
    } catch (final TransactionCommitFailedException e) {
        LOG.error("Transaction failed", e);
        txError++;
    }
    try {
        chain.close();
    } catch (final IllegalStateException e) {
        LOG.error("Transaction close failed,", e);
    }
    LOG.debug("Transactions: submitted {}, completed {}", txSubmitted, (txOk + txError));
}
Also used : DOMTransactionChain(org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)

Example 30 with TransactionCommitFailedException

use of org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException in project controller by opendaylight.

the class DOMForwardedWriteTransaction method submit.

@Override
@SuppressWarnings("checkstyle:illegalcatch")
public CheckedFuture<Void, TransactionCommitFailedException> submit() {
    final AbstractDOMForwardedTransactionFactory<?> impl = IMPL_UPDATER.getAndSet(this, null);
    checkRunning(impl);
    final Collection<T> txns = getSubtransactions();
    final Collection<DOMStoreThreePhaseCommitCohort> cohorts = new ArrayList<>(txns.size());
    CheckedFuture<Void, TransactionCommitFailedException> ret;
    try {
        for (DOMStoreWriteTransaction txn : txns) {
            cohorts.add(txn.ready());
        }
        ret = impl.submit(this, cohorts);
    } catch (RuntimeException e) {
        ret = Futures.immediateFailedCheckedFuture(TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER.apply(e));
    }
    FUTURE_UPDATER.lazySet(this, ret);
    return ret;
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) DOMStoreWriteTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction) ArrayList(java.util.ArrayList) DOMStoreThreePhaseCommitCohort(org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort)

Aggregations

TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)117 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)32 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)23 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)21 Test (org.junit.Test)19 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)16 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)13 ArrayList (java.util.ArrayList)12 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)12 DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)11 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)9 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)9 OptimisticLockFailedException (org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException)8 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)8 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)8 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)7 Optional (com.google.common.base.Optional)6 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)6 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)6 ExternalNetworks (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ExternalNetworks)6