use of org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain 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.binding.api.BindingTransactionChain in project bgpcep by opendaylight.
the class RIBImpl method onTransactionChainFailed.
@Override
public synchronized void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction, final Throwable cause) {
LOG.error("Broken chain in RIB {} transaction {}", getInstanceIdentifier(), transaction != null ? transaction.getIdentifier() : null, cause);
if (this.txChainToLocRibWriter.containsKey(chain)) {
final LocRibWriter locRibWriter = this.txChainToLocRibWriter.remove(chain);
final BindingTransactionChain newChain = createPeerChain(this);
startLocRib(locRibWriter.getTableKey());
locRibWriter.restart(newChain);
this.txChainToLocRibWriter.put(newChain, locRibWriter);
}
}
use of org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain in project openflowplugin by opendaylight.
the class FlowWriterTxChainTest method setUp.
@Before
public void setUp() throws Exception {
Mockito.doAnswer(invocation -> {
((Runnable) invocation.getArguments()[0]).run();
return null;
}).when(mockFlowPusher).execute(Matchers.<Runnable>any());
final BindingTransactionChain mockedTxChain = mock(BindingTransactionChain.class);
when(mockedTxChain.newWriteOnlyTransaction()).thenReturn(writeTransaction);
doReturn(mockedTxChain).when(mockDataBroker).createTransactionChain(Matchers.<TransactionChainListener>any());
when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null));
flowWriterTxChain = new FlowWriterTxChain(mockDataBroker, mockFlowPusher);
}
use of org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain in project controller by opendaylight.
the class TxchainBaDelete method executeList.
@Override
public void executeList() {
final LogicalDatastoreType dsType = getDataStoreType();
final BindingTransactionChain chain = bindingDataBroker.createTransactionChain(this);
WriteTransaction tx = chain.newWriteOnlyTransaction();
int txSubmitted = 0;
int writeCnt = 0;
for (int l = 0; l < outerListElem; l++) {
InstanceIdentifier<OuterList> iid = InstanceIdentifier.create(TestExec.class).child(OuterList.class, new OuterListKey(l));
tx.delete(dsType, iid);
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 chain before closing it
try {
if (writeCnt > 0) {
txSubmitted++;
}
tx.submit().checkedGet();
} catch (final TransactionCommitFailedException e) {
LOG.error("Transaction failed", e);
}
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.binding.api.BindingTransactionChain in project bgpcep by opendaylight.
the class RIBImpl method createLocRibWriter.
private synchronized void createLocRibWriter(final TablesKey key) {
final RIBSupport ribSupport = this.ribContextRegistry.getRIBSupport(key);
if (ribSupport == null) {
return;
}
LOG.debug("Creating LocRIB writer for key {}", key);
final BindingTransactionChain txChain = createPeerChain(this);
PathSelectionMode pathSelectionStrategy = this.bestPathSelectionStrategies.get(key);
if (pathSelectionStrategy == null) {
pathSelectionStrategy = BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker);
}
final LocRibWriter locRibWriter = LocRibWriter.create(ribSupport, key, txChain, getInstanceIdentifier(), this.localAs, getDataBroker(), this.ribPolicies, this.peerTracker, pathSelectionStrategy);
registerTotalPathCounter(key, locRibWriter);
registerTotalPrefixesCounter(key, locRibWriter);
this.txChainToLocRibWriter.put(txChain, locRibWriter);
}
Aggregations