@Test public void test_on_any_not_yes_voted() throws Exception { when(part1.onRPC(eq("tx_rpc"), any(ArrayList.class))) .thenReturn(TransactionManager.Vote.YES); when(part2.onRPC(eq("tx_rpc"), any(ArrayList.class))) .thenReturn(TransactionManager.Vote.UNCERTIAN); Boolean isAllYes = participants.allParticipantsVotedYes(id); assertFalse(isAllYes); }
public Boolean allParticipantsVotedYes(UUID transactionId) throws TransactionExecutionException { ArrayList<Object> paramsVoteReq = TransactionWrapper.getTransactionRPCParams( transactionId, TwoPCPrimitive.VoteReq, null); TransactionContext.enterTransaction( transactionId, this.getParticipantManager(transactionId)); try { boolean isAllYes = true; for (ClientPolicy p : this.getParticipants(transactionId)) { if (TransactionContext.getProcessedClients().contains(p)) { continue; } try { TransactionContext.getProcessedClients().add(p); Object vote = p.onRPC(TransactionWrapper.txWrapperTag, paramsVoteReq); if (!TransactionManager.Vote.YES.equals(vote)) { isAllYes = false; break; } } catch (Exception e) { throw new TransactionExecutionException( "2PC transaction exception: vote_req", e); } } return isAllYes; } finally { TransactionContext.leaveTransaction(); } }
TwoPCLocalParticipants implements Serializable { public Boolean allParticipantsVotedYes(UUID transactionId) throws TransactionExecutionException { ArrayList<Object> paramsVoteReq = TransactionWrapper.getTransactionRPCParams( transactionId, TwoPCPrimitive.VoteReq, null); TransactionContext.enterTransaction( transactionId, this.getParticipantManager(transactionId)); try { boolean isAllYes = true; for (ClientPolicy p : this.getParticipants(transactionId)) { if (TransactionContext.getProcessedClients().contains(p)) { continue; } try { TransactionContext.getProcessedClients().add(p); Object vote = p.onRPC(TransactionWrapper.txWrapperTag, paramsVoteReq); if (!TransactionManager.Vote.YES.equals(vote)) { isAllYes = false; break; } } catch (Exception e) { throw new TransactionExecutionException( "2PC transaction exception: vote_req", e); } } return isAllYes; } finally { TransactionContext.leaveTransaction(); } } }
TwoPCLocalParticipants implements Serializable { public Boolean allParticipantsVotedYes(UUID transactionId) throws TransactionExecutionException { ArrayList<Object> paramsVoteReq = TransactionWrapper.getTransactionRPCParams( transactionId, TwoPCPrimitive.VoteReq, null); TransactionContext.enterTransaction( transactionId, this.getParticipantManager(transactionId)); try { boolean isAllYes = true; for (ClientPolicy p : this.getParticipants(transactionId)) { if (TransactionContext.getProcessedClients().contains(p)) { continue; } try { TransactionContext.getProcessedClients().add(p); Object vote = p.onRPC(TransactionWrapper.txWrapperTag, paramsVoteReq); if (!TransactionManager.Vote.YES.equals(vote)) { isAllYes = false; break; } } catch (Exception e) { throw new TransactionExecutionException( "2PC transaction exception: vote_req", e); } } return isAllYes; } finally { TransactionContext.leaveTransaction(); } }  }
TwoPCLocalParticipants implements Serializable { public Boolean allParticipantsVotedYes(UUID transactionId) throws TransactionExecutionException { ArrayList<Object> paramsVoteReq = TransactionWrapper.getTransactionRPCParams( transactionId, TwoPCPrimitive.VoteReq, null); TransactionContext.enterTransaction( transactionId, this.getParticipantManager(transactionId)); try { boolean isAllYes = true; for (ClientPolicy p : this.getParticipants(transactionId)) { if (TransactionContext.getProcessedClients().contains(p)) { continue; } try { TransactionContext.getProcessedClients().add(p); Object vote = p.onRPC(TransactionWrapper.txWrapperTag, paramsVoteReq); if (!TransactionManager.Vote.YES.equals(vote)) { isAllYes = false; break; } } catch (Exception e) { throw new TransactionExecutionException( "2PC transaction exception: vote_req", e); } } return isAllYes; } finally { TransactionContext.leaveTransaction(); } }  TwoPCParticipants getParticipantManager(UUID transactionId); Collection<ClientPolicy> getParticipants(UUID transactionId); void addParticipants(UUID transactionId, Collection<ClientPolicy> participants); void cleanup(UUID transactionId); void fanOutTransactionPrimitive(UUID transactionId, String primitiveMethod); Boolean allParticipantsVotedYes(UUID transactionId); }
TwoPCLocalParticipants implements Serializable { public Boolean allParticipantsVotedYes(UUID transactionId) throws TransactionExecutionException { ArrayList<Object> paramsVoteReq = TransactionWrapper.getTransactionRPCParams( transactionId, TwoPCPrimitive.VoteReq, null); TransactionContext.enterTransaction( transactionId, this.getParticipantManager(transactionId)); try { boolean isAllYes = true; for (ClientPolicy p : this.getParticipants(transactionId)) { if (TransactionContext.getProcessedClients().contains(p)) { continue; } try { TransactionContext.getProcessedClients().add(p); Object vote = p.onRPC(TransactionWrapper.txWrapperTag, paramsVoteReq); if (!TransactionManager.Vote.YES.equals(vote)) { isAllYes = false; break; } } catch (Exception e) { throw new TransactionExecutionException( "2PC transaction exception: vote_req", e); } } return isAllYes; } finally { TransactionContext.leaveTransaction(); } }  TwoPCParticipants getParticipantManager(UUID transactionId); Collection<ClientPolicy> getParticipants(UUID transactionId); void addParticipants(UUID transactionId, Collection<ClientPolicy> participants); void cleanup(UUID transactionId); void fanOutTransactionPrimitive(UUID transactionId, String primitiveMethod); Boolean allParticipantsVotedYes(UUID transactionId);  }