-
Notifications
You must be signed in to change notification settings - Fork 25k
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 term and config to cluster state #32100
Add term and config to cluster state #32100
Conversation
Pinging @elastic/es-distributed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asked for a few more tests around VotingConfiguration
. Also I would slightly prefer term
to come ahead of version
throughout, certainly in display but also really in other serialisations.
} | ||
|
||
public void testVotingConfiguration() { | ||
ClusterState.VotingConfiguration config0 = new ClusterState.VotingConfiguration(Sets.newHashSet()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also assert that this is .equals(VotingConfiguration.EMPTY_CONFIG)
?
assertThat(config3.hasQuorum(Sets.newHashSet("id2")), equalTo(false)); | ||
assertThat(config3.hasQuorum(Sets.newHashSet("id3")), equalTo(false)); | ||
assertThat(config3.hasQuorum(Sets.newHashSet("id1", "id4")), equalTo(false)); | ||
assertThat(config3.hasQuorum(Sets.newHashSet()), equalTo(false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we also assertThat(config3.hasQuorum(Sets.newHashSet("id1", "id4", "id5")), equalTo(false));
?
} | ||
|
||
@Override | ||
public boolean equals(Object o) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any assertions that this works - specifically that it ever returns false
. Could we have some?
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(nodeIds); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an easy way to assert that this is consistent with equals()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed one (unimportant) term <-> version swap, but LGTM apart from that. TIL EqualsHashCodeTestUtils.checkEqualsAndHashCode 😄
@@ -77,7 +77,10 @@ protected void masterOperation(final ClusterStateRequest request, final ClusterS | |||
logger.trace("Serving cluster state request using version {}", currentState.version()); | |||
ClusterState.Builder builder = ClusterState.builder(currentState.getClusterName()); | |||
builder.version(currentState.version()); | |||
builder.term(currentState.term()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed a term<->version swap.
Thanks @DaveCTurner |
Adds the publication term and the last accepted and committed configurations to the cluster state, following the formal model in https://github.com/elastic/elasticsearch-formal-models/blob/master/ZenWithTerms/tla/ZenWithTerms.tla
The term represents the reign of a master, and the last committed / accepted configurations represent the set of quorums that cluster state changes will require (If there's no reconfiguration, last accepted and last committed configurations coincide).
We might end up shifting the last committed and last accepted configuration to a different sub-object of the cluster state (e.g. MetaData), but this depends mainly on the storage system that we will chose further down the line. The most natural object for now is the main cluster state object.
Relates to #32006