Beispiel #1
0
  /** @inheritDoc */
  @SuppressWarnings("unchecked")
  @Override
  public void voteReceived(Vote vote) {
    if (vote.getVotePiggyBack().getPiggyback() == null) {
      /*
       * init transaction.
       */
      return;
    }

    try {

      PartitionDependenceVector<String> commitVC =
          (PartitionDependenceVector<String>) vote.getVotePiggyBack().getPiggyback();

      /*
       * Corresponds to line 19
       */

      PartitionDependenceVector<String> receivedVector =
          receivedVectors.putIfAbsent(vote.getTransactionHandler().getId(), commitVC);
      if (receivedVector != null) {
        receivedVector.update(commitVC);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Beispiel #2
0
  @Override
  public boolean transactionDeliveredForTermination(
      ConcurrentLinkedHashMap<UUID, Object> terminatedTransactions,
      ConcurrentHashMap<TransactionHandler, VotingQuorum> quorumes,
      TerminateTransactionRequestMessage msg) {
    try {
      if (msg.getExecutionHistory().getTransactionType() != TransactionType.INIT_TRANSACTION) {
        int seqNo = PartitionDependenceVector.lastCommitSeqNo.incrementAndGet();
        PartitionDependenceVector<String> vector = new PartitionDependenceVector<String>();
        for (JessyEntity entity : msg.getExecutionHistory().getReadSet().getEntities()) {
          vector.update(entity.getLocalVector());
        }
        vector.update(PartitionDependenceVector.lastCommit);
        vector.setSelfKey(manager.getMyGroup().name());
        vector.setValue(vector.getSelfKey(), seqNo);
        msg.setComputedObjectUponDelivery(vector);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    return true;
  }