diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/Graph.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/Graph.java index a44c990ab80..4b9a338fe4b 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/Graph.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/Graph.java @@ -5,10 +5,6 @@ */ package org.elasticsearch.graph; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; - import org.elasticsearch.action.ActionModule; import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.inject.Module; @@ -18,12 +14,13 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.graph.action.GraphExploreAction; import org.elasticsearch.graph.action.TransportGraphExploreAction; -import org.elasticsearch.graph.license.GraphLicensee; -import org.elasticsearch.graph.license.GraphModule; import org.elasticsearch.graph.rest.action.RestGraphAction; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.xpack.XPackPlugin; +import java.util.Collection; +import java.util.Collections; + public class Graph extends Plugin { public static final String NAME = "graph"; @@ -48,8 +45,20 @@ public class Graph extends Plugin { public static boolean enabled(Settings settings) { return XPackPlugin.featureEnabled(settings, NAME, true); - } - + } + + public Collection nodeModules() { + return Collections.singletonList(new GraphModule(enabled, transportClientMode)); + } + + @Override + public Collection> nodeServices() { + if (enabled == false|| transportClientMode) { + return Collections.emptyList(); + } + return Collections.singletonList(GraphLicensee.class); + } + public void onModule(ActionModule actionModule) { if (enabled) { actionModule.registerAction(GraphExploreAction.INSTANCE, TransportGraphExploreAction.class); @@ -65,23 +74,5 @@ public class Graph extends Plugin { public void onModule(SettingsModule module) { module.registerSetting(Setting.boolSetting(XPackPlugin.featureEnabledSetting(NAME), true, Setting.Property.NodeScope)); } - - public Collection nodeModules() { - if (enabled == false|| transportClientMode) { - return Collections.emptyList(); - } - return Arrays. asList(new GraphModule()); - } - - @Override - public Collection> nodeServices() { - if (enabled == false|| transportClientMode) { - return Collections.emptyList(); - } - return Arrays.>asList( - GraphLicensee.class - ); - } - } diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphFeatureSet.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphFeatureSet.java new file mode 100644 index 00000000000..ea0fdf18e7c --- /dev/null +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphFeatureSet.java @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.graph; + +import org.elasticsearch.common.Nullable; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.xpack.XPackFeatureSet; + +/** + * + */ +public class GraphFeatureSet implements XPackFeatureSet { + + private final boolean enabled; + private final GraphLicensee licensee; + + @Inject + public GraphFeatureSet(Settings settings, @Nullable GraphLicensee licensee) { + this.enabled = Graph.enabled(settings); + this.licensee = licensee; + } + + @Override + public String name() { + return Graph.NAME; + } + + @Override + public String description() { + return "Graph Data Exploration for the Elastic Stack"; + } + + @Override + public boolean available() { + return licensee != null && licensee.isAvailable(); + } + + @Override + public boolean enabled() { + return enabled; + } +} diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/license/GraphLicensee.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphLicensee.java similarity index 95% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/license/GraphLicensee.java rename to elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphLicensee.java index 9848e4679b0..4aaec502c59 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/license/GraphLicensee.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphLicensee.java @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.graph.license; +package org.elasticsearch.graph; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -13,7 +13,6 @@ import org.elasticsearch.license.core.License.OperationMode; import org.elasticsearch.license.plugin.core.AbstractLicenseeComponent; import org.elasticsearch.license.plugin.core.LicenseState; import org.elasticsearch.license.plugin.core.LicenseeRegistry; -import org.elasticsearch.graph.Graph; public class GraphLicensee extends AbstractLicenseeComponent { @@ -60,7 +59,7 @@ public class GraphLicensee extends AbstractLicenseeComponent { * * @return {@code true} as long as the license is valid. Otherwise {@code false}. */ - public boolean isGraphExploreEnabled() { + public boolean isAvailable() { // status is volatile Status localStatus = status; OperationMode operationMode = localStatus.getMode(); diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphModule.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphModule.java new file mode 100644 index 00000000000..eaf145e5e9c --- /dev/null +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/GraphModule.java @@ -0,0 +1,35 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.graph; + +import org.elasticsearch.common.inject.AbstractModule; +import org.elasticsearch.common.inject.util.Providers; +import org.elasticsearch.xpack.XPackPlugin; + +/** + * + */ +public class GraphModule extends AbstractModule { + + private final boolean enabled; + private final boolean transportClientNode; + + public GraphModule(boolean enabled, boolean transportClientNode) { + this.enabled = enabled; + this.transportClientNode = transportClientNode; + } + + @Override + protected void configure() { + XPackPlugin.bindFeatureSet(binder(), GraphFeatureSet.class); + if (enabled && transportClientNode == false) { + bind(GraphLicensee.class).asEagerSingleton(); + } else { + bind(GraphLicensee.class).toProvider(Providers.of(null)); + } + } + +} diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/TransportGraphExploreAction.java b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/TransportGraphExploreAction.java index b6a1af125cf..74263e9b500 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/TransportGraphExploreAction.java +++ b/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/action/TransportGraphExploreAction.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.util.CollectionUtils; import org.elasticsearch.graph.action.Connection.ConnectionId; import org.elasticsearch.graph.action.GraphExploreRequest.TermBoost; import org.elasticsearch.graph.action.Vertex.VertexId; -import org.elasticsearch.graph.license.GraphLicensee; +import org.elasticsearch.graph.GraphLicensee; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.license.plugin.core.LicenseUtils; @@ -85,7 +85,7 @@ public class TransportGraphExploreAction extends HandledTransportAction listener) { - if (licensee.isGraphExploreEnabled()) { + if (licensee.isAvailable()) { new AsyncGraphAction(request, listener).start(); } else { listener.onFailure(LicenseUtils.newComplianceException(GraphLicensee.ID)); diff --git a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/license/LicenseTests.java b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/license/LicenseTests.java index ebf339b7d88..fc1084c43b9 100644 --- a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/license/LicenseTests.java +++ b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/license/LicenseTests.java @@ -6,6 +6,7 @@ package org.elasticsearch.graph.license; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.graph.GraphLicensee; import org.elasticsearch.license.core.License.OperationMode; import org.elasticsearch.license.plugin.core.AbstractLicenseeTestCase; @@ -95,10 +96,10 @@ public class LicenseTests extends AbstractLicenseeTestCase { } private void assertLicensePlatinumTrialBehaviour(GraphLicensee graphLicensee) { - assertThat("Expected graph exploration to be allowed", graphLicensee.isGraphExploreEnabled(), is(true)); + assertThat("Expected graph exploration to be allowed", graphLicensee.isAvailable(), is(true)); } private void assertLicenseBasicOrGoldOrNoneOrExpiredBehaviour(GraphLicensee graphLicensee) { - assertThat("Expected graph exploration not to be allowed", graphLicensee.isGraphExploreEnabled(), is(false)); + assertThat("Expected graph exploration not to be allowed", graphLicensee.isAvailable(), is(false)); } } diff --git a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/test/GraphTests.java b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/test/GraphTests.java index 1c633cdf61a..ae41b198e26 100644 --- a/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/test/GraphTests.java +++ b/elasticsearch/x-pack/graph/src/test/java/org/elasticsearch/graph/test/GraphTests.java @@ -19,7 +19,7 @@ import org.elasticsearch.graph.action.Vertex; import org.elasticsearch.graph.action.VertexRequest; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.ScriptQueryBuilder; -import org.elasticsearch.marvel.Marvel; +import org.elasticsearch.marvel.Monitoring; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.script.AbstractSearchScript; import org.elasticsearch.script.ExecutableScript; @@ -126,7 +126,7 @@ public class GraphTests extends ESSingleNodeTestCase { // Disable Shield otherwise authentication failures happen creating indices. Builder newSettings = Settings.builder(); newSettings.put(XPackPlugin.featureEnabledSetting(Security.NAME), false); - newSettings.put(XPackPlugin.featureEnabledSetting(Marvel.NAME), false); + newSettings.put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false); newSettings.put(XPackPlugin.featureEnabledSetting(Watcher.NAME), false); return newSettings.build(); } diff --git a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/AbstractLicensesIntegrationTestCase.java b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/AbstractLicensesIntegrationTestCase.java index e46027d642c..be32fbb528f 100644 --- a/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/AbstractLicensesIntegrationTestCase.java +++ b/elasticsearch/x-pack/license-plugin/src/test/java/org/elasticsearch/license/plugin/AbstractLicensesIntegrationTestCase.java @@ -24,7 +24,7 @@ import org.elasticsearch.license.plugin.core.LicenseState; import org.elasticsearch.license.plugin.core.LicensesManagerService; import org.elasticsearch.license.plugin.core.LicensesMetaData; import org.elasticsearch.license.plugin.core.LicensesStatus; -import org.elasticsearch.marvel.Marvel; +import org.elasticsearch.marvel.Monitoring; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.shield.Security; import org.elasticsearch.test.ESIntegTestCase; @@ -49,7 +49,7 @@ public abstract class AbstractLicensesIntegrationTestCase extends ESIntegTestCas protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(XPackPlugin.featureEnabledSetting(Security.NAME), false) - .put(XPackPlugin.featureEnabledSetting(Marvel.NAME), false) + .put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false) .put(XPackPlugin.featureEnabledSetting(Watcher.NAME), false) .put(XPackPlugin.featureEnabledSetting(Graph.NAME), false) .build(); diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MarvelModule.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MarvelModule.java deleted file mode 100644 index c5125da6c2c..00000000000 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MarvelModule.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.marvel; - -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.marvel.agent.AgentService; -import org.elasticsearch.marvel.cleaner.CleanerService; - -public class MarvelModule extends AbstractModule { - - @Override - protected void configure() { - bind(MarvelSettings.class).asEagerSingleton(); - bind(AgentService.class).asEagerSingleton(); - bind(CleanerService.class).asEagerSingleton(); - } -} diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/Marvel.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/Monitoring.java similarity index 83% rename from elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/Marvel.java rename to elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/Monitoring.java index 6440795572d..c4725e523c9 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/Marvel.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/Monitoring.java @@ -18,16 +18,16 @@ import org.elasticsearch.marvel.agent.collector.CollectorModule; import org.elasticsearch.marvel.agent.exporter.ExporterModule; import org.elasticsearch.marvel.cleaner.CleanerService; import org.elasticsearch.marvel.client.MonitoringClientModule; -import org.elasticsearch.marvel.license.LicenseModule; -import org.elasticsearch.marvel.license.MarvelLicensee; import org.elasticsearch.marvel.rest.action.RestMonitoringBulkAction; import org.elasticsearch.marvel.support.init.proxy.MonitoringClientProxy; import org.elasticsearch.xpack.XPackPlugin; import org.elasticsearch.xpack.common.init.LazyInitializationModule; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.List; /** * This class activates/deactivates the monitoring modules depending if we're running a node client, transport client or tribe client: @@ -35,7 +35,7 @@ import java.util.Collections; * - transport clients: only action/transport actions are binded * - tribe clients: everything is disables by default but can be enabled per tribe cluster */ -public class Marvel { +public class Monitoring { public static final String NAME = "monitoring"; @@ -43,9 +43,9 @@ public class Marvel { private final boolean enabled; private final boolean transportClientMode; - public Marvel(Settings settings) { + public Monitoring(Settings settings) { this.settings = settings; - this.enabled = MarvelSettings.ENABLED.get(settings); + this.enabled = MonitoringSettings.ENABLED.get(settings); this.transportClientMode = XPackPlugin.transportClientMode(settings); } @@ -58,29 +58,27 @@ public class Marvel { } public Collection nodeModules() { - if (enabled == false || transportClientMode) { - return Collections.emptyList(); + List modules = new ArrayList<>(); + modules.add(new MonitoringModule(enabled, transportClientMode)); + if (enabled && transportClientMode == false) { + modules.add(new CollectorModule()); + modules.add(new ExporterModule(settings)); + modules.add(new MonitoringClientModule()); } - - return Arrays.asList( - new MarvelModule(), - new LicenseModule(), - new CollectorModule(), - new ExporterModule(settings), - new MonitoringClientModule()); + return modules; } public Collection> nodeServices() { if (enabled == false || transportClientMode) { return Collections.emptyList(); } - return Arrays.>asList(MarvelLicensee.class, + return Arrays.>asList(MonitoringLicensee.class, AgentService.class, CleanerService.class); } public void onModule(SettingsModule module) { - MarvelSettings.register(module); + MonitoringSettings.register(module); } public void onModule(ActionModule module) { diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringFeatureSet.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringFeatureSet.java new file mode 100644 index 00000000000..c8b6dd29005 --- /dev/null +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringFeatureSet.java @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.marvel; + +import org.elasticsearch.common.Nullable; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.xpack.XPackFeatureSet; + +/** + * + */ +public class MonitoringFeatureSet implements XPackFeatureSet { + + private final boolean enabled; + private final MonitoringLicensee licensee; + + @Inject + public MonitoringFeatureSet(Settings settings, @Nullable MonitoringLicensee licensee) { + this.enabled = MonitoringSettings.ENABLED.get(settings); + this.licensee = licensee; + } + + @Override + public String name() { + return Monitoring.NAME; + } + + @Override + public String description() { + return "Monitoring for the Elastic Stack"; + } + + @Override + public boolean available() { + return licensee != null && licensee.available(); + } + + @Override + public boolean enabled() { + return enabled; + } +} diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/license/MarvelLicensee.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringLicensee.java similarity index 88% rename from elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/license/MarvelLicensee.java rename to elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringLicensee.java index aa70d45106b..e73a8f40321 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/license/MarvelLicensee.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringLicensee.java @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.marvel.license; +package org.elasticsearch.marvel; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -15,8 +15,6 @@ import org.elasticsearch.license.plugin.core.AbstractLicenseeComponent; import org.elasticsearch.license.plugin.core.LicenseState; import org.elasticsearch.license.plugin.core.Licensee; import org.elasticsearch.license.plugin.core.LicenseeRegistry; -import org.elasticsearch.marvel.Marvel; -import org.elasticsearch.marvel.MarvelSettings; /** * {@code MarvelLicensee} determines whether certain features of Monitoring are enabled or disabled. @@ -27,11 +25,11 @@ import org.elasticsearch.marvel.MarvelSettings; *
  • Cleaning up (deleting) older indices.
  • * */ -public class MarvelLicensee extends AbstractLicenseeComponent implements Licensee { +public class MonitoringLicensee extends AbstractLicenseeComponent implements Licensee { @Inject - public MarvelLicensee(Settings settings, LicenseeRegistry clientService) { - super(settings, Marvel.NAME, clientService); + public MonitoringLicensee(Settings settings, LicenseeRegistry clientService) { + super(settings, Monitoring.NAME, clientService); } /** @@ -67,7 +65,7 @@ public class MarvelLicensee extends AbstractLicenseeComponent im newLicense.type(), newLicense.type(), newLicense.type()), LoggerMessageFormat.format( "Automatic index cleanup is locked to {} days for clusters with [{}] license.", - MarvelSettings.HISTORY_DURATION.getDefault(Settings.EMPTY).days(), newLicense.type()) + MonitoringSettings.HISTORY_DURATION.getDefault(Settings.EMPTY).days(), newLicense.type()) }; } } @@ -76,6 +74,15 @@ public class MarvelLicensee extends AbstractLicenseeComponent im return Strings.EMPTY_ARRAY; } + /** + * Monitoring is always available regardless of the license type (operation mode) + * + * @return true + */ + public boolean available() { + return true; + } + /** * Determine if the index cleaning service is enabled. *

    diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringModule.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringModule.java new file mode 100644 index 00000000000..6bf0f453c99 --- /dev/null +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringModule.java @@ -0,0 +1,37 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.marvel; + +import org.elasticsearch.common.inject.AbstractModule; +import org.elasticsearch.common.inject.util.Providers; +import org.elasticsearch.marvel.agent.AgentService; +import org.elasticsearch.marvel.cleaner.CleanerService; +import org.elasticsearch.xpack.XPackPlugin; + +public class MonitoringModule extends AbstractModule { + + private final boolean enabled; + private final boolean transportClientMode; + + public MonitoringModule(boolean enabled, boolean transportClientMode) { + this.enabled = enabled; + this.transportClientMode = transportClientMode; + } + + @Override + protected void configure() { + XPackPlugin.bindFeatureSet(binder(), MonitoringFeatureSet.class); + + if (enabled && transportClientMode == false) { + bind(MonitoringLicensee.class).asEagerSingleton(); + bind(MonitoringSettings.class).asEagerSingleton(); + bind(AgentService.class).asEagerSingleton(); + bind(CleanerService.class).asEagerSingleton(); + } else { + bind(MonitoringLicensee.class).toProvider(Providers.of(null)); + } + } +} diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MarvelSettings.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringSettings.java similarity index 96% rename from elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MarvelSettings.java rename to elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringSettings.java index 6d6a74212b7..3ee8afcce21 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MarvelSettings.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/MonitoringSettings.java @@ -25,7 +25,7 @@ import static org.elasticsearch.common.settings.Setting.groupSetting; import static org.elasticsearch.common.settings.Setting.listSetting; import static org.elasticsearch.common.settings.Setting.timeSetting; -public class MarvelSettings extends AbstractComponent { +public class MonitoringSettings extends AbstractComponent { public static final String LEGACY_DATA_INDEX_NAME = ".marvel-es-data"; @@ -40,7 +40,7 @@ public class MarvelSettings extends AbstractComponent { * Determines whether monitoring is enabled/disabled */ public static final Setting ENABLED = - new Setting<>(XPackPlugin.featureEnabledSetting(Marvel.NAME), + new Setting<>(XPackPlugin.featureEnabledSetting(Monitoring.NAME), // By default, marvel is disabled on tribe nodes (s) -> String.valueOf(!XPackPlugin.isTribeNode(s) && !XPackPlugin.isTribeClientNode(s)), @@ -153,7 +153,7 @@ public class MarvelSettings extends AbstractComponent { private volatile String[] indices; @Inject - public MarvelSettings(Settings settings, ClusterSettings clusterSettings) { + public MonitoringSettings(Settings settings, ClusterSettings clusterSettings) { super(settings); setIndexStatsTimeout(INDEX_STATS_TIMEOUT.get(settings)); @@ -233,7 +233,7 @@ public class MarvelSettings extends AbstractComponent { * @return The key prefixed by the product prefixes. */ static String key(String key) { - return XPackPlugin.featureSettingPrefix(Marvel.NAME) + "." + key; + return XPackPlugin.featureSettingPrefix(Monitoring.NAME) + "." + key; } } diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/AgentService.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/AgentService.java index b7dfbc57193..697c9b0f52a 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/AgentService.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/AgentService.java @@ -16,7 +16,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.CollectionUtils; import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.common.util.concurrent.ReleasableLock; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.agent.collector.Collector; import org.elasticsearch.marvel.agent.collector.cluster.ClusterStatsCollector; import org.elasticsearch.marvel.agent.exporter.ExportException; @@ -54,12 +54,12 @@ public class AgentService extends AbstractLifecycleComponent { @Inject public AgentService(Settings settings, ClusterSettings clusterSettings, Set collectors, Exporters exporters) { super(settings); - this.samplingIntervalMillis = MarvelSettings.INTERVAL.get(settings).millis(); - this.settingsCollectors = MarvelSettings.COLLECTORS.get(settings).toArray(new String[0]); + this.samplingIntervalMillis = MonitoringSettings.INTERVAL.get(settings).millis(); + this.settingsCollectors = MonitoringSettings.COLLECTORS.get(settings).toArray(new String[0]); this.collectors = Collections.unmodifiableSet(filterCollectors(collectors, settingsCollectors)); this.exporters = exporters; - clusterSettings.addSettingsUpdateConsumer(MarvelSettings.INTERVAL, this::setInterval); + clusterSettings.addSettingsUpdateConsumer(MonitoringSettings.INTERVAL, this::setInterval); } private void setInterval(TimeValue interval) { diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/AbstractCollector.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/AbstractCollector.java index 4fb939fcb27..bbed7bf34c5 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/AbstractCollector.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/AbstractCollector.java @@ -12,10 +12,10 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.component.AbstractLifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.exporter.MonitoringDoc; -import org.elasticsearch.marvel.license.MarvelLicensee; +import org.elasticsearch.marvel.MonitoringLicensee; import java.util.Collection; @@ -24,16 +24,16 @@ public abstract class AbstractCollector extends AbstractLifecycleComponent private final String name; protected final ClusterService clusterService; - protected final MarvelSettings marvelSettings; - protected final MarvelLicensee licensee; + protected final MonitoringSettings monitoringSettings; + protected final MonitoringLicensee licensee; @Inject public AbstractCollector(Settings settings, String name, ClusterService clusterService, - MarvelSettings marvelSettings, MarvelLicensee licensee) { + MonitoringSettings monitoringSettings, MonitoringLicensee licensee) { super(settings); this.name = name; this.clusterService = clusterService; - this.marvelSettings = marvelSettings; + this.monitoringSettings = monitoringSettings; this.licensee = licensee; } diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollector.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollector.java index d24162e9673..cd444432395 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollector.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollector.java @@ -13,10 +13,10 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.agent.collector.AbstractCollector; import org.elasticsearch.marvel.agent.exporter.MonitoringDoc; -import org.elasticsearch.marvel.license.MarvelLicensee; +import org.elasticsearch.marvel.MonitoringLicensee; import org.elasticsearch.shield.InternalClient; import java.util.ArrayList; @@ -38,8 +38,8 @@ public class ClusterStateCollector extends AbstractCollector results = new ArrayList<>(1); try { RecoveryResponse recoveryResponse = client.admin().indices().prepareRecoveries() - .setIndices(marvelSettings.indices()) + .setIndices(monitoringSettings.indices()) .setIndicesOptions(IndicesOptions.lenientExpandOpen()) - .setActiveOnly(marvelSettings.recoveryActiveOnly()) - .get(marvelSettings.recoveryTimeout()); + .setActiveOnly(monitoringSettings.recoveryActiveOnly()) + .get(monitoringSettings.recoveryTimeout()); if (recoveryResponse.hasRecoveries()) { IndexRecoveryMonitoringDoc indexRecoveryDoc = new IndexRecoveryMonitoringDoc(monitoringId(), monitoringVersion()); @@ -69,7 +69,7 @@ public class IndexRecoveryCollector extends AbstractCollector @Inject public IndexStatsCollector(Settings settings, ClusterService clusterService, - MarvelSettings marvelSettings, MarvelLicensee marvelLicensee, InternalClient client) { - super(settings, NAME, clusterService, marvelSettings, marvelLicensee); + MonitoringSettings monitoringSettings, MonitoringLicensee licensee, InternalClient client) { + super(settings, NAME, clusterService, monitoringSettings, licensee); this.client = client; } @@ -57,7 +57,7 @@ public class IndexStatsCollector extends AbstractCollector List results = new ArrayList<>(); try { IndicesStatsResponse indicesStats = client.admin().indices().prepareStats() - .setIndices(marvelSettings.indices()) + .setIndices(monitoringSettings.indices()) .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .clear() .setDocs(true) @@ -68,7 +68,7 @@ public class IndexStatsCollector extends AbstractCollector .setSegments(true) .setStore(true) .setRefresh(true) - .get(marvelSettings.indexStatsTimeout()); + .get(monitoringSettings.indexStatsTimeout()); long timestamp = System.currentTimeMillis(); String clusterUUID = clusterUUID(); @@ -83,7 +83,7 @@ public class IndexStatsCollector extends AbstractCollector results.add(indexStatsDoc); } } catch (IndexNotFoundException e) { - if (Security.enabled(settings) && IndexNameExpressionResolver.isAllIndices(Arrays.asList(marvelSettings.indices()))) { + if (Security.enabled(settings) && IndexNameExpressionResolver.isAllIndices(Arrays.asList(monitoringSettings.indices()))) { logger.debug("collector [{}] - unable to collect data for missing index [{}]", name(), e.getIndex()); } else { throw e; diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollector.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollector.java index 8c56780f640..170e230ff0a 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollector.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollector.java @@ -13,10 +13,10 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexNotFoundException; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.agent.collector.AbstractCollector; import org.elasticsearch.marvel.agent.exporter.MonitoringDoc; -import org.elasticsearch.marvel.license.MarvelLicensee; +import org.elasticsearch.marvel.MonitoringLicensee; import org.elasticsearch.shield.InternalClient; import org.elasticsearch.shield.Security; @@ -37,8 +37,8 @@ public class IndicesStatsCollector extends AbstractCollector doCollect() throws Exception { try { IndicesStatsResponse indicesStats = client.admin().indices().prepareStats() - .setIndices(marvelSettings.indices()) + .setIndices(monitoringSettings.indices()) .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .clear() .setDocs(true) .setIndexing(true) .setSearch(true) .setStore(true) - .get(marvelSettings.indicesStatsTimeout()); + .get(monitoringSettings.indicesStatsTimeout()); IndicesStatsMonitoringDoc indicesStatsDoc = new IndicesStatsMonitoringDoc(monitoringId(), monitoringVersion()); indicesStatsDoc.setClusterUUID(clusterUUID()); @@ -68,7 +68,7 @@ public class IndicesStatsCollector extends AbstractCollector { private final DiskThresholdDecider diskThresholdDecider; @Inject - public NodeStatsCollector(Settings settings, ClusterService clusterService, MarvelSettings marvelSettings, - MarvelLicensee marvelLicensee, InternalClient client, + public NodeStatsCollector(Settings settings, ClusterService clusterService, MonitoringSettings monitoringSettings, + MonitoringLicensee licensee, InternalClient client, NodeEnvironment nodeEnvironment, DiskThresholdDecider diskThresholdDecider) { - super(settings, NAME, clusterService, marvelSettings, marvelLicensee); + super(settings, NAME, clusterService, monitoringSettings, licensee); this.client = client; this.nodeEnvironment = nodeEnvironment; this.diskThresholdDecider = diskThresholdDecider; diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollector.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollector.java index 5c6fef95b3c..919408139dd 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollector.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollector.java @@ -13,10 +13,10 @@ import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.agent.collector.AbstractCollector; import org.elasticsearch.marvel.agent.exporter.MonitoringDoc; -import org.elasticsearch.marvel.license.MarvelLicensee; +import org.elasticsearch.marvel.MonitoringLicensee; import java.util.ArrayList; import java.util.Arrays; @@ -36,8 +36,8 @@ public class ShardsCollector extends AbstractCollector { @Inject public ShardsCollector(Settings settings, ClusterService clusterService, - MarvelSettings marvelSettings, MarvelLicensee marvelLicensee) { - super(settings, NAME, clusterService, marvelSettings, marvelLicensee); + MonitoringSettings monitoringSettings, MonitoringLicensee licensee) { + super(settings, NAME, clusterService, monitoringSettings, licensee); } @Override @@ -82,7 +82,8 @@ public class ShardsCollector extends AbstractCollector { } private boolean match(String indexName) { - String[] indices = marvelSettings.indices(); - return IndexNameExpressionResolver.isAllIndices(Arrays.asList(marvelSettings.indices())) || Regex.simpleMatch(indices, indexName); + String[] indices = monitoringSettings.indices(); + return IndexNameExpressionResolver + .isAllIndices(Arrays.asList(monitoringSettings.indices())) || Regex.simpleMatch(indices, indexName); } } diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/exporter/Exporter.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/exporter/Exporter.java index 581a253daee..6bf3b09564f 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/exporter/Exporter.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/exporter/Exporter.java @@ -10,7 +10,7 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import java.util.concurrent.atomic.AtomicBoolean; @@ -65,7 +65,7 @@ public abstract class Exporter implements AutoCloseable { protected abstract void doClose(); protected String settingFQN(String setting) { - return MarvelSettings.EXPORTERS_SETTINGS.getKey() + config.name + "." + setting; + return MonitoringSettings.EXPORTERS_SETTINGS.getKey() + config.name + "." + setting; } public static class Config { diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/exporter/Exporters.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/exporter/Exporters.java index 2910664b8ef..4c98b6194c2 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/exporter/Exporters.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/exporter/Exporters.java @@ -13,7 +13,7 @@ import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsException; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.agent.exporter.local.LocalExporter; import org.elasticsearch.node.Node; @@ -48,7 +48,7 @@ public class Exporters extends AbstractLifecycleComponent implements this.factories = factories; this.clusterService = clusterService; this.exporters = new AtomicReference<>(emptyMap()); - clusterSettings.addSettingsUpdateConsumer(MarvelSettings.EXPORTERS_SETTINGS, this::setExportersSetting); + clusterSettings.addSettingsUpdateConsumer(MonitoringSettings.EXPORTERS_SETTINGS, this::setExportersSetting); } private void setExportersSetting(Settings exportersSetting) { @@ -63,7 +63,7 @@ public class Exporters extends AbstractLifecycleComponent implements @Override protected void doStart() { - exporters.set(initExporters(MarvelSettings.EXPORTERS_SETTINGS.get(settings))); + exporters.set(initExporters(MonitoringSettings.EXPORTERS_SETTINGS.get(settings))); } @Override diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/cleaner/CleanerService.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/cleaner/CleanerService.java index 1eb6aaba2d7..a0a0c8f813b 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/cleaner/CleanerService.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/cleaner/CleanerService.java @@ -13,8 +13,8 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.AbstractLifecycleRunnable; import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.common.util.concurrent.FutureUtils; -import org.elasticsearch.marvel.MarvelSettings; -import org.elasticsearch.marvel.license.MarvelLicensee; +import org.elasticsearch.marvel.MonitoringSettings; +import org.elasticsearch.marvel.MonitoringLicensee; import org.elasticsearch.threadpool.ThreadPool; import org.joda.time.DateTime; import org.joda.time.chrono.ISOChronology; @@ -28,7 +28,7 @@ import java.util.concurrent.ScheduledFuture; */ public class CleanerService extends AbstractLifecycleComponent { - private final MarvelLicensee licensee; + private final MonitoringLicensee licensee; private final ThreadPool threadPool; private final ExecutionScheduler executionScheduler; private final List listeners = new CopyOnWriteArrayList<>(); @@ -36,21 +36,21 @@ public class CleanerService extends AbstractLifecycleComponent { private volatile TimeValue globalRetention; - CleanerService(Settings settings, ClusterSettings clusterSettings, MarvelLicensee licensee, ThreadPool threadPool, + CleanerService(Settings settings, ClusterSettings clusterSettings, MonitoringLicensee licensee, ThreadPool threadPool, ExecutionScheduler executionScheduler) { super(settings); this.licensee = licensee; this.threadPool = threadPool; this.executionScheduler = executionScheduler; - this.globalRetention = MarvelSettings.HISTORY_DURATION.get(settings); + this.globalRetention = MonitoringSettings.HISTORY_DURATION.get(settings); this.runnable = new IndicesCleaner(); // the validation is performed by the setting's object itself - clusterSettings.addSettingsUpdateConsumer(MarvelSettings.HISTORY_DURATION, this::setGlobalRetention); + clusterSettings.addSettingsUpdateConsumer(MonitoringSettings.HISTORY_DURATION, this::setGlobalRetention); } @Inject - public CleanerService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool, MarvelLicensee licensee) { + public CleanerService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool, MonitoringLicensee licensee) { this(settings, clusterSettings, licensee,threadPool, new DefaultExecutionScheduler()); } @@ -85,7 +85,7 @@ public class CleanerService extends AbstractLifecycleComponent { * This will ignore the global retention if the license does not allow retention updates. * * @return Never {@code null} - * @see MarvelLicensee#allowUpdateRetention() + * @see MonitoringLicensee#allowUpdateRetention() */ public TimeValue getRetention() { // we only care about their value if they are allowed to set it @@ -93,7 +93,7 @@ public class CleanerService extends AbstractLifecycleComponent { return globalRetention; } else { - return MarvelSettings.HISTORY_DURATION.getDefault(Settings.EMPTY); + return MonitoringSettings.HISTORY_DURATION.getDefault(Settings.EMPTY); } } @@ -108,7 +108,8 @@ public class CleanerService extends AbstractLifecycleComponent { public void setGlobalRetention(TimeValue globalRetention) { // notify the user that their setting will be ignored until they get the right license if (licensee.allowUpdateRetention() == false) { - logger.warn("[{}] setting will be ignored until an appropriate license is applied", MarvelSettings.HISTORY_DURATION.getKey()); + logger.warn("[{}] setting will be ignored until an appropriate license is applied", + MonitoringSettings.HISTORY_DURATION.getKey()); } this.globalRetention = globalRetention; diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/license/LicenseModule.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/license/LicenseModule.java deleted file mode 100644 index 40cba26b5d4..00000000000 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/license/LicenseModule.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.marvel.license; - -import org.elasticsearch.common.inject.AbstractModule; - -public class LicenseModule extends AbstractModule { - - @Override - protected void configure() { - bind(MarvelLicensee.class).asEagerSingleton(); - } - -} \ No newline at end of file diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginClientTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginClientTests.java index 6eb4d8bbb0f..cc1dc71e881 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginClientTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginClientTests.java @@ -16,16 +16,15 @@ import java.util.Collection; import static org.hamcrest.Matchers.is; public class MarvelPluginClientTests extends ESTestCase { + public void testModulesWithClientSettings() { Settings settings = Settings.builder() .put(Client.CLIENT_TYPE_SETTING_S.getKey(), TransportClient.CLIENT_TYPE) .build(); - Marvel plugin = new Marvel(settings); + Monitoring plugin = new Monitoring(settings); assertThat(plugin.isEnabled(), is(true)); assertThat(plugin.isTransportClient(), is(true)); - Collection modules = plugin.nodeModules(); - assertThat(modules.size(), is(0)); } public void testModulesWithNodeSettings() { @@ -33,10 +32,8 @@ public class MarvelPluginClientTests extends ESTestCase { Settings settings = Settings.builder() .put(Client.CLIENT_TYPE_SETTING_S.getKey(), "node") .build(); - Marvel plugin = new Marvel(settings); + Monitoring plugin = new Monitoring(settings); assertThat(plugin.isEnabled(), is(true)); assertThat(plugin.isTransportClient(), is(false)); - Collection modules = plugin.nodeModules(); - assertThat(modules.size(), is(5)); } } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginTests.java index a0fb6d3a4b2..63b4753e673 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelPluginTests.java @@ -35,13 +35,13 @@ public class MarvelPluginTests extends MarvelIntegTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.INTERVAL.getKey(), "-1") .build(); } public void testMarvelEnabled() { internalCluster().startNode(Settings.builder() - .put(XPackPlugin.featureEnabledSetting(Marvel.NAME), true) + .put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), true) .build()); assertPluginIsLoaded(); assertServiceIsBound(AgentService.class); @@ -49,7 +49,7 @@ public class MarvelPluginTests extends MarvelIntegTestCase { public void testMarvelDisabled() { internalCluster().startNode(Settings.builder() - .put(XPackPlugin.featureEnabledSetting(Marvel.NAME), false) + .put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false) .build()); assertPluginIsLoaded(); assertServiceIsNotBound(AgentService.class); @@ -57,7 +57,7 @@ public class MarvelPluginTests extends MarvelIntegTestCase { public void testMarvelEnabledOnTribeNode() { internalCluster().startNode(Settings.builder() - .put(XPackPlugin.featureEnabledSetting(Marvel.NAME), true) + .put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), true) .put("tribe.name", "t1") .build()); assertPluginIsLoaded(); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelSettingsTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelSettingsTests.java index 82f1a9d2abd..d6240ea4c71 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelSettingsTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/MarvelSettingsTests.java @@ -13,7 +13,7 @@ import org.junit.Rule; import org.junit.rules.ExpectedException; /** - * Tests {@link MarvelSettings} + * Tests {@link MonitoringSettings} */ public class MarvelSettingsTests extends ESTestCase { @Rule @@ -23,24 +23,24 @@ public class MarvelSettingsTests extends ESTestCase { TimeValue sevenDays = TimeValue.timeValueHours(7 * 24); // 7 days - assertEquals(sevenDays, MarvelSettings.HISTORY_DURATION.get(Settings.EMPTY)); + assertEquals(sevenDays, MonitoringSettings.HISTORY_DURATION.get(Settings.EMPTY)); // Note: this verifies the semantics because this is taken for granted that it never returns null! - assertEquals(sevenDays, MarvelSettings.HISTORY_DURATION.get(buildSettings(MarvelSettings.HISTORY_DURATION.getKey(), null))); + assertEquals(sevenDays, MonitoringSettings.HISTORY_DURATION.get(buildSettings(MonitoringSettings.HISTORY_DURATION.getKey(), null))); } public void testHistoryDurationMinimum24Hours() { // hit the minimum - assertEquals(MarvelSettings.HISTORY_DURATION_MINIMUM, - MarvelSettings.HISTORY_DURATION.get(buildSettings(MarvelSettings.HISTORY_DURATION.getKey(), "24h"))); + assertEquals(MonitoringSettings.HISTORY_DURATION_MINIMUM, + MonitoringSettings.HISTORY_DURATION.get(buildSettings(MonitoringSettings.HISTORY_DURATION.getKey(), "24h"))); } public void testHistoryDurationMinimum24HoursBlocksLower() { expectedException.expect(IllegalArgumentException.class); // 1 ms early! - String oneSecondEarly = (MarvelSettings.HISTORY_DURATION_MINIMUM.millis() - 1) + "ms"; + String oneSecondEarly = (MonitoringSettings.HISTORY_DURATION_MINIMUM.millis() - 1) + "ms"; - MarvelSettings.HISTORY_DURATION.get(buildSettings(MarvelSettings.HISTORY_DURATION.getKey(), oneSecondEarly)); + MonitoringSettings.HISTORY_DURATION.get(buildSettings(MonitoringSettings.HISTORY_DURATION.getKey(), oneSecondEarly)); } private Settings buildSettings(String key, String value) { diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/action/TransportMonitoringBulkActionTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/action/TransportMonitoringBulkActionTests.java index d5cb049176a..4dc0f3d7d11 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/action/TransportMonitoringBulkActionTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/action/TransportMonitoringBulkActionTests.java @@ -23,7 +23,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.DummyTransportAddress; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.discovery.DiscoverySettings; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.exporter.ExportException; import org.elasticsearch.marvel.agent.exporter.Exporters; @@ -257,7 +257,7 @@ public class TransportMonitoringBulkActionTests extends ESTestCase { public CapturingExporters() { super(Settings.EMPTY, Collections.emptyMap(), clusterService, - new ClusterSettings(Settings.EMPTY, Collections.singleton(MarvelSettings.EXPORTERS_SETTINGS))); + new ClusterSettings(Settings.EMPTY, Collections.singleton(MonitoringSettings.EXPORTERS_SETTINGS))); } @Override @@ -279,7 +279,7 @@ public class TransportMonitoringBulkActionTests extends ESTestCase { public ConsumingExporters(Consumer> consumer) { super(Settings.EMPTY, Collections.emptyMap(), clusterService, - new ClusterSettings(Settings.EMPTY, Collections.singleton(MarvelSettings.EXPORTERS_SETTINGS))); + new ClusterSettings(Settings.EMPTY, Collections.singleton(MonitoringSettings.EXPORTERS_SETTINGS))); this.consumer = consumer; } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/AbstractCollectorTestCase.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/AbstractCollectorTestCase.java index 0c0cc7f61f5..c9d20457c6b 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/AbstractCollectorTestCase.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/AbstractCollectorTestCase.java @@ -23,7 +23,7 @@ import org.elasticsearch.license.plugin.core.LicenseState; import org.elasticsearch.license.plugin.core.Licensee; import org.elasticsearch.license.plugin.core.LicenseeRegistry; import org.elasticsearch.license.plugin.core.LicensesManagerService; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.shield.InternalClient; @@ -54,7 +54,7 @@ public abstract class AbstractCollectorTestCase extends MarvelIntegTestCase { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) .put(NetworkModule.HTTP_ENABLED.getKey(), false) - .put(MarvelSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.INTERVAL.getKey(), "-1") .build(); } @@ -126,7 +126,7 @@ public abstract class AbstractCollectorTestCase extends MarvelIntegTestCase { } protected static void endGracefulPeriod() { - long expiryDate = System.currentTimeMillis() - MarvelSettings.MAX_LICENSE_GRACE_PERIOD.millis() - timeValueMinutes(10).millis(); + long expiryDate = System.currentTimeMillis() - MonitoringSettings.MAX_LICENSE_GRACE_PERIOD.millis() - timeValueMinutes(10).millis(); long issueDate = expiryDate - randomDaysInMillis(); final License license = createTestingLicense(issueDate, expiryDate); @@ -139,7 +139,7 @@ public abstract class AbstractCollectorTestCase extends MarvelIntegTestCase { } protected static void disableLicense() { - long expiryDate = System.currentTimeMillis() - MarvelSettings.MAX_LICENSE_GRACE_PERIOD.millis() - randomDaysInMillis(); + long expiryDate = System.currentTimeMillis() - MonitoringSettings.MAX_LICENSE_GRACE_PERIOD.millis() - randomDaysInMillis(); long issueDate = expiryDate - randomDaysInMillis(); final License license = createTestingLicense(issueDate, expiryDate); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollectorTests.java index b330155d6cb..c1075c51af0 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStateCollectorTests.java @@ -10,11 +10,11 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MonitoringDoc; -import org.elasticsearch.marvel.license.MarvelLicensee; +import org.elasticsearch.marvel.MonitoringLicensee; import java.util.ArrayList; import java.util.Collection; @@ -153,8 +153,8 @@ public class ClusterStateCollectorTests extends AbstractCollectorTestCase { assertNotNull(nodeId); return new ClusterStateCollector(internalCluster().getInstance(Settings.class, nodeId), internalCluster().getInstance(ClusterService.class, nodeId), - internalCluster().getInstance(MarvelSettings.class, nodeId), - internalCluster().getInstance(MarvelLicensee.class, nodeId), + internalCluster().getInstance(MonitoringSettings.class, nodeId), + internalCluster().getInstance(MonitoringLicensee.class, nodeId), securedClient(nodeId)); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java index fb2ec67f9d9..8d6c4120677 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java @@ -11,12 +11,12 @@ import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.plugin.core.LicensesManagerService; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.collector.AbstractCollector; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MonitoringDoc; -import org.elasticsearch.marvel.license.MarvelLicensee; +import org.elasticsearch.marvel.MonitoringLicensee; import java.util.Collection; @@ -131,8 +131,8 @@ public class ClusterStatsCollectorTests extends AbstractCollectorTestCase { assertNotNull(nodeId); return new ClusterStatsCollector(internalCluster().getInstance(Settings.class, nodeId), internalCluster().getInstance(ClusterService.class, nodeId), - internalCluster().getInstance(MarvelSettings.class, nodeId), - internalCluster().getInstance(MarvelLicensee.class, nodeId), + internalCluster().getInstance(MonitoringSettings.class, nodeId), + internalCluster().getInstance(MonitoringLicensee.class, nodeId), securedClient(nodeId), internalCluster().getInstance(LicensesManagerService.class, nodeId), internalCluster().getInstance(ClusterName.class, nodeId)); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexRecoveryCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexRecoveryCollectorTests.java index 759ba460cae..20c07c55cb0 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexRecoveryCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexRecoveryCollectorTests.java @@ -13,11 +13,11 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.indices.recovery.RecoveryState; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MonitoringDoc; -import org.elasticsearch.marvel.license.MarvelLicensee; +import org.elasticsearch.marvel.MonitoringLicensee; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import java.util.Collection; @@ -47,8 +47,8 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INDEX_RECOVERY_ACTIVE_ONLY.getKey(), activeOnly) - .put(MarvelSettings.INDICES.getKey(), indexName) + .put(MonitoringSettings.INDEX_RECOVERY_ACTIVE_ONLY.getKey(), activeOnly) + .put(MonitoringSettings.INDICES.getKey(), indexName) .build(); } @@ -85,8 +85,8 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase { waitForNoBlocksOnNode(node2); waitForRelocation(); - for (MarvelSettings marvelSettings : internalCluster().getInstances(MarvelSettings.class)) { - assertThat(marvelSettings.recoveryActiveOnly(), equalTo(activeOnly)); + for (MonitoringSettings monitoringSettings : internalCluster().getInstances(MonitoringSettings.class)) { + assertThat(monitoringSettings.recoveryActiveOnly(), equalTo(activeOnly)); } logger.info("--> collect index recovery data"); @@ -168,7 +168,7 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase { } public void testEmptyCluster() throws Exception { - final String node = internalCluster().startNode(Settings.builder().put(MarvelSettings.INDICES.getKey(), + final String node = internalCluster().startNode(Settings.builder().put(MonitoringSettings.INDICES.getKey(), Strings.EMPTY_ARRAY)); waitForNoBlocksOnNode(node); @@ -180,7 +180,7 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase { } public void testEmptyClusterAllIndices() throws Exception { - final String node = internalCluster().startNode(Settings.builder().put(MarvelSettings.INDICES.getKey(), MetaData.ALL)); + final String node = internalCluster().startNode(Settings.builder().put(MonitoringSettings.INDICES.getKey(), MetaData.ALL)); waitForNoBlocksOnNode(node); try { @@ -191,7 +191,7 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase { } public void testEmptyClusterMissingIndex() throws Exception { - final String node = internalCluster().startNode(Settings.builder().put(MarvelSettings.INDICES.getKey(), "unknown")); + final String node = internalCluster().startNode(Settings.builder().put(MonitoringSettings.INDICES.getKey(), "unknown")); waitForNoBlocksOnNode(node); try { @@ -207,8 +207,8 @@ public class IndexRecoveryCollectorTests extends AbstractCollectorTestCase { } return new IndexRecoveryCollector(internalCluster().getInstance(Settings.class, nodeId), internalCluster().getInstance(ClusterService.class, nodeId), - internalCluster().getInstance(MarvelSettings.class, nodeId), - internalCluster().getInstance(MarvelLicensee.class, nodeId), + internalCluster().getInstance(MonitoringSettings.class, nodeId), + internalCluster().getInstance(MonitoringLicensee.class, nodeId), securedClient(nodeId)); } } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexStatsCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexStatsCollectorTests.java index 16203ddf14d..b66bfee4e50 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexStatsCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndexStatsCollectorTests.java @@ -11,11 +11,11 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexNotFoundException; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MonitoringDoc; -import org.elasticsearch.marvel.license.MarvelLicensee; +import org.elasticsearch.marvel.MonitoringLicensee; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import java.util.Collection; @@ -52,7 +52,7 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase { } public void testEmptyClusterAllIndices() throws Exception { - final String node = internalCluster().startNode(Settings.builder().put(MarvelSettings.INDICES.getKey(), MetaData.ALL)); + final String node = internalCluster().startNode(Settings.builder().put(MonitoringSettings.INDICES.getKey(), MetaData.ALL)); waitForNoBlocksOnNode(node); try { @@ -63,7 +63,7 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase { } public void testEmptyClusterMissingIndex() throws Exception { - final String node = internalCluster().startNode(Settings.builder().put(MarvelSettings.INDICES.getKey(), "unknown")); + final String node = internalCluster().startNode(Settings.builder().put(MonitoringSettings.INDICES.getKey(), "unknown")); waitForNoBlocksOnNode(node); try { @@ -240,8 +240,8 @@ public class IndexStatsCollectorTests extends AbstractCollectorTestCase { assertNotNull(nodeId); return new IndexStatsCollector(internalCluster().getInstance(Settings.class, nodeId), internalCluster().getInstance(ClusterService.class, nodeId), - internalCluster().getInstance(MarvelSettings.class, nodeId), - internalCluster().getInstance(MarvelLicensee.class, nodeId), + internalCluster().getInstance(MonitoringSettings.class, nodeId), + internalCluster().getInstance(MonitoringLicensee.class, nodeId), securedClient(nodeId)); } } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollectorTests.java index ce6094ef1e3..84ee2b73585 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/indices/IndicesStatsCollectorTests.java @@ -13,11 +13,11 @@ import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexNotFoundException; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MonitoringDoc; -import org.elasticsearch.marvel.license.MarvelLicensee; +import org.elasticsearch.marvel.MonitoringLicensee; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import java.util.Collection; @@ -52,7 +52,7 @@ public class IndicesStatsCollectorTests extends AbstractCollectorTestCase { } public void testEmptyClusterAllIndices() throws Exception { - final String node = internalCluster().startNode(Settings.builder().put(MarvelSettings.INDICES.getKey(), MetaData.ALL)); + final String node = internalCluster().startNode(Settings.builder().put(MonitoringSettings.INDICES.getKey(), MetaData.ALL)); waitForNoBlocksOnNode(node); try { @@ -63,7 +63,7 @@ public class IndicesStatsCollectorTests extends AbstractCollectorTestCase { } public void testEmptyClusterMissingIndex() throws Exception { - final String node = internalCluster().startNode(Settings.builder().put(MarvelSettings.INDICES.getKey(), "unknown")); + final String node = internalCluster().startNode(Settings.builder().put(MonitoringSettings.INDICES.getKey(), "unknown")); waitForNoBlocksOnNode(node); try { @@ -215,8 +215,8 @@ public class IndicesStatsCollectorTests extends AbstractCollectorTestCase { } return new IndicesStatsCollector(internalCluster().getInstance(Settings.class, nodeId), internalCluster().getInstance(ClusterService.class, nodeId), - internalCluster().getInstance(MarvelSettings.class, nodeId), - internalCluster().getInstance(MarvelLicensee.class, nodeId), + internalCluster().getInstance(MonitoringSettings.class, nodeId), + internalCluster().getInstance(MonitoringLicensee.class, nodeId), securedClient(nodeId)); } } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java index 089fe6adcd2..c30c83602a8 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/node/NodeStatsCollectorTests.java @@ -11,11 +11,11 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.NodeEnvironment; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MonitoringDoc; -import org.elasticsearch.marvel.license.MarvelLicensee; +import org.elasticsearch.marvel.MonitoringLicensee; import org.elasticsearch.shield.InternalClient; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; @@ -96,8 +96,8 @@ public class NodeStatsCollectorTests extends AbstractCollectorTestCase { private NodeStatsCollector newNodeStatsCollector(final String nodeId) { return new NodeStatsCollector(internalCluster().getInstance(Settings.class, nodeId), internalCluster().getInstance(ClusterService.class, nodeId), - internalCluster().getInstance(MarvelSettings.class, nodeId), - internalCluster().getInstance(MarvelLicensee.class, nodeId), + internalCluster().getInstance(MonitoringSettings.class, nodeId), + internalCluster().getInstance(MonitoringLicensee.class, nodeId), internalCluster().getInstance(InternalClient.class, nodeId), internalCluster().getInstance(NodeEnvironment.class, nodeId), internalCluster().getInstance(DiskThresholdDecider.class, nodeId)); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollectorTests.java index 8f2553296a0..f873790ea7c 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/shards/ShardsCollectorTests.java @@ -10,11 +10,11 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.collector.AbstractCollectorTestCase; import org.elasticsearch.marvel.agent.exporter.MonitoringDoc; -import org.elasticsearch.marvel.license.MarvelLicensee; +import org.elasticsearch.marvel.MonitoringLicensee; import java.util.Collection; @@ -39,7 +39,7 @@ public class ShardsCollectorTests extends AbstractCollectorTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INDICES.getKey(), "test-shards*") + .put(MonitoringSettings.INDICES.getKey(), "test-shards*") .build(); } @@ -207,7 +207,7 @@ public class ShardsCollectorTests extends AbstractCollectorTestCase { assertNotNull(nodeId); return new ShardsCollector(internalCluster().getInstance(Settings.class, nodeId), internalCluster().getInstance(ClusterService.class, nodeId), - internalCluster().getInstance(MarvelSettings.class, nodeId), - internalCluster().getInstance(MarvelLicensee.class, nodeId)); + internalCluster().getInstance(MonitoringSettings.class, nodeId), + internalCluster().getInstance(MonitoringLicensee.class, nodeId)); } } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/AbstractExporterTemplateTestCase.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/AbstractExporterTemplateTestCase.java index f079f405b13..c2d35393b02 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/AbstractExporterTemplateTestCase.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/AbstractExporterTemplateTestCase.java @@ -8,7 +8,7 @@ package org.elasticsearch.marvel.agent.exporter; import org.elasticsearch.Version; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.collector.Collector; import org.elasticsearch.marvel.agent.collector.cluster.ClusterStatsCollector; @@ -31,7 +31,7 @@ public abstract class AbstractExporterTemplateTestCase extends MarvelIntegTestCa protected Settings nodeSettings(int nodeOrdinal) { Settings.Builder settings = Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INTERVAL.getKey(), "-1"); + .put(MonitoringSettings.INTERVAL.getKey(), "-1"); for (Map.Entry setting : exporterSettings().getAsMap().entrySet()) { settings.put("xpack.monitoring.agent.exporters._exporter." + setting.getKey(), setting.getValue()); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/ExportersTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/ExportersTests.java index aa894898e3c..7ed76f5c9f8 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/ExportersTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/ExportersTests.java @@ -15,7 +15,7 @@ import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsException; import org.elasticsearch.common.util.concurrent.AbstractRunnable; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.exporter.local.LocalExporter; import org.elasticsearch.marvel.cleaner.CleanerService; @@ -71,8 +71,8 @@ public class ExportersTests extends ESTestCase { // we always need to have the local exporter as it serves as the default one factories.put(LocalExporter.TYPE, new LocalExporter.Factory(MonitoringClientProxy.of(client), clusterService, mock(CleanerService.class))); - clusterSettings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(MarvelSettings.COLLECTORS, - MarvelSettings.INTERVAL, MarvelSettings.EXPORTERS_SETTINGS))); + clusterSettings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList(MonitoringSettings.COLLECTORS, + MonitoringSettings.INTERVAL, MonitoringSettings.EXPORTERS_SETTINGS))); exporters = new Exporters(Settings.EMPTY, factories, clusterService, clusterSettings); } @@ -179,7 +179,7 @@ public class ExportersTests extends ESTestCase { .put("xpack.monitoring.agent.exporters._name0.type", "_type") .put("xpack.monitoring.agent.exporters._name1.type", "_type") .build(); - clusterSettings = new ClusterSettings(nodeSettings, new HashSet<>(Arrays.asList(MarvelSettings.EXPORTERS_SETTINGS))); + clusterSettings = new ClusterSettings(nodeSettings, new HashSet<>(Arrays.asList(MonitoringSettings.EXPORTERS_SETTINGS))); exporters = new Exporters(nodeSettings, factories, clusterService, clusterSettings) { @Override diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/http/HttpExporterTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/http/HttpExporterTests.java index 922ae058a20..60338a77393 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/http/HttpExporterTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/http/HttpExporterTests.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.DummyTransportAddress; import org.elasticsearch.common.xcontent.XContentHelper; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.collector.cluster.ClusterStateMonitoringDoc; import org.elasticsearch.marvel.agent.collector.indices.IndexRecoveryMonitoringDoc; @@ -94,7 +94,7 @@ public class HttpExporterTests extends MarvelIntegTestCase { enqueueResponse(200, "{\"errors\": false, \"msg\": \"successful bulk request\"}"); Settings.Builder builder = Settings.builder() - .put(MarvelSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.INTERVAL.getKey(), "-1") .put("xpack.monitoring.agent.exporters._http.type", "http") .put("xpack.monitoring.agent.exporters._http.host", webServer.getHostName() + ":" + webServer.getPort()) .put("xpack.monitoring.agent.exporters._http.connection.keep_alive", false) @@ -132,7 +132,7 @@ public class HttpExporterTests extends MarvelIntegTestCase { public void testDynamicHostChange() { // disable exporting to be able to use non valid hosts Settings.Builder builder = Settings.builder() - .put(MarvelSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.INTERVAL.getKey(), "-1") .put("xpack.monitoring.agent.exporters._http.type", "http") .put("xpack.monitoring.agent.exporters._http.host", "test0"); @@ -156,7 +156,7 @@ public class HttpExporterTests extends MarvelIntegTestCase { public void testHostChangeReChecksTemplate() throws Exception { Settings.Builder builder = Settings.builder() - .put(MarvelSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.INTERVAL.getKey(), "-1") .put("xpack.monitoring.agent.exporters._http.type", "http") .put("xpack.monitoring.agent.exporters._http.host", webServer.getHostName() + ":" + webServer.getPort()) .put("xpack.monitoring.agent.exporters._http.connection.keep_alive", false) @@ -273,7 +273,7 @@ public class HttpExporterTests extends MarvelIntegTestCase { public void testUnsupportedClusterVersion() throws Exception { Settings.Builder builder = Settings.builder() - .put(MarvelSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.INTERVAL.getKey(), "-1") .put("xpack.monitoring.agent.exporters._http.type", "http") .put("xpack.monitoring.agent.exporters._http.host", webServer.getHostName() + ":" + webServer.getPort()) .put("xpack.monitoring.agent.exporters._http.connection.keep_alive", false); @@ -301,7 +301,7 @@ public class HttpExporterTests extends MarvelIntegTestCase { public void testDynamicIndexFormatChange() throws Exception { Settings.Builder builder = Settings.builder() - .put(MarvelSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.INTERVAL.getKey(), "-1") .put("xpack.monitoring.agent.exporters._http.type", "http") .put("xpack.monitoring.agent.exporters._http.host", webServer.getHostName() + ":" + webServer.getPort()) .put("xpack.monitoring.agent.exporters._http.connection.keep_alive", false) @@ -401,7 +401,7 @@ public class HttpExporterTests extends MarvelIntegTestCase { final String host = webServer.getHostName() + ":" + webServer.getPort(); Settings.Builder builder = Settings.builder() - .put(MarvelSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.INTERVAL.getKey(), "-1") .put("xpack.monitoring.agent.exporters._http.type", "http") .put("xpack.monitoring.agent.exporters._http.host", host) .put("xpack.monitoring.agent.exporters._http.connection.keep_alive", false); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/local/LocalExporterTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/local/LocalExporterTests.java index a5af0be8bc4..59080b27735 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/local/LocalExporterTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/local/LocalExporterTests.java @@ -14,7 +14,7 @@ import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.DummyTransportAddress; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.collector.cluster.ClusterStateMonitoringDoc; import org.elasticsearch.marvel.agent.collector.indices.IndexRecoveryMonitoringDoc; @@ -53,7 +53,7 @@ public class LocalExporterTests extends MarvelIntegTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.INTERVAL.getKey(), "-1") .build(); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterInfoTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterInfoTests.java index e8cc28a9f31..fabb79d69f6 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterInfoTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterInfoTests.java @@ -11,7 +11,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.license.core.License; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.agent.collector.cluster.ClusterStatsCollector; import org.elasticsearch.marvel.agent.exporter.MarvelTemplateUtils; import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolver; @@ -39,8 +39,8 @@ public class ClusterInfoTests extends MarvelIntegTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INTERVAL.getKey(), "-1") - .put(MarvelSettings.COLLECTORS.getKey(), ClusterStatsCollector.NAME) + .put(MonitoringSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.COLLECTORS.getKey(), ClusterStatsCollector.NAME) .build(); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStateTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStateTests.java index 41cdd6b314c..e1d1ffd7415 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStateTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStateTests.java @@ -10,7 +10,7 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.agent.collector.cluster.ClusterStateCollector; import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolver; import org.elasticsearch.marvel.test.MarvelIntegTestCase; @@ -43,8 +43,8 @@ public class ClusterStateTests extends MarvelIntegTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INTERVAL.getKey(), "-1") - .put(MarvelSettings.COLLECTORS.getKey(), ClusterStateCollector.NAME) + .put(MonitoringSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.COLLECTORS.getKey(), ClusterStateCollector.NAME) .put("xpack.monitoring.agent.exporters.default_local.type", "local") .put("node.attr.custom", randomInt) .build(); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStatsTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStatsTests.java index ef4915895c7..d787ff3cea6 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStatsTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStatsTests.java @@ -8,7 +8,7 @@ package org.elasticsearch.marvel.agent.resolver.cluster; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsNodes; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.agent.collector.cluster.ClusterStatsCollector; import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.search.SearchHit; @@ -30,8 +30,8 @@ public class ClusterStatsTests extends MarvelIntegTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INTERVAL.getKey(), "-1") - .put(MarvelSettings.COLLECTORS.getKey(), ClusterStatsCollector.NAME) + .put(MonitoringSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.COLLECTORS.getKey(), ClusterStatsCollector.NAME) .put("xpack.monitoring.agent.exporters.default_local.type", "local") .build(); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/indices/IndexRecoveryTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/indices/IndexRecoveryTests.java index b270f6c7acd..561563f4445 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/indices/IndexRecoveryTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/indices/IndexRecoveryTests.java @@ -9,7 +9,7 @@ import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.agent.collector.indices.IndexRecoveryCollector; import org.elasticsearch.marvel.agent.resolver.MonitoringIndexNameResolver; import org.elasticsearch.marvel.test.MarvelIntegTestCase; @@ -35,9 +35,9 @@ public class IndexRecoveryTests extends MarvelIntegTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INTERVAL.getKey(), "-1") - .put(MarvelSettings.INDICES.getKey(), INDEX_PREFIX + "*") - .put(MarvelSettings.COLLECTORS.getKey(), IndexRecoveryCollector.NAME) + .put(MonitoringSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.INDICES.getKey(), INDEX_PREFIX + "*") + .put(MonitoringSettings.COLLECTORS.getKey(), IndexRecoveryCollector.NAME) .put("xpack.monitoring.agent.exporters.default_local.type", "local") .build(); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/indices/IndexStatsTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/indices/IndexStatsTests.java index 9c2eb30aad4..d1af88aadaf 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/indices/IndexStatsTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/indices/IndexStatsTests.java @@ -8,7 +8,7 @@ package org.elasticsearch.marvel.agent.resolver.indices; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.agent.collector.indices.IndexStatsCollector; import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.search.SearchHit; @@ -28,8 +28,8 @@ public class IndexStatsTests extends MarvelIntegTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INTERVAL.getKey(), "-1") - .put(MarvelSettings.COLLECTORS.getKey(), IndexStatsCollector.NAME) + .put(MonitoringSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.COLLECTORS.getKey(), IndexStatsCollector.NAME) .put("xpack.monitoring.agent.exporters.default_local.type", "local") .build(); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/indices/IndicesStatsTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/indices/IndicesStatsTests.java index cfaddb309f6..25ae10e8e2f 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/indices/IndicesStatsTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/indices/IndicesStatsTests.java @@ -8,9 +8,8 @@ package org.elasticsearch.marvel.agent.resolver.indices; import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.agent.collector.indices.IndicesStatsCollector; -import org.elasticsearch.marvel.agent.resolver.indices.IndicesStatsResolver; import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.search.SearchHit; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; @@ -29,8 +28,8 @@ public class IndicesStatsTests extends MarvelIntegTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INTERVAL.getKey(), "-1") - .put(MarvelSettings.COLLECTORS.getKey(), IndicesStatsCollector.NAME) + .put(MonitoringSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.COLLECTORS.getKey(), IndicesStatsCollector.NAME) .put("xpack.monitoring.agent.exporters.default_local.type", "local") .build(); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/node/MultiNodesStatsTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/node/MultiNodesStatsTests.java index 06a13a72446..3c6a862d84a 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/node/MultiNodesStatsTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/node/MultiNodesStatsTests.java @@ -8,7 +8,7 @@ package org.elasticsearch.marvel.agent.resolver.node; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexNotFoundException; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.node.Node; import org.elasticsearch.search.aggregations.Aggregation; @@ -34,7 +34,7 @@ public class MultiNodesStatsTests extends MarvelIntegTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.INTERVAL.getKey(), "-1") .put("xpack.monitoring.agent.exporters.default_local.type", "local") .build(); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/node/NodeStatsTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/node/NodeStatsTests.java index a54223eba0f..863e81fc0e6 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/node/NodeStatsTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/node/NodeStatsTests.java @@ -8,7 +8,7 @@ package org.elasticsearch.marvel.agent.resolver.node; import org.apache.lucene.util.Constants; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.agent.collector.node.NodeStatsCollector; import org.elasticsearch.marvel.agent.exporter.local.LocalExporter; import org.elasticsearch.marvel.test.MarvelIntegTestCase; @@ -31,8 +31,8 @@ public class NodeStatsTests extends MarvelIntegTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INTERVAL.getKey(), "-1") - .put(MarvelSettings.COLLECTORS.getKey(), NodeStatsCollector.NAME) + .put(MonitoringSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.COLLECTORS.getKey(), NodeStatsCollector.NAME) .put("xpack.monitoring.agent.exporters.default_local.type", LocalExporter.TYPE) .build(); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/shards/ShardsTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/shards/ShardsTests.java index d8e50b9bed0..970e714fd49 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/shards/ShardsTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/shards/ShardsTests.java @@ -11,9 +11,8 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.agent.collector.shards.ShardsCollector; -import org.elasticsearch.marvel.agent.resolver.shards.ShardsResolver; import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.aggregations.Aggregation; @@ -43,9 +42,9 @@ public class ShardsTests extends MarvelIntegTestCase { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INTERVAL.getKey(), "-1") - .put(MarvelSettings.COLLECTORS.getKey(), ShardsCollector.NAME) - .put(MarvelSettings.INDICES.getKey(), INDEX_PREFIX + "*") + .put(MonitoringSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.COLLECTORS.getKey(), ShardsCollector.NAME) + .put(MonitoringSettings.INDICES.getKey(), INDEX_PREFIX + "*") .put("xpack.monitoring.agent.exporters.default_local.type", "local") .build(); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/settings/MarvelSettingsTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/settings/MarvelSettingsTests.java index a22f238e7d7..bea8fe25868 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/settings/MarvelSettingsTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/settings/MarvelSettingsTests.java @@ -10,7 +10,7 @@ import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.agent.AgentService; import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.test.ESIntegTestCase; @@ -46,28 +46,28 @@ public class MarvelSettingsTests extends MarvelIntegTestCase { private Settings marvelSettings() { return Settings.builder() - .put(MarvelSettings.INTERVAL.getKey(), interval) - .put(MarvelSettings.INDEX_STATS_TIMEOUT.getKey(), indexStatsTimeout) - .put(MarvelSettings.INDICES_STATS_TIMEOUT.getKey(), indicesStatsTimeout) - .putArray(MarvelSettings.INDICES.getKey(), indices) - .put(MarvelSettings.CLUSTER_STATE_TIMEOUT.getKey(), clusterStateTimeout) - .put(MarvelSettings.CLUSTER_STATS_TIMEOUT.getKey(), clusterStatsTimeout) - .put(MarvelSettings.INDEX_RECOVERY_TIMEOUT.getKey(), recoveryTimeout) - .put(MarvelSettings.INDEX_RECOVERY_ACTIVE_ONLY.getKey(), recoveryActiveOnly) - .putArray(MarvelSettings.COLLECTORS.getKey(), collectors) + .put(MonitoringSettings.INTERVAL.getKey(), interval) + .put(MonitoringSettings.INDEX_STATS_TIMEOUT.getKey(), indexStatsTimeout) + .put(MonitoringSettings.INDICES_STATS_TIMEOUT.getKey(), indicesStatsTimeout) + .putArray(MonitoringSettings.INDICES.getKey(), indices) + .put(MonitoringSettings.CLUSTER_STATE_TIMEOUT.getKey(), clusterStateTimeout) + .put(MonitoringSettings.CLUSTER_STATS_TIMEOUT.getKey(), clusterStatsTimeout) + .put(MonitoringSettings.INDEX_RECOVERY_TIMEOUT.getKey(), recoveryTimeout) + .put(MonitoringSettings.INDEX_RECOVERY_ACTIVE_ONLY.getKey(), recoveryActiveOnly) + .putArray(MonitoringSettings.COLLECTORS.getKey(), collectors) .build(); } public void testMarvelSettings() throws Exception { logger.info("--> testing monitoring settings service initialization"); - for (final MarvelSettings marvelSettings : internalCluster().getInstances(MarvelSettings.class)) { - assertThat(marvelSettings.indexStatsTimeout().millis(), equalTo(indexStatsTimeout.millis())); - assertThat(marvelSettings.indicesStatsTimeout().millis(), equalTo(indicesStatsTimeout.millis())); - assertArrayEquals(marvelSettings.indices(), indices); - assertThat(marvelSettings.clusterStateTimeout().millis(), equalTo(clusterStateTimeout.millis())); - assertThat(marvelSettings.clusterStatsTimeout().millis(), equalTo(clusterStatsTimeout.millis())); - assertThat(marvelSettings.recoveryTimeout().millis(), equalTo(recoveryTimeout.millis())); - assertThat(marvelSettings.recoveryActiveOnly(), equalTo(recoveryActiveOnly)); + for (final MonitoringSettings monitoringSettings : internalCluster().getInstances(MonitoringSettings.class)) { + assertThat(monitoringSettings.indexStatsTimeout().millis(), equalTo(indexStatsTimeout.millis())); + assertThat(monitoringSettings.indicesStatsTimeout().millis(), equalTo(indicesStatsTimeout.millis())); + assertArrayEquals(monitoringSettings.indices(), indices); + assertThat(monitoringSettings.clusterStateTimeout().millis(), equalTo(clusterStateTimeout.millis())); + assertThat(monitoringSettings.clusterStatsTimeout().millis(), equalTo(clusterStatsTimeout.millis())); + assertThat(monitoringSettings.recoveryTimeout().millis(), equalTo(recoveryTimeout.millis())); + assertThat(monitoringSettings.recoveryActiveOnly(), equalTo(recoveryActiveOnly)); } for (final AgentService service : internalCluster().getInstances(AgentService.class)) { @@ -79,15 +79,15 @@ public class MarvelSettingsTests extends MarvelIntegTestCase { logger.info("--> testing monitoring dynamic settings update"); Settings.Builder transientSettings = Settings.builder(); final Setting[] marvelSettings = new Setting[] { - MarvelSettings.INDICES, - MarvelSettings.INTERVAL, - MarvelSettings.INDEX_RECOVERY_TIMEOUT, - MarvelSettings.INDEX_STATS_TIMEOUT, - MarvelSettings.INDICES_STATS_TIMEOUT, - MarvelSettings.INDEX_RECOVERY_ACTIVE_ONLY, - MarvelSettings.COLLECTORS, - MarvelSettings.CLUSTER_STATE_TIMEOUT, - MarvelSettings.CLUSTER_STATS_TIMEOUT }; + MonitoringSettings.INDICES, + MonitoringSettings.INTERVAL, + MonitoringSettings.INDEX_RECOVERY_TIMEOUT, + MonitoringSettings.INDEX_STATS_TIMEOUT, + MonitoringSettings.INDICES_STATS_TIMEOUT, + MonitoringSettings.INDEX_RECOVERY_ACTIVE_ONLY, + MonitoringSettings.COLLECTORS, + MonitoringSettings.CLUSTER_STATE_TIMEOUT, + MonitoringSettings.CLUSTER_STATS_TIMEOUT }; for (Setting setting : marvelSettings) { if (setting.isDynamic()) { Object updated = null; @@ -115,26 +115,26 @@ public class MarvelSettingsTests extends MarvelIntegTestCase { if (setting.isDynamic() == false) { continue; } - if (setting == MarvelSettings.INTERVAL) { + if (setting == MonitoringSettings.INTERVAL) { for (final AgentService service : internalCluster().getInstances(AgentService.class)) { assertEquals(service.getSamplingInterval(), setting.get(updatedSettings)); } } else { - for (final MarvelSettings marvelSettings1 : internalCluster().getInstances(MarvelSettings.class)) { - if (setting == MarvelSettings.INDEX_STATS_TIMEOUT) { - assertEquals(marvelSettings1.indexStatsTimeout(), setting.get(updatedSettings)); - } else if (setting == MarvelSettings.INDICES_STATS_TIMEOUT) { - assertEquals(marvelSettings1.indicesStatsTimeout(), setting.get(updatedSettings)); - } else if (setting == MarvelSettings.CLUSTER_STATS_TIMEOUT) { - assertEquals(marvelSettings1.clusterStatsTimeout(), setting.get(updatedSettings)); - } else if (setting == MarvelSettings.CLUSTER_STATE_TIMEOUT) { - assertEquals(marvelSettings1.clusterStateTimeout(), setting.get(updatedSettings)); - } else if (setting == MarvelSettings.INDEX_RECOVERY_TIMEOUT) { - assertEquals(marvelSettings1.recoveryTimeout(), setting.get(updatedSettings)); - } else if (setting == MarvelSettings.INDEX_RECOVERY_ACTIVE_ONLY) { - assertEquals(Boolean.valueOf(marvelSettings1.recoveryActiveOnly()), setting.get(updatedSettings)); - } else if (setting == MarvelSettings.INDICES) { - assertEquals(Arrays.asList(marvelSettings1.indices()), setting.get(updatedSettings)); + for (final MonitoringSettings monitoringSettings1 : internalCluster().getInstances(MonitoringSettings.class)) { + if (setting == MonitoringSettings.INDEX_STATS_TIMEOUT) { + assertEquals(monitoringSettings1.indexStatsTimeout(), setting.get(updatedSettings)); + } else if (setting == MonitoringSettings.INDICES_STATS_TIMEOUT) { + assertEquals(monitoringSettings1.indicesStatsTimeout(), setting.get(updatedSettings)); + } else if (setting == MonitoringSettings.CLUSTER_STATS_TIMEOUT) { + assertEquals(monitoringSettings1.clusterStatsTimeout(), setting.get(updatedSettings)); + } else if (setting == MonitoringSettings.CLUSTER_STATE_TIMEOUT) { + assertEquals(monitoringSettings1.clusterStateTimeout(), setting.get(updatedSettings)); + } else if (setting == MonitoringSettings.INDEX_RECOVERY_TIMEOUT) { + assertEquals(monitoringSettings1.recoveryTimeout(), setting.get(updatedSettings)); + } else if (setting == MonitoringSettings.INDEX_RECOVERY_ACTIVE_ONLY) { + assertEquals(Boolean.valueOf(monitoringSettings1.recoveryActiveOnly()), setting.get(updatedSettings)); + } else if (setting == MonitoringSettings.INDICES) { + assertEquals(Arrays.asList(monitoringSettings1.indices()), setting.get(updatedSettings)); } else { fail("unable to check value for unknown dynamic setting [" + setting + "]"); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/AbstractIndicesCleanerTestCase.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/AbstractIndicesCleanerTestCase.java index 1d56ea411bb..39060b09797 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/AbstractIndicesCleanerTestCase.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/AbstractIndicesCleanerTestCase.java @@ -7,7 +7,7 @@ package org.elasticsearch.marvel.cleaner; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.exporter.Exporter; import org.elasticsearch.marvel.agent.exporter.Exporters; @@ -31,7 +31,7 @@ public abstract class AbstractIndicesCleanerTestCase extends MarvelIntegTestCase protected Settings nodeSettings(int nodeOrdinal) { Settings.Builder settings = Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put(MarvelSettings.INTERVAL.getKey(), "-1"); + .put(MonitoringSettings.INTERVAL.getKey(), "-1"); return settings.build(); } @@ -68,7 +68,7 @@ public abstract class AbstractIndicesCleanerTestCase extends MarvelIntegTestCase public void testIgnoreDataIndicesInOtherVersions() throws Exception { internalCluster().startNode(); - createIndex(MarvelSettings.LEGACY_DATA_INDEX_NAME, now().minusYears(1)); + createIndex(MonitoringSettings.LEGACY_DATA_INDEX_NAME, now().minusYears(1)); createDataIndex(0, now().minusDays(10)); createDataIndex(Integer.MAX_VALUE, now().minusDays(20)); assertIndicesCount(3); @@ -143,7 +143,7 @@ public abstract class AbstractIndicesCleanerTestCase extends MarvelIntegTestCase public void testRetentionAsGlobalSetting() throws Exception { final int max = 10; final int retention = randomIntBetween(1, max); - internalCluster().startNode(Settings.builder().put(MarvelSettings.HISTORY_DURATION.getKey(), + internalCluster().startNode(Settings.builder().put(MonitoringSettings.HISTORY_DURATION.getKey(), String.format(Locale.ROOT, "%dd", retention))); final DateTime now = now(); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/CleanerServiceTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/CleanerServiceTests.java index 8476a92e69b..97b3e7da384 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/CleanerServiceTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/cleaner/CleanerServiceTests.java @@ -8,8 +8,8 @@ package org.elasticsearch.marvel.cleaner; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.marvel.MarvelSettings; -import org.elasticsearch.marvel.license.MarvelLicensee; +import org.elasticsearch.marvel.MonitoringSettings; +import org.elasticsearch.marvel.MonitoringLicensee; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.joda.time.DateTime; @@ -33,13 +33,13 @@ public class CleanerServiceTests extends ESTestCase { @Rule public ExpectedException expectedException = ExpectedException.none(); - private final MarvelLicensee licensee = mock(MarvelLicensee.class); + private final MonitoringLicensee licensee = mock(MonitoringLicensee.class); private ClusterSettings clusterSettings; private ThreadPool threadPool; @Before public void start() { - clusterSettings = new ClusterSettings(Settings.EMPTY, Collections.singleton(MarvelSettings.HISTORY_DURATION)); + clusterSettings = new ClusterSettings(Settings.EMPTY, Collections.singleton(MonitoringSettings.HISTORY_DURATION)); threadPool = new ThreadPool("CleanerServiceTests"); } @@ -53,14 +53,14 @@ public class CleanerServiceTests extends ESTestCase { expectedException.expect(IllegalArgumentException.class); TimeValue expected = TimeValue.timeValueHours(1); - Settings settings = Settings.builder().put(MarvelSettings.HISTORY_DURATION.getKey(), expected.getStringRep()).build(); + Settings settings = Settings.builder().put(MonitoringSettings.HISTORY_DURATION.getKey(), expected.getStringRep()).build(); new CleanerService(settings, clusterSettings, threadPool, licensee); } public void testGetRetentionWithSettingWithUpdatesAllowed() { TimeValue expected = TimeValue.timeValueHours(25); - Settings settings = Settings.builder().put(MarvelSettings.HISTORY_DURATION.getKey(), expected.getStringRep()).build(); + Settings settings = Settings.builder().put(MonitoringSettings.HISTORY_DURATION.getKey(), expected.getStringRep()).build(); when(licensee.allowUpdateRetention()).thenReturn(true); @@ -72,7 +72,7 @@ public class CleanerServiceTests extends ESTestCase { public void testGetRetentionDefaultValueWithNoSettings() { when(licensee.allowUpdateRetention()).thenReturn(true); - assertEquals(MarvelSettings.HISTORY_DURATION.get(Settings.EMPTY), + assertEquals(MonitoringSettings.HISTORY_DURATION.get(Settings.EMPTY), new CleanerService(Settings.EMPTY, clusterSettings, threadPool, licensee).getRetention()); verify(licensee).allowUpdateRetention(); @@ -80,11 +80,11 @@ public class CleanerServiceTests extends ESTestCase { public void testGetRetentionDefaultValueWithSettingsButUpdatesNotAllowed() { TimeValue notExpected = TimeValue.timeValueHours(25); - Settings settings = Settings.builder().put(MarvelSettings.HISTORY_DURATION.getKey(), notExpected.getStringRep()).build(); + Settings settings = Settings.builder().put(MonitoringSettings.HISTORY_DURATION.getKey(), notExpected.getStringRep()).build(); when(licensee.allowUpdateRetention()).thenReturn(false); - assertEquals(MarvelSettings.HISTORY_DURATION.get(Settings.EMPTY), + assertEquals(MonitoringSettings.HISTORY_DURATION.get(Settings.EMPTY), new CleanerService(settings, clusterSettings, threadPool, licensee).getRetention()); verify(licensee).allowUpdateRetention(); @@ -150,7 +150,7 @@ public class CleanerServiceTests extends ESTestCase { CountDownLatch latch = new CountDownLatch(nbExecutions); logger.debug("--> creates a cleaner service that cleans every second"); - MarvelLicensee licensee = mock(MarvelLicensee.class); + MonitoringLicensee licensee = mock(MonitoringLicensee.class); when(licensee.cleaningEnabled()).thenReturn(true); CleanerService service = new CleanerService(Settings.EMPTY, clusterSettings, licensee, threadPool, new TestExecutionScheduler(1_000)); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/license/LicenseIntegrationTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/license/LicenseIntegrationTests.java index 85669fe130c..c574e3f4912 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/license/LicenseIntegrationTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/license/LicenseIntegrationTests.java @@ -19,6 +19,7 @@ import org.elasticsearch.license.plugin.core.LicenseState; import org.elasticsearch.license.plugin.core.Licensee; import org.elasticsearch.license.plugin.core.LicenseeRegistry; import org.elasticsearch.license.plugin.core.LicensesManagerService; +import org.elasticsearch.marvel.MonitoringLicensee; import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; @@ -62,10 +63,10 @@ public class LicenseIntegrationTests extends MarvelIntegTestCase { assertThat(getLicensee().collectionEnabled(), is(true)); } - private MarvelLicensee getLicensee() { - MarvelLicensee marvelLicensee = internalCluster().getInstance(MarvelLicensee.class); - assertNotNull(marvelLicensee); - return marvelLicensee; + private MonitoringLicensee getLicensee() { + MonitoringLicensee licensee = internalCluster().getInstance(MonitoringLicensee.class); + assertNotNull(licensee); + return licensee; } public static void disableLicensing() { diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/license/MarvelLicenseeTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/license/MarvelLicenseeTests.java index 7e1eb108c72..dd5e017daf2 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/license/MarvelLicenseeTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/license/MarvelLicenseeTests.java @@ -11,6 +11,7 @@ import org.elasticsearch.license.plugin.core.AbstractLicenseeTestCase; import org.elasticsearch.license.plugin.core.LicenseState; import org.elasticsearch.license.plugin.core.Licensee.Status; import org.elasticsearch.license.plugin.core.LicenseeRegistry; +import org.elasticsearch.marvel.MonitoringLicensee; import java.util.function.Predicate; @@ -21,13 +22,13 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; /** - * Tests {@link MarvelLicensee}. + * Tests {@link MonitoringLicensee}. *

    * If you change the behavior of these tests, then it means that licensing changes for Monitoring! */ public class MarvelLicenseeTests extends AbstractLicenseeTestCase { private final LicenseeRegistry registry = mock(LicenseeRegistry.class); - private final MarvelLicensee licensee = new MarvelLicensee(Settings.EMPTY, registry); + private final MonitoringLicensee licensee = new MonitoringLicensee(Settings.EMPTY, registry); public void testAcknowledgementMessagesToAnyFromFreeIsNoOp() { assertEmptyAck(OperationMode.BASIC, randomMode(), licensee); @@ -48,27 +49,27 @@ public class MarvelLicenseeTests extends AbstractLicenseeTestCase { } public void testCollectionEnabledIsTrueForActiveState() { - assertEnabled(randomEnabledOrGracePeriodState(), MarvelLicensee::collectionEnabled, true); + assertEnabled(randomEnabledOrGracePeriodState(), MonitoringLicensee::collectionEnabled, true); } public void testCollectionEnabledIsFalseForInactiveState() { - assertEnabled(LicenseState.DISABLED, MarvelLicensee::collectionEnabled, false); + assertEnabled(LicenseState.DISABLED, MonitoringLicensee::collectionEnabled, false); } public void testCleaningEnabledIsTrueForActiveState() { - assertEnabled(randomEnabledOrGracePeriodState(), MarvelLicensee::cleaningEnabled, true); + assertEnabled(randomEnabledOrGracePeriodState(), MonitoringLicensee::cleaningEnabled, true); } public void testCleaningEnabledIsFalseForInactiveState() { - assertEnabled(LicenseState.DISABLED, MarvelLicensee::cleaningEnabled, false); + assertEnabled(LicenseState.DISABLED, MonitoringLicensee::cleaningEnabled, false); } public void testAllowUpdateRetentionIsTrueForNotBasic() { - assertEnabled(randomModeExcept(OperationMode.BASIC), MarvelLicensee::allowUpdateRetention, true); + assertEnabled(randomModeExcept(OperationMode.BASIC), MonitoringLicensee::allowUpdateRetention, true); } public void testAllowUpdateRetentionIsFalseForBasic() { - assertEnabled(OperationMode.BASIC, MarvelLicensee::allowUpdateRetention, false); + assertEnabled(OperationMode.BASIC, MonitoringLicensee::allowUpdateRetention, false); } /** @@ -78,7 +79,7 @@ public class MarvelLicenseeTests extends AbstractLicenseeTestCase { * @param predicate The method to invoke (expected to be an instance method). * @param expected The expected outcome given the {@code state} and {@code predicate}. */ - private void assertEnabled(LicenseState state, Predicate predicate, boolean expected) { + private void assertEnabled(LicenseState state, Predicate predicate, boolean expected) { Status status = mock(Status.class); when(status.getLicenseState()).thenReturn(state); @@ -97,7 +98,7 @@ public class MarvelLicenseeTests extends AbstractLicenseeTestCase { * @param predicate The method to invoke (expected to be an instance method). * @param expected The expected outcome given the {@code mode} and {@code predicate}. */ - private void assertEnabled(OperationMode mode, Predicate predicate, boolean expected) { + private void assertEnabled(OperationMode mode, Predicate predicate, boolean expected) { Status status = mock(Status.class); when(status.getMode()).thenReturn(mode); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/shield/MarvelInternalClientTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/shield/MarvelInternalClientTests.java index 8a21703608e..4a51d2d28c0 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/shield/MarvelInternalClientTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/shield/MarvelInternalClientTests.java @@ -10,7 +10,7 @@ import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexNotFoundException; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.shield.InternalClient; @@ -27,7 +27,7 @@ public class MarvelInternalClientTests extends MarvelIntegTestCase { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) .put(NetworkModule.HTTP_ENABLED.getKey(), false) - .put(MarvelSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.INTERVAL.getKey(), "-1") .build(); } diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/shield/MarvelSettingsFilterTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/shield/MarvelSettingsFilterTests.java index cf7c6459fcf..f847966061a 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/shield/MarvelSettingsFilterTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/shield/MarvelSettingsFilterTests.java @@ -11,7 +11,7 @@ import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.http.HttpServerTransport; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.test.MarvelIntegTestCase; import org.elasticsearch.shield.authc.support.SecuredString; import org.elasticsearch.test.rest.client.http.HttpRequestBuilder; @@ -41,7 +41,7 @@ public class MarvelSettingsFilterTests extends MarvelIntegTestCase { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) .put(NetworkModule.HTTP_ENABLED.getKey(), true) - .put(MarvelSettings.INTERVAL.getKey(), "-1") + .put(MonitoringSettings.INTERVAL.getKey(), "-1") .put("xpack.monitoring.agent.exporters._http.type", "http") .put("xpack.monitoring.agent.exporters._http.enabled", false) .put("xpack.monitoring.agent.exporters._http.auth.username", "_user") diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/test/MarvelIntegTestCase.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/test/MarvelIntegTestCase.java index b09d1c269f4..c007990500e 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/test/MarvelIntegTestCase.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/test/MarvelIntegTestCase.java @@ -17,7 +17,7 @@ import org.elasticsearch.common.util.concurrent.CountDown; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.IndexNotFoundException; -import org.elasticsearch.marvel.MarvelSettings; +import org.elasticsearch.marvel.MonitoringSettings; import org.elasticsearch.marvel.MonitoredSystem; import org.elasticsearch.marvel.agent.AgentService; import org.elasticsearch.marvel.agent.exporter.MonitoringDoc; @@ -435,7 +435,7 @@ public abstract class MarvelIntegTestCase extends ESIntegTestCase { protected void updateMarvelInterval(long value, TimeUnit timeUnit) { assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings( - Settings.builder().put(MarvelSettings.INTERVAL.getKey(), value, timeUnit))); + Settings.builder().put(MonitoringSettings.INTERVAL.getKey(), value, timeUnit))); } protected class MockDataIndexNameResolver extends MonitoringIndexNameResolver.Data { diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/Security.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/Security.java index 641e779b672..285bc330ca3 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/Security.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/Security.java @@ -21,28 +21,28 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.index.IndexModule; -import org.elasticsearch.shield.action.filter.ShieldActionFilter; import org.elasticsearch.shield.action.ShieldActionModule; +import org.elasticsearch.shield.action.filter.ShieldActionFilter; import org.elasticsearch.shield.action.realm.ClearRealmCacheAction; import org.elasticsearch.shield.action.realm.TransportClearRealmCacheAction; -import org.elasticsearch.shield.action.role.PutRoleAction; import org.elasticsearch.shield.action.role.ClearRolesCacheAction; import org.elasticsearch.shield.action.role.DeleteRoleAction; import org.elasticsearch.shield.action.role.GetRolesAction; -import org.elasticsearch.shield.action.role.TransportPutRoleAction; +import org.elasticsearch.shield.action.role.PutRoleAction; import org.elasticsearch.shield.action.role.TransportClearRolesCacheAction; import org.elasticsearch.shield.action.role.TransportDeleteRoleAction; import org.elasticsearch.shield.action.role.TransportGetRolesAction; +import org.elasticsearch.shield.action.role.TransportPutRoleAction; import org.elasticsearch.shield.action.user.AuthenticateAction; import org.elasticsearch.shield.action.user.ChangePasswordAction; -import org.elasticsearch.shield.action.user.PutUserAction; import org.elasticsearch.shield.action.user.DeleteUserAction; import org.elasticsearch.shield.action.user.GetUsersAction; +import org.elasticsearch.shield.action.user.PutUserAction; import org.elasticsearch.shield.action.user.TransportAuthenticateAction; import org.elasticsearch.shield.action.user.TransportChangePasswordAction; -import org.elasticsearch.shield.action.user.TransportPutUserAction; import org.elasticsearch.shield.action.user.TransportDeleteUserAction; import org.elasticsearch.shield.action.user.TransportGetUsersAction; +import org.elasticsearch.shield.action.user.TransportPutUserAction; import org.elasticsearch.shield.audit.AuditTrailModule; import org.elasticsearch.shield.audit.index.IndexAuditTrail; import org.elasticsearch.shield.audit.index.IndexNameResolver; @@ -62,20 +62,17 @@ import org.elasticsearch.shield.authz.store.FileRolesStore; import org.elasticsearch.shield.authz.store.NativeRolesStore; import org.elasticsearch.shield.crypto.CryptoModule; import org.elasticsearch.shield.crypto.InternalCryptoService; -import org.elasticsearch.shield.license.LicenseModule; -import org.elasticsearch.shield.license.ShieldLicenseState; -import org.elasticsearch.shield.license.ShieldLicensee; import org.elasticsearch.shield.rest.ShieldRestModule; import org.elasticsearch.shield.rest.action.RestAuthenticateAction; import org.elasticsearch.shield.rest.action.realm.RestClearRealmCacheAction; -import org.elasticsearch.shield.rest.action.role.RestPutRoleAction; import org.elasticsearch.shield.rest.action.role.RestClearRolesCacheAction; import org.elasticsearch.shield.rest.action.role.RestDeleteRoleAction; import org.elasticsearch.shield.rest.action.role.RestGetRolesAction; +import org.elasticsearch.shield.rest.action.role.RestPutRoleAction; import org.elasticsearch.shield.rest.action.user.RestChangePasswordAction; -import org.elasticsearch.shield.rest.action.user.RestPutUserAction; import org.elasticsearch.shield.rest.action.user.RestDeleteUserAction; import org.elasticsearch.shield.rest.action.user.RestGetUsersAction; +import org.elasticsearch.shield.rest.action.user.RestPutUserAction; import org.elasticsearch.shield.ssl.SSLModule; import org.elasticsearch.shield.ssl.SSLSettings; import org.elasticsearch.shield.support.OptionalStringSetting; @@ -114,7 +111,7 @@ public class Security { private final Settings settings; private final boolean enabled; private final boolean transportClientMode; - private ShieldLicenseState shieldLicenseState; + private SecurityLicenseState securityLicenseState; public Security(Settings settings) { this.settings = settings; @@ -126,32 +123,36 @@ public class Security { } public Collection nodeModules() { - - if (enabled == false) { - return Collections.singletonList(new ShieldDisabledModule(settings)); - } - - if (transportClientMode == true) { - return Arrays.asList( - new ShieldTransportModule(settings), - new SSLModule(settings)); - } + List modules = new ArrayList<>(); // we can't load that at construction time since the license plugin might not have been loaded at that point // which might not be the case during Plugin class instantiation. Once nodeModules are pulled // everything should have been loaded - shieldLicenseState = new ShieldLicenseState(); - return Arrays.asList( - new ShieldModule(settings), - new LicenseModule(settings, shieldLicenseState), - new CryptoModule(settings), - new AuthenticationModule(settings), - new AuthorizationModule(settings), - new AuditTrailModule(settings), - new ShieldRestModule(settings), - new ShieldActionModule(settings), - new ShieldTransportModule(settings), - new SSLModule(settings)); + if (enabled && transportClientMode == false) { + securityLicenseState = new SecurityLicenseState(); + } + + modules.add(new SecurityModule(settings, securityLicenseState)); + + if (enabled == false) { + return modules; + } + + if (transportClientMode == true) { + modules.add(new ShieldTransportModule(settings)); + modules.add(new SSLModule(settings)); + return modules; + } + + modules.add(new CryptoModule(settings)); + modules.add(new AuthenticationModule(settings)); + modules.add(new AuthorizationModule(settings)); + modules.add(new AuditTrailModule(settings)); + modules.add(new ShieldRestModule(settings)); + modules.add(new ShieldActionModule(settings)); + modules.add(new ShieldTransportModule(settings)); + modules.add(new SSLModule(settings)); + return modules; } public Collection> nodeServices() { @@ -164,7 +165,7 @@ public class Security { if (AuditTrailModule.fileAuditLoggingEnabled(settings) == true) { list.add(LoggingAuditTrail.class); } - list.add(ShieldLicensee.class); + list.add(SecurityLicensee.class); list.add(InternalCryptoService.class); list.add(FileRolesStore.class); list.add(Realms.class); @@ -249,12 +250,12 @@ public class Security { return; } - assert shieldLicenseState != null; + assert securityLicenseState != null; if (flsDlsEnabled(settings)) { module.setSearcherWrapper((indexService) -> new ShieldIndexSearcherWrapper(indexService.getIndexSettings(), indexService.newQueryShardContext(), indexService.mapperService(), indexService.cache().bitsetFilterCache(), indexService.getIndexServices().getThreadPool().getThreadContext(), - shieldLicenseState)); + securityLicenseState)); } if (transportClientMode == false) { /* We need to forcefully overwrite the query cache implementation to use Shield's opt out query cache implementation. diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/SecurityFeatureSet.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/SecurityFeatureSet.java new file mode 100644 index 00000000000..2d0410d41ef --- /dev/null +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/SecurityFeatureSet.java @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.shield; + +import org.elasticsearch.common.Nullable; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.xpack.XPackFeatureSet; + +/** + * + */ +public class SecurityFeatureSet implements XPackFeatureSet { + + private final boolean enabled; + private final SecurityLicenseState licenseState; + + @Inject + public SecurityFeatureSet(Settings settings, @Nullable SecurityLicenseState licenseState) { + this.enabled = Security.enabled(settings); + this.licenseState = licenseState; + } + + @Override + public String name() { + return Security.NAME; + } + + @Override + public String description() { + return "Security for the Elastic Stack"; + } + + @Override + public boolean available() { + return licenseState != null && licenseState.securityEnabled(); + } + + @Override + public boolean enabled() { + return enabled; + } +} diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/license/ShieldLicenseState.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/SecurityLicenseState.java similarity index 95% rename from elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/license/ShieldLicenseState.java rename to elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/SecurityLicenseState.java index 078ed00af1f..8426e555057 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/license/ShieldLicenseState.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/SecurityLicenseState.java @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.shield.license; +package org.elasticsearch.shield; import org.elasticsearch.license.core.License.OperationMode; import org.elasticsearch.license.plugin.core.LicenseState; @@ -11,10 +11,10 @@ import org.elasticsearch.license.plugin.core.Licensee.Status; /** - * This class serves to decouple shield code that needs to check the license state from the {@link ShieldLicensee} as the + * This class serves to decouple shield code that needs to check the license state from the {@link SecurityLicensee} as the * tight coupling causes issues with guice injection and circular dependencies */ -public class ShieldLicenseState { +public class SecurityLicenseState { // we initialize the licensee status to enabled with trial operation mode to ensure no // legitimate requests are blocked before initial license plugin notification diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/license/ShieldLicensee.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/SecurityLicensee.java similarity index 90% rename from elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/license/ShieldLicensee.java rename to elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/SecurityLicensee.java index 185794a978b..49db1413600 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/license/ShieldLicensee.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/SecurityLicensee.java @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.shield.license; +package org.elasticsearch.shield; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.Strings; @@ -13,18 +13,17 @@ import org.elasticsearch.license.core.License; import org.elasticsearch.license.plugin.core.AbstractLicenseeComponent; import org.elasticsearch.license.plugin.core.Licensee; import org.elasticsearch.license.plugin.core.LicenseeRegistry; -import org.elasticsearch.shield.Security; /** * */ -public class ShieldLicensee extends AbstractLicenseeComponent implements Licensee { +public class SecurityLicensee extends AbstractLicenseeComponent implements Licensee { private final boolean isTribeNode; - private final ShieldLicenseState shieldLicenseState; + private final SecurityLicenseState shieldLicenseState; @Inject - public ShieldLicensee(Settings settings, LicenseeRegistry clientService, ShieldLicenseState shieldLicenseState) { + public SecurityLicensee(Settings settings, LicenseeRegistry clientService, SecurityLicenseState shieldLicenseState) { super(settings, Security.NAME, clientService); this.shieldLicenseState = shieldLicenseState; this.isTribeNode = settings.getGroups("tribe", true).isEmpty() == false; diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/SecurityModule.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/SecurityModule.java new file mode 100644 index 00000000000..5cc3881532f --- /dev/null +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/SecurityModule.java @@ -0,0 +1,53 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.shield; + +import org.elasticsearch.common.inject.util.Providers; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.shield.support.AbstractShieldModule; +import org.elasticsearch.xpack.XPackPlugin; + +/** + * + */ +public class SecurityModule extends AbstractShieldModule { + + private final SecurityLicenseState securityLicenseState; + + public SecurityModule(Settings settings, SecurityLicenseState securityLicenseState) { + super(settings); + this.securityLicenseState = securityLicenseState; + } + + @Override + protected void configure(boolean clientMode) { + if (clientMode) { + return; + } + + if (securityLicenseState != null) { + bind(SecurityLicenseState.class).toInstance(securityLicenseState); + } else { + bind(SecurityLicenseState.class).toProvider(Providers.of(null)); + } + + XPackPlugin.bindFeatureSet(binder(), SecurityFeatureSet.class); + + if (shieldEnabled) { + bind(SecurityContext.Secure.class).asEagerSingleton(); + bind(SecurityContext.class).to(SecurityContext.Secure.class); + bind(ShieldLifecycleService.class).asEagerSingleton(); + bind(InternalClient.Secure.class).asEagerSingleton(); + bind(InternalClient.class).to(InternalClient.Secure.class); + + } else { + bind(SecurityContext.class).toInstance(SecurityContext.Insecure.INSTANCE); + bind(InternalClient.Insecure.class).asEagerSingleton(); + bind(InternalClient.class).to(InternalClient.Insecure.class); + } + } + +} diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldDisabledModule.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldDisabledModule.java deleted file mode 100644 index a52a695d7d7..00000000000 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldDisabledModule.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.shield; - -import org.elasticsearch.common.inject.util.Providers; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.shield.license.ShieldLicenseState; -import org.elasticsearch.shield.support.AbstractShieldModule; - -public class ShieldDisabledModule extends AbstractShieldModule { - - public ShieldDisabledModule(Settings settings) { - super(settings); - } - - @Override - protected void configure(boolean clientMode) { - assert !shieldEnabled : "shield disabled module should only get loaded with shield disabled"; - if (!clientMode) { - // required by the shield info rest action (when shield is disabled) - bind(ShieldLicenseState.class).toProvider(Providers.of(null)); - - bind(SecurityContext.class).toInstance(SecurityContext.Insecure.INSTANCE); - - bind(InternalClient.Insecure.class).asEagerSingleton(); - bind(InternalClient.class).to(InternalClient.Insecure.class); - } - } -} diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldModule.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldModule.java deleted file mode 100644 index d82cf10cffc..00000000000 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/ShieldModule.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.shield; - -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.shield.support.AbstractShieldModule; - -/** - * - */ -public class ShieldModule extends AbstractShieldModule { - - public ShieldModule(Settings settings) { - super(settings); - } - - @Override - protected void configure(boolean clientMode) { - if (!clientMode) { - bind(SecurityContext.Secure.class).asEagerSingleton(); - bind(SecurityContext.class).to(SecurityContext.Secure.class); - bind(ShieldLifecycleService.class).asEagerSingleton(); - bind(InternalClient.Secure.class).asEagerSingleton(); - bind(InternalClient.class).to(InternalClient.Secure.class); - } - } -} diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/filter/ShieldActionFilter.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/filter/ShieldActionFilter.java index 426fcc7240e..5d7c10bddc9 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/filter/ShieldActionFilter.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/filter/ShieldActionFilter.java @@ -31,7 +31,7 @@ import org.elasticsearch.shield.authz.AuthorizationService; import org.elasticsearch.shield.authz.AuthorizationUtils; import org.elasticsearch.shield.authz.privilege.HealthAndStatsPrivilege; import org.elasticsearch.shield.crypto.CryptoService; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; @@ -56,12 +56,12 @@ public class ShieldActionFilter extends AbstractComponent implements ActionFilte private final AuditTrail auditTrail; private final ShieldActionMapper actionMapper; private final Set requestInterceptors; - private final ShieldLicenseState licenseState; + private final SecurityLicenseState licenseState; private final ThreadContext threadContext; @Inject public ShieldActionFilter(Settings settings, AuthenticationService authcService, AuthorizationService authzService, - CryptoService cryptoService, AuditTrail auditTrail, ShieldLicenseState licenseState, + CryptoService cryptoService, AuditTrail auditTrail, SecurityLicenseState licenseState, ShieldActionMapper actionMapper, Set requestInterceptors, ThreadPool threadPool) { super(settings); this.authcService = authcService; diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/Realms.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/Realms.java index 0bc68a60247..90ed0446392 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/Realms.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/Realms.java @@ -16,7 +16,7 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.shield.authc.esnative.ReservedRealm; import org.elasticsearch.shield.authc.esnative.NativeRealm; import org.elasticsearch.shield.authc.file.FileRealm; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import java.util.ArrayList; import java.util.Collections; @@ -37,7 +37,7 @@ public class Realms extends AbstractLifecycleComponent implements Iterab private final Environment env; private final Map factories; - private final ShieldLicenseState shieldLicenseState; + private final SecurityLicenseState shieldLicenseState; private final ReservedRealm reservedRealm; protected List realms = Collections.emptyList(); @@ -45,7 +45,7 @@ public class Realms extends AbstractLifecycleComponent implements Iterab protected List internalRealmsOnly = Collections.emptyList(); @Inject - public Realms(Settings settings, Environment env, Map factories, ShieldLicenseState shieldLicenseState, + public Realms(Settings settings, Environment env, Map factories, SecurityLicenseState shieldLicenseState, ReservedRealm reservedRealm) { super(settings); this.env = env; diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapper.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapper.java index 0fcae47b741..f4ca7e9e24a 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapper.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapper.java @@ -6,7 +6,6 @@ package org.elasticsearch.shield.authz.accesscontrol; import org.apache.lucene.index.DirectoryReader; -import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.BulkScorer; @@ -33,10 +32,8 @@ import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.cache.bitset.BitsetFilterCache; import org.elasticsearch.index.engine.EngineException; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.internal.ParentFieldMapper; -import org.elasticsearch.index.percolator.PercolatorFieldMapper; import org.elasticsearch.index.query.ParsedQuery; import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.index.shard.IndexSearcherWrapper; @@ -44,7 +41,7 @@ import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardUtils; import org.elasticsearch.shield.authz.InternalAuthorizationService; import org.elasticsearch.shield.authz.accesscontrol.DocumentSubsetReader.DocumentSubsetDirectoryReader; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import org.elasticsearch.shield.support.Exceptions; import java.io.IOException; @@ -73,13 +70,13 @@ public class ShieldIndexSearcherWrapper extends IndexSearcherWrapper { private final Set allowedMetaFields; private final QueryShardContext queryShardContext; private final BitsetFilterCache bitsetFilterCache; - private final ShieldLicenseState shieldLicenseState; + private final SecurityLicenseState shieldLicenseState; private final ThreadContext threadContext; private final ESLogger logger; public ShieldIndexSearcherWrapper(IndexSettings indexSettings, QueryShardContext queryShardContext, MapperService mapperService, BitsetFilterCache bitsetFilterCache, - ThreadContext threadContext, ShieldLicenseState shieldLicenseState) { + ThreadContext threadContext, SecurityLicenseState shieldLicenseState) { this.logger = Loggers.getLogger(getClass(), indexSettings.getSettings()); this.mapperService = mapperService; this.queryShardContext = queryShardContext; diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/license/LicenseModule.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/license/LicenseModule.java deleted file mode 100644 index f15708b3254..00000000000 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/license/LicenseModule.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.shield.license; - -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.shield.support.AbstractShieldModule; - -/** - * - */ -public class LicenseModule extends AbstractShieldModule.Node { - - private final ShieldLicenseState shieldLicenseState; - - public LicenseModule(Settings settings, ShieldLicenseState shieldLicenseState) { - super(settings); - this.shieldLicenseState = shieldLicenseState; - } - - @Override - protected void configureNode() { - bind(ShieldLicensee.class).asEagerSingleton(); - bind(ShieldLicenseState.class).toInstance(shieldLicenseState); - } - -} diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/ShieldRestFilter.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/ShieldRestFilter.java index cb470ffa4d3..f938566c224 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/ShieldRestFilter.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/rest/ShieldRestFilter.java @@ -18,7 +18,7 @@ import org.elasticsearch.rest.RestFilterChain; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.shield.authc.AuthenticationService; import org.elasticsearch.shield.authc.pki.PkiRealm; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import org.elasticsearch.shield.transport.netty.ShieldNettyHttpServerTransport; import org.elasticsearch.threadpool.ThreadPool; import org.jboss.netty.handler.ssl.SslHandler; @@ -34,13 +34,13 @@ public class ShieldRestFilter extends RestFilter { private final AuthenticationService service; private final ESLogger logger; - private final ShieldLicenseState licenseState; + private final SecurityLicenseState licenseState; private final ThreadContext threadContext; private final boolean extractClientCertificate; @Inject public ShieldRestFilter(AuthenticationService service, RestController controller, Settings settings, - ThreadPool threadPool, ShieldLicenseState licenseState) { + ThreadPool threadPool, SecurityLicenseState licenseState) { this.service = service; this.licenseState = licenseState; this.threadContext = threadPool.getThreadContext(); diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldServerTransportService.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldServerTransportService.java index ee79f6628d0..ed0ac6070c5 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldServerTransportService.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldServerTransportService.java @@ -14,7 +14,7 @@ import org.elasticsearch.shield.authc.AuthenticationService; import org.elasticsearch.shield.authz.AuthorizationService; import org.elasticsearch.shield.authz.AuthorizationUtils; import org.elasticsearch.shield.authz.accesscontrol.RequestContext; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import org.elasticsearch.shield.transport.netty.ShieldNettyTransport; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; @@ -49,7 +49,7 @@ public class ShieldServerTransportService extends TransportService { protected final AuthorizationService authzService; protected final ShieldActionMapper actionMapper; protected final ClientTransportFilter clientFilter; - protected final ShieldLicenseState licenseState; + protected final SecurityLicenseState licenseState; protected final Map profileFilters; @@ -59,7 +59,7 @@ public class ShieldServerTransportService extends TransportService { AuthorizationService authzService, ShieldActionMapper actionMapper, ClientTransportFilter clientTransportFilter, - ShieldLicenseState licenseState) { + SecurityLicenseState licenseState) { super(settings, transport, threadPool); this.authcService = authcService; this.authzService = authzService; @@ -158,11 +158,11 @@ public class ShieldServerTransportService extends TransportService { protected final String action; protected final TransportRequestHandler handler; private final Map profileFilters; - private final ShieldLicenseState licenseState; + private final SecurityLicenseState licenseState; private final ThreadContext threadContext; public ProfileSecuredRequestHandler(String action, TransportRequestHandler handler, - Map profileFilters, ShieldLicenseState licenseState, + Map profileFilters, SecurityLicenseState licenseState, ThreadContext threadContext) { this.action = action; this.handler = handler; diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/filter/IPFilter.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/filter/IPFilter.java index 7a4100c6bd6..3fe73e781c9 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/filter/IPFilter.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/filter/IPFilter.java @@ -18,7 +18,7 @@ import org.elasticsearch.common.settings.SettingsModule; import org.elasticsearch.common.transport.BoundTransportAddress; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.shield.audit.AuditTrail; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import org.elasticsearch.transport.TransportSettings; import java.net.InetAddress; @@ -89,7 +89,7 @@ public class IPFilter { }; private final AuditTrail auditTrail; - private final ShieldLicenseState licenseState; + private final SecurityLicenseState licenseState; private final boolean alwaysAllowBoundAddresses; private final ESLogger logger; @@ -107,7 +107,7 @@ public class IPFilter { @Inject public IPFilter(final Settings settings, AuditTrail auditTrail, ClusterSettings clusterSettings, - ShieldLicenseState licenseState) { + SecurityLicenseState licenseState) { this.logger = Loggers.getLogger(getClass(), settings); this.auditTrail = auditTrail; this.licenseState = licenseState; diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/license/ShieldLicenseStateTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ShieldLicenseStateTests.java similarity index 86% rename from elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/license/ShieldLicenseStateTests.java rename to elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ShieldLicenseStateTests.java index 5c806a972aa..cbef7881fa8 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/license/ShieldLicenseStateTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ShieldLicenseStateTests.java @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.shield.license; +package org.elasticsearch.shield; import org.elasticsearch.license.core.License; import org.elasticsearch.license.plugin.core.LicenseState; @@ -13,12 +13,12 @@ import org.elasticsearch.test.ESTestCase; import static org.hamcrest.Matchers.is; /** - * Unit tests for the {@link ShieldLicenseState} + * Unit tests for the {@link SecurityLicenseState} */ public class ShieldLicenseStateTests extends ESTestCase { public void testDefaults() { - ShieldLicenseState licenseState = new ShieldLicenseState(); + SecurityLicenseState licenseState = new SecurityLicenseState(); assertThat(licenseState.securityEnabled(), is(true)); assertThat(licenseState.statsAndHealthEnabled(), is(true)); assertThat(licenseState.documentAndFieldLevelSecurityEnabled(), is(true)); @@ -26,7 +26,7 @@ public class ShieldLicenseStateTests extends ESTestCase { } public void testBasic() { - ShieldLicenseState licenseState = new ShieldLicenseState(); + SecurityLicenseState licenseState = new SecurityLicenseState(); licenseState.updateStatus(new Licensee.Status(License.OperationMode.BASIC, randomBoolean() ? LicenseState.ENABLED : LicenseState.GRACE_PERIOD)); @@ -37,7 +37,7 @@ public class ShieldLicenseStateTests extends ESTestCase { } public void testBasicExpired() { - ShieldLicenseState licenseState = new ShieldLicenseState(); + SecurityLicenseState licenseState = new SecurityLicenseState(); licenseState.updateStatus(new Licensee.Status(License.OperationMode.BASIC, LicenseState.DISABLED)); assertThat(licenseState.securityEnabled(), is(false)); @@ -47,7 +47,7 @@ public class ShieldLicenseStateTests extends ESTestCase { } public void testGold() { - ShieldLicenseState licenseState = new ShieldLicenseState(); + SecurityLicenseState licenseState = new SecurityLicenseState(); licenseState.updateStatus(new Licensee.Status(License.OperationMode.GOLD, randomBoolean() ? LicenseState.ENABLED : LicenseState.GRACE_PERIOD)); @@ -58,7 +58,7 @@ public class ShieldLicenseStateTests extends ESTestCase { } public void testGoldExpired() { - ShieldLicenseState licenseState = new ShieldLicenseState(); + SecurityLicenseState licenseState = new SecurityLicenseState(); licenseState.updateStatus(new Licensee.Status(License.OperationMode.GOLD, LicenseState.DISABLED)); assertThat(licenseState.securityEnabled(), is(true)); @@ -68,7 +68,7 @@ public class ShieldLicenseStateTests extends ESTestCase { } public void testPlatinum() { - ShieldLicenseState licenseState = new ShieldLicenseState(); + SecurityLicenseState licenseState = new SecurityLicenseState(); licenseState.updateStatus(new Licensee.Status(License.OperationMode.PLATINUM, randomBoolean() ? LicenseState.ENABLED : LicenseState.GRACE_PERIOD)); @@ -79,7 +79,7 @@ public class ShieldLicenseStateTests extends ESTestCase { } public void testPlatinumExpired() { - ShieldLicenseState licenseState = new ShieldLicenseState(); + SecurityLicenseState licenseState = new SecurityLicenseState(); licenseState.updateStatus(new Licensee.Status(License.OperationMode.PLATINUM, LicenseState.DISABLED)); assertThat(licenseState.securityEnabled(), is(true)); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/license/ShieldLicenseeTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ShieldLicenseeTests.java similarity index 84% rename from elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/license/ShieldLicenseeTests.java rename to elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ShieldLicenseeTests.java index 2ff192f37ec..6e4cfdf845e 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/license/ShieldLicenseeTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ShieldLicenseeTests.java @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.shield.license; +package org.elasticsearch.shield; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.core.License.OperationMode; @@ -17,16 +17,16 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; /** - * Tests {@link ShieldLicensee}. + * Tests {@link SecurityLicensee}. *

    * If you change the behavior of these tests, then it means that licensing changes for Security! */ public class ShieldLicenseeTests extends AbstractLicenseeTestCase { - private final ShieldLicenseState shieldState = mock(ShieldLicenseState.class); + private final SecurityLicenseState shieldState = mock(SecurityLicenseState.class); private final LicenseeRegistry registry = mock(LicenseeRegistry.class); public void testStartsWithoutTribeNode() { - ShieldLicensee licensee = new ShieldLicensee(Settings.EMPTY, registry, shieldState); + SecurityLicensee licensee = new SecurityLicensee(Settings.EMPTY, registry, shieldState); // starting the Licensee start trigger it being registered licensee.start(); @@ -37,7 +37,7 @@ public class ShieldLicenseeTests extends AbstractLicenseeTestCase { public void testDoesNotStartWithTribeNode() { Settings settings = Settings.builder().put("tribe.fake.cluster.name", "notchecked").build(); - ShieldLicensee licensee = new ShieldLicensee(settings, registry, shieldState); + SecurityLicensee licensee = new SecurityLicensee(settings, registry, shieldState); // starting the Licensee as a tribe node should not trigger it being registered licensee.start(); @@ -48,7 +48,7 @@ public class ShieldLicenseeTests extends AbstractLicenseeTestCase { public void testOnChangeModifiesShieldLicenseState() { Status status = mock(Status.class); - ShieldLicensee licensee = new ShieldLicensee(Settings.EMPTY, registry, shieldState); + SecurityLicensee licensee = new SecurityLicensee(Settings.EMPTY, registry, shieldState); licensee.onChange(status); @@ -83,7 +83,7 @@ public class ShieldLicenseeTests extends AbstractLicenseeTestCase { assertThat(messages.length, equalTo(2)); } - private ShieldLicensee buildLicensee() { - return new ShieldLicensee(Settings.EMPTY, registry, shieldState); + private SecurityLicensee buildLicensee() { + return new SecurityLicensee(Settings.EMPTY, registry, shieldState); } } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ShieldPluginTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ShieldPluginTests.java index 9fd7c5febe2..2f543a4b280 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ShieldPluginTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/ShieldPluginTests.java @@ -26,6 +26,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; public class ShieldPluginTests extends ShieldIntegTestCase { + @Override public Settings nodeSettings(int nodeOrdinal) { return Settings.builder() @@ -53,9 +54,6 @@ public class ShieldPluginTests extends ShieldIntegTestCase { new SecuredString(ShieldSettingsSource.DEFAULT_PASSWORD.toCharArray()))) .execute(); assertThat(response.getStatusCode(), is(OK.getStatus())); - assertThat(response.getBody(), allOf(containsString("status"), containsString("hash"), - containsString("timestamp"), containsString("uid"), - containsString("type"), containsString("status"))); } } } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/action/filter/ShieldActionFilterTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/action/filter/ShieldActionFilterTests.java index 24e7c4feb34..38010bf5a0c 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/action/filter/ShieldActionFilterTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/action/filter/ShieldActionFilterTests.java @@ -19,7 +19,7 @@ import org.elasticsearch.shield.audit.AuditTrail; import org.elasticsearch.shield.authc.AuthenticationService; import org.elasticsearch.shield.authz.AuthorizationService; import org.elasticsearch.shield.crypto.CryptoService; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import org.elasticsearch.tasks.Task; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; @@ -47,7 +47,7 @@ public class ShieldActionFilterTests extends ESTestCase { private AuthorizationService authzService; private CryptoService cryptoService; private AuditTrail auditTrail; - private ShieldLicenseState shieldLicenseState; + private SecurityLicenseState shieldLicenseState; private ShieldActionFilter filter; @Before @@ -56,7 +56,7 @@ public class ShieldActionFilterTests extends ESTestCase { authzService = mock(AuthorizationService.class); cryptoService = mock(CryptoService.class); auditTrail = mock(AuditTrail.class); - shieldLicenseState = mock(ShieldLicenseState.class); + shieldLicenseState = mock(SecurityLicenseState.class); when(shieldLicenseState.securityEnabled()).thenReturn(true); when(shieldLicenseState.statsAndHealthEnabled()).thenReturn(true); ThreadPool threadPool = mock(ThreadPool.class); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/InternalAuthenticationServiceTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/InternalAuthenticationServiceTests.java index 5301e33bb0f..ea9ebb28d89 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/InternalAuthenticationServiceTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/InternalAuthenticationServiceTests.java @@ -23,7 +23,7 @@ import org.elasticsearch.shield.authc.esnative.ReservedRealm; import org.elasticsearch.shield.authc.support.SecuredString; import org.elasticsearch.shield.authc.support.UsernamePasswordToken; import org.elasticsearch.shield.crypto.CryptoService; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.rest.FakeRestRequest; import org.elasticsearch.threadpool.ThreadPool; @@ -87,7 +87,7 @@ public class InternalAuthenticationServiceTests extends ESTestCase { secondRealm = mock(Realm.class); when(secondRealm.type()).thenReturn("second"); Settings settings = Settings.builder().put("path.home", createTempDir()).build(); - ShieldLicenseState shieldLicenseState = mock(ShieldLicenseState.class); + SecurityLicenseState shieldLicenseState = mock(SecurityLicenseState.class); when(shieldLicenseState.customRealmsEnabled()).thenReturn(true); realms = new Realms(Settings.EMPTY, new Environment(settings), Collections.emptyMap(), shieldLicenseState, mock(ReservedRealm.class)) { diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/RealmsTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/RealmsTests.java index c9e5f0ea54a..f5afd3fdd10 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/RealmsTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authc/RealmsTests.java @@ -13,7 +13,7 @@ import org.elasticsearch.shield.authc.esnative.ReservedRealm; import org.elasticsearch.shield.authc.esnative.NativeRealm; import org.elasticsearch.shield.authc.file.FileRealm; import org.elasticsearch.shield.authc.ldap.LdapRealm; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import org.elasticsearch.test.ESTestCase; import org.junit.Before; @@ -37,7 +37,7 @@ import static org.mockito.Mockito.when; */ public class RealmsTests extends ESTestCase { private Map factories; - private ShieldLicenseState shieldLicenseState; + private SecurityLicenseState shieldLicenseState; private ReservedRealm reservedRealm; @Before @@ -49,7 +49,7 @@ public class RealmsTests extends ESTestCase { DummyRealm.Factory factory = new DummyRealm.Factory("type_" + i, rarely()); factories.put("type_" + i, factory); } - shieldLicenseState = mock(ShieldLicenseState.class); + shieldLicenseState = mock(SecurityLicenseState.class); reservedRealm = mock(ReservedRealm.class); when(shieldLicenseState.customRealmsEnabled()).thenReturn(true); } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapperIntegrationTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapperIntegrationTests.java index 839b0f8e7b1..6418399f3e0 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapperIntegrationTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapperIntegrationTests.java @@ -31,7 +31,7 @@ import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.query.ParsedQuery; import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.IndexSettingsModule; @@ -71,7 +71,7 @@ public class ShieldIndexSearcherWrapperIntegrationTests extends ESTestCase { } }); - ShieldLicenseState licenseState = mock(ShieldLicenseState.class); + SecurityLicenseState licenseState = mock(SecurityLicenseState.class); when(licenseState.documentAndFieldLevelSecurityEnabled()).thenReturn(true); ShieldIndexSearcherWrapper wrapper = new ShieldIndexSearcherWrapper(indexSettings, queryShardContext, mapperService, bitsetFilterCache, threadContext, licenseState) { diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapperUnitTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapperUnitTests.java index a5d7a61fe57..15a9de93d97 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapperUnitTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/authz/accesscontrol/ShieldIndexSearcherWrapperUnitTests.java @@ -52,7 +52,7 @@ import org.elasticsearch.index.similarity.SimilarityService; import org.elasticsearch.indices.IndicesModule; import org.elasticsearch.search.aggregations.LeafBucketCollector; import org.elasticsearch.shield.authz.accesscontrol.DocumentSubsetReader.DocumentSubsetDirectoryReader; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.IndexSettingsModule; import org.junit.After; @@ -82,7 +82,7 @@ public class ShieldIndexSearcherWrapperUnitTests extends ESTestCase { private MapperService mapperService; private ShieldIndexSearcherWrapper shieldIndexSearcherWrapper; private ElasticsearchDirectoryReader esIn; - private ShieldLicenseState licenseState; + private SecurityLicenseState licenseState; private IndexSettings indexSettings; @Before @@ -96,7 +96,7 @@ public class ShieldIndexSearcherWrapperUnitTests extends ESTestCase { new IndicesModule().getMapperRegistry(), () -> null); ShardId shardId = new ShardId(index, 0); - licenseState = mock(ShieldLicenseState.class); + licenseState = mock(SecurityLicenseState.class); when(licenseState.documentAndFieldLevelSecurityEnabled()).thenReturn(true); threadContext = new ThreadContext(Settings.EMPTY); IndexShard indexShard = mock(IndexShard.class); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/rest/ShieldRestFilterTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/rest/ShieldRestFilterTests.java index b65026fa7b5..122ed9381d3 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/rest/ShieldRestFilterTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/rest/ShieldRestFilterTests.java @@ -14,7 +14,7 @@ import org.elasticsearch.rest.RestFilterChain; import org.elasticsearch.rest.RestRequest; import org.elasticsearch.shield.user.User; import org.elasticsearch.shield.authc.AuthenticationService; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.junit.Before; @@ -34,7 +34,7 @@ public class ShieldRestFilterTests extends ESTestCase { private RestChannel channel; private RestFilterChain chain; private ShieldRestFilter filter; - private ShieldLicenseState licenseState; + private SecurityLicenseState licenseState; @Before public void init() throws Exception { @@ -42,7 +42,7 @@ public class ShieldRestFilterTests extends ESTestCase { RestController restController = mock(RestController.class); channel = mock(RestChannel.class); chain = mock(RestFilterChain.class); - licenseState = mock(ShieldLicenseState.class); + licenseState = mock(SecurityLicenseState.class); when(licenseState.securityEnabled()).thenReturn(true); ThreadPool threadPool = mock(ThreadPool.class); when(threadPool.getThreadContext()).thenReturn(new ThreadContext(Settings.EMPTY)); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/TransportFilterTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/TransportFilterTests.java index 67f46b299c8..91e3c8adeff 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/TransportFilterTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/TransportFilterTests.java @@ -10,7 +10,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Module; -import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.network.NetworkModule; @@ -19,7 +18,7 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.shield.action.ShieldActionMapper; import org.elasticsearch.shield.authc.AuthenticationService; import org.elasticsearch.shield.authz.AuthorizationService; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.threadpool.ThreadPool; @@ -311,7 +310,7 @@ public class TransportFilterTests extends ESIntegTestCase { AuthenticationService authcService, AuthorizationService authzService, ShieldActionMapper actionMapper, ClientTransportFilter clientTransportFilter) { super(settings, transport, threadPool, authcService, authzService, actionMapper, clientTransportFilter, - mock(ShieldLicenseState.class)); + mock(SecurityLicenseState.class)); when(licenseState.securityEnabled()).thenReturn(true); } diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/filter/IPFilterTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/filter/IPFilterTests.java index b532c7de159..3ae9464b125 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/filter/IPFilterTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/filter/IPFilterTests.java @@ -15,7 +15,7 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.http.HttpServerTransport; import org.elasticsearch.shield.audit.AuditTrail; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.junit.annotations.Network; import org.elasticsearch.transport.Transport; @@ -44,7 +44,7 @@ import static org.mockito.Mockito.when; */ public class IPFilterTests extends ESTestCase { private IPFilter ipFilter; - private ShieldLicenseState licenseState; + private SecurityLicenseState licenseState; private AuditTrail auditTrail; private Transport transport; private HttpServerTransport httpTransport; @@ -52,7 +52,7 @@ public class IPFilterTests extends ESTestCase { @Before public void init() { - licenseState = mock(ShieldLicenseState.class); + licenseState = mock(SecurityLicenseState.class); when(licenseState.securityEnabled()).thenReturn(true); auditTrail = mock(AuditTrail.class); clusterSettings = new ClusterSettings(Settings.EMPTY, new HashSet<>(Arrays.asList( diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/netty/IPFilterNettyUpstreamHandlerTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/netty/IPFilterNettyUpstreamHandlerTests.java index 8bdf4a4df20..79738bf4fcc 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/netty/IPFilterNettyUpstreamHandlerTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/netty/IPFilterNettyUpstreamHandlerTests.java @@ -14,7 +14,7 @@ import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.http.HttpServerTransport; import org.elasticsearch.shield.audit.AuditTrail; -import org.elasticsearch.shield.license.ShieldLicenseState; +import org.elasticsearch.shield.SecurityLicenseState; import org.elasticsearch.shield.transport.filter.IPFilter; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.Transport; @@ -68,7 +68,7 @@ public class IPFilterNettyUpstreamHandlerTests extends ESTestCase { IPFilter.TRANSPORT_FILTER_ALLOW_SETTING, IPFilter.TRANSPORT_FILTER_DENY_SETTING, TransportSettings.TRANSPORT_PROFILES_SETTING))); - ShieldLicenseState licenseState = mock(ShieldLicenseState.class); + SecurityLicenseState licenseState = mock(SecurityLicenseState.class); when(licenseState.securityEnabled()).thenReturn(true); IPFilter ipFilter = new IPFilter(settings, AuditTrail.NOOP, clusterSettings, licenseState); ipFilter.setBoundTransportAddress(transport.boundAddress(), transport.profileBoundAddresses()); diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java index 77158f37463..2f3fbaea06c 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/test/ShieldSettingsSource.java @@ -9,7 +9,7 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.io.PathUtils; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; -import org.elasticsearch.marvel.Marvel; +import org.elasticsearch.marvel.Monitoring; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.shield.authc.file.FileRealm; import org.elasticsearch.shield.authc.esnative.NativeRealm; @@ -123,7 +123,7 @@ public class ShieldSettingsSource extends ClusterDiscoveryConfiguration.UnicastZ //TODO: for now isolate shield tests from watcher & monitoring (randomize this later) .put(XPackPlugin.featureEnabledSetting(Watcher.NAME), false) - .put(XPackPlugin.featureEnabledSetting(Marvel.NAME), false) + .put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false) .put(AuditTrailModule.ENABLED_SETTING.getKey(), randomBoolean()) .put(LoggingAuditTrail.HOST_ADDRESS_SETTING.getKey(), randomBoolean()) .put(LoggingAuditTrail.HOST_NAME_SETTING.getKey(), randomBoolean()) diff --git a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/license/GraphModule.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackFeatureSet.java similarity index 50% rename from elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/license/GraphModule.java rename to elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackFeatureSet.java index 0416ef9a7ce..af26f5ef8d2 100644 --- a/elasticsearch/x-pack/graph/src/main/java/org/elasticsearch/graph/license/GraphModule.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackFeatureSet.java @@ -3,18 +3,19 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.graph.license; - -import org.elasticsearch.common.inject.AbstractModule; +package org.elasticsearch.xpack; /** * */ -public class GraphModule extends AbstractModule { +public interface XPackFeatureSet { - @Override - protected void configure() { - bind(GraphLicensee.class).asEagerSingleton(); - } + String name(); + + String description(); + + boolean available(); + + boolean enabled(); } diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java index 266cf949009..98a9fc04d04 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/XPackPlugin.java @@ -10,7 +10,9 @@ import org.elasticsearch.action.ActionModule; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.common.component.LifecycleComponent; +import org.elasticsearch.common.inject.Binder; import org.elasticsearch.common.inject.Module; +import org.elasticsearch.common.inject.multibindings.Multibinder; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; @@ -19,11 +21,11 @@ import org.elasticsearch.env.Environment; import org.elasticsearch.graph.Graph; import org.elasticsearch.index.IndexModule; import org.elasticsearch.license.plugin.Licensing; -import org.elasticsearch.marvel.Marvel; +import org.elasticsearch.marvel.Monitoring; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.script.ScriptModule; -import org.elasticsearch.shield.authc.AuthenticationModule; import org.elasticsearch.shield.Security; +import org.elasticsearch.shield.authc.AuthenticationModule; import org.elasticsearch.watcher.Watcher; import org.elasticsearch.xpack.action.TransportXPackInfoAction; import org.elasticsearch.xpack.action.XPackInfoAction; @@ -31,7 +33,7 @@ import org.elasticsearch.xpack.common.init.LazyInitializationModule; import org.elasticsearch.xpack.common.init.LazyInitializationService; import org.elasticsearch.xpack.extensions.XPackExtension; import org.elasticsearch.xpack.extensions.XPackExtensionsService; -import org.elasticsearch.xpack.rest.RestXPackInfoAction; +import org.elasticsearch.xpack.rest.action.RestXPackInfoAction; import java.nio.file.Path; import java.security.AccessController; @@ -83,7 +85,7 @@ public class XPackPlugin extends Plugin { protected Licensing licensing; protected Security security; - protected Marvel marvel; + protected Monitoring monitoring; protected Watcher watcher; protected Graph graph; @@ -92,7 +94,7 @@ public class XPackPlugin extends Plugin { transportClientMode = transportClientMode(settings); this.licensing = new Licensing(settings); this.security = new Security(settings); - this.marvel = new Marvel(settings); + this.monitoring = new Monitoring(settings); this.watcher = new Watcher(settings); this.graph = new Graph(settings); // Check if the node is a transport client. @@ -125,7 +127,7 @@ public class XPackPlugin extends Plugin { modules.addAll(licensing.nodeModules()); modules.addAll(security.nodeModules()); modules.addAll(watcher.nodeModules()); - modules.addAll(marvel.nodeModules()); + modules.addAll(monitoring.nodeModules()); modules.addAll(graph.nodeModules()); return modules; } @@ -140,7 +142,7 @@ public class XPackPlugin extends Plugin { services.addAll(licensing.nodeServices()); services.addAll(security.nodeServices()); services.addAll(watcher.nodeServices()); - services.addAll(marvel.nodeServices()); + services.addAll(monitoring.nodeServices()); services.addAll(graph.nodeServices()); return services; } @@ -164,7 +166,7 @@ public class XPackPlugin extends Plugin { module.registerSetting(Setting.simpleString("index.xpack.version", Setting.Property.IndexScope)); security.onModule(module); - marvel.onModule(module); + monitoring.onModule(module); watcher.onModule(module); graph.onModule(module); licensing.onModule(module); @@ -175,7 +177,7 @@ public class XPackPlugin extends Plugin { module.registerRestHandler(RestXPackInfoAction.class); } licensing.onModule(module); - marvel.onModule(module); + monitoring.onModule(module); security.onModule(module); watcher.onModule(module); graph.onModule(module); @@ -186,7 +188,7 @@ public class XPackPlugin extends Plugin { module.registerAction(XPackInfoAction.INSTANCE, TransportXPackInfoAction.class); } licensing.onModule(module); - marvel.onModule(module); + monitoring.onModule(module); security.onModule(module); watcher.onModule(module); graph.onModule(module); @@ -204,10 +206,16 @@ public class XPackPlugin extends Plugin { } public void onModule(LazyInitializationModule module) { - marvel.onModule(module); + monitoring.onModule(module); watcher.onModule(module); } + public static void bindFeatureSet(Binder binder, Class featureSet) { + binder.bind(featureSet).asEagerSingleton(); + Multibinder featureSetBinder = Multibinder.newSetBinder(binder, XPackFeatureSet.class); + featureSetBinder.addBinding().to(featureSet); + } + public static boolean transportClientMode(Settings settings) { return TransportClient.CLIENT_TYPE.equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey())); } diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/TransportXPackInfoAction.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/TransportXPackInfoAction.java index a80e49759c1..2473618c571 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/TransportXPackInfoAction.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/TransportXPackInfoAction.java @@ -16,29 +16,55 @@ import org.elasticsearch.license.plugin.core.LicensesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.XPackBuild; +import org.elasticsearch.xpack.XPackFeatureSet; +import org.elasticsearch.xpack.action.XPackInfoResponse.FeatureSetsInfo.FeatureSet; import org.elasticsearch.xpack.action.XPackInfoResponse.LicenseInfo; +import java.util.Set; +import java.util.stream.Collectors; + /** */ public class TransportXPackInfoAction extends HandledTransportAction { private final LicensesService licensesService; + private final Set featureSets; @Inject public TransportXPackInfoAction(Settings settings, ThreadPool threadPool, TransportService transportService, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, - LicensesService licensesService) { + LicensesService licensesService, Set featureSets) { super(settings, XPackInfoAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, XPackInfoRequest::new); this.licensesService = licensesService; + this.featureSets = featureSets; } @Override protected void doExecute(XPackInfoRequest request, ActionListener listener) { - XPackInfoResponse.BuildInfo buildInfo = new XPackInfoResponse.BuildInfo(XPackBuild.CURRENT); - License license = licensesService.getLicense(); - LicenseInfo licenseInfo = license != null ? new LicenseInfo(license) : null; - XPackInfoResponse response = new XPackInfoResponse(buildInfo, licenseInfo); - listener.onResponse(response); + + + XPackInfoResponse.BuildInfo buildInfo = null; + if (request.getCategories().contains(XPackInfoRequest.Category.BUILD)) { + buildInfo = new XPackInfoResponse.BuildInfo(XPackBuild.CURRENT); + } + + LicenseInfo licenseInfo = null; + if (request.getCategories().contains(XPackInfoRequest.Category.LICENSE)) { + License license = licensesService.getLicense(); + if (license != null) { + licenseInfo = new LicenseInfo(license); + } + } + + XPackInfoResponse.FeatureSetsInfo featureSetsInfo = null; + if (request.getCategories().contains(XPackInfoRequest.Category.FEATURES)) { + Set featureSets = this.featureSets.stream().map(fs -> + new FeatureSet(fs.name(), request.isVerbose() ? fs.description() : null, fs.available(), fs.enabled())) + .collect(Collectors.toSet()); + featureSetsInfo = new XPackInfoResponse.FeatureSetsInfo(featureSets); + } + + listener.onResponse(new XPackInfoResponse(buildInfo, licenseInfo, featureSetsInfo)); } } diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/XPackInfoRequest.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/XPackInfoRequest.java index e3364c6a140..a01fc96b249 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/XPackInfoRequest.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/XPackInfoRequest.java @@ -7,16 +7,73 @@ package org.elasticsearch.xpack.action; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; + +import java.io.IOException; +import java.util.EnumSet; +import java.util.Locale; /** * */ public class XPackInfoRequest extends ActionRequest { + public enum Category { + BUILD, LICENSE, FEATURES; + + public static EnumSet toSet(String... categories) { + EnumSet set = EnumSet.noneOf(Category.class); + for (String category : categories) { + set.add(Category.valueOf(category.toUpperCase(Locale.ROOT))); + } + return set; + } + } + + private boolean verbose; + private EnumSet categories = EnumSet.noneOf(Category.class); + public XPackInfoRequest() {} + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } + + public boolean isVerbose() { + return verbose; + } + + public void setCategories(EnumSet categories) { + this.categories = categories; + } + + public EnumSet getCategories() { + return categories; + } + @Override public ActionRequestValidationException validate() { return null; } + + @Override + public void readFrom(StreamInput in) throws IOException { + this.verbose = in.readBoolean(); + EnumSet categories = EnumSet.noneOf(Category.class); + int size = in.readVInt(); + for (int i = 0; i < size; i++) { + categories.add(Category.valueOf(in.readString())); + } + this.categories = categories; + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + out.writeBoolean(verbose); + out.writeVInt(categories.size()); + for (Category category : categories) { + out.writeString(category.name()); + } + } } diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/XPackInfoRequestBuilder.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/XPackInfoRequestBuilder.java index b5e3bc9c8e0..c440c44fa1b 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/XPackInfoRequestBuilder.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/XPackInfoRequestBuilder.java @@ -8,6 +8,8 @@ package org.elasticsearch.xpack.action; import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.client.ElasticsearchClient; +import java.util.EnumSet; + /** */ public class XPackInfoRequestBuilder extends ActionRequestBuilder { @@ -20,4 +22,15 @@ public class XPackInfoRequestBuilder extends ActionRequestBuilder categories) { + request.setCategories(categories); + return this; + } + } diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/XPackInfoResponse.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/XPackInfoResponse.java index 478b41a20ea..6ee7351b3a3 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/XPackInfoResponse.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/action/XPackInfoResponse.java @@ -9,26 +9,37 @@ import org.elasticsearch.action.ActionResponse; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.license.core.License; import org.elasticsearch.xpack.XPackBuild; +import org.elasticsearch.xpack.XPackFeatureSet; import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; /** */ public class XPackInfoResponse extends ActionResponse { - private BuildInfo buildInfo; + private @Nullable BuildInfo buildInfo; private @Nullable LicenseInfo licenseInfo; + private @Nullable FeatureSetsInfo featureSetsInfo; public XPackInfoResponse() {} - public XPackInfoResponse(BuildInfo buildInfo, @Nullable LicenseInfo licenseInfo) { + public XPackInfoResponse(@Nullable BuildInfo buildInfo, @Nullable LicenseInfo licenseInfo, @Nullable FeatureSetsInfo featureSetsInfo) { this.buildInfo = buildInfo; this.licenseInfo = licenseInfo; + this.featureSetsInfo = featureSetsInfo; } /** @@ -46,25 +57,29 @@ public class XPackInfoResponse extends ActionResponse { return licenseInfo; } + /** + * @return The current status of the feature sets in X-Pack. Feature sets describe the features available/enabled in X-Pack. + */ + public FeatureSetsInfo getFeatureSetsInfo() { + return featureSetsInfo; + } + @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - buildInfo.writeTo(out); - if (licenseInfo != null) { - out.writeBoolean(true); - licenseInfo.writeTo(out); - } else { - out.writeBoolean(false); - } + out.writeOptionalWriteable(buildInfo); + out.writeOptionalWriteable(licenseInfo); + out.writeOptionalWriteable(featureSetsInfo); } @Override public void readFrom(StreamInput in) throws IOException { - this.buildInfo = new BuildInfo(in); - this.licenseInfo = in.readBoolean() ? new LicenseInfo(in) : null; + this.buildInfo = in.readOptionalWriteable(BuildInfo::new); + this.licenseInfo = in.readOptionalWriteable(LicenseInfo::new); + this.featureSetsInfo = in.readOptionalWriteable(FeatureSetsInfo::new); } - public static class LicenseInfo implements ToXContent { + public static class LicenseInfo implements ToXContent, Writeable { private final String uid; private final String type; @@ -121,7 +136,7 @@ public class XPackInfoResponse extends ActionResponse { } } - public static class BuildInfo implements ToXContent { + public static class BuildInfo implements ToXContent, Writeable { private final String hash; private final String timestamp; @@ -160,4 +175,106 @@ public class XPackInfoResponse extends ActionResponse { output.writeString(timestamp); } } + + public static class FeatureSetsInfo implements ToXContent, Writeable { + + private final Map featureSets; + + public FeatureSetsInfo(StreamInput in) throws IOException { + int size = in.readVInt(); + Map featureSets = new HashMap<>(size); + for (int i = 0; i < size; i++) { + FeatureSet featureSet = new FeatureSet(in); + featureSets.put(featureSet.name, featureSet); + } + this.featureSets = Collections.unmodifiableMap(featureSets); + } + + public FeatureSetsInfo(Set featureSets) { + Map map = new HashMap<>(featureSets.size()); + for (FeatureSet featureSet : featureSets) { + map.put(featureSet.name, featureSet); + } + this.featureSets = Collections.unmodifiableMap(map); + } + + public Map getFeatureSets() { + return featureSets; + } + + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + builder.startObject(); + List names = new ArrayList<>(this.featureSets.keySet()).stream().sorted().collect(Collectors.toList()); + for (String name : names) { + builder.field(name, featureSets.get(name), params); + } + return builder.endObject(); + } + + public void writeTo(StreamOutput out) throws IOException { + out.writeVInt(featureSets.size()); + for (FeatureSet featureSet : featureSets.values()) { + featureSet.writeTo(out); + } + } + + public static class FeatureSet implements XPackFeatureSet, ToXContent, Writeable { + + private final String name; + private final @Nullable String description; + private final boolean available; + private final boolean enabled; + + public FeatureSet(StreamInput in) throws IOException { + this(in.readString(), in.readOptionalString(), in.readBoolean(), in.readBoolean()); + } + + public FeatureSet(String name, @Nullable String description, boolean available, boolean enabled) { + this.name = name; + this.description = description; + this.available = available; + this.enabled = enabled; + } + + @Override + public String name() { + return name; + } + + @Override + @Nullable + public String description() { + return description; + } + + @Override + public boolean available() { + return available; + } + + @Override + public boolean enabled() { + return enabled; + } + + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + builder.startObject(); + if (description != null) { + builder.field("description", description); + } + builder.field("available", available); + builder.field("enabled", enabled); + return builder.endObject(); + } + + public void writeTo(StreamOutput out) throws IOException { + out.writeString(name); + out.writeOptionalString(description); + out.writeBoolean(available); + out.writeBoolean(enabled); + } + } + + } } diff --git a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/rest/RestXPackInfoAction.java b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/rest/action/RestXPackInfoAction.java similarity index 61% rename from elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/rest/RestXPackInfoAction.java rename to elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/rest/action/RestXPackInfoAction.java index 6d7a4a4809a..5b1119c8ac4 100644 --- a/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/rest/RestXPackInfoAction.java +++ b/elasticsearch/x-pack/src/main/java/org/elasticsearch/xpack/rest/action/RestXPackInfoAction.java @@ -3,9 +3,10 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.xpack.rest; +package org.elasticsearch.xpack.rest.action; import org.elasticsearch.client.Client; +import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -16,7 +17,11 @@ import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestResponse; import org.elasticsearch.rest.action.support.RestBuilderListener; import org.elasticsearch.xpack.XPackClient; +import org.elasticsearch.xpack.action.XPackInfoRequest; import org.elasticsearch.xpack.action.XPackInfoResponse; +import org.elasticsearch.xpack.rest.XPackRestHandler; + +import java.util.EnumSet; import static org.elasticsearch.rest.RestRequest.Method.GET; import static org.elasticsearch.rest.RestRequest.Method.HEAD; @@ -33,7 +38,13 @@ public class RestXPackInfoAction extends XPackRestHandler { @Override protected void handleRequest(RestRequest request, RestChannel restChannel, XPackClient client) throws Exception { - client.prepareInfo().execute(new RestBuilderListener(restChannel) { + + // we piggyback verbosity on "human" output + boolean verbose = request.paramAsBoolean("human", false); + + EnumSet categories = XPackInfoRequest.Category + .toSet(request.paramAsStringArray("categories", Strings.EMPTY_ARRAY)); + client.prepareInfo().setVerbose(verbose).setCategories(categories).execute(new RestBuilderListener(restChannel) { @Override public RestResponse buildResponse(XPackInfoResponse infoResponse, XContentBuilder builder) throws Exception { @@ -44,13 +55,28 @@ public class RestXPackInfoAction extends XPackRestHandler { } builder.startObject(); - builder.field("build", infoResponse.getBuildInfo(), request); + + if (infoResponse.getBuildInfo() != null) { + builder.field("build", infoResponse.getBuildInfo(), request); + } + if (infoResponse.getLicenseInfo() != null) { builder.field("license", infoResponse.getLicenseInfo(), request); - } else { + } else if (categories.contains(XPackInfoRequest.Category.LICENSE)) { + // if the user requested the license info, and there is no license, we should send + // back an explicit null value (indicating there is no license). This is different + // than not adding the license info at all builder.nullField("license"); } - builder.field("tagline", "You know, for X"); + + if (infoResponse.getFeatureSetsInfo() != null) { + builder.field("features", infoResponse.getFeatureSetsInfo(), request); + } + + if (verbose) { + builder.field("tagline", "You know, for X"); + } + builder.endObject(); return new BytesRestResponse(OK, builder); } diff --git a/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java b/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java index ac4a1bfe4cd..39582f72159 100644 --- a/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java +++ b/elasticsearch/x-pack/src/test/java/org/elasticsearch/xpack/action/TransportXPackInfoActionTests.java @@ -15,13 +15,21 @@ import org.elasticsearch.shield.user.AnonymousUser; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import org.elasticsearch.xpack.XPackFeatureSet; +import org.elasticsearch.xpack.action.XPackInfoResponse.FeatureSetsInfo.FeatureSet; import org.junit.After; import org.junit.Before; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.hamcrest.core.IsNull.nullValue; @@ -50,8 +58,20 @@ public class TransportXPackInfoActionTests extends ESTestCase { LicensesService licensesService = mock(LicensesService.class); + final Set featureSets = new HashSet<>(); + int featureSetCount = randomIntBetween(0, 5); + for (int i = 0; i < featureSetCount; i++) { + XPackFeatureSet fs = mock(XPackFeatureSet.class); + when(fs.name()).thenReturn(randomAsciiOfLength(5)); + when(fs.description()).thenReturn(randomAsciiOfLength(10)); + when(fs.available()).thenReturn(randomBoolean()); + when(fs.enabled()).thenReturn(randomBoolean()); + featureSets.add(fs); + } + TransportXPackInfoAction action = new TransportXPackInfoAction(Settings.EMPTY, mock(ThreadPool.class), - mock(TransportService.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), licensesService); + mock(TransportService.class), mock(ActionFilters.class), mock(IndexNameExpressionResolver.class), + licensesService, featureSets); License license = mock(License.class); long expiryDate = randomLong(); @@ -65,6 +85,14 @@ public class TransportXPackInfoActionTests extends ESTestCase { when(licensesService.getLicense()).thenReturn(license); XPackInfoRequest request = new XPackInfoRequest(); + request.setVerbose(randomBoolean()); + + EnumSet categories = EnumSet.noneOf(XPackInfoRequest.Category.class); + int maxCategoryCount = randomIntBetween(0, XPackInfoRequest.Category.values().length); + for (int i = 0; i < maxCategoryCount; i++) { + categories.add(randomFrom(XPackInfoRequest.Category.values())); + } + request.setCategories(categories); final CountDownLatch latch = new CountDownLatch(1); final AtomicReference response = new AtomicReference<>(); @@ -90,12 +118,41 @@ public class TransportXPackInfoActionTests extends ESTestCase { assertThat(error.get(), nullValue()); assertThat(response.get(), notNullValue()); - assertThat(response.get().getBuildInfo(), notNullValue()); - assertThat(response.get().getLicenseInfo(), notNullValue()); - assertThat(response.get().getLicenseInfo().getExpiryDate(), is(expiryDate)); - assertThat(response.get().getLicenseInfo().getStatus(), is(status)); - assertThat(response.get().getLicenseInfo().getType(), is(type)); - assertThat(response.get().getLicenseInfo().getUid(), is(uid)); + if (request.getCategories().contains(XPackInfoRequest.Category.BUILD)) { + assertThat(response.get().getBuildInfo(), notNullValue()); + } else { + assertThat(response.get().getBuildInfo(), nullValue()); + } + + if (request.getCategories().contains(XPackInfoRequest.Category.LICENSE)) { + assertThat(response.get().getLicenseInfo(), notNullValue()); + assertThat(response.get().getLicenseInfo().getExpiryDate(), is(expiryDate)); + assertThat(response.get().getLicenseInfo().getStatus(), is(status)); + assertThat(response.get().getLicenseInfo().getType(), is(type)); + assertThat(response.get().getLicenseInfo().getUid(), is(uid)); + } else { + assertThat(response.get().getLicenseInfo(), nullValue()); + } + + if (request.getCategories().contains(XPackInfoRequest.Category.FEATURES)) { + assertThat(response.get().getFeatureSetsInfo(), notNullValue()); + Map features = response.get().getFeatureSetsInfo().getFeatureSets(); + assertThat(features.size(), is(featureSets.size())); + for (XPackFeatureSet fs : featureSets) { + assertThat(features, hasKey(fs.name())); + assertThat(features.get(fs.name()).name(), equalTo(fs.name())); + if (!request.isVerbose()) { + assertThat(features.get(fs.name()).description(), is(nullValue())); + } else { + assertThat(features.get(fs.name()).description(), is(fs.description())); + } + assertThat(features.get(fs.name()).available(), equalTo(fs.available())); + assertThat(features.get(fs.name()).enabled(), equalTo(fs.enabled())); + } + } else { + assertThat(response.get().getFeatureSetsInfo(), nullValue()); + } + } } diff --git a/elasticsearch/x-pack/src/test/resources/rest-api-spec/api/xpack.info.json b/elasticsearch/x-pack/src/test/resources/rest-api-spec/api/xpack.info.json index 36dea81cded..206cbf40a0a 100644 --- a/elasticsearch/x-pack/src/test/resources/rest-api-spec/api/xpack.info.json +++ b/elasticsearch/x-pack/src/test/resources/rest-api-spec/api/xpack.info.json @@ -6,7 +6,16 @@ "path": "/_xpack", "paths": [ "/_xpack" ], "parts": {}, - "params": {} + "params": { + "human" : { + "type" : "boolean", + "description" : "Presents additional info for humans (feature descriptions and X-Pack tagline)" + }, + "categories": { + "type": "list", + "description" : "Comma-separated list of info categories. Can be any of: build, license, features" + } + } }, "body": null } diff --git a/elasticsearch/x-pack/src/test/resources/rest-api-spec/test/xpack/15_basic.yaml b/elasticsearch/x-pack/src/test/resources/rest-api-spec/test/xpack/15_basic.yaml index 8e62c2ee28c..6d5e3413c1a 100644 --- a/elasticsearch/x-pack/src/test/resources/rest-api-spec/test/xpack/15_basic.yaml +++ b/elasticsearch/x-pack/src/test/resources/rest-api-spec/test/xpack/15_basic.yaml @@ -1,9 +1,10 @@ # Integration tests xpack info API # "X-Pack Info": + - do: cluster.health: - wait_for_status: yellow + wait_for_status: yellow - do: license.delete: {} @@ -11,12 +12,23 @@ # we don't have a license now - do: - xpack.info: {} - - is_true: build.hash - - is_true: build.timestamp + xpack.info: + categories: "license,features" - is_false: license + - is_true: features + - is_true: features.watcher + - is_true: features.watcher.enabled +# - is_false: features.watcher.available TODO fix once licensing is fixed + - is_true: features.security + - is_true: features.security.enabled +# - is_false: features.security.available TODO fix once licensing is fixed + - is_true: features.graph + - is_true: features.graph.enabled +# - is_false: features.graph.available TODO fix once licensing is fixed + - is_true: features.monitoring + - is_true: features.monitoring.enabled +# - is_false: features.monitoring.available TODO fix once licensing is fixed - # lets put an active license - do: license.post: body: > @@ -37,13 +49,31 @@ - match: { license_status: "valid" } - do: - license.get: {} + license.get: {} - match: { license.uid: "893361dc-9749-4997-93cb-802e3dofh7aa" } - match: { license.type: "internal" } - match: { license.status: "active" } - do: xpack.info: {} + - is_false: tagline + - is_false: build + - is_false: features + - is_false: license + + - do: + xpack.info: + categories: "build" + - is_true: build + - is_true: build.hash + - is_true: build.timestamp + - is_false: tagline + - is_false: features + - is_false: license + + - do: + xpack.info: + categories: "build,license" - is_true: build.hash - is_true: build.timestamp - is_true: license @@ -52,3 +82,66 @@ - match: { license.mode: "platinum" } - match: { license.status: "active" } - match: { license.expiry_date_in_millis: 1914278399999 } + - is_false: tagline + - is_false: features + + - do: + xpack.info: + categories: "build,license,features" + - is_true: build.hash + - is_true: build.timestamp + - is_true: license + - match: { license.uid: "893361dc-9749-4997-93cb-802e3dofh7aa" } + - match: { license.type: "internal" } + - match: { license.mode: "platinum" } + - match: { license.status: "active" } + - match: { license.expiry_date_in_millis: 1914278399999 } + - is_true: features + - is_true: features.watcher + - is_true: features.watcher.enabled + - is_true: features.watcher.available + - is_false: features.watcher.description + - is_true: features.security + - is_true: features.security.enabled + - is_true: features.security.available + - is_false: features.security.description + - is_true: features.graph + - is_true: features.graph.enabled + - is_true: features.graph.available + - is_false: features.graph.description + - is_true: features.monitoring + - is_true: features.monitoring.enabled + - is_true: features.monitoring.available + - is_false: features.monitoring.description + - is_false: tagline + + - do: + xpack.info: + categories: "build,license,features" + human: "true" + - is_true: build.hash + - is_true: build.timestamp + - is_true: license + - match: { license.uid: "893361dc-9749-4997-93cb-802e3dofh7aa" } + - match: { license.type: "internal" } + - match: { license.mode: "platinum" } + - match: { license.status: "active" } + - match: { license.expiry_date_in_millis: 1914278399999 } + - is_true: features + - is_true: features.watcher + - is_true: features.watcher.enabled + - is_true: features.watcher.available + - is_true: features.watcher.description + - is_true: features.security + - is_true: features.security.enabled + - is_true: features.security.available + - is_true: features.security.description + - is_true: features.graph + - is_true: features.graph.enabled + - is_true: features.graph.available + - is_true: features.graph.description + - is_true: features.monitoring + - is_true: features.monitoring.enabled + - is_true: features.monitoring.available + - is_true: features.monitoring.description + - is_true: tagline diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/Watcher.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/Watcher.java index 2a7c4abae67..0e08369d642 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/Watcher.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/Watcher.java @@ -38,8 +38,6 @@ import org.elasticsearch.watcher.history.HistoryModule; import org.elasticsearch.watcher.history.HistoryStore; import org.elasticsearch.watcher.input.InputModule; import org.elasticsearch.watcher.input.chain.ChainInputFactory; -import org.elasticsearch.watcher.license.LicenseModule; -import org.elasticsearch.watcher.license.WatcherLicensee; import org.elasticsearch.watcher.rest.action.RestAckWatchAction; import org.elasticsearch.watcher.rest.action.RestActivateWatchAction; import org.elasticsearch.watcher.rest.action.RestDeleteWatchAction; @@ -119,26 +117,25 @@ public class Watcher { } public Collection nodeModules() { - if (enabled == false|| transportClient) { - return Collections.emptyList(); + List modules = new ArrayList<>(); + modules.add(new WatcherModule(enabled, transportClient)); + if (enabled && transportClient == false) { + modules.add(new WatchModule()); + modules.add(new TextTemplateModule()); + modules.add(new HttpClientModule()); + modules.add(new ClockModule()); + modules.add(new WatcherClientModule()); + modules.add(new TransformModule()); + modules.add(new TriggerModule(settings)); + modules.add(new ScheduleModule()); + modules.add(new ConditionModule()); + modules.add(new InputModule()); + modules.add(new WatcherActionModule()); + modules.add(new HistoryModule()); + modules.add(new ExecutionModule()); + modules.add(new SecretModule(settings)); } - return Arrays.asList( - new WatcherModule(settings), - new LicenseModule(), - new WatchModule(), - new TextTemplateModule(), - new HttpClientModule(), - new ClockModule(), - new WatcherClientModule(), - new TransformModule(), - new TriggerModule(settings), - new ScheduleModule(), - new ConditionModule(), - new InputModule(), - new WatcherActionModule(), - new HistoryModule(), - new ExecutionModule(), - new SecretModule(settings)); + return modules; } public Collection> nodeServices() { diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/WatcherFeatureSet.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/WatcherFeatureSet.java new file mode 100644 index 00000000000..ba8814182f0 --- /dev/null +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/WatcherFeatureSet.java @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.watcher; + +import org.elasticsearch.common.Nullable; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.xpack.XPackFeatureSet; + +/** + * + */ +public class WatcherFeatureSet implements XPackFeatureSet { + + private final boolean enabled; + private final WatcherLicensee licensee; + + @Inject + public WatcherFeatureSet(Settings settings, @Nullable WatcherLicensee licensee) { + this.enabled = Watcher.enabled(settings); + this.licensee = licensee; + } + + @Override + public String name() { + return Watcher.NAME; + } + + @Override + public String description() { + return "Alerting, Notification and Automation for the Elastic Stack"; + } + + @Override + public boolean available() { + return licensee != null && licensee.available(); + } + + @Override + public boolean enabled() { + return enabled; + } +} diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/license/WatcherLicensee.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/WatcherLicensee.java similarity index 87% rename from elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/license/WatcherLicensee.java rename to elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/WatcherLicensee.java index e3cb1f885d6..d4796d30b36 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/license/WatcherLicensee.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/WatcherLicensee.java @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -package org.elasticsearch.watcher.license; +package org.elasticsearch.watcher; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; @@ -13,7 +13,6 @@ import org.elasticsearch.license.core.License.OperationMode; import org.elasticsearch.license.plugin.core.AbstractLicenseeComponent; import org.elasticsearch.license.plugin.core.LicenseState; import org.elasticsearch.license.plugin.core.LicenseeRegistry; -import org.elasticsearch.watcher.Watcher; public class WatcherLicensee extends AbstractLicenseeComponent { @@ -51,22 +50,10 @@ public class WatcherLicensee extends AbstractLicenseeComponent return Strings.EMPTY_ARRAY; } - public boolean isExecutingActionsAllowed() { - return isPutWatchAllowed(); - } - - public boolean isGetWatchAllowed() { - return isPutWatchAllowed(); - } - - public boolean isPutWatchAllowed() { - return isWatcherTransportActionAllowed(); - } - /** - * Determine if Watcher should be enabled. + * Determine if Watcher is available based on the current license. *

    - * Watcher is only disabled when the license has expired or if the mode is not: + * Watcher is available if the license is active (hasn't expired) and of one of the following types: *

      *
    • {@link OperationMode#PLATINUM}
    • *
    • {@link OperationMode#GOLD}
    • @@ -75,11 +62,30 @@ public class WatcherLicensee extends AbstractLicenseeComponent * * @return {@code true} as long as the license is valid. Otherwise {@code false}. */ - public boolean isWatcherTransportActionAllowed() { + public boolean available() { // status is volatile, so a local variable is used for a consistent view Status localStatus = status; return localStatus.getLicenseState() != LicenseState.DISABLED && (localStatus.getMode() == OperationMode.TRIAL || localStatus.getMode() == OperationMode.GOLD || localStatus.getMode() == OperationMode.PLATINUM); } + + public boolean isExecutingActionsAllowed() { + return isWatcherTransportActionAllowed(); + } + + public boolean isGetWatchAllowed() { + return isWatcherTransportActionAllowed(); + } + + public boolean isPutWatchAllowed() { + return isWatcherTransportActionAllowed(); + } + + + public boolean isWatcherTransportActionAllowed() { + return available(); + } + + } diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/WatcherModule.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/WatcherModule.java index 46cbad6864f..61aa80b6cac 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/WatcherModule.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/WatcherModule.java @@ -9,11 +9,13 @@ package org.elasticsearch.watcher; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.multibindings.Multibinder; +import org.elasticsearch.common.inject.util.Providers; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.watcher.support.WatcherIndexTemplateRegistry; import org.elasticsearch.watcher.support.WatcherIndexTemplateRegistry.TemplateConfig; import org.elasticsearch.watcher.support.validation.WatcherSettingsValidation; +import org.elasticsearch.xpack.XPackPlugin; import java.io.IOException; import java.io.InputStream; @@ -42,14 +44,24 @@ public class WatcherModule extends AbstractModule { new TemplateConfig(WATCHES_TEMPLATE_NAME, WATCHES_TEMPLATE_SETTING) }; - protected final Settings settings; + private final boolean enabled; + private final boolean transportClientMode; - public WatcherModule(Settings settings) { - this.settings = settings; + public WatcherModule(boolean enabled, boolean transportClientMode) { + this.enabled = enabled; + this.transportClientMode = transportClientMode; } @Override protected void configure() { + XPackPlugin.bindFeatureSet(binder(), WatcherFeatureSet.class); + + if (enabled == false || transportClientMode) { + bind(WatcherLicensee.class).toProvider(Providers.of(null)); + return; + } + + bind(WatcherLicensee.class).asEagerSingleton(); bind(WatcherLifeCycleService.class).asEagerSingleton(); bind(WatcherSettingsValidation.class).asEagerSingleton(); diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/ActionRegistry.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/ActionRegistry.java index 942305515d5..9065e7a7b1a 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/ActionRegistry.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/ActionRegistry.java @@ -8,7 +8,7 @@ package org.elasticsearch.watcher.actions; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import org.elasticsearch.watcher.support.clock.Clock; import org.elasticsearch.watcher.support.validation.Validation; import org.elasticsearch.watcher.transform.TransformRegistry; diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/ActionWrapper.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/ActionWrapper.java index 957477bd4db..6d9b3779223 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/ActionWrapper.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/ActionWrapper.java @@ -17,7 +17,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.watcher.actions.throttler.ActionThrottler; import org.elasticsearch.watcher.actions.throttler.Throttler; import org.elasticsearch.watcher.execution.WatchExecutionContext; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import org.elasticsearch.watcher.support.WatcherDateTimeUtils; import org.elasticsearch.watcher.support.clock.Clock; import org.elasticsearch.watcher.transform.ExecutableTransform; diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/throttler/ActionThrottler.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/throttler/ActionThrottler.java index 32243fa7dca..22130006863 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/throttler/ActionThrottler.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/actions/throttler/ActionThrottler.java @@ -8,7 +8,7 @@ package org.elasticsearch.watcher.actions.throttler; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.watcher.execution.WatchExecutionContext; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import org.elasticsearch.watcher.support.clock.Clock; /** diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/license/LicenseModule.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/license/LicenseModule.java deleted file mode 100644 index 8f72298707d..00000000000 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/license/LicenseModule.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -package org.elasticsearch.watcher.license; - -import org.elasticsearch.common.inject.AbstractModule; - -/** - * - */ -public class LicenseModule extends AbstractModule { - - @Override - protected void configure() { - bind(WatcherLicensee.class).asEagerSingleton(); - } - -} diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/WatcherTransportAction.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/WatcherTransportAction.java index e7a9fc8dd3e..2f2b0c578b9 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/WatcherTransportAction.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/WatcherTransportAction.java @@ -17,7 +17,7 @@ import org.elasticsearch.license.plugin.core.LicenseUtils; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import java.util.function.Supplier; diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/ack/TransportAckWatchAction.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/ack/TransportAckWatchAction.java index dd81b2ca563..6db822e4754 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/ack/TransportAckWatchAction.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/ack/TransportAckWatchAction.java @@ -18,7 +18,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.watcher.WatcherService; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import org.elasticsearch.watcher.transport.actions.WatcherTransportAction; import org.elasticsearch.watcher.watch.WatchStatus; import org.elasticsearch.watcher.watch.WatchStore; diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/activate/TransportActivateWatchAction.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/activate/TransportActivateWatchAction.java index 854053b9c77..3fdc7854bf7 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/activate/TransportActivateWatchAction.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/activate/TransportActivateWatchAction.java @@ -18,7 +18,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.watcher.WatcherService; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import org.elasticsearch.watcher.transport.actions.WatcherTransportAction; import org.elasticsearch.watcher.watch.WatchStatus; import org.elasticsearch.watcher.watch.WatchStore; diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/delete/TransportDeleteWatchAction.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/delete/TransportDeleteWatchAction.java index 40084fbb79f..be98e3e08db 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/delete/TransportDeleteWatchAction.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/delete/TransportDeleteWatchAction.java @@ -19,7 +19,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.watcher.WatcherService; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import org.elasticsearch.watcher.transport.actions.WatcherTransportAction; import org.elasticsearch.watcher.watch.WatchStore; diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/execute/TransportExecuteWatchAction.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/execute/TransportExecuteWatchAction.java index f69bbb71421..238a7d88d69 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/execute/TransportExecuteWatchAction.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/execute/TransportExecuteWatchAction.java @@ -26,7 +26,7 @@ import org.elasticsearch.watcher.execution.ExecutionService; import org.elasticsearch.watcher.execution.ManualExecutionContext; import org.elasticsearch.watcher.history.WatchRecord; import org.elasticsearch.watcher.input.simple.SimpleInput; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import org.elasticsearch.watcher.support.clock.Clock; import org.elasticsearch.watcher.support.xcontent.WatcherParams; import org.elasticsearch.watcher.transport.actions.WatcherTransportAction; diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/get/TransportGetWatchAction.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/get/TransportGetWatchAction.java index 83686c5d1b8..3a85d1c8072 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/get/TransportGetWatchAction.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/get/TransportGetWatchAction.java @@ -22,7 +22,7 @@ import org.elasticsearch.license.plugin.core.LicenseUtils; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.watcher.WatcherService; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import org.elasticsearch.watcher.support.xcontent.WatcherParams; import org.elasticsearch.watcher.transport.actions.WatcherTransportAction; import org.elasticsearch.watcher.watch.Watch; diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/put/TransportPutWatchAction.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/put/TransportPutWatchAction.java index e5ffe4274ee..4ac9597b32c 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/put/TransportPutWatchAction.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/put/TransportPutWatchAction.java @@ -20,7 +20,7 @@ import org.elasticsearch.license.plugin.core.LicenseUtils; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.watcher.WatcherService; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import org.elasticsearch.watcher.transport.actions.WatcherTransportAction; import org.elasticsearch.watcher.watch.WatchStore; diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/service/TransportWatcherServiceAction.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/service/TransportWatcherServiceAction.java index 166e0e87e80..de92311e0d2 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/service/TransportWatcherServiceAction.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/service/TransportWatcherServiceAction.java @@ -18,7 +18,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.watcher.WatcherLifeCycleService; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import org.elasticsearch.watcher.transport.actions.WatcherTransportAction; /** diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/stats/TransportWatcherStatsAction.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/stats/TransportWatcherStatsAction.java index fc6ac8b9ad6..5fb77a0f59d 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/stats/TransportWatcherStatsAction.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/transport/actions/stats/TransportWatcherStatsAction.java @@ -21,7 +21,7 @@ import org.elasticsearch.watcher.WatcherBuild; import org.elasticsearch.watcher.WatcherLifeCycleService; import org.elasticsearch.watcher.WatcherService; import org.elasticsearch.watcher.execution.ExecutionService; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import org.elasticsearch.watcher.transport.actions.WatcherTransportAction; /** diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/WatcherPluginDisableTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/WatcherPluginDisableTests.java index 98d06faa40b..468afd30644 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/WatcherPluginDisableTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/WatcherPluginDisableTests.java @@ -13,7 +13,7 @@ import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.http.HttpServerTransport; -import org.elasticsearch.marvel.Marvel; +import org.elasticsearch.marvel.Monitoring; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.shield.Security; import org.elasticsearch.test.ESIntegTestCase; @@ -45,7 +45,7 @@ public class WatcherPluginDisableTests extends ESIntegTestCase { // disable shield because of query cache check and authentication/authorization .put(XPackPlugin.featureEnabledSetting(Security.NAME), false) - .put(XPackPlugin.featureEnabledSetting(Marvel.NAME), false) + .put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false) .put(NetworkModule.HTTP_ENABLED.getKey(), true) .build(); diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/actions/throttler/WatchThrottlerTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/actions/throttler/WatchThrottlerTests.java index 596630e2f28..d958bab3a92 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/actions/throttler/WatchThrottlerTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/actions/throttler/WatchThrottlerTests.java @@ -7,7 +7,7 @@ package org.elasticsearch.watcher.actions.throttler; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.watcher.execution.WatchExecutionContext; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/license/LicenseTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/license/LicenseTests.java index def1a44e72b..0be401bbbef 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/license/LicenseTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/license/LicenseTests.java @@ -8,6 +8,7 @@ package org.elasticsearch.watcher.license; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.license.core.License; import org.elasticsearch.license.plugin.core.AbstractLicenseeTestCase; +import org.elasticsearch.watcher.WatcherLicensee; import static org.elasticsearch.license.core.License.OperationMode.BASIC; import static org.elasticsearch.license.core.License.OperationMode.GOLD; diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/test/AbstractWatcherIntegrationTestCase.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/test/AbstractWatcherIntegrationTestCase.java index b4c7379d5ce..9dd18ae6566 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -22,7 +22,7 @@ import org.elasticsearch.common.util.Callback; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.query.QueryBuilder; -import org.elasticsearch.marvel.Marvel; +import org.elasticsearch.marvel.Monitoring; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.script.MockMustacheScriptEngine; import org.elasticsearch.search.SearchHit; @@ -51,7 +51,7 @@ import org.elasticsearch.watcher.client.WatcherClient; import org.elasticsearch.watcher.execution.ExecutionService; import org.elasticsearch.watcher.execution.ExecutionState; import org.elasticsearch.watcher.history.HistoryStore; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import org.elasticsearch.watcher.support.WatcherIndexTemplateRegistry; import org.elasticsearch.watcher.support.clock.ClockMock; import org.elasticsearch.watcher.support.http.HttpClient; @@ -130,7 +130,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) //TODO: for now lets isolate watcher tests from monitoring (randomize this later) - .put(XPackPlugin.featureEnabledSetting(Marvel.NAME), false) + .put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false) // we do this by default in core, but for watcher this isn't needed and only adds noise. .put("index.store.mock.check_index_on_close", false) .put("xpack.watcher.execution.scroll.size", randomIntBetween(1, 100)) @@ -394,32 +394,29 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase final boolean assertConditionMet) throws Exception { final AtomicReference lastResponse = new AtomicReference<>(); try { - assertBusy(new Runnable() { - @Override - public void run() { - ClusterState state = client().admin().cluster().prepareState().get().getState(); - String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames(state, - IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX + "*"); - assertThat(watchHistoryIndices, not(emptyArray())); - for (String index : watchHistoryIndices) { - IndexRoutingTable routingTable = state.getRoutingTable().index(index); - assertThat(routingTable, notNullValue()); - assertThat(routingTable.allPrimaryShardsActive(), is(true)); - } + assertBusy(() -> { + ClusterState state = client().admin().cluster().prepareState().get().getState(); + String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames(state, + IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX + "*"); + assertThat(watchHistoryIndices, not(emptyArray())); + for (String index : watchHistoryIndices) { + IndexRoutingTable routingTable = state.getRoutingTable().index(index); + assertThat(routingTable, notNullValue()); + assertThat(routingTable.allPrimaryShardsActive(), is(true)); + } - refresh(); - SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*") - .setIndicesOptions(IndicesOptions.lenientExpandOpen()) - .setQuery(boolQuery().must(matchQuery("watch_id", watchName)).must(matchQuery("state", - ExecutionState.EXECUTED.id()))) - .get(); - lastResponse.set(searchResponse); - assertThat("could not find executed watch record", searchResponse.getHits().getTotalHits(), - greaterThanOrEqualTo(minimumExpectedWatchActionsWithActionPerformed)); - if (assertConditionMet) { - assertThat((Integer) XContentMapValues.extractValue("result.input.payload.hits.total", - searchResponse.getHits().getAt(0).sourceAsMap()), greaterThanOrEqualTo(1)); - } + refresh(); + SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*") + .setIndicesOptions(IndicesOptions.lenientExpandOpen()) + .setQuery(boolQuery().must(matchQuery("watch_id", watchName)).must(matchQuery("state", + ExecutionState.EXECUTED.id()))) + .get(); + lastResponse.set(searchResponse); + assertThat("could not find executed watch record", searchResponse.getHits().getTotalHits(), + greaterThanOrEqualTo(minimumExpectedWatchActionsWithActionPerformed)); + if (assertConditionMet) { + assertThat((Integer) XContentMapValues.extractValue("result.input.payload.hits.total", + searchResponse.getHits().getAt(0).sourceAsMap()), greaterThanOrEqualTo(1)); } }); } catch (AssertionError error) { @@ -462,29 +459,26 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase final long expectedWatchActionsWithNoActionNeeded) throws Exception { final AtomicReference lastResponse = new AtomicReference<>(); try { - assertBusy(new Runnable() { - @Override - public void run() { - // The watch_history index gets created in the background when the first watch is triggered - // so we to check first is this index is created and shards are started - ClusterState state = client().admin().cluster().prepareState().get().getState(); - String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames(state, - IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX + "*"); - assertThat(watchHistoryIndices, not(emptyArray())); - for (String index : watchHistoryIndices) { - IndexRoutingTable routingTable = state.getRoutingTable().index(index); - assertThat(routingTable, notNullValue()); - assertThat(routingTable.allPrimaryShardsActive(), is(true)); - } - refresh(); - SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*") - .setIndicesOptions(IndicesOptions.lenientExpandOpen()) - .setQuery(boolQuery().must(matchQuery("watch_id", watchName)).must(matchQuery("state", - ExecutionState.EXECUTION_NOT_NEEDED.id()))) - .get(); - lastResponse.set(searchResponse); - assertThat(searchResponse.getHits().getTotalHits(), greaterThanOrEqualTo(expectedWatchActionsWithNoActionNeeded)); + assertBusy(() -> { + // The watch_history index gets created in the background when the first watch is triggered + // so we to check first is this index is created and shards are started + ClusterState state = client().admin().cluster().prepareState().get().getState(); + String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames(state, + IndicesOptions.lenientExpandOpen(), HistoryStore.INDEX_PREFIX + "*"); + assertThat(watchHistoryIndices, not(emptyArray())); + for (String index : watchHistoryIndices) { + IndexRoutingTable routingTable = state.getRoutingTable().index(index); + assertThat(routingTable, notNullValue()); + assertThat(routingTable.allPrimaryShardsActive(), is(true)); } + refresh(); + SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*") + .setIndicesOptions(IndicesOptions.lenientExpandOpen()) + .setQuery(boolQuery().must(matchQuery("watch_id", watchName)).must(matchQuery("state", + ExecutionState.EXECUTION_NOT_NEEDED.id()))) + .get(); + lastResponse.set(searchResponse); + assertThat(searchResponse.getHits().getTotalHits(), greaterThanOrEqualTo(expectedWatchActionsWithNoActionNeeded)); }); } catch (AssertionError error) { SearchResponse searchResponse = lastResponse.get(); @@ -499,27 +493,24 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase protected void assertWatchWithMinimumActionsCount(final String watchName, final ExecutionState recordState, final long recordCount) throws Exception { - assertBusy(new Runnable() { - @Override - public void run() { - ClusterState state = client().admin().cluster().prepareState().get().getState(); - String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames(state, IndicesOptions.lenientExpandOpen(), - HistoryStore.INDEX_PREFIX + "*"); - assertThat(watchHistoryIndices, not(emptyArray())); - for (String index : watchHistoryIndices) { - IndexRoutingTable routingTable = state.getRoutingTable().index(index); - assertThat(routingTable, notNullValue()); - assertThat(routingTable.allPrimaryShardsActive(), is(true)); - } - - refresh(); - SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*") - .setIndicesOptions(IndicesOptions.lenientExpandOpen()) - .setQuery(boolQuery().must(matchQuery("watch_id", watchName)).must(matchQuery("state", recordState.id()))) - .get(); - assertThat("could not find executed watch record", searchResponse.getHits().getTotalHits(), - greaterThanOrEqualTo(recordCount)); + assertBusy(() -> { + ClusterState state = client().admin().cluster().prepareState().get().getState(); + String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames(state, IndicesOptions.lenientExpandOpen(), + HistoryStore.INDEX_PREFIX + "*"); + assertThat(watchHistoryIndices, not(emptyArray())); + for (String index : watchHistoryIndices) { + IndexRoutingTable routingTable = state.getRoutingTable().index(index); + assertThat(routingTable, notNullValue()); + assertThat(routingTable.allPrimaryShardsActive(), is(true)); } + + refresh(); + SearchResponse searchResponse = client().prepareSearch(HistoryStore.INDEX_PREFIX + "*") + .setIndicesOptions(IndicesOptions.lenientExpandOpen()) + .setQuery(boolQuery().must(matchQuery("watch_id", watchName)).must(matchQuery("state", recordState.id()))) + .get(); + assertThat("could not find executed watch record", searchResponse.getHits().getTotalHits(), + greaterThanOrEqualTo(recordCount)); }); } @@ -528,14 +519,11 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase } protected void ensureWatcherStarted(final boolean useClient) throws Exception { - assertBusy(new Runnable() { - @Override - public void run() { - if (useClient) { - assertThat(watcherClient().prepareWatcherStats().get().getWatcherState(), is(WatcherState.STARTED)); - } else { - assertThat(getInstanceFromMaster(WatcherService.class).state(), is(WatcherState.STARTED)); - } + assertBusy(() -> { + if (useClient) { + assertThat(watcherClient().prepareWatcherStats().get().getWatcherState(), is(WatcherState.STARTED)); + } else { + assertThat(getInstanceFromMaster(WatcherService.class).state(), is(WatcherState.STARTED)); } }); @@ -549,12 +537,9 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase } protected void ensureLicenseEnabled() throws Exception { - assertBusy(new Runnable() { - @Override - public void run() { - for (WatcherLicensee service : internalCluster().getInstances(WatcherLicensee.class)) { - assertThat(service.isWatcherTransportActionAllowed(), is(true)); - } + assertBusy(() -> { + for (WatcherLicensee service : internalCluster().getInstances(WatcherLicensee.class)) { + assertThat(service.isWatcherTransportActionAllowed(), is(true)); } }); } @@ -564,14 +549,11 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase } protected void ensureWatcherStopped(final boolean useClient) throws Exception { - assertBusy(new Runnable() { - @Override - public void run() { - if (useClient) { - assertThat(watcherClient().prepareWatcherStats().get().getWatcherState(), is(WatcherState.STOPPED)); - } else { - assertThat(getInstanceFromMaster(WatcherService.class).state(), is(WatcherState.STOPPED)); - } + assertBusy(() -> { + if (useClient) { + assertThat(watcherClient().prepareWatcherStats().get().getWatcherState(), is(WatcherState.STOPPED)); + } else { + assertThat(getInstanceFromMaster(WatcherService.class).state(), is(WatcherState.STOPPED)); } }); } diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/test/integration/HttpSecretsIntegrationTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/test/integration/HttpSecretsIntegrationTests.java index 71a077dbb2d..14f073e0fb4 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/test/integration/HttpSecretsIntegrationTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/test/integration/HttpSecretsIntegrationTests.java @@ -53,6 +53,7 @@ import static org.joda.time.DateTimeZone.UTC; * */ public class HttpSecretsIntegrationTests extends AbstractWatcherIntegrationTestCase { + static final String USERNAME = "_user"; static final String PASSWORD = "_passwd"; diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/watch/WatchTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/watch/WatchTests.java index 8735bbb3630..a059b29de4e 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/watch/WatchTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/watch/WatchTests.java @@ -15,7 +15,6 @@ import java.util.Map; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.common.bytes.BytesReference; -import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Settings; @@ -75,7 +74,7 @@ import org.elasticsearch.watcher.input.search.SearchInputFactory; import org.elasticsearch.watcher.input.simple.ExecutableSimpleInput; import org.elasticsearch.watcher.input.simple.SimpleInput; import org.elasticsearch.watcher.input.simple.SimpleInputFactory; -import org.elasticsearch.watcher.license.WatcherLicensee; +import org.elasticsearch.watcher.WatcherLicensee; import org.elasticsearch.watcher.support.Script; import org.elasticsearch.watcher.support.WatcherUtils; import org.elasticsearch.watcher.support.clock.Clock;