/** @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(); } }
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()); }
@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()); } }
@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; }