private boolean isLatestRound(PaxosValue value) { return isLatestRound(Optional.of(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 StillLeadingStatus determineLeadershipStatus(PaxosValue value) { if (!isThisNodeTheLeaderFor(value)) { return StillLeadingStatus.NOT_LEADING; } if (!isLatestRound(value)) { return StillLeadingStatus.NOT_LEADING; } return latestRoundVerifier.isLatestRound(value.getRound()) .toStillLeadingStatus(); }
private boolean isLatestRound(PaxosValue value) { return isLatestRound(Optional.of(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 StillLeadingStatus determineLeadershipStatus(PaxosValue value) { if (!isThisNodeTheLeaderFor(value)) { return StillLeadingStatus.NOT_LEADING; } if (!isLatestRound(value)) { return StillLeadingStatus.NOT_LEADING; } return latestRoundVerifier.isLatestRound(value.getRound()) .toStillLeadingStatus(); }