-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[Zen2] Introduce vote withdrawal #35446
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
Merged
DaveCTurner
merged 19 commits into
elastic:zen2
from
DaveCTurner:2018-11-09-voting-tombstones
Nov 13, 2018
Merged
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
afbec68
[Zen2] Introduce vote withdrawal
DaveCTurner cc76db2
assertBusy() because this sometimes gives AWAITING_INFO
DaveCTurner 1d4eaf6
Don't withdraw no votes, because this withdraws _all_ the votes
DaveCTurner 661ad5e
Review feedback
DaveCTurner af714a0
Pre-flight resolution
DaveCTurner 6a340dc
Lambdas
DaveCTurner 0a1f9fb
Review feedback
DaveCTurner 2a8b054
Remove ActionFilters.EMPTY_FILTERS
DaveCTurner cac7101
Review feedback
DaveCTurner 39c7579
Create observer later
DaveCTurner 403b5b3
Imports
DaveCTurner 1f86af6
Merge branch 'zen2' into 2018-11-09-voting-tombstones
DaveCTurner 24134d5
Change default of waitForRemoval to true
DaveCTurner ae9eb02
Tombstone tasks are URGENT
DaveCTurner ab72d36
Check maximum in preflight too
DaveCTurner efbaf1b
Always withdraw votes
DaveCTurner 933662f
Fix message
DaveCTurner fdd03fa
Merge branch 'zen2' into 2018-11-09-voting-tombstones
DaveCTurner 5ca67f9
Use stopRandomNode not ensureAtMostNumDataNodes
DaveCTurner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
.../java/org/elasticsearch/action/admin/cluster/configuration/AddVotingTombstonesAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Licensed to Elasticsearch under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.elasticsearch.action.admin.cluster.configuration; | ||
|
|
||
| import org.elasticsearch.action.Action; | ||
| import org.elasticsearch.common.io.stream.Writeable.Reader; | ||
|
|
||
| public class AddVotingTombstonesAction extends Action<AddVotingTombstonesResponse> { | ||
| public static final AddVotingTombstonesAction INSTANCE = new AddVotingTombstonesAction(); | ||
| public static final String NAME = "cluster:admin/voting/add_tombstones"; | ||
|
|
||
| private AddVotingTombstonesAction() { | ||
| super(NAME); | ||
| } | ||
|
|
||
| @Override | ||
| public AddVotingTombstonesResponse newResponse() { | ||
| throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); | ||
| } | ||
|
|
||
| @Override | ||
| public Reader<AddVotingTombstonesResponse> getResponseReader() { | ||
| return AddVotingTombstonesResponse::new; | ||
| } | ||
| } |
124 changes: 124 additions & 0 deletions
124
...java/org/elasticsearch/action/admin/cluster/configuration/AddVotingTombstonesRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| /* | ||
| * Licensed to Elasticsearch under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.elasticsearch.action.admin.cluster.configuration; | ||
|
|
||
| import org.elasticsearch.action.ActionRequestValidationException; | ||
| import org.elasticsearch.action.support.master.MasterNodeRequest; | ||
| import org.elasticsearch.cluster.ClusterState; | ||
| import org.elasticsearch.cluster.node.DiscoveryNode; | ||
| import org.elasticsearch.cluster.node.DiscoveryNodes; | ||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.common.unit.TimeValue; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.Arrays; | ||
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| /** | ||
| * A request to add voting tombstones for certain master-eligible nodes, and wait for these nodes to be removed from the voting | ||
| * configuration. | ||
| */ | ||
| public class AddVotingTombstonesRequest extends MasterNodeRequest<AddVotingTombstonesRequest> { | ||
| private final String[] nodeDescriptions; | ||
| private final TimeValue timeout; | ||
|
|
||
| /** | ||
| * Construct a request to add voting tombstones for master-eligible nodes matching the given descriptions, and wait for a default 30 | ||
| * seconds for these nodes to be removed from the voting configuration. | ||
| * @param nodeDescriptions Descriptions of the nodes to add - see {@link DiscoveryNodes#resolveNodes(String...)} | ||
| */ | ||
| public AddVotingTombstonesRequest(String[] nodeDescriptions) { | ||
| this(nodeDescriptions, TimeValue.timeValueSeconds(30)); | ||
| } | ||
|
|
||
| /** | ||
| * Construct a request to add voting tombstones for master-eligible nodes matching the given descriptions, and wait for these nodes to | ||
| * be removed from the voting configuration. | ||
| * @param nodeDescriptions Descriptions of the nodes whose tombstones to add - see {@link DiscoveryNodes#resolveNodes(String...)}. | ||
| * @param timeout How long to wait for the nodes to be removed from the voting configuration. | ||
| */ | ||
| public AddVotingTombstonesRequest(String[] nodeDescriptions, TimeValue timeout) { | ||
| if (timeout.compareTo(TimeValue.ZERO) < 0) { | ||
| throw new IllegalArgumentException("timeout [" + timeout + "] must be non-negative"); | ||
| } | ||
| this.nodeDescriptions = nodeDescriptions; | ||
| this.timeout = timeout; | ||
| } | ||
|
|
||
| public AddVotingTombstonesRequest(StreamInput in) throws IOException { | ||
| super(in); | ||
| nodeDescriptions = in.readStringArray(); | ||
| timeout = in.readTimeValue(); | ||
| } | ||
|
|
||
| Set<DiscoveryNode> resolveNodes(ClusterState currentState) { | ||
| DiscoveryNodes allNodes = currentState.nodes(); | ||
| Set<DiscoveryNode> resolvedNodes = Arrays.stream(allNodes.resolveNodes(nodeDescriptions)) | ||
| .map(allNodes::get).filter(DiscoveryNode::isMasterNode).collect(Collectors.toSet()); | ||
|
|
||
| if (resolvedNodes.isEmpty()) { | ||
| throw new IllegalArgumentException("add voting tombstones request for " + Arrays.asList(nodeDescriptions) | ||
| + " matched no master-eligible nodes"); | ||
| } | ||
|
|
||
| resolvedNodes.removeIf(n -> currentState.getVotingTombstones().contains(n)); | ||
| return resolvedNodes; | ||
| } | ||
|
|
||
| /** | ||
| * @return descriptions of the nodes for whom to add tombstones. | ||
| */ | ||
| public String[] getNodeDescriptions() { | ||
| return nodeDescriptions; | ||
| } | ||
|
|
||
| /** | ||
| * @return how long to wait after adding the tombstones for the nodes to be removed from the voting configuration. | ||
| */ | ||
| public TimeValue getTimeout() { | ||
| return timeout; | ||
| } | ||
|
|
||
| @Override | ||
| public ActionRequestValidationException validate() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public void readFrom(StreamInput in) throws IOException { | ||
| throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| super.writeTo(out); | ||
| out.writeStringArray(nodeDescriptions); | ||
| out.writeTimeValue(timeout); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "AddVotingTombstonesRequest{" + | ||
| "nodeDescriptions=" + Arrays.asList(nodeDescriptions) + | ||
| ", timeout=" + timeout + | ||
| '}'; | ||
| } | ||
| } |
49 changes: 49 additions & 0 deletions
49
...ava/org/elasticsearch/action/admin/cluster/configuration/AddVotingTombstonesResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Licensed to Elasticsearch under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.elasticsearch.action.admin.cluster.configuration; | ||
|
|
||
| import org.elasticsearch.action.ActionResponse; | ||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| /** | ||
| * A response to {@link AddVotingTombstonesRequest} indicating that voting tombstones have been added for the requested nodes and these | ||
| * nodes have been removed from the voting configuration. | ||
| */ | ||
| public class AddVotingTombstonesResponse extends ActionResponse { | ||
|
|
||
| public AddVotingTombstonesResponse() { | ||
| } | ||
|
|
||
| public AddVotingTombstonesResponse(StreamInput in) throws IOException { | ||
| super(in); | ||
| } | ||
|
|
||
| @Override | ||
| public void readFrom(StreamInput in) throws IOException { | ||
| throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| super.writeTo(out); | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
...ava/org/elasticsearch/action/admin/cluster/configuration/ClearVotingTombstonesAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Licensed to Elasticsearch under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.elasticsearch.action.admin.cluster.configuration; | ||
|
|
||
| import org.elasticsearch.action.Action; | ||
| import org.elasticsearch.common.io.stream.Writeable.Reader; | ||
|
|
||
| public class ClearVotingTombstonesAction extends Action<ClearVotingTombstonesResponse> { | ||
| public static final ClearVotingTombstonesAction INSTANCE = new ClearVotingTombstonesAction(); | ||
| public static final String NAME = "cluster:admin/voting/clear_tombstones"; | ||
|
|
||
| private ClearVotingTombstonesAction() { | ||
| super(NAME); | ||
| } | ||
|
|
||
| @Override | ||
| public ClearVotingTombstonesResponse newResponse() { | ||
| throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); | ||
| } | ||
|
|
||
| @Override | ||
| public Reader<ClearVotingTombstonesResponse> getResponseReader() { | ||
| return ClearVotingTombstonesResponse::new; | ||
| } | ||
| } |
102 changes: 102 additions & 0 deletions
102
...va/org/elasticsearch/action/admin/cluster/configuration/ClearVotingTombstonesRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /* | ||
| * Licensed to Elasticsearch under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.elasticsearch.action.admin.cluster.configuration; | ||
|
|
||
| import org.elasticsearch.action.ActionRequestValidationException; | ||
| import org.elasticsearch.action.support.master.MasterNodeRequest; | ||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.common.unit.TimeValue; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| /** | ||
| * A request to clear the voting tombstones from the cluster state, optionally waiting for these nodes to be removed from the cluster first. | ||
| */ | ||
| public class ClearVotingTombstonesRequest extends MasterNodeRequest<ClearVotingTombstonesRequest> { | ||
| private boolean waitForRemoval; | ||
| private TimeValue timeout = TimeValue.timeValueSeconds(30); | ||
|
|
||
| /** | ||
| * Construct a request to remove all the voting tombstones from the cluster state. | ||
| */ | ||
| public ClearVotingTombstonesRequest() { | ||
| } | ||
|
|
||
| public ClearVotingTombstonesRequest(StreamInput in) throws IOException { | ||
| super(in); | ||
| waitForRemoval = in.readBoolean(); | ||
| timeout = in.readTimeValue(); | ||
| } | ||
|
|
||
| /** | ||
| * @return whether to wait for the tombstoned nodes to be removed from the cluster before removing their tombstones. | ||
| */ | ||
| public boolean getWaitForRemoval() { | ||
| return waitForRemoval; | ||
| } | ||
|
|
||
| /** | ||
| * @param waitForRemoval whether to wait for the tombstoned nodes to be removed from the cluster before removing their tombstones. | ||
| */ | ||
| public void setWaitForRemoval(boolean waitForRemoval) { | ||
| this.waitForRemoval = waitForRemoval; | ||
| } | ||
|
|
||
| /** | ||
| * @param timeout how long to wait for the tombstoned nodes to be removed if {@link ClearVotingTombstonesRequest#waitForRemoval} is | ||
| * true. Defaults to 30 seconds. | ||
| */ | ||
| public void setTimeout(TimeValue timeout) { | ||
| this.timeout = timeout; | ||
| } | ||
|
|
||
| /** | ||
| * @return how long to wait for the tombstoned nodes to be removed if {@link ClearVotingTombstonesRequest#waitForRemoval} is | ||
| * true. Defaults to 30 seconds. | ||
| */ | ||
| public TimeValue getTimeout() { | ||
| return timeout; | ||
| } | ||
|
|
||
| @Override | ||
| public ActionRequestValidationException validate() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public void readFrom(StreamInput in) throws IOException { | ||
| throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| super.writeTo(out); | ||
| out.writeBoolean(waitForRemoval); | ||
| out.writeTimeValue(timeout); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "ClearVotingTombstonesRequest{" + | ||
| ", waitForRemoval=" + waitForRemoval + | ||
| ", timeout=" + timeout + | ||
| '}'; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.