-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[Zen2] VotingTombstone class #35832
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
[Zen2] VotingTombstone class #35832
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.
Looks good, I left only nits. Again I would like @ywelsch to look over the XContent-related things.
.field(LAST_ACCEPTED_CONFIGURATION_FIELD.getPreferredName(), lastAcceptedConfiguration); | ||
// TODO include voting tombstones here | ||
.field(LAST_ACCEPTED_CONFIGURATION_FIELD.getPreferredName(), lastAcceptedConfiguration) | ||
.field(VOTING_TOMBSTONES_FIELD.getPreferredName(), votingTombstones); |
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.
nit: indenting seems inconsistent here.
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.
@@ -418,20 +415,18 @@ public void testXContentWithIndexGraveyard() throws IOException { | |||
return new CoordinationMetaData.VotingConfiguration(Sets.newHashSet(generateRandomStringArray(randomInt(10), 20, false))); | |||
} | |||
|
|||
private Set<DiscoveryNode> randomDiscoveryNodeSet() { | |||
private Set<VotingTombstone> randomVotingTombstones() { | |||
final int size = randomIntBetween(1, 10); |
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.
We should probably test the empty case too.
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.
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append('{').append(nodeId).append('}'); |
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.
In DiscoveryNode#toString()
the node name comes first (if present). I think we should do the same here.
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.
@@ -220,6 +228,97 @@ public CoordinationMetaData build() { | |||
} | |||
} | |||
|
|||
public static class VotingTombstone implements Writeable, ToXContentFragment { | |||
private String nodeId; |
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.
final
?
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 hate that things are not final by default in Java. 1037370
@@ -220,6 +228,97 @@ public CoordinationMetaData build() { | |||
} | |||
} | |||
|
|||
public static class VotingTombstone implements Writeable, ToXContentFragment { | |||
private String nodeId; | |||
private String nodeName; |
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.
final
?
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.
Ok, I'm done with the changes, waiting for @ywelsch xcontent review. |
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.
Some minor comments. Can you also add the JSON output of a CoordinationMetaData example object with voting tombstones to the PR description? Makes it easier for me to see what the change is :) Thank you
@@ -69,10 +70,10 @@ public AddVotingTombstonesRequest(StreamInput in) throws IOException { | |||
timeout = in.readTimeValue(); | |||
} | |||
|
|||
Set<DiscoveryNode> resolveNodes(ClusterState currentState) { | |||
Set<VotingTombstone> resolveNodes(ClusterState currentState) { |
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.
maybe this should now be called resolveVotingTombStones
?
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.
@@ -83,8 +84,8 @@ public AddVotingTombstonesRequest(StreamInput in) throws IOException { | |||
return resolvedNodes; | |||
} | |||
|
|||
Set<DiscoveryNode> resolveNodesAndCheckMaximum(ClusterState currentState, int maxTombstoneCount, String maximumSettingKey) { | |||
final Set<DiscoveryNode> resolvedNodes = resolveNodes(currentState); | |||
Set<VotingTombstone> resolveNodesAndCheckMaximum(ClusterState currentState, int maxTombstoneCount, String maximumSettingKey) { |
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.
idem here (resolveVoting....
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.
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.
And forgot "AndCheckMaximumPart" 8f63927
@@ -77,10 +77,10 @@ protected void masterOperation(ClearVotingTombstonesRequest request, ClusterStat | |||
final long startTimeMillis = threadPool.relativeTimeInMillis(); | |||
|
|||
final Predicate<ClusterState> allTombstonedNodesRemoved = newState -> { | |||
for (DiscoveryNode tombstone : initialState.getVotingTombstones()) { | |||
for (VotingTombstone tombstone : initialState.getVotingTombstones()) { | |||
// NB checking for the existence of any node with this persistent ID, because persistent IDs are how votes are counted. | |||
// Calling nodeExists(tombstone) is insufficient because this compares on the ephemeral ID. |
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.
the second part of the comment is now superfluous as VotingTombstone does not have the ephemeral id and there is no nodeExists method that takes a voting tombstone
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.
@ywelsch I've made changes you've requested for |
Today voting tombstones are stored in
CoordinationMetaData
asSet<DiscoveryNode>
.DiscoveryNode
is not a lightweight object and have a lot of fields.It also has
toXContent
method, but nofromXContent
method and theoutput of
toXContent
is not enough to re-createDiscoveryNode
object.
And
votingTombstone
set should be persisted as a part ofMetaData
.On the other hand, the only thing required from the tombstone is the
nodeId
.This PR adds
VotingTombstone
class for voting tombstones, whichconsists of two fields for now -
nodeId
andnodeName
. It could beextended/shrank in the future if needed.
This PR also resolves TODO's related to the voting tombstones xcontent
story.
Example of
CoordinationMetaData.toXContent
with voting tombstones: