Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for fencing via sequence ids #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add support for fencing via sequence ids #3

wants to merge 2 commits into from

Conversation

fernomac
Copy link

@fernomac fernomac commented Nov 6, 2017

As discussed in #1; I finally had time to put together a pull request. Contributed under the terms of the Amazon Software License.

// If we're tracking sequence IDs, initialize or increment the current value.
Optional<Long> sequenceId = Optional.empty();
if (trackSequenceIds) {
sequenceId = existingLock.flatMap(value -> value.getSequenceId());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

sequenceId = Optional.of(existingLock.flatMap(value -> value.getSequenceId()).orElse(0L) + 1)

Motivation:

  1. make it clear that you fallback to 0L when there was no lock / seq. id
  2. the step (+1) is also clearly defined

final boolean deleteLockOnRelease = options.getDeleteLockOnRelease();
final boolean deleteLockOnRelease;
if (this.trackSequenceIds) {
if (options.getDeleteLockOnRelease().isPresent() && options.getDeleteLockOnRelease().get()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functional police is here 👮 😄

if (options.getDeleteLockOnRelease().orElse(false)) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants