use of org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction in project controller by opendaylight.
the class LegacyDOMDataBrokerAdapter method createTransactionChain.
@Override
public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
AtomicReference<DOMTransactionChain> legacyChain = new AtomicReference<>();
org.opendaylight.mdsal.common.api.TransactionChainListener delegateListener = new org.opendaylight.mdsal.common.api.TransactionChainListener() {
@SuppressWarnings("rawtypes")
@Override
public void onTransactionChainFailed(final org.opendaylight.mdsal.common.api.TransactionChain<?, ?> chain, final org.opendaylight.mdsal.common.api.AsyncTransaction<?, ?> transaction, final Throwable cause) {
listener.onTransactionChainFailed(legacyChain.get(), (AsyncTransaction) () -> transaction.getIdentifier(), cause instanceof Exception ? SUBMIT_EX_MAPPER.apply((Exception) cause) : cause);
}
@Override
public void onTransactionChainSuccessful(org.opendaylight.mdsal.common.api.TransactionChain<?, ?> chain) {
listener.onTransactionChainSuccessful(legacyChain.get());
}
};
final org.opendaylight.mdsal.dom.api.DOMTransactionChain delegateChain = delegate().createTransactionChain(delegateListener);
legacyChain.set(new DOMTransactionChain() {
@Override
public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
return new DOMDataReadOnlyTransactionAdapter(delegateChain.newReadOnlyTransaction());
}
@Override
public DOMDataReadWriteTransaction newReadWriteTransaction() {
return new DOMDataTransactionAdapter(delegateChain.newReadWriteTransaction());
}
@Override
public DOMDataWriteTransaction newWriteOnlyTransaction() {
return new DOMDataTransactionAdapter(delegateChain.newWriteOnlyTransaction());
}
@Override
public void close() {
delegateChain.close();
}
});
return legacyChain.get();
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction in project controller by opendaylight.
the class AbstractInMemoryBrokerWriteTransactionBenchmark method write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark.
@Benchmark
@Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
public void write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark() throws Exception {
for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_10K_PATHS[outerListKey], OUTER_LIST_TEN_ITEM_INNER_LIST[outerListKey]);
writeTx.submit().get();
}
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction in project controller by opendaylight.
the class AbstractInMemoryBrokerWriteTransactionBenchmark method write100KSingleNodeWithOneInnerItemInCommitPerWriteBenchmark.
@Benchmark
@Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
public void write100KSingleNodeWithOneInnerItemInCommitPerWriteBenchmark() throws Exception {
for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
DOMDataReadWriteTransaction writeTx = domBroker.newReadWriteTransaction();
writeTx.put(LogicalDatastoreType.OPERATIONAL, OUTER_LIST_100K_PATHS[outerListKey], OUTER_LIST_ONE_ITEM_INNER_LIST[outerListKey]);
writeTx.submit().get();
}
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction in project controller by opendaylight.
the class DOMTransactionChainTest method allocateAndDelete.
private static DOMDataReadWriteTransaction allocateAndDelete(final DOMTransactionChain txChain) throws InterruptedException, ExecutionException {
DOMDataReadWriteTransaction tx = txChain.newReadWriteTransaction();
/**
* We test existence of /test in third transaction container should
* still be visible from first one (which is still uncommmited).
*/
assertTestContainerExists(tx);
/**
* We delete node in third transaction
*/
tx.delete(LogicalDatastoreType.OPERATIONAL, TestModel.TEST_PATH);
return tx;
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction in project controller by opendaylight.
the class DOMBrokerPerformanceTest method measureOneTransactionTopContainer.
private void measureOneTransactionTopContainer() throws Exception {
final DOMDataReadWriteTransaction writeTx = measure("Txs:1 Allocate", () -> domBroker.newReadWriteTransaction());
measure("Txs:1 Write", (Callable<Void>) () -> {
writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
writeTx.put(OPERATIONAL, TestModel.OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build());
return null;
});
measure("Txs:1 Reads:1", (Callable<Void>) () -> {
// Reads /test in writeTx
ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(OPERATIONAL, TestModel.TEST_PATH);
assertTrue(writeTxContainer.get().isPresent());
return null;
});
measure("Txs:1 Reads:1", (Callable<Void>) () -> {
// Reads /test in writeTx
ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(OPERATIONAL, TestModel.TEST_PATH);
assertTrue(writeTxContainer.get().isPresent());
return null;
});
measure("Txs:1 Submit, Finish", (Callable<Void>) () -> {
measure("Txs:1 Submit", (Callable<ListenableFuture<?>>) () -> writeTx.submit()).get();
return null;
});
}
Aggregations