@Test public void testDecrNextIndex() { MockRaftActorContext context = new MockRaftActorContext(); context.setCommitIndex(1); FollowerLogInformation followerLogInformation = new FollowerLogInformation(new PeerInfo("follower1", null, VotingState.VOTING), 1, context); assertTrue(followerLogInformation.decrNextIndex(1)); assertEquals("getNextIndex", 0, followerLogInformation.getNextIndex()); assertTrue(followerLogInformation.decrNextIndex(1)); assertEquals("getNextIndex", -1, followerLogInformation.getNextIndex()); assertFalse(followerLogInformation.decrNextIndex(1)); assertEquals("getNextIndex", -1, followerLogInformation.getNextIndex()); }
public boolean decrNextIndex(final long followerLastIndex) { if (nextIndex < 0) { return false; } if (followerLastIndex >= 0 && nextIndex > followerLastIndex) { nextIndex = followerLastIndex; } else { nextIndex--; } return true; }
FollowerLogInformation { public boolean decrNextIndex(final long followerLastIndex) { if (nextIndex < 0) { return false; } if (followerLastIndex >= 0 && nextIndex > followerLastIndex) { nextIndex = followerLastIndex; } else { nextIndex--; } return true; } }
FollowerLogInformation { public boolean decrNextIndex(final long followerLastIndex) { if (nextIndex < 0) { return false; } if (followerLastIndex >= 0 && nextIndex > followerLastIndex) { nextIndex = followerLastIndex; } else { nextIndex--; } return true; } @VisibleForTesting  FollowerLogInformation(final PeerInfo peerInfo, final long matchIndex, final RaftActorContext context);  FollowerLogInformation(final PeerInfo peerInfo, final RaftActorContext context); }
FollowerLogInformation { public boolean decrNextIndex(final long followerLastIndex) { if (nextIndex < 0) { return false; } if (followerLastIndex >= 0 && nextIndex > followerLastIndex) { nextIndex = followerLastIndex; } else { nextIndex--; } return true; } @VisibleForTesting  FollowerLogInformation(final PeerInfo peerInfo, final long matchIndex, final RaftActorContext context);  FollowerLogInformation(final PeerInfo peerInfo, final RaftActorContext context); boolean decrNextIndex(final long followerLastIndex); @SuppressWarnings("checkstyle:hiddenField") boolean setNextIndex(final long nextIndex); long incrMatchIndex(); @SuppressWarnings("checkstyle:hiddenField") boolean setMatchIndex(final long matchIndex); String getId(); long getNextIndex(); long getMatchIndex(); boolean isFollowerActive(); void markFollowerActive(); @VisibleForTesting void markFollowerInActive(); long nanosSinceLastActivity(); boolean okToReplicate(final long commitIndex); short getPayloadVersion(); void setPayloadVersion(final short payloadVersion); short getRaftVersion(); void setRaftVersion(final short raftVersion); @Nullable LeaderInstallSnapshotState getInstallSnapshotState(); void setLeaderInstallSnapshotState(final @NonNull LeaderInstallSnapshotState state); void clearLeaderInstallSnapshotState(); void setSlicedLogEntryIndex(final long index); boolean isLogEntrySlicingInProgress(); void setNeedsLeaderAddress(final boolean value); @Nullable String needsLeaderAddress(final String leaderId); boolean hasStaleCommitIndex(final long commitIndex); void setSentCommitIndex(final long commitIndex); @Override String toString(); }
FollowerLogInformation { public boolean decrNextIndex(final long followerLastIndex) { if (nextIndex < 0) { return false; } if (followerLastIndex >= 0 && nextIndex > followerLastIndex) { nextIndex = followerLastIndex; } else { nextIndex--; } return true; } @VisibleForTesting  FollowerLogInformation(final PeerInfo peerInfo, final long matchIndex, final RaftActorContext context);  FollowerLogInformation(final PeerInfo peerInfo, final RaftActorContext context); boolean decrNextIndex(final long followerLastIndex); @SuppressWarnings("checkstyle:hiddenField") boolean setNextIndex(final long nextIndex); long incrMatchIndex(); @SuppressWarnings("checkstyle:hiddenField") boolean setMatchIndex(final long matchIndex); String getId(); long getNextIndex(); long getMatchIndex(); boolean isFollowerActive(); void markFollowerActive(); @VisibleForTesting void markFollowerInActive(); long nanosSinceLastActivity(); boolean okToReplicate(final long commitIndex); short getPayloadVersion(); void setPayloadVersion(final short payloadVersion); short getRaftVersion(); void setRaftVersion(final short raftVersion); @Nullable LeaderInstallSnapshotState getInstallSnapshotState(); void setLeaderInstallSnapshotState(final @NonNull LeaderInstallSnapshotState state); void clearLeaderInstallSnapshotState(); void setSlicedLogEntryIndex(final long index); boolean isLogEntrySlicingInProgress(); void setNeedsLeaderAddress(final boolean value); @Nullable String needsLeaderAddress(final String leaderId); boolean hasStaleCommitIndex(final long commitIndex); void setSentCommitIndex(final long commitIndex); @Override String toString(); static final long NO_INDEX; }