() {
+ @Override
+ public void onComplete(Throwable failure, ActorSelection primaryShard) {
+ if(failure != null) {
+ newTxFutureCallback.onComplete(failure, null);
+ } else {
+ newTxFutureCallback.setPrimaryShard(primaryShard);
+ }
}
- };
-
- return MappingCheckedFuture.create(executor.submit(call), ReadFailedException.MAPPER);
+ }, actorContext.getActorSystem().dispatcher());
}
- @Override public void writeData(YangInstanceIdentifier path, NormalizedNode, ?> data) {
- getActor().tell(new WriteData(path, data, schemaContext).toSerializable(), null);
- }
+ return txFutureCallback;
+ }
+ public String getTransactionChainId() {
+ return transactionChainId;
}
- private class NoOpTransactionContext implements TransactionContext {
+ protected ActorContext getActorContext() {
+ return actorContext;
+ }
- private final Logger
- LOG = LoggerFactory.getLogger(NoOpTransactionContext.class);
+ /**
+ * Interfaces for transaction operations to be invoked later.
+ */
+ private static interface TransactionOperation {
+ void invoke(TransactionContext transactionContext);
+ }
- private final String shardName;
+ /**
+ * Implements a Future OnComplete callback for a CreateTransaction message. This class handles
+ * retries, up to a limit, if the shard doesn't have a leader yet. This is done by scheduling a
+ * retry task after a short delay.
+ *
+ * The end result from a completed CreateTransaction message is a TransactionContext that is
+ * used to perform transaction operations. Transaction operations that occur before the
+ * CreateTransaction completes are cache and executed once the CreateTransaction completes,
+ * successfully or not.
+ */
+ private class TransactionFutureCallback extends OnComplete