use of org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.ProduceTransactionsOutput in project controller by opendaylight.
the class ProduceTransactionsHandler method runSuccessful.
@Override
void runSuccessful(final long allTx) {
closeProducer(itemProducer);
final ProduceTransactionsOutput output = new ProduceTransactionsOutputBuilder().setAllTx(allTx).setInsertTx(insertTx).setDeleteTx(deleteTx).build();
future.set(RpcResultBuilder.<ProduceTransactionsOutput>success().withResult(output).build());
}
use of org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.ProduceTransactionsOutput in project controller by opendaylight.
the class ProduceTransactionsHandler method start.
public static ListenableFuture<RpcResult<ProduceTransactionsOutput>> start(final DOMDataTreeService domDataTreeService, final ProduceTransactionsInput input) {
final String id = input.getId();
LOG.debug("Filling the item list {} with initial values.", id);
final YangInstanceIdentifier idListWithKey = ID_INT_YID.node(new NodeIdentifierWithPredicates(ID_INT, ID, id));
final DOMDataTreeProducer itemProducer = domDataTreeService.createProducer(Collections.singleton(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, idListWithKey)));
final DOMDataTreeCursorAwareTransaction tx = itemProducer.createTransaction(false);
final DOMDataTreeWriteCursor cursor = tx.createCursor(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, idListWithKey));
final MapNode list = ImmutableNodes.mapNodeBuilder(ITEM).build();
cursor.write(list.getIdentifier(), list);
cursor.close();
try {
tx.submit().get(INIT_TX_TIMEOUT_SECONDS, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOG.warn("Unable to fill the initial item list.", e);
closeProducer(itemProducer);
return Futures.immediateFuture(RpcResultBuilder.<ProduceTransactionsOutput>failed().withError(RpcError.ErrorType.APPLICATION, "Unexpected-exception", e).build());
}
final ProduceTransactionsHandler handler = new ProduceTransactionsHandler(itemProducer, new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, idListWithKey.node(list.getIdentifier()).toOptimized()), input);
// It is handler's responsibility to close itemProducer when the work is finished.
handler.doStart();
return handler.future;
}
Aggregations