-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'zen2' into 2018-11-13-simple-unsafe-test-bootstrapping
- Loading branch information
Showing
26 changed files
with
1,803 additions
and
67 deletions.
There are no files selected for viewing
This file contains 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 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; | ||
} | ||
} |
138 changes: 138 additions & 0 deletions
138
...java/org/elasticsearch/action/admin/cluster/configuration/AddVotingTombstonesRequest.java
This file contains 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,138 @@ | ||
/* | ||
* 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) { | ||
final DiscoveryNodes allNodes = currentState.nodes(); | ||
final 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; | ||
} | ||
|
||
Set<DiscoveryNode> resolveNodesAndCheckMaximum(ClusterState currentState, int maxTombstoneCount, String maximumSettingKey) { | ||
final Set<DiscoveryNode> resolvedNodes = resolveNodes(currentState); | ||
|
||
final int oldTombstoneCount = currentState.getVotingTombstones().size(); | ||
final int newTombstoneCount = resolvedNodes.size(); | ||
if (oldTombstoneCount + newTombstoneCount > maxTombstoneCount) { | ||
throw new IllegalArgumentException("add voting tombstones request for " + Arrays.asList(nodeDescriptions) | ||
+ " would add [" + newTombstoneCount + "] voting tombstones to the existing [" + oldTombstoneCount | ||
+ "] which would exceed the maximum of [" + maxTombstoneCount + "] set by [" | ||
+ maximumSettingKey + "]"); | ||
} | ||
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 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 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; | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
...va/org/elasticsearch/action/admin/cluster/configuration/ClearVotingTombstonesRequest.java
This file contains 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,103 @@ | ||
/* | ||
* 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 = true; | ||
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. True by default. | ||
*/ | ||
public boolean getWaitForRemoval() { | ||
return waitForRemoval; | ||
} | ||
|
||
/** | ||
* @param waitForRemoval whether to wait for the tombstoned nodes to be removed from the cluster before removing their tombstones. True | ||
* by default. | ||
*/ | ||
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.