Skip to content

Commit

Permalink
Fix split package with voting-only nodes (elastic#73965)
Browse files Browse the repository at this point in the history
Moves the implementation of voting-only nodes to the
`o.e.c.c.votingonly` package.
  • Loading branch information
DaveCTurner committed Jun 10, 2021
1 parent 8d88286 commit a2c1d31
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ protected static int defaultInt(Setting<Integer> setting) {
// then wait for the new leader to commit a state without the old leader
+ DEFAULT_CLUSTER_STATE_UPDATE_DELAY;

class Cluster implements Releasable {
public class Cluster implements Releasable {

static final long EXTREME_DELAY_VARIABILITY = 10000L;
static final long DEFAULT_DELAY_VARIABILITY = 100L;
Expand Down Expand Up @@ -261,7 +261,7 @@ class Cluster implements Releasable {
this(initialNodeCount, true, Settings.EMPTY);
}

Cluster(int initialNodeCount, boolean allNodesMasterEligible, Settings nodeSettings) {
public Cluster(int initialNodeCount, boolean allNodesMasterEligible, Settings nodeSettings) {
this(initialNodeCount, allNodesMasterEligible, nodeSettings, () -> new StatusInfo(HEALTHY, "healthy-info"));
}

Expand Down Expand Up @@ -326,7 +326,7 @@ int size() {
return clusterNodes.size();
}

void runRandomly() {
public void runRandomly() {
runRandomly(true, true, EXTREME_DELAY_VARIABILITY);
}

Expand Down Expand Up @@ -495,7 +495,7 @@ private void updateCommittedStates() {
}
}

void stabilise() {
public void stabilise() {
stabilise(DEFAULT_STABILISATION_TIME);
}

Expand Down Expand Up @@ -653,7 +653,7 @@ && getConnectionStatus(n2.getLocalNode(), n1.getLocalNode()) == ConnectionStatus
(n1.nodeHealthService.getHealth().getStatus() == HEALTHY && n2.nodeHealthService.getHealth().getStatus() == HEALTHY);
}

ClusterNode getAnyLeader() {
public ClusterNode getAnyLeader() {
List<ClusterNode> allLeaders = clusterNodes.stream().filter(ClusterNode::isLeader).collect(Collectors.toList());
assertThat("leaders", allLeaders, not(empty()));
return randomFrom(allLeaders);
Expand Down Expand Up @@ -883,7 +883,7 @@ public void close() {
}
}

class ClusterNode {
public class ClusterNode {
private final Logger logger = LogManager.getLogger(ClusterNode.class);

private final int nodeIndex;
Expand Down Expand Up @@ -1019,7 +1019,7 @@ String getId() {
return localNode.getId();
}

DiscoveryNode getLocalNode() {
public DiscoveryNode getLocalNode() {
return localNode;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void setInitialState(CoordinationMetadata.VotingConfiguration initialConfig, lon
final CoordinationMetadata.VotingConfiguration initialConfiguration;
final long initialValue;

CoordinationStateTestCluster(List<DiscoveryNode> nodes, ElectionStrategy electionStrategy) {
public CoordinationStateTestCluster(List<DiscoveryNode> nodes, ElectionStrategy electionStrategy) {
this.electionStrategy = electionStrategy;
messages = new ArrayList<>();

Expand Down Expand Up @@ -203,7 +203,7 @@ void applyMessage(Message message) {
}
}

void runRandomly() {
public void runRandomly() {
final int iterations = 10000;
final long maxTerm = 4;
long nextTerm = 1;
Expand Down
8 changes: 1 addition & 7 deletions x-pack/plugin/voting-only-node/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@ apply plugin: 'elasticsearch.internal-cluster-test'
esplugin {
name 'x-pack-voting-only-node'
description 'Elasticsearch Expanded Pack Plugin - Voting-only node'
classname 'org.elasticsearch.cluster.coordination.VotingOnlyNodePlugin'
classname 'org.elasticsearch.cluster.coordination.votingonly.VotingOnlyNodePlugin'
extendedPlugins = ['x-pack-core']
}

dependencies {
compileOnly project(path: xpackModule('core'))
testImplementation(testArtifact(project(xpackModule('core'))))
}

tasks.named('splitPackagesAudit').configure {
// o.e.cluster is owned by server, rename these
ignoreClasses 'org.elasticsearch.cluster.coordination.VotingOnlyNodeFeatureSet',
'org.elasticsearch.cluster.coordination.VotingOnlyNodePlugin'
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.cluster.coordination;
package org.elasticsearch.cluster.coordination.votingonly;

import org.elasticsearch.Version;
import org.elasticsearch.action.admin.cluster.repositories.verify.VerifyRepositoryResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.cluster.coordination;
package org.elasticsearch.cluster.coordination.votingonly;

import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

package org.elasticsearch.cluster.coordination;
package org.elasticsearch.cluster.coordination.votingonly;

import org.apache.lucene.util.SetOnce;
import org.elasticsearch.ElasticsearchException;
Expand All @@ -14,7 +14,9 @@
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.coordination.CoordinationMetadata.VotingConfiguration;
import org.elasticsearch.cluster.coordination.CoordinationState.VoteCollection;
import org.elasticsearch.cluster.coordination.VotingOnlyNodeFeatureSet.UsageTransportAction;
import org.elasticsearch.cluster.coordination.ElectionStrategy;
import org.elasticsearch.cluster.coordination.Join;
import org.elasticsearch.cluster.coordination.PublicationTransportHandler;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
Expand Down Expand Up @@ -98,7 +100,7 @@ public Collection<Object> createComponents(
@Override
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
return Arrays.asList(
new ActionHandler<>(XPackUsageFeatureAction.VOTING_ONLY, UsageTransportAction.class),
new ActionHandler<>(XPackUsageFeatureAction.VOTING_ONLY, VotingOnlyNodeFeatureSet.UsageTransportAction.class),
new ActionHandler<>(XPackInfoFeatureAction.VOTING_ONLY, VotingOnlyNodeFeatureSet.UsageInfoAction.class)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.cluster.coordination;
package org.elasticsearch.cluster.coordination.votingonly;

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.cluster.coordination;
package org.elasticsearch.cluster.coordination.votingonly;

import org.elasticsearch.Version;
import org.elasticsearch.cluster.coordination.CoordinationStateTestCluster;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
import org.elasticsearch.test.ESTestCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
package org.elasticsearch.cluster.coordination;
package org.elasticsearch.cluster.coordination.votingonly;

import org.elasticsearch.Version;
import org.elasticsearch.cluster.coordination.AbstractCoordinatorTestCase;
import org.elasticsearch.cluster.coordination.ElectionStrategy;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
import org.elasticsearch.common.UUIDs;
Expand Down

0 comments on commit a2c1d31

Please sign in to comment.