示例#1
0
  private void createTransaction(CreateTransaction createTransaction) {
    try {
      if (TransactionType.fromInt(createTransaction.getTransactionType())
              != TransactionType.READ_ONLY
          && failIfIsolatedLeader(getSender())) {
        return;
      }

      ActorRef transactionActor =
          createTransaction(
              createTransaction.getTransactionType(),
              createTransaction.getTransactionId(),
              createTransaction.getTransactionChainId(),
              createTransaction.getVersion());

      getSender()
          .tell(
              new CreateTransactionReply(
                      Serialization.serializedActorPath(transactionActor),
                      createTransaction.getTransactionId())
                  .toSerializable(),
              getSelf());
    } catch (Exception e) {
      getSender().tell(new akka.actor.Status.Failure(e), getSelf());
    }
  }
示例#2
0
 private void handleCreateTransaction(final Object message) {
   if (isLeader()) {
     createTransaction(CreateTransaction.fromSerializable(message));
   } else if (getLeader() != null) {
     getLeader().forward(message, getContext());
   } else {
     getSender()
         .tell(
             new akka.actor.Status.Failure(
                 new NoShardLeaderException(
                     "Could not create a shard transaction", persistenceId())),
             getSelf());
   }
 }