Exemplo n.º 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();
    }
  }
Exemplo n.º 2
0
  public void postCommit(ExecutionHistory executionHistory) {
    if (executionHistory.getTransactionType() != TransactionType.INIT_TRANSACTION) {
      PartitionDependenceVector<String> commitVC =
          receivedVectors.get(executionHistory.getTransactionHandler().getId());

      PartitionDependenceVector.lastCommit = commitVC.clone();
    }

    /*
     * Garbage collect the received vectors. We don't need them anymore.
     */
    if (receivedVectors.containsKey(executionHistory.getTransactionHandler().getId()))
      receivedVectors.remove(executionHistory.getTransactionHandler().getId());
  }
Exemplo n.º 3
0
  @Override
  public void prepareToCommit(TerminateTransactionRequestMessage msg) {
    ExecutionHistory executionHistory = msg.getExecutionHistory();

    PartitionDependenceVector<String> commitVC =
        receivedVectors.get(executionHistory.getTransactionHandler().getId());

    /*
     * Assigning commitVC to the entities
     */
    for (JessyEntity entity : executionHistory.getWriteSet().getEntities()) {
      entity.setLocalVector(commitVC.clone());
      entity.temporaryObject = null;
      entity.getLocalVector().setSelfKey(manager.getMyGroup().name());
    }
  }
Exemplo n.º 4
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;
  }