RATIS-2379. Support returning applied index for ReadIndex#1332
Conversation
szetszwo
left a comment
There was a problem hiding this comment.
@ivandika3 , Thanks for working on this!
Sorry that I reviewed this earlier but forgot to press "Submit review". Please see the comments inlined.
| interface ReadIndex { | ||
| String PREFIX = Read.PREFIX + ".read-index"; | ||
|
|
||
| String READ_INDEX_USE_APPLIED_INDEX_ENABLED_KEY = PREFIX + ".use.applied-index.enabled"; |
There was a problem hiding this comment.
- Let's remove "
use", i.e.raft.server.read-index.applied-index.enabled. - The field names must be the same as the String value. Otherwise, the TestConfUtils will fail as shown in the CI.
It needs a setter method.
interface ReadIndex {
String PREFIX = Read.PREFIX + ".read-index";
String APPLIED_INDEX_ENABLED_KEY = PREFIX + ".applied-index.enabled";
boolean APPLIED_INDEX_ENABLED_DEFAULT = false;
static boolean appliedIndexEnabled(RaftProperties properties) {
return getBoolean(properties::getBoolean, APPLIED_INDEX_ENABLED_KEY,
APPLIED_INDEX_ENABLED_DEFAULT, getDefaultLog());
}
static void setAppliedIndexEnabled(RaftProperties properties, boolean enabled) {
setBoolean(properties::setBoolean, APPLIED_INDEX_ENABLED_KEY, enabled);
}
}| } else { | ||
| this.followerMaxGapThreshold = (long) (followerGapRatioMax * maxPendingRequests); | ||
| } | ||
| this.readIndexUseAppliedIndexEnabled = RaftServerConfigKeys.Read.ReadIndex |
| */ | ||
| CompletableFuture<Long> getReadIndex(Long readAfterWriteConsistentIndex) { | ||
| final long commitIndex = server.getRaftLog().getLastCommittedIndex(); | ||
| final long lastAppliedOrCommitIndex = readIndexUseAppliedIndexEnabled ? |
There was a problem hiding this comment.
Let's just call it index instead of lastAppliedOrCommitIndex.
|
|
||
| | **Property** | `raft.server.read.read-index.use.applied-index.enabled` | | ||
| |:----------------|:--------------------------------------------------------------------------| | ||
| | **Description** | whether leader return applied index instead of commit index for ReadIndex | |
There was a problem hiding this comment.
Suggestion: "whether applied index (instead of commit index) is used for ReadIndex"
There was a problem hiding this comment.
Thanks, this is more concise. Updated.
szetszwo
left a comment
There was a problem hiding this comment.
@ivandika3 , thanks for the update! Just have a comment inlined about the names. Please take a look.
| String READ_INDEX_APPLIED_INDEX_ENABLED_KEY = PREFIX + ".applied-index.enabled"; | ||
| boolean READ_INDEX_APPLIED_INDEX_ENABLED_DEFAULT = false; | ||
| static boolean readIndexAppliedIndexEnabled(RaftProperties properties) { | ||
| return getBoolean(properties::getBoolean, READ_INDEX_APPLIED_INDEX_ENABLED_KEY, | ||
| READ_INDEX_APPLIED_INDEX_ENABLED_DEFAULT, getDefaultLog()); | ||
| } | ||
|
|
||
| static void setReadIndexAppliedIndexEnabled(RaftProperties properties, boolean enabled) { | ||
| setBoolean(properties::setBoolean, READ_INDEX_APPLIED_INDEX_ENABLED_KEY, enabled); | ||
| } |
There was a problem hiding this comment.
Let's remove the "readIndex" prefix from the fields and methods since the interface name already has it, i.e.
interface ReadIndex {
String PREFIX = Read.PREFIX + ".read-index";
String APPLIED_INDEX_ENABLED_KEY = PREFIX + ".applied-index.enabled";
boolean APPLIED_INDEX_ENABLED_DEFAULT = false;
static boolean appliedIndexEnabled(RaftProperties properties) {
return getBoolean(properties::getBoolean, APPLIED_INDEX_ENABLED_KEY,
APPLIED_INDEX_ENABLED_DEFAULT, getDefaultLog());
}
static void setAppliedIndexEnabled(RaftProperties properties, boolean enabled) {
setBoolean(properties::setBoolean, APPLIED_INDEX_ENABLED_KEY, enabled);
}
}(Since this is a public API, we have to be more meticulous.)
szetszwo
left a comment
There was a problem hiding this comment.
+1 the change looks good.
|
Thanks @szetszwo for the review. |
)" This reverts commit 51f1e8e.
What changes were proposed in this pull request?
Please refer to https://issues.apache.org/jira/browse/RATIS-2379
How was this patch tested?
Unit test.