@VisibleForTesting boolean getAndRecordLeaderPingResult(@Nullable Future<Boolean> pingFuture) throws InterruptedException { if (pingFuture == null) { eventRecorder.recordLeaderPingTimeout(); return false; } try { boolean isLeader = pingFuture.get(); if (!isLeader) { eventRecorder.recordLeaderPingReturnedFalse(); } return isLeader; } catch (ExecutionException ex) { eventRecorder.recordLeaderPingFailure(ex.getCause()); return false; } }
private void recordLeadershipStatus( PaxosLeadershipToken token, StillLeadingStatus status) { if (status == StillLeadingStatus.NO_QUORUM) { eventRecorder.recordNoQuorum(token.value); } else if (status == StillLeadingStatus.NOT_LEADING) { eventRecorder.recordNotLeading(token.value); } }
private void proposeLeadershipAfter(Optional<PaxosValue> value) { lock.lock(); try { log.debug("Proposing leadership with value [{}]", SafeArg.of("paxosValue", value)); if (!isLatestRound(value)) { // This means that new data has come in so we shouldn't propose leadership. // We do this check in a lock to ensure concurrent callers to blockOnBecomingLeader behaves correctly. return; } long seq = value.map(val -> val.getRound()).orElse(PaxosAcceptor.NO_LOG_ENTRY) + 1; eventRecorder.recordProposalAttempt(seq); proposer.propose(seq, null); } catch (PaxosRoundFailureException e) { // We have failed trying to become the leader. eventRecorder.recordProposalFailure(e); return; } finally { lock.unlock(); } }
private void proposeLeadershipAfter(Optional<PaxosValue> value) { lock.lock(); try { log.debug("Proposing leadership with value [{}]", SafeArg.of("paxosValue", value)); if (!isLatestRound(value)) { // This means that new data has come in so we shouldn't propose leadership. // We do this check in a lock to ensure concurrent callers to blockOnBecomingLeader behaves correctly. return; } long seq = value.map(val -> val.getRound()).orElse(PaxosAcceptor.NO_LOG_ENTRY) + 1; eventRecorder.recordProposalAttempt(seq); proposer.propose(seq, null); } catch (PaxosRoundFailureException e) { // We have failed trying to become the leader. eventRecorder.recordProposalFailure(e); return; } finally { lock.unlock(); } }
@VisibleForTesting boolean getAndRecordLeaderPingResult(@Nullable Future<Boolean> pingFuture) throws InterruptedException { if (pingFuture == null) { eventRecorder.recordLeaderPingTimeout(); return false; } try { boolean isLeader = pingFuture.get(); if (!isLeader) { eventRecorder.recordLeaderPingReturnedFalse(); } return isLeader; } catch (ExecutionException ex) { eventRecorder.recordLeaderPingFailure(ex.getCause()); return false; } }
private void recordLeadershipStatus( PaxosLeadershipToken token, StillLeadingStatus status) { if (status == StillLeadingStatus.NO_QUORUM) { eventRecorder.recordNoQuorum(token.value); } else if (status == StillLeadingStatus.NOT_LEADING) { eventRecorder.recordNotLeading(token.value); } }