Skip to content

Commit

Permalink
Fix merge issue between #43410 and #43449
Browse files Browse the repository at this point in the history
PR builds on #43410 had not picked up the change merged in #43449
  • Loading branch information
ywelsch committed Jun 25, 2019
1 parent e63e755 commit 00b114d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ public class XPackInfoFeatureAction extends Action<XPackInfoFeatureResponse> {
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<XPackInfoFeatureAction> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public class XPackUsageFeatureAction extends Action<XPackUsageFeatureResponse> {
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<XPackUsageFeatureAction> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@
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;
import java.util.Map;
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<Boolean> VOTING_ONLY_NODE_SETTING
Expand Down Expand Up @@ -112,7 +112,8 @@ public Collection<Object> createComponents(Client client, ClusterService cluster

@Override
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> 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
Expand Down

0 comments on commit 00b114d

Please sign in to comment.