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);
}
}
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);
}
}
}
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));
}
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));
}
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;
}
Aggregations