From 00b114d98345192cd5b4c3845686dc3842114052 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Tue, 25 Jun 2019 18:46:47 +0200 Subject: [PATCH] Fix merge issue between #43410 and #43449 PR builds on #43410 had not picked up the change merged in #43449 --- .../core/action/XPackInfoFeatureAction.java | 4 ++- .../core/action/XPackUsageFeatureAction.java | 4 +-- .../VotingOnlyNodeFeatureSet.java | 31 ++++++++++++++++++- .../coordination/VotingOnlyNodePlugin.java | 7 +++-- 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/XPackInfoFeatureAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/XPackInfoFeatureAction.java index 170ab11c16ee2..81fe7c7f0af21 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/XPackInfoFeatureAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/XPackInfoFeatureAction.java @@ -34,9 +34,11 @@ public class XPackInfoFeatureAction extends Action { public static final XPackInfoFeatureAction CCR = new XPackInfoFeatureAction(XPackField.CCR); public static final XPackInfoFeatureAction DATA_FRAME = new XPackInfoFeatureAction(XPackField.DATA_FRAME); public static final XPackInfoFeatureAction VECTORS = new XPackInfoFeatureAction(XPackField.VECTORS); + public static final XPackInfoFeatureAction VOTING_ONLY = new XPackInfoFeatureAction(XPackField.VOTING_ONLY); public static final List ALL = Arrays.asList( - SECURITY, MONITORING, WATCHER, GRAPH, MACHINE_LEARNING, LOGSTASH, SQL, ROLLUP, INDEX_LIFECYCLE, CCR, DATA_FRAME, VECTORS + SECURITY, MONITORING, WATCHER, GRAPH, MACHINE_LEARNING, LOGSTASH, SQL, ROLLUP, INDEX_LIFECYCLE, CCR, DATA_FRAME, VECTORS, + VOTING_ONLY ); private XPackInfoFeatureAction(String name) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/XPackUsageFeatureAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/XPackUsageFeatureAction.java index ead19996007e5..7721f9070a6d5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/XPackUsageFeatureAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/XPackUsageFeatureAction.java @@ -34,11 +34,11 @@ public class XPackUsageFeatureAction extends Action { public static final XPackUsageFeatureAction CCR = new XPackUsageFeatureAction(XPackField.CCR); public static final XPackUsageFeatureAction DATA_FRAME = new XPackUsageFeatureAction(XPackField.DATA_FRAME); public static final XPackUsageFeatureAction VECTORS = new XPackUsageFeatureAction(XPackField.VECTORS); - public static final XPackUsageFeatureAction VOTING_ONLY_NODE = new XPackUsageFeatureAction(XPackField.VOTING_ONLY); + public static final XPackUsageFeatureAction VOTING_ONLY = new XPackUsageFeatureAction(XPackField.VOTING_ONLY); public static final List ALL = Arrays.asList( SECURITY, MONITORING, WATCHER, GRAPH, MACHINE_LEARNING, LOGSTASH, SQL, ROLLUP, INDEX_LIFECYCLE, CCR, DATA_FRAME, VECTORS, - VOTING_ONLY_NODE + VOTING_ONLY ); private XPackUsageFeatureAction(String name) { diff --git a/x-pack/plugin/voting-only-node/src/main/java/org/elasticsearch/cluster/coordination/VotingOnlyNodeFeatureSet.java b/x-pack/plugin/voting-only-node/src/main/java/org/elasticsearch/cluster/coordination/VotingOnlyNodeFeatureSet.java index ef54d0ea5ccc2..1d84099ff7afa 100644 --- a/x-pack/plugin/voting-only-node/src/main/java/org/elasticsearch/cluster/coordination/VotingOnlyNodeFeatureSet.java +++ b/x-pack/plugin/voting-only-node/src/main/java/org/elasticsearch/cluster/coordination/VotingOnlyNodeFeatureSet.java @@ -18,6 +18,8 @@ import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackFeatureSet; import org.elasticsearch.xpack.core.XPackField; +import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; +import org.elasticsearch.xpack.core.action.XPackInfoFeatureTransportAction; import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; import org.elasticsearch.xpack.core.action.XPackUsageFeatureTransportAction; @@ -55,7 +57,7 @@ public static class UsageTransportAction extends XPackUsageFeatureTransportActio public UsageTransportAction(TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, XPackLicenseState licenseState) { - super(XPackUsageFeatureAction.VOTING_ONLY_NODE.name(), transportService, clusterService, + super(XPackUsageFeatureAction.VOTING_ONLY.name(), transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver); this.licenseState = licenseState; } @@ -68,4 +70,31 @@ protected void masterOperation(XPackUsageRequest request, ClusterState state, Ac listener.onResponse(new XPackUsageFeatureResponse(usage)); } } + + public static class UsageInfoAction extends XPackInfoFeatureTransportAction { + + private final XPackLicenseState licenseState; + + @Inject + public UsageInfoAction(TransportService transportService, ActionFilters actionFilters, + XPackLicenseState licenseState) { + super(XPackInfoFeatureAction.VOTING_ONLY.name(), transportService, actionFilters); + this.licenseState = licenseState; + } + + @Override + protected String name() { + return XPackField.VOTING_ONLY; + } + + @Override + protected boolean available() { + return licenseState.isVotingOnlyAllowed(); + } + + @Override + protected boolean enabled() { + return true; + } + } } diff --git a/x-pack/plugin/voting-only-node/src/main/java/org/elasticsearch/cluster/coordination/VotingOnlyNodePlugin.java b/x-pack/plugin/voting-only-node/src/main/java/org/elasticsearch/cluster/coordination/VotingOnlyNodePlugin.java index 0c062ee1df591..2f16179ae227c 100644 --- a/x-pack/plugin/voting-only-node/src/main/java/org/elasticsearch/cluster/coordination/VotingOnlyNodePlugin.java +++ b/x-pack/plugin/voting-only-node/src/main/java/org/elasticsearch/cluster/coordination/VotingOnlyNodePlugin.java @@ -42,10 +42,12 @@ import org.elasticsearch.transport.TransportResponseHandler; import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xpack.core.XPackPlugin; +import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -53,8 +55,6 @@ import java.util.Set; import java.util.function.Supplier; -import static java.util.Collections.singletonList; - public class VotingOnlyNodePlugin extends Plugin implements DiscoveryPlugin, NetworkPlugin, ActionPlugin { public static final Setting VOTING_ONLY_NODE_SETTING @@ -112,7 +112,8 @@ public Collection createComponents(Client client, ClusterService cluster @Override public List> getActions() { - return singletonList(new ActionHandler<>(XPackUsageFeatureAction.VOTING_ONLY_NODE, UsageTransportAction.class)); + return Arrays.asList(new ActionHandler<>(XPackUsageFeatureAction.VOTING_ONLY, UsageTransportAction.class), + new ActionHandler<>(XPackInfoFeatureAction.VOTING_ONLY, VotingOnlyNodeFeatureSet.UsageInfoAction.class)); } @Override