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