+ public enum TransactionType {
+ READ_ONLY,
+ WRITE_ONLY,
+ READ_WRITE
+ }
+
+ private static final AtomicLong counter = new AtomicLong();
+
+ private final TransactionType transactionType;
+ private final ActorContext actorContext;
+ private final Map<String, ActorSelection> remoteTransactionPaths = new HashMap<>();
+ private final String identifier;
+ private final ExecutorService executor;
+
+ public TransactionProxy(
+ ActorContext actorContext,
+ TransactionType transactionType,
+ ExecutorService executor
+ ) {
+
+ this.identifier = "txn-" + counter.getAndIncrement();
+ this.transactionType = transactionType;
+ this.actorContext = actorContext;
+ this.executor = executor;
+
+ Object response = actorContext.executeShardOperation(Shard.DEFAULT_NAME, new CreateTransaction(identifier), ActorContext.ASK_DURATION);
+ if(response instanceof CreateTransactionReply){
+ CreateTransactionReply reply = (CreateTransactionReply) response;
+ remoteTransactionPaths.put(Shard.DEFAULT_NAME, actorContext.actorSelection(reply.getTransactionPath()));
+ }
+ }
+