Extended X-Pack Info API with Features Info

- introduced the "Feature Set" notion - graph, security, monitoring, watcher, these are all feature sets
- each feature set can be:
 - `available` - indicates whether this feature set is available under the current license
 - `enabled` - indicates whether this feature set is enabled (note that the feature set can be enabled, yet unavailable under the current license)
- while at it, cleaned up the main modules of watcher, security, monitoring and graph.

Original commit: elastic/x-pack-elasticsearch@5b3e19fe8c
This commit is contained in:
uboness 2016-04-18 12:36:07 +02:00
parent 8af3f91eb5
commit 5c9d96211f
120 changed files with 1341 additions and 786 deletions

View File

@ -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";
@ -50,6 +47,18 @@ public class Graph extends Plugin {
return XPackPlugin.featureEnabled(settings, NAME, true);
}
public Collection<Module> nodeModules() {
return Collections.singletonList(new GraphModule(enabled, transportClientMode));
}
@Override
public Collection<Class<? extends LifecycleComponent>> 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);
@ -66,22 +75,4 @@ public class Graph extends Plugin {
module.registerSetting(Setting.boolSetting(XPackPlugin.featureEnabledSetting(NAME), true, Setting.Property.NodeScope));
}
public Collection<Module> nodeModules() {
if (enabled == false|| transportClientMode) {
return Collections.emptyList();
}
return Arrays.<Module> asList(new GraphModule());
}
@Override
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
if (enabled == false|| transportClientMode) {
return Collections.emptyList();
}
return Arrays.<Class<? extends LifecycleComponent>>asList(
GraphLicensee.class
);
}
}

View File

@ -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;
}
}

View File

@ -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<GraphLicensee> {
@ -60,7 +59,7 @@ public class GraphLicensee extends AbstractLicenseeComponent<GraphLicensee> {
*
* @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();

View File

@ -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));
}
}
}

View File

@ -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<GraphExp
@Override
protected void doExecute(GraphExploreRequest request, ActionListener<GraphExploreResponse> listener) {
if (licensee.isGraphExploreEnabled()) {
if (licensee.isAvailable()) {
new AsyncGraphAction(request, listener).start();
} else {
listener.onFailure(LicenseUtils.newComplianceException(GraphLicensee.ID));

View File

@ -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));
}
}

View File

@ -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();
}

View File

@ -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();

View File

@ -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();
}
}

View File

@ -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<Module> nodeModules() {
if (enabled == false || transportClientMode) {
return Collections.emptyList();
List<Module> 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.<Module>asList(
new MarvelModule(),
new LicenseModule(),
new CollectorModule(),
new ExporterModule(settings),
new MonitoringClientModule());
return modules;
}
public Collection<Class<? extends LifecycleComponent>> nodeServices() {
if (enabled == false || transportClientMode) {
return Collections.emptyList();
}
return Arrays.<Class<? extends LifecycleComponent>>asList(MarvelLicensee.class,
return Arrays.<Class<? extends LifecycleComponent>>asList(MonitoringLicensee.class,
AgentService.class,
CleanerService.class);
}
public void onModule(SettingsModule module) {
MarvelSettings.register(module);
MonitoringSettings.register(module);
}
public void onModule(ActionModule module) {

View File

@ -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;
}
}

View File

@ -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;
* <li>Cleaning up (deleting) older indices.</li>
* </ul>
*/
public class MarvelLicensee extends AbstractLicenseeComponent<MarvelLicensee> implements Licensee {
public class MonitoringLicensee extends AbstractLicenseeComponent<MonitoringLicensee> 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<MarvelLicensee> 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<MarvelLicensee> 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.
* <p>

View File

@ -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));
}
}
}

View File

@ -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<Boolean> 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;
}
}

View File

@ -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<AgentService> {
@Inject
public AgentService(Settings settings, ClusterSettings clusterSettings, Set<Collector> 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) {

View File

@ -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<T> extends AbstractLifecycleComponent<T>
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;
}

View File

@ -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<ClusterStateCollect
@Inject
public ClusterStateCollector(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;
}
@ -58,7 +58,7 @@ public class ClusterStateCollector extends AbstractCollector<ClusterStateCollect
long timestamp = System.currentTimeMillis();
DiscoveryNode sourceNode = localNode();
ClusterHealthResponse clusterHealth = client.admin().cluster().prepareHealth().get(marvelSettings.clusterStateTimeout());
ClusterHealthResponse clusterHealth = client.admin().cluster().prepareHealth().get(monitoringSettings.clusterStateTimeout());
// Adds a cluster_state document with associated status
ClusterStateMonitoringDoc clusterStateDoc = new ClusterStateMonitoringDoc(monitoringId(), monitoringVersion());

View File

@ -16,10 +16,10 @@ import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.plugin.core.LicenseUtils;
import org.elasticsearch.license.plugin.core.LicensesManagerService;
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;
@ -47,9 +47,9 @@ public class ClusterStatsCollector extends AbstractCollector<ClusterStatsCollect
@Inject
public ClusterStatsCollector(Settings settings, ClusterService clusterService,
MarvelSettings marvelSettings, MarvelLicensee marvelLicensee, InternalClient client,
MonitoringSettings monitoringSettings, MonitoringLicensee licensee, InternalClient client,
LicensesManagerService licensesManagerService, ClusterName clusterName) {
super(settings, NAME, clusterService, marvelSettings, marvelLicensee);
super(settings, NAME, clusterService, monitoringSettings, licensee);
this.client = client;
this.clusterName = clusterName;
this.licensesManagerService = licensesManagerService;
@ -68,7 +68,7 @@ public class ClusterStatsCollector extends AbstractCollector<ClusterStatsCollect
// Retrieves cluster stats
ClusterStatsResponse clusterStats = null;
try {
clusterStats = client.admin().cluster().prepareClusterStats().get(marvelSettings.clusterStatsTimeout());
clusterStats = client.admin().cluster().prepareClusterStats().get(monitoringSettings.clusterStatsTimeout());
} catch (ElasticsearchSecurityException e) {
if (LicenseUtils.isLicenseExpiredException(e)) {
logger.trace("collector [{}] - unable to collect data because of expired license", e, name());

View File

@ -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;
@ -40,8 +40,8 @@ public class IndexRecoveryCollector extends AbstractCollector<IndexRecoveryColle
@Inject
public IndexRecoveryCollector(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;
}
@ -55,10 +55,10 @@ public class IndexRecoveryCollector extends AbstractCollector<IndexRecoveryColle
List<MonitoringDoc> 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<IndexRecoveryColle
results.add(indexRecoveryDoc);
}
} 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;

View File

@ -15,10 +15,10 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
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;
@ -42,8 +42,8 @@ public class IndexStatsCollector extends AbstractCollector<IndexStatsCollector>
@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<IndexStatsCollector>
List<MonitoringDoc> 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<IndexStatsCollector>
.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<IndexStatsCollector>
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;

View File

@ -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<IndicesStatsCollect
@Inject
public IndicesStatsCollector(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;
}
@ -51,14 +51,14 @@ public class IndicesStatsCollector extends AbstractCollector<IndicesStatsCollect
protected Collection<MonitoringDoc> 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<IndicesStatsCollect
return Collections.singletonList(indicesStatsDoc);
} 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());
return Collections.emptyList();
}

View File

@ -17,10 +17,10 @@ import org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDecider
import org.elasticsearch.common.inject.Inject;
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.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.Collection;
@ -42,10 +42,10 @@ public class NodeStatsCollector extends AbstractCollector<NodeStatsCollector> {
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;

View File

@ -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<ShardsCollector> {
@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<ShardsCollector> {
}
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);
}
}

View File

@ -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 {

View File

@ -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<Exporters> 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<Exporters> implements
@Override
protected void doStart() {
exporters.set(initExporters(MarvelSettings.EXPORTERS_SETTINGS.get(settings)));
exporters.set(initExporters(MonitoringSettings.EXPORTERS_SETTINGS.get(settings)));
}
@Override

View File

@ -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<CleanerService> {
private final MarvelLicensee licensee;
private final MonitoringLicensee licensee;
private final ThreadPool threadPool;
private final ExecutionScheduler executionScheduler;
private final List<Listener> listeners = new CopyOnWriteArrayList<>();
@ -36,21 +36,21 @@ public class CleanerService extends AbstractLifecycleComponent<CleanerService> {
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<CleanerService> {
* 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<CleanerService> {
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<CleanerService> {
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;

View File

@ -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();
}
}

View File

@ -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<Module> 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<Module> modules = plugin.nodeModules();
assertThat(modules.size(), is(5));
}
}

View File

@ -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();

View File

@ -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) {

View File

@ -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<Collection<? extends MonitoringDoc>> 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;
}

View File

@ -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);

View File

@ -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));
}

View File

@ -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));

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -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));

View File

@ -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));
}
}

View File

@ -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<String, String> setting : exporterSettings().getAsMap().entrySet()) {
settings.put("xpack.monitoring.agent.exporters._exporter." + setting.getKey(), setting.getValue());

View File

@ -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

View File

@ -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);

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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 + "]");
}

View File

@ -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();

View File

@ -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));

View File

@ -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() {

View File

@ -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}.
* <p>
* 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<MarvelLicensee> predicate, boolean expected) {
private void assertEnabled(LicenseState state, Predicate<MonitoringLicensee> 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<MarvelLicensee> predicate, boolean expected) {
private void assertEnabled(OperationMode mode, Predicate<MonitoringLicensee> predicate, boolean expected) {
Status status = mock(Status.class);
when(status.getMode()).thenReturn(mode);

View File

@ -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();
}

View File

@ -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")

View File

@ -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<MonitoringDoc> {

View File

@ -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<Module> nodeModules() {
if (enabled == false) {
return Collections.singletonList(new ShieldDisabledModule(settings));
}
if (transportClientMode == true) {
return Arrays.<Module>asList(
new ShieldTransportModule(settings),
new SSLModule(settings));
}
List<Module> 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.<Module>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<Class<? extends LifecycleComponent>> 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.

View File

@ -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;
}
}

View File

@ -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

View File

@ -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<ShieldLicensee> implements Licensee {
public class SecurityLicensee extends AbstractLicenseeComponent<SecurityLicensee> 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;

View File

@ -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.<SecurityLicenseState>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);
}
}
}

View File

@ -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.<ShieldLicenseState>of(null));
bind(SecurityContext.class).toInstance(SecurityContext.Insecure.INSTANCE);
bind(InternalClient.Insecure.class).asEagerSingleton();
bind(InternalClient.class).to(InternalClient.Insecure.class);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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<RequestInterceptor> 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<RequestInterceptor> requestInterceptors, ThreadPool threadPool) {
super(settings);
this.authcService = authcService;

View File

@ -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<Realms> implements Iterab
private final Environment env;
private final Map<String, Realm.Factory> factories;
private final ShieldLicenseState shieldLicenseState;
private final SecurityLicenseState shieldLicenseState;
private final ReservedRealm reservedRealm;
protected List<Realm> realms = Collections.emptyList();
@ -45,7 +45,7 @@ public class Realms extends AbstractLifecycleComponent<Realms> implements Iterab
protected List<Realm> internalRealmsOnly = Collections.emptyList();
@Inject
public Realms(Settings settings, Environment env, Map<String, Realm.Factory> factories, ShieldLicenseState shieldLicenseState,
public Realms(Settings settings, Environment env, Map<String, Realm.Factory> factories, SecurityLicenseState shieldLicenseState,
ReservedRealm reservedRealm) {
super(settings);
this.env = env;

View File

@ -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<String> 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;

View File

@ -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);
}
}

View File

@ -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();

View File

@ -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<String, ServerTransportFilter> 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<T> handler;
private final Map<String, ServerTransportFilter> profileFilters;
private final ShieldLicenseState licenseState;
private final SecurityLicenseState licenseState;
private final ThreadContext threadContext;
public ProfileSecuredRequestHandler(String action, TransportRequestHandler<T> handler,
Map<String, ServerTransportFilter> profileFilters, ShieldLicenseState licenseState,
Map<String, ServerTransportFilter> profileFilters, SecurityLicenseState licenseState,
ThreadContext threadContext) {
this.action = action;
this.handler = handler;

View File

@ -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;

View File

@ -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));

View File

@ -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}.
* <p>
* 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);
}
}

View File

@ -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")));
}
}
}

View File

@ -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);

View File

@ -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.<String, Realm.Factory>emptyMap(), shieldLicenseState,
mock(ReservedRealm.class)) {

View File

@ -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<String, Realm.Factory> 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);
}

View File

@ -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) {

View File

@ -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);

View File

@ -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));

View File

@ -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);
}

View File

@ -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(

View File

@ -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());

View File

@ -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())

View File

@ -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();
}

View File

@ -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<? extends XPackFeatureSet> featureSet) {
binder.bind(featureSet).asEagerSingleton();
Multibinder<XPackFeatureSet> 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()));
}

View File

@ -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<XPackInfoRequest, XPackInfoResponse> {
private final LicensesService licensesService;
private final Set<XPackFeatureSet> featureSets;
@Inject
public TransportXPackInfoAction(Settings settings, ThreadPool threadPool, TransportService transportService,
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
LicensesService licensesService) {
LicensesService licensesService, Set<XPackFeatureSet> featureSets) {
super(settings, XPackInfoAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver,
XPackInfoRequest::new);
this.licensesService = licensesService;
this.featureSets = featureSets;
}
@Override
protected void doExecute(XPackInfoRequest request, ActionListener<XPackInfoResponse> 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<FeatureSet> 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));
}
}

View File

@ -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<XPackInfoRequest> {
public enum Category {
BUILD, LICENSE, FEATURES;
public static EnumSet<Category> toSet(String... categories) {
EnumSet<Category> set = EnumSet.noneOf(Category.class);
for (String category : categories) {
set.add(Category.valueOf(category.toUpperCase(Locale.ROOT)));
}
return set;
}
}
private boolean verbose;
private EnumSet<Category> categories = EnumSet.noneOf(Category.class);
public XPackInfoRequest() {}
public void setVerbose(boolean verbose) {
this.verbose = verbose;
}
public boolean isVerbose() {
return verbose;
}
public void setCategories(EnumSet<Category> categories) {
this.categories = categories;
}
public EnumSet<Category> getCategories() {
return categories;
}
@Override
public ActionRequestValidationException validate() {
return null;
}
@Override
public void readFrom(StreamInput in) throws IOException {
this.verbose = in.readBoolean();
EnumSet<Category> 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());
}
}
}

View File

@ -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<XPackInfoRequest, XPackInfoResponse, XPackInfoRequestBuilder> {
@ -20,4 +22,15 @@ public class XPackInfoRequestBuilder extends ActionRequestBuilder<XPackInfoReque
super(client, action, new XPackInfoRequest());
}
public XPackInfoRequestBuilder setVerbose(boolean verbose) {
request.setVerbose(verbose);
return this;
}
public XPackInfoRequestBuilder setCategories(EnumSet<XPackInfoRequest.Category> categories) {
request.setCategories(categories);
return this;
}
}

View File

@ -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<String, FeatureSet> featureSets;
public FeatureSetsInfo(StreamInput in) throws IOException {
int size = in.readVInt();
Map<String, FeatureSet> 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<FeatureSet> featureSets) {
Map<String, FeatureSet> map = new HashMap<>(featureSets.size());
for (FeatureSet featureSet : featureSets) {
map.put(featureSet.name, featureSet);
}
this.featureSets = Collections.unmodifiableMap(map);
}
public Map<String, FeatureSet> getFeatureSets() {
return featureSets;
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
List<String> 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);
}
}
}
}

View File

@ -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<XPackInfoResponse>(restChannel) {
// we piggyback verbosity on "human" output
boolean verbose = request.paramAsBoolean("human", false);
EnumSet<XPackInfoRequest.Category> categories = XPackInfoRequest.Category
.toSet(request.paramAsStringArray("categories", Strings.EMPTY_ARRAY));
client.prepareInfo().setVerbose(verbose).setCategories(categories).execute(new RestBuilderListener<XPackInfoResponse>(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);
}

View File

@ -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<XPackFeatureSet> 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<XPackInfoRequest.Category> 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<XPackInfoResponse> 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<String, FeatureSet> 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());
}
}
}

View File

@ -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
}

View File

@ -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

View File

@ -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<Module> nodeModules() {
if (enabled == false|| transportClient) {
return Collections.emptyList();
List<Module> 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.<Module>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<Class<? extends LifecycleComponent>> nodeServices() {

View File

@ -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;
}
}

View File

@ -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<WatcherLicensee> {
@ -51,22 +50,10 @@ public class WatcherLicensee extends AbstractLicenseeComponent<WatcherLicensee>
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.
* <p>
* 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:
* <ul>
* <li>{@link OperationMode#PLATINUM}</li>
* <li>{@link OperationMode#GOLD}</li>
@ -75,11 +62,30 @@ public class WatcherLicensee extends AbstractLicenseeComponent<WatcherLicensee>
*
* @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();
}
}

Some files were not shown because too many files have changed in this diff Show More