mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 09:28:27 +00:00
Adds licensing to machine learning feature (elastic/x-pack-elasticsearch#559)
This change adds licensing to the maching learning feature, and only allows access to machine learning if a trial or platinum license is installed. Further, this change also renames `MlPlugin` to `MachineLearning` in line with the other feature plugin names and move the enabled setting to `XPackSettings` Original commit: elastic/x-pack-elasticsearch@48ea9d781b
This commit is contained in:
parent
67fe584e0f
commit
6183015639
@ -5,6 +5,13 @@
|
||||
*/
|
||||
package org.elasticsearch.license;
|
||||
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.logging.LoggerMessageFormat;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.License.OperationMode;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoringSettings;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@ -13,13 +20,6 @@ import java.util.Objects;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.logging.LoggerMessageFormat;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.License.OperationMode;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoringSettings;
|
||||
|
||||
/**
|
||||
* A holder for the current state of the license for all xpack features.
|
||||
*/
|
||||
@ -45,6 +45,9 @@ public class XPackLicenseState {
|
||||
messages.put(XPackPlugin.GRAPH, new String[] {
|
||||
"Graph explore APIs are disabled"
|
||||
});
|
||||
messages.put(XPackPlugin.MACHINE_LEARNING, new String[] {
|
||||
"Machine learning APIs are disabled"
|
||||
});
|
||||
EXPIRATION_MESSAGES = Collections.unmodifiableMap(messages);
|
||||
}
|
||||
|
||||
@ -355,4 +358,27 @@ public class XPackLicenseState {
|
||||
|
||||
return licensed && localStatus.active;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if Machine Learning should be enabled.
|
||||
* <p>
|
||||
* Machine Learning is only disabled when the license has expired or if the
|
||||
* mode is not:
|
||||
* <ul>
|
||||
* <li>{@link OperationMode#PLATINUM}</li>
|
||||
* <li>{@link OperationMode#TRIAL}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return {@code true} as long as the license is valid. Otherwise
|
||||
* {@code false}.
|
||||
*/
|
||||
public boolean isMachineLearningAllowed() {
|
||||
// status is volatile
|
||||
Status localStatus = status;
|
||||
OperationMode operationMode = localStatus.mode;
|
||||
|
||||
boolean licensed = operationMode == OperationMode.TRIAL || operationMode == OperationMode.PLATINUM;
|
||||
|
||||
return licensed && localStatus.active;
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,8 @@ import org.elasticsearch.xpack.extensions.XPackExtension;
|
||||
import org.elasticsearch.xpack.extensions.XPackExtensionsService;
|
||||
import org.elasticsearch.xpack.graph.Graph;
|
||||
import org.elasticsearch.xpack.graph.GraphFeatureSet;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.MachineLearningFeatureSet;
|
||||
import org.elasticsearch.xpack.monitoring.Monitoring;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoringFeatureSet;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoringSettings;
|
||||
@ -92,13 +93,11 @@ import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.security.SecurityFeatureSet;
|
||||
import org.elasticsearch.xpack.security.authc.AuthenticationService;
|
||||
import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken;
|
||||
import org.elasticsearch.xpack.ssl.SSLBootstrapCheck;
|
||||
import org.elasticsearch.xpack.ssl.SSLConfigurationReloader;
|
||||
import org.elasticsearch.xpack.ssl.SSLService;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
import org.elasticsearch.xpack.watcher.WatcherFeatureSet;
|
||||
|
||||
import javax.security.auth.DestroyFailedException;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.security.AccessController;
|
||||
@ -120,6 +119,8 @@ import java.util.function.Supplier;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.security.auth.DestroyFailedException;
|
||||
|
||||
public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, IngestPlugin, NetworkPlugin {
|
||||
|
||||
public static final String NAME = "x-pack";
|
||||
@ -187,7 +188,7 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, I
|
||||
protected Monitoring monitoring;
|
||||
protected Watcher watcher;
|
||||
protected Graph graph;
|
||||
protected MlPlugin machineLearning;
|
||||
protected MachineLearning machineLearning;
|
||||
|
||||
public XPackPlugin(Settings settings) throws IOException, CertificateException, UnrecoverableKeyException, NoSuchAlgorithmException,
|
||||
KeyStoreException, DestroyFailedException, OperatorCreationException {
|
||||
@ -202,7 +203,7 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, I
|
||||
this.monitoring = new Monitoring(settings, licenseState);
|
||||
this.watcher = new Watcher(settings);
|
||||
this.graph = new Graph(settings);
|
||||
this.machineLearning = new MlPlugin(settings, env);
|
||||
this.machineLearning = new MachineLearning(settings, env);
|
||||
// Check if the node is a transport client.
|
||||
if (transportClientMode == false) {
|
||||
this.extensionsService = new XPackExtensionsService(settings, resolveXPackExtensionsFile(env), getExtensions());
|
||||
@ -452,6 +453,7 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, I
|
||||
entries.add(new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, WATCHER, WatcherFeatureSet.Usage::new));
|
||||
entries.add(new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, MONITORING, MonitoringFeatureSet.Usage::new));
|
||||
entries.add(new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, GRAPH, GraphFeatureSet.Usage::new));
|
||||
entries.add(new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, MACHINE_LEARNING, MachineLearningFeatureSet.Usage::new));
|
||||
entries.addAll(watcher.getNamedWriteables());
|
||||
entries.addAll(machineLearning.getNamedWriteables());
|
||||
entries.addAll(licensing.getNamedWriteables());
|
||||
|
@ -41,6 +41,9 @@ public class XPackSettings {
|
||||
/** Setting for enabling or disabling graph. Defaults to true. */
|
||||
public static final Setting<Boolean> GRAPH_ENABLED = enabledSetting(XPackPlugin.GRAPH, true);
|
||||
|
||||
/** Setting for enabling or disabling machine learning. Defaults to false. */
|
||||
public static final Setting<Boolean> MACHINE_LEARNING_ENABLED = enabledSetting(XPackPlugin.MACHINE_LEARNING, false);
|
||||
|
||||
/** Setting for enabling or disabling auditing. Defaults to false. */
|
||||
public static final Setting<Boolean> AUDIT_ENABLED = enabledSetting(XPackPlugin.SECURITY + ".audit", false);
|
||||
|
||||
|
@ -17,6 +17,8 @@ import org.elasticsearch.cluster.node.DiscoveryNodes;
|
||||
import org.elasticsearch.cluster.routing.UnassignedInfo;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.ParseField;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.util.Providers;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.IndexScopedSettings;
|
||||
@ -37,6 +39,8 @@ import org.elasticsearch.threadpool.ExecutorBuilder;
|
||||
import org.elasticsearch.threadpool.FixedExecutorBuilder;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.watcher.ResourceWatcherService;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.ml.action.CloseJobAction;
|
||||
import org.elasticsearch.xpack.ml.action.DeleteDatafeedAction;
|
||||
import org.elasticsearch.xpack.ml.action.DeleteFilterAction;
|
||||
@ -127,9 +131,11 @@ import org.elasticsearch.xpack.persistent.PersistentTasksInProgress;
|
||||
import org.elasticsearch.xpack.persistent.RemovePersistentTaskAction;
|
||||
import org.elasticsearch.xpack.persistent.StartPersistentTaskAction;
|
||||
import org.elasticsearch.xpack.persistent.UpdatePersistentTaskStatusAction;
|
||||
import org.elasticsearch.xpack.watcher.WatcherFeatureSet;
|
||||
import org.elasticsearch.xpack.watcher.WatcherService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -138,7 +144,7 @@ import java.util.function.Supplier;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
|
||||
public class MlPlugin extends Plugin implements ActionPlugin {
|
||||
public class MachineLearning extends Plugin implements ActionPlugin {
|
||||
public static final String NAME = "ml";
|
||||
public static final String BASE_PATH = "/_xpack/ml/";
|
||||
public static final String THREAD_POOL_NAME = NAME;
|
||||
@ -149,28 +155,26 @@ public class MlPlugin extends Plugin implements ActionPlugin {
|
||||
public static final Setting<Boolean> USE_NATIVE_PROCESS_OPTION = Setting.boolSetting("useNativeProcess", true, Property.NodeScope,
|
||||
Property.Deprecated);
|
||||
|
||||
/** Setting for enabling or disabling machine learning. Defaults to true. */
|
||||
public static final Setting<Boolean> ML_ENABLED = Setting.boolSetting("xpack.ml.enabled", false, Setting.Property.NodeScope);
|
||||
|
||||
private final Settings settings;
|
||||
private final Environment env;
|
||||
private boolean enabled;
|
||||
private boolean transportClientMode;
|
||||
|
||||
public MlPlugin(Settings settings) {
|
||||
public MachineLearning(Settings settings) {
|
||||
this(settings, new Environment(settings));
|
||||
}
|
||||
|
||||
public MlPlugin(Settings settings, Environment env) {
|
||||
this.enabled = ML_ENABLED.get(settings);
|
||||
public MachineLearning(Settings settings, Environment env) {
|
||||
this.enabled = XPackSettings.MACHINE_LEARNING_ENABLED.get(settings);
|
||||
this.settings = settings;
|
||||
this.env = env;
|
||||
this.transportClientMode = XPackPlugin.transportClientMode(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Setting<?>> getSettings() {
|
||||
return Collections.unmodifiableList(
|
||||
Arrays.asList(USE_NATIVE_PROCESS_OPTION,
|
||||
ML_ENABLED,
|
||||
ProcessCtrl.DONT_PERSIST_MODEL_STATE_SETTING,
|
||||
ProcessCtrl.MAX_ANOMALY_RECORDS_SETTING,
|
||||
DataCountsReporter.ACCEPTABLE_PERCENTAGE_DATE_PARSE_ERRORS_SETTING,
|
||||
@ -241,7 +245,7 @@ public class MlPlugin extends Plugin implements ActionPlugin {
|
||||
executorService) -> new MultiplyingNormalizerProcess(settings, 1.0);
|
||||
}
|
||||
NormalizerFactory normalizerFactory = new NormalizerFactory(normalizerProcessFactory,
|
||||
threadPool.executor(MlPlugin.THREAD_POOL_NAME));
|
||||
threadPool.executor(MachineLearning.THREAD_POOL_NAME));
|
||||
AutodetectProcessManager dataProcessor = new AutodetectProcessManager(settings, client, threadPool, jobManager, jobProvider,
|
||||
jobResultsPersister, jobDataCountsPersister, autodetectProcessFactory, normalizerFactory);
|
||||
DatafeedJobRunner datafeedJobRunner = new DatafeedJobRunner(threadPool, client, clusterService, jobProvider,
|
||||
@ -262,6 +266,18 @@ public class MlPlugin extends Plugin implements ActionPlugin {
|
||||
);
|
||||
}
|
||||
|
||||
public Collection<Module> nodeModules() {
|
||||
List<Module> modules = new ArrayList<>();
|
||||
modules.add(b -> {
|
||||
XPackPlugin.bindFeatureSet(b, WatcherFeatureSet.class);
|
||||
if (transportClientMode || enabled == false) {
|
||||
b.bind(WatcherService.class).toProvider(Providers.of(null));
|
||||
}
|
||||
});
|
||||
|
||||
return modules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RestHandler> getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings,
|
||||
IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter,
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.xpack.ml;
|
||||
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.xpack.XPackFeatureSet;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class MachineLearningFeatureSet implements XPackFeatureSet {
|
||||
|
||||
private final boolean enabled;
|
||||
private final XPackLicenseState licenseState;
|
||||
|
||||
@Inject
|
||||
public MachineLearningFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState) {
|
||||
this.enabled = XPackSettings.MACHINE_LEARNING_ENABLED.get(settings);
|
||||
this.licenseState = licenseState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return XPackPlugin.MACHINE_LEARNING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description() {
|
||||
return "Machine Learning for the Elastic Stack";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean available() {
|
||||
return licenseState != null && licenseState.isMachineLearningAllowed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XPackFeatureSet.Usage usage() {
|
||||
return new Usage(available(), enabled());
|
||||
}
|
||||
|
||||
public static class Usage extends XPackFeatureSet.Usage {
|
||||
|
||||
public Usage(StreamInput input) throws IOException {
|
||||
super(input);
|
||||
}
|
||||
|
||||
public Usage(boolean available, boolean enabled) {
|
||||
super(XPackPlugin.MACHINE_LEARNING, available, enabled);
|
||||
}
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.job.JobManager;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager;
|
||||
@ -247,11 +247,11 @@ public class FlushJobAction extends Action<FlushJobAction.Request, FlushJobActio
|
||||
|
||||
@Inject
|
||||
public TransportAction(Settings settings, TransportService transportService, ThreadPool threadPool, ClusterService clusterService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
|
||||
AutodetectProcessManager processManager, JobManager jobManager, TransportListTasksAction listTasksAction) {
|
||||
super(settings, FlushJobAction.NAME, threadPool, clusterService, transportService, actionFilters,
|
||||
indexNameExpressionResolver, FlushJobAction.Request::new, FlushJobAction.Response::new, MlPlugin.THREAD_POOL_NAME,
|
||||
jobManager, processManager, Request::getJobId, listTasksAction);
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
|
||||
AutodetectProcessManager processManager, JobManager jobManager, TransportListTasksAction listTasksAction) {
|
||||
super(settings, FlushJobAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
FlushJobAction.Request::new, FlushJobAction.Response::new, MachineLearning.THREAD_POOL_NAME, jobManager, processManager,
|
||||
Request::getJobId, listTasksAction);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +26,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.job.JobManager;
|
||||
import org.elasticsearch.xpack.ml.job.config.DataDescription;
|
||||
import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager;
|
||||
@ -223,10 +223,11 @@ public class PostDataAction extends Action<PostDataAction.Request, PostDataActio
|
||||
|
||||
@Inject
|
||||
public TransportAction(Settings settings, TransportService transportService, ThreadPool threadPool, ClusterService clusterService,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
|
||||
JobManager jobManager, AutodetectProcessManager processManager, TransportListTasksAction listTasksAction) {
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver, JobManager jobManager,
|
||||
AutodetectProcessManager processManager, TransportListTasksAction listTasksAction) {
|
||||
super(settings, PostDataAction.NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
Request::new, Response::new, MlPlugin.THREAD_POOL_NAME, jobManager, processManager, Request::getJobId, listTasksAction);
|
||||
Request::new, Response::new, MachineLearning.THREAD_POOL_NAME, jobManager, processManager, Request::getJobId,
|
||||
listTasksAction);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,7 +24,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.job.JobManager;
|
||||
import org.elasticsearch.xpack.ml.job.config.JobUpdate;
|
||||
import org.elasticsearch.xpack.ml.job.config.ModelDebugConfig;
|
||||
@ -184,7 +184,7 @@ public class UpdateProcessAction extends
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
|
||||
JobManager jobManager, AutodetectProcessManager processManager, TransportListTasksAction listTasksAction) {
|
||||
super(settings, NAME, threadPool, clusterService, transportService, actionFilters, indexNameExpressionResolver,
|
||||
Request::new, Response::new, MlPlugin.THREAD_POOL_NAME, jobManager, processManager, Request::getJobId,
|
||||
Request::new, Response::new, MachineLearning.THREAD_POOL_NAME, jobManager, processManager, Request::getJobId,
|
||||
listTasksAction);
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ public class UpdateProcessAction extends
|
||||
|
||||
@Override
|
||||
protected void taskOperation(Request request, OpenJobAction.JobTask task, ActionListener<Response> listener) {
|
||||
threadPool.executor(MlPlugin.THREAD_POOL_NAME).execute(() -> {
|
||||
threadPool.executor(MachineLearning.THREAD_POOL_NAME).execute(() -> {
|
||||
try {
|
||||
if (request.getModelDebugConfig() != null) {
|
||||
processManager.writeUpdateModelDebugMessage(request.getJobId(), request.getModelDebugConfig());
|
||||
|
@ -16,7 +16,7 @@ import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||
import org.elasticsearch.common.util.concurrent.FutureUtils;
|
||||
import org.elasticsearch.index.mapper.DateFieldMapper;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.StartDatafeedAction;
|
||||
import org.elasticsearch.xpack.ml.action.util.QueryPage;
|
||||
import org.elasticsearch.xpack.ml.datafeed.extractor.DataExtractorFactory;
|
||||
@ -93,7 +93,7 @@ public class DatafeedJobRunner extends AbstractComponent {
|
||||
logger.info("Starting datafeed [{}] for job [{}] in [{}, {})", holder.datafeed.getId(), holder.datafeed.getJobId(),
|
||||
DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.printer().print(startTime),
|
||||
endTime == null ? INF_SYMBOL : DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.printer().print(endTime));
|
||||
holder.future = threadPool.executor(MlPlugin.DATAFEED_RUNNER_THREAD_POOL_NAME).submit(() -> {
|
||||
holder.future = threadPool.executor(MachineLearning.DATAFEED_RUNNER_THREAD_POOL_NAME).submit(() -> {
|
||||
Long next = null;
|
||||
try {
|
||||
next = holder.datafeedJob.runLookBack(startTime, endTime);
|
||||
@ -129,7 +129,7 @@ public class DatafeedJobRunner extends AbstractComponent {
|
||||
if (holder.isRunning()) {
|
||||
TimeValue delay = computeNextDelay(delayInMsSinceEpoch);
|
||||
logger.debug("Waiting [{}] before executing next realtime import for job [{}]", delay, jobId);
|
||||
holder.future = threadPool.schedule(delay, MlPlugin.DATAFEED_RUNNER_THREAD_POOL_NAME, () -> {
|
||||
holder.future = threadPool.schedule(delay, MachineLearning.DATAFEED_RUNNER_THREAD_POOL_NAME, () -> {
|
||||
long nextDelayInMsSinceEpoch;
|
||||
try {
|
||||
nextDelayInMsSinceEpoch = holder.datafeedJob.runRealtime();
|
||||
|
@ -17,7 +17,7 @@ import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.job.JobManager;
|
||||
import org.elasticsearch.xpack.ml.job.config.DetectionRule;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
@ -238,13 +238,13 @@ public class AutodetectProcessManager extends AbstractComponent {
|
||||
|
||||
Job job = jobManager.getJobOrThrowIfUnknown(jobId);
|
||||
// A TP with no queue, so that we fail immediately if there are no threads available
|
||||
ExecutorService executorService = threadPool.executor(MlPlugin.AUTODETECT_PROCESS_THREAD_POOL_NAME);
|
||||
ExecutorService executorService = threadPool.executor(MachineLearning.AUTODETECT_PROCESS_THREAD_POOL_NAME);
|
||||
try (DataCountsReporter dataCountsReporter = new DataCountsReporter(threadPool, settings, job.getId(), dataCounts,
|
||||
jobDataCountsPersister)) {
|
||||
ScoresUpdater scoresUpdater = new ScoresUpdater(job, jobProvider, new JobRenormalizedResultsPersister(settings, client),
|
||||
normalizerFactory);
|
||||
Renormalizer renormalizer = new ShortCircuitingRenormalizer(jobId, scoresUpdater,
|
||||
threadPool.executor(MlPlugin.THREAD_POOL_NAME), job.getAnalysisConfig().getUsePerPartitionNormalization());
|
||||
threadPool.executor(MachineLearning.THREAD_POOL_NAME), job.getAnalysisConfig().getUsePerPartitionNormalization());
|
||||
|
||||
AutodetectProcess process = autodetectProcessFactory.createAutodetectProcess(job, modelSnapshot, quantiles, filters,
|
||||
ignoreDowntime, executorService);
|
||||
|
@ -11,7 +11,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.AcknowledgedRestListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.DeleteDatafeedAction;
|
||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
||||
|
||||
@ -21,7 +21,7 @@ public class RestDeleteDatafeedAction extends BaseRestHandler {
|
||||
|
||||
public RestDeleteDatafeedAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.DELETE, MlPlugin.BASE_PATH + "datafeeds/{"
|
||||
controller.registerHandler(RestRequest.Method.DELETE, MachineLearning.BASE_PATH + "datafeeds/{"
|
||||
+ DatafeedConfig.ID.getPreferredName() + "}", this);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.GetDatafeedsStatsAction;
|
||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
||||
|
||||
@ -22,9 +22,9 @@ public class RestGetDatafeedStatsAction extends BaseRestHandler {
|
||||
|
||||
public RestGetDatafeedStatsAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH
|
||||
controller.registerHandler(RestRequest.Method.GET, MachineLearning.BASE_PATH
|
||||
+ "datafeeds/{" + DatafeedConfig.ID.getPreferredName() + "}/_stats", this);
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH
|
||||
controller.registerHandler(RestRequest.Method.GET, MachineLearning.BASE_PATH
|
||||
+ "datafeeds/_stats", this);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.GetDatafeedsAction;
|
||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
||||
|
||||
@ -21,9 +21,9 @@ public class RestGetDatafeedsAction extends BaseRestHandler {
|
||||
|
||||
public RestGetDatafeedsAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH
|
||||
controller.registerHandler(RestRequest.Method.GET, MachineLearning.BASE_PATH
|
||||
+ "datafeeds/{" + DatafeedConfig.ID.getPreferredName() + "}", this);
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH
|
||||
controller.registerHandler(RestRequest.Method.GET, MachineLearning.BASE_PATH
|
||||
+ "datafeeds", this);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.PutDatafeedAction;
|
||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
||||
|
||||
@ -22,7 +22,7 @@ public class RestPutDatafeedAction extends BaseRestHandler {
|
||||
|
||||
public RestPutDatafeedAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.PUT, MlPlugin.BASE_PATH + "datafeeds/{"
|
||||
controller.registerHandler(RestRequest.Method.PUT, MachineLearning.BASE_PATH + "datafeeds/{"
|
||||
+ DatafeedConfig.ID.getPreferredName() + "}", this);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.RestResponse;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.rest.action.RestBuilderListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.StartDatafeedAction;
|
||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
||||
import org.elasticsearch.xpack.ml.job.messages.Messages;
|
||||
@ -34,7 +34,7 @@ public class RestStartDatafeedAction extends BaseRestHandler {
|
||||
public RestStartDatafeedAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
MlPlugin.BASE_PATH + "datafeeds/{" + DatafeedConfig.ID.getPreferredName() + "}/_start", this);
|
||||
MachineLearning.BASE_PATH + "datafeeds/{" + DatafeedConfig.ID.getPreferredName() + "}/_start", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,7 +11,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.AcknowledgedRestListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.StopDatafeedAction;
|
||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
||||
|
||||
@ -21,7 +21,7 @@ public class RestStopDatafeedAction extends BaseRestHandler {
|
||||
|
||||
public RestStopDatafeedAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH + "datafeeds/{"
|
||||
controller.registerHandler(RestRequest.Method.POST, MachineLearning.BASE_PATH + "datafeeds/{"
|
||||
+ DatafeedConfig.ID.getPreferredName() + "}/_stop", this);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.UpdateDatafeedAction;
|
||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
||||
|
||||
@ -22,7 +22,7 @@ public class RestUpdateDatafeedAction extends BaseRestHandler {
|
||||
|
||||
public RestUpdateDatafeedAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH + "datafeeds/{"
|
||||
controller.registerHandler(RestRequest.Method.POST, MachineLearning.BASE_PATH + "datafeeds/{"
|
||||
+ DatafeedConfig.ID.getPreferredName() + "}/_update", this);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.AcknowledgedRestListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.DeleteFilterAction;
|
||||
import org.elasticsearch.xpack.ml.action.DeleteFilterAction.Request;
|
||||
|
||||
@ -22,7 +22,7 @@ public class RestDeleteFilterAction extends BaseRestHandler {
|
||||
public RestDeleteFilterAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.DELETE,
|
||||
MlPlugin.BASE_PATH + "filters/{" + Request.FILTER_ID.getPreferredName() + "}", this);
|
||||
MachineLearning.BASE_PATH + "filters/{" + Request.FILTER_ID.getPreferredName() + "}", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestStatusToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.GetFiltersAction;
|
||||
import org.elasticsearch.xpack.ml.action.util.PageParams;
|
||||
import org.elasticsearch.xpack.ml.job.config.MlFilter;
|
||||
@ -23,9 +23,9 @@ public class RestGetFiltersAction extends BaseRestHandler {
|
||||
|
||||
public RestGetFiltersAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH + "filters/{" + MlFilter.ID.getPreferredName() + "}",
|
||||
controller.registerHandler(RestRequest.Method.GET, MachineLearning.BASE_PATH + "filters/{" + MlFilter.ID.getPreferredName() + "}",
|
||||
this);
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH + "filters/", this);
|
||||
controller.registerHandler(RestRequest.Method.GET, MachineLearning.BASE_PATH + "filters/", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.AcknowledgedRestListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.PutFilterAction;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -21,7 +21,7 @@ public class RestPutFilterAction extends BaseRestHandler {
|
||||
|
||||
public RestPutFilterAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.PUT, MlPlugin.BASE_PATH + "filters", this);
|
||||
controller.registerHandler(RestRequest.Method.PUT, MachineLearning.BASE_PATH + "filters", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.CloseJobAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
|
||||
@ -22,7 +22,7 @@ public class RestCloseJobAction extends BaseRestHandler {
|
||||
|
||||
public RestCloseJobAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH
|
||||
controller.registerHandler(RestRequest.Method.POST, MachineLearning.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_close", this);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.AcknowledgedRestListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.DeleteJobAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
|
||||
@ -21,7 +21,7 @@ public class RestDeleteJobAction extends BaseRestHandler {
|
||||
|
||||
public RestDeleteJobAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.DELETE, MlPlugin.BASE_PATH
|
||||
controller.registerHandler(RestRequest.Method.DELETE, MachineLearning.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}", this);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.FlushJobAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
|
||||
@ -27,7 +27,7 @@ public class RestFlushJobAction extends BaseRestHandler {
|
||||
|
||||
public RestFlushJobAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH
|
||||
controller.registerHandler(RestRequest.Method.POST, MachineLearning.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_flush", this);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.GetJobsStatsAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
|
||||
@ -22,9 +22,9 @@ public class RestGetJobStatsAction extends BaseRestHandler {
|
||||
|
||||
public RestGetJobStatsAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH
|
||||
controller.registerHandler(RestRequest.Method.GET, MachineLearning.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_stats", this);
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH
|
||||
controller.registerHandler(RestRequest.Method.GET, MachineLearning.BASE_PATH
|
||||
+ "anomaly_detectors/_stats", this);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.GetJobsAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
|
||||
@ -23,9 +23,9 @@ public class RestGetJobsAction extends BaseRestHandler {
|
||||
public RestGetJobsAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH
|
||||
controller.registerHandler(RestRequest.Method.GET, MachineLearning.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}", this);
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH
|
||||
controller.registerHandler(RestRequest.Method.GET, MachineLearning.BASE_PATH
|
||||
+ "anomaly_detectors", this);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.RestResponse;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.rest.action.RestBuilderListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.OpenJobAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.persistent.PersistentActionResponse;
|
||||
@ -27,7 +27,7 @@ public class RestOpenJobAction extends BaseRestHandler {
|
||||
|
||||
public RestOpenJobAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH
|
||||
controller.registerHandler(RestRequest.Method.POST, MachineLearning.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_open", this);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestStatusToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.PostDataAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
|
||||
@ -24,7 +24,7 @@ public class RestPostDataAction extends BaseRestHandler {
|
||||
|
||||
public RestPostDataAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH
|
||||
controller.registerHandler(RestRequest.Method.POST, MachineLearning.BASE_PATH
|
||||
+ "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_data", this);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.UpdateJobAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
|
||||
@ -22,7 +22,7 @@ public class RestPostJobUpdateAction extends BaseRestHandler {
|
||||
public RestPostJobUpdateAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_update", this);
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/_update", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.PutJobAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
|
||||
@ -23,7 +23,7 @@ public class RestPutJobAction extends BaseRestHandler {
|
||||
public RestPutJobAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.PUT,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}", this);
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,7 +11,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.AcknowledgedRestListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.DeleteModelSnapshotAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.ml.job.process.autodetect.state.ModelSnapshot;
|
||||
@ -22,7 +22,7 @@ public class RestDeleteModelSnapshotAction extends BaseRestHandler {
|
||||
|
||||
public RestDeleteModelSnapshotAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.DELETE, MlPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
controller.registerHandler(RestRequest.Method.DELETE, MachineLearning.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/model_snapshots/{" + ModelSnapshot.SNAPSHOT_ID.getPreferredName() + "}", this);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.GetModelSnapshotsAction;
|
||||
import org.elasticsearch.xpack.ml.action.GetModelSnapshotsAction.Request;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
@ -35,16 +35,16 @@ public class RestGetModelSnapshotsAction extends BaseRestHandler {
|
||||
|
||||
public RestGetModelSnapshotsAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
controller.registerHandler(RestRequest.Method.GET, MachineLearning.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/model_snapshots/{" + Request.SNAPSHOT_ID.getPreferredName() + "}", this);
|
||||
// endpoints that support body parameters must also accept POST
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
controller.registerHandler(RestRequest.Method.POST, MachineLearning.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/model_snapshots/{" + Request.SNAPSHOT_ID.getPreferredName() + "}", this);
|
||||
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
controller.registerHandler(RestRequest.Method.GET, MachineLearning.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/model_snapshots", this);
|
||||
// endpoints that support body parameters must also accept POST
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
controller.registerHandler(RestRequest.Method.POST, MachineLearning.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/model_snapshots", this);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestStatusToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.RevertModelSnapshotAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
|
||||
@ -25,7 +25,7 @@ public class RestRevertModelSnapshotAction extends BaseRestHandler {
|
||||
public RestRevertModelSnapshotAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/model_snapshots/{" +
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/model_snapshots/{" +
|
||||
RevertModelSnapshotAction.Request.SNAPSHOT_ID.getPreferredName() + "}/_revert", this);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestStatusToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.UpdateModelSnapshotAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.ml.job.process.autodetect.state.ModelSnapshot;
|
||||
@ -23,7 +23,7 @@ public class RestUpdateModelSnapshotAction extends BaseRestHandler {
|
||||
|
||||
public RestUpdateModelSnapshotAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
controller.registerHandler(RestRequest.Method.POST, MachineLearning.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/model_snapshots/{" + ModelSnapshot.SNAPSHOT_ID +"}/_update",
|
||||
this);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.GetBucketsAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.ml.job.results.Bucket;
|
||||
@ -25,16 +25,16 @@ public class RestGetBucketsAction extends BaseRestHandler {
|
||||
public RestGetBucketsAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.GET,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName()
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName()
|
||||
+ "}/results/buckets/{" + Bucket.TIMESTAMP.getPreferredName() + "}", this);
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName()
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName()
|
||||
+ "}/results/buckets/{" + Bucket.TIMESTAMP.getPreferredName() + "}", this);
|
||||
|
||||
controller.registerHandler(RestRequest.Method.GET,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/buckets", this);
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/buckets", this);
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/buckets", this);
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/buckets", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.GetCategoriesAction;
|
||||
import org.elasticsearch.xpack.ml.action.GetCategoriesAction.Request;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
@ -27,16 +27,16 @@ public class RestGetCategoriesAction extends BaseRestHandler {
|
||||
public RestGetCategoriesAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.GET,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories/{"
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories/{"
|
||||
+ Request.CATEGORY_ID.getPreferredName() + "}", this);
|
||||
controller.registerHandler(RestRequest.Method.GET,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories", this);
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories", this);
|
||||
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories/{"
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories/{"
|
||||
+ Request.CATEGORY_ID.getPreferredName() + "}", this);
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories", this);
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/categories", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.GetInfluencersAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.ml.job.results.Influencer;
|
||||
@ -25,10 +25,10 @@ public class RestGetInfluencersAction extends BaseRestHandler {
|
||||
public RestGetInfluencersAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.GET,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/influencers", this);
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/influencers", this);
|
||||
// endpoints that support body parameters must also accept POST
|
||||
controller.registerHandler(RestRequest.Method.POST,
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/influencers", this);
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/{" + Job.ID.getPreferredName() + "}/results/influencers", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.RestToXContentListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.GetRecordsAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.ml.job.results.AnomalyRecord;
|
||||
@ -24,9 +24,9 @@ public class RestGetRecordsAction extends BaseRestHandler {
|
||||
|
||||
public RestGetRecordsAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
controller.registerHandler(RestRequest.Method.GET, MachineLearning.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/results/records", this);
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH + "anomaly_detectors/{"
|
||||
controller.registerHandler(RestRequest.Method.POST, MachineLearning.BASE_PATH + "anomaly_detectors/{"
|
||||
+ Job.ID.getPreferredName() + "}/results/records", this);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.AcknowledgedRestListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.ValidateDetectorAction;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -21,7 +21,7 @@ public class RestValidateDetectorAction extends BaseRestHandler {
|
||||
|
||||
public RestValidateDetectorAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH + "anomaly_detectors/_validate/detector", this);
|
||||
controller.registerHandler(RestRequest.Method.POST, MachineLearning.BASE_PATH + "anomaly_detectors/_validate/detector", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.action.AcknowledgedRestListener;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.ValidateJobConfigAction;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -21,7 +21,7 @@ public class RestValidateJobConfigAction extends BaseRestHandler {
|
||||
|
||||
public RestValidateJobConfigAction(Settings settings, RestController controller) {
|
||||
super(settings);
|
||||
controller.registerHandler(RestRequest.Method.POST, MlPlugin.BASE_PATH + "anomaly_detectors/_validate", this);
|
||||
controller.registerHandler(RestRequest.Method.POST, MachineLearning.BASE_PATH + "anomaly_detectors/_validate", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,16 +5,16 @@
|
||||
*/
|
||||
package org.elasticsearch.license;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.elasticsearch.license.License.OperationMode;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.monitoring.Monitoring;
|
||||
import org.hamcrest.Matchers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.elasticsearch.license.License.OperationMode.BASIC;
|
||||
import static org.elasticsearch.license.License.OperationMode.GOLD;
|
||||
import static org.elasticsearch.license.License.OperationMode.MISSING;
|
||||
@ -256,7 +256,29 @@ public class XPackLicenseStateTests extends ESTestCase {
|
||||
}
|
||||
|
||||
public void testGraphInactivePlatinumTrial() throws Exception {
|
||||
assertAllowed(TRIAL, false, XPackLicenseState::isGraphAllowed, false);
|
||||
assertAllowed(PLATINUM, false, XPackLicenseState::isGraphAllowed, false);
|
||||
assertAllowed(TRIAL, false, XPackLicenseState::isMachineLearningAllowed, false);
|
||||
assertAllowed(PLATINUM, false, XPackLicenseState::isMachineLearningAllowed, false);
|
||||
}
|
||||
|
||||
public void testMachineLearningPlatinumTrial() throws Exception {
|
||||
assertAllowed(TRIAL, true, XPackLicenseState::isMachineLearningAllowed, true);
|
||||
assertAllowed(PLATINUM, true, XPackLicenseState::isMachineLearningAllowed, true);
|
||||
}
|
||||
|
||||
public void testMachineLearningBasic() throws Exception {
|
||||
assertAllowed(BASIC, true, XPackLicenseState::isMachineLearningAllowed, false);
|
||||
}
|
||||
|
||||
public void testMachineLearningStandard() throws Exception {
|
||||
assertAllowed(STANDARD, true, XPackLicenseState::isMachineLearningAllowed, false);
|
||||
}
|
||||
|
||||
public void testMachineLearningInactiveBasic() {
|
||||
assertAllowed(BASIC, false, XPackLicenseState::isMachineLearningAllowed, false);
|
||||
}
|
||||
|
||||
public void testMachineLearningInactivePlatinumTrial() throws Exception {
|
||||
assertAllowed(TRIAL, false, XPackLicenseState::isMachineLearningAllowed, false);
|
||||
assertAllowed(PLATINUM, false, XPackLicenseState::isMachineLearningAllowed, false);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import org.elasticsearch.test.SecurityIntegTestCase;
|
||||
import org.elasticsearch.test.discovery.TestZenDiscovery;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.graph.Graph;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.security.action.SecurityActionModule;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
@ -142,7 +142,7 @@ public class KnownActionsTests extends SecurityIntegTestCase {
|
||||
loadActions(collectSubClasses(Action.class, Graph.class), actions);
|
||||
|
||||
// also loading all actions from the machine learning plugin
|
||||
loadActions(collectSubClasses(Action.class, MlPlugin.class), actions);
|
||||
loadActions(collectSubClasses(Action.class, MachineLearning.class), actions);
|
||||
|
||||
return unmodifiableSet(actions);
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.xpack.ml;
|
||||
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.XPackFeatureSet;
|
||||
import org.junit.Before;
|
||||
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class MachineLearningFeatureSetTests extends ESTestCase {
|
||||
|
||||
private XPackLicenseState licenseState;
|
||||
|
||||
@Before
|
||||
public void init() throws Exception {
|
||||
licenseState = mock(XPackLicenseState.class);
|
||||
}
|
||||
|
||||
public void testAvailable() throws Exception {
|
||||
MachineLearningFeatureSet featureSet = new MachineLearningFeatureSet(Settings.EMPTY, licenseState);
|
||||
boolean available = randomBoolean();
|
||||
when(licenseState.isMachineLearningAllowed()).thenReturn(available);
|
||||
assertThat(featureSet.available(), is(available));
|
||||
assertThat(featureSet.usage().available(), is(available));
|
||||
|
||||
BytesStreamOutput out = new BytesStreamOutput();
|
||||
featureSet.usage().writeTo(out);
|
||||
XPackFeatureSet.Usage serializedUsage = new MachineLearningFeatureSet.Usage(out.bytes().streamInput());
|
||||
assertThat(serializedUsage.available(), is(available));
|
||||
}
|
||||
|
||||
public void testEnabled() throws Exception {
|
||||
boolean enabled = randomBoolean();
|
||||
Settings.Builder settings = Settings.builder();
|
||||
if (enabled) {
|
||||
if (randomBoolean()) {
|
||||
settings.put("xpack.ml.enabled", enabled);
|
||||
}
|
||||
} else {
|
||||
settings.put("xpack.ml.enabled", enabled);
|
||||
}
|
||||
MachineLearningFeatureSet featureSet = new MachineLearningFeatureSet(settings.build(), licenseState);
|
||||
assertThat(featureSet.enabled(), is(enabled));
|
||||
assertThat(featureSet.usage().enabled(), is(enabled));
|
||||
|
||||
BytesStreamOutput out = new BytesStreamOutput();
|
||||
featureSet.usage().writeTo(out);
|
||||
XPackFeatureSet.Usage serializedUsage = new MachineLearningFeatureSet.Usage(out.bytes().streamInput());
|
||||
assertThat(serializedUsage.enabled(), is(enabled));
|
||||
}
|
||||
|
||||
}
|
@ -19,7 +19,7 @@ import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.FlushJobAction;
|
||||
import org.elasticsearch.xpack.ml.action.PostDataAction;
|
||||
import org.elasticsearch.xpack.ml.action.StartDatafeedAction;
|
||||
@ -96,7 +96,7 @@ public class DatafeedJobRunnerTests extends ESTestCase {
|
||||
((Runnable) invocation.getArguments()[0]).run();
|
||||
return null;
|
||||
}).when(executorService).submit(any(Runnable.class));
|
||||
when(threadPool.executor(MlPlugin.DATAFEED_RUNNER_THREAD_POOL_NAME)).thenReturn(executorService);
|
||||
when(threadPool.executor(MachineLearning.DATAFEED_RUNNER_THREAD_POOL_NAME)).thenReturn(executorService);
|
||||
when(threadPool.executor(ThreadPool.Names.GENERIC)).thenReturn(executorService);
|
||||
when(client.execute(same(PostDataAction.INSTANCE), any())).thenReturn(jobDataFuture);
|
||||
when(client.execute(same(FlushJobAction.INSTANCE), any())).thenReturn(flushJobFuture);
|
||||
@ -147,7 +147,7 @@ public class DatafeedJobRunnerTests extends ESTestCase {
|
||||
StartDatafeedAction.DatafeedTask task = mock(StartDatafeedAction.DatafeedTask.class);
|
||||
datafeedJobRunner.run("datafeed1", 0L, 60000L, task, handler);
|
||||
|
||||
verify(threadPool, times(1)).executor(MlPlugin.DATAFEED_RUNNER_THREAD_POOL_NAME);
|
||||
verify(threadPool, times(1)).executor(MachineLearning.DATAFEED_RUNNER_THREAD_POOL_NAME);
|
||||
verify(threadPool, never()).schedule(any(), any(), any());
|
||||
verify(client).execute(same(PostDataAction.INSTANCE), eq(createExpectedPostDataRequest(job)));
|
||||
verify(client).execute(same(FlushJobAction.INSTANCE), any());
|
||||
@ -184,7 +184,7 @@ public class DatafeedJobRunnerTests extends ESTestCase {
|
||||
StartDatafeedAction.DatafeedTask task = mock(StartDatafeedAction.DatafeedTask.class);
|
||||
datafeedJobRunner.run("datafeed1", 0L, 60000L, task, handler);
|
||||
|
||||
verify(threadPool, times(1)).executor(MlPlugin.DATAFEED_RUNNER_THREAD_POOL_NAME);
|
||||
verify(threadPool, times(1)).executor(MachineLearning.DATAFEED_RUNNER_THREAD_POOL_NAME);
|
||||
verify(threadPool, never()).schedule(any(), any(), any());
|
||||
verify(client, never()).execute(same(PostDataAction.INSTANCE), eq(new PostDataAction.Request("foo")));
|
||||
verify(client, never()).execute(same(FlushJobAction.INSTANCE), any());
|
||||
@ -214,14 +214,14 @@ public class DatafeedJobRunnerTests extends ESTestCase {
|
||||
StartDatafeedAction.DatafeedTask task = new StartDatafeedAction.DatafeedTask(1, "type", "action", null, "datafeed1");
|
||||
datafeedJobRunner.run("datafeed1", 0L, null, task, handler);
|
||||
|
||||
verify(threadPool, times(1)).executor(MlPlugin.DATAFEED_RUNNER_THREAD_POOL_NAME);
|
||||
verify(threadPool, times(1)).executor(MachineLearning.DATAFEED_RUNNER_THREAD_POOL_NAME);
|
||||
if (cancelled) {
|
||||
task.stop();
|
||||
verify(handler).accept(null);
|
||||
} else {
|
||||
verify(client).execute(same(PostDataAction.INSTANCE), eq(createExpectedPostDataRequest(job)));
|
||||
verify(client).execute(same(FlushJobAction.INSTANCE), any());
|
||||
verify(threadPool, times(1)).schedule(eq(new TimeValue(480100)), eq(MlPlugin.DATAFEED_RUNNER_THREAD_POOL_NAME), any());
|
||||
verify(threadPool, times(1)).schedule(eq(new TimeValue(480100)), eq(MachineLearning.DATAFEED_RUNNER_THREAD_POOL_NAME), any());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.elasticsearch.client.RestClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.security.authc.support.SecuredString;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@ -209,7 +209,8 @@ public class DatafeedJobIT extends ESRestTestCase {
|
||||
+ "\"detectors\":[{\"function\":\"mean\",\"field_name\":\"responsetime\",\"by_field_name\":\"airline\"}]},"
|
||||
+ "\"data_description\" : {\"time_field\":\"time stamp\"}"
|
||||
+ "}";
|
||||
client().performRequest("put", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId, Collections.emptyMap(), new StringEntity(job));
|
||||
client().performRequest("put", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId, Collections.emptyMap(),
|
||||
new StringEntity(job));
|
||||
|
||||
String datafeedId = "datafeed-" + jobId;
|
||||
String aggregations = "{\"time stamp\":{\"histogram\":{\"field\":\"time stamp\",\"interval\":3600000},"
|
||||
@ -219,7 +220,7 @@ public class DatafeedJobIT extends ESRestTestCase {
|
||||
openJob(client(), jobId);
|
||||
|
||||
startDatafeedAndWaitUntilStopped(datafeedId);
|
||||
Response jobStatsResponse = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats");
|
||||
Response jobStatsResponse = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats");
|
||||
String jobStatsResponseAsString = responseEntityToString(jobStatsResponse);
|
||||
assertThat(jobStatsResponseAsString, containsString("\"input_record_count\":4"));
|
||||
assertThat(jobStatsResponseAsString, containsString("\"processed_record_count\":4"));
|
||||
@ -232,7 +233,8 @@ public class DatafeedJobIT extends ESRestTestCase {
|
||||
+ "\"detectors\":[{\"function\":\"mean\",\"field_name\":\"responsetime\",\"by_field_name\":\"airline\"}]},"
|
||||
+ "\"data_description\" : {\"time_field\":\"time stamp\"}"
|
||||
+ "}";
|
||||
client().performRequest("put", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId, Collections.emptyMap(), new StringEntity(job));
|
||||
client().performRequest("put", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId, Collections.emptyMap(),
|
||||
new StringEntity(job));
|
||||
|
||||
String datafeedId = "datafeed-" + jobId;
|
||||
String aggregations = "{\"time stamp\":{\"date_histogram\":{\"field\":\"time stamp\",\"interval\":\"1h\"},"
|
||||
@ -242,7 +244,7 @@ public class DatafeedJobIT extends ESRestTestCase {
|
||||
openJob(client(), jobId);
|
||||
|
||||
startDatafeedAndWaitUntilStopped(datafeedId);
|
||||
Response jobStatsResponse = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats");
|
||||
Response jobStatsResponse = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats");
|
||||
String jobStatsResponseAsString = responseEntityToString(jobStatsResponse);
|
||||
assertThat(jobStatsResponseAsString, containsString("\"input_record_count\":4"));
|
||||
assertThat(jobStatsResponseAsString, containsString("\"processed_record_count\":4"));
|
||||
@ -257,13 +259,13 @@ public class DatafeedJobIT extends ESRestTestCase {
|
||||
openJob(client(), jobId);
|
||||
|
||||
Response response = client().performRequest("post",
|
||||
MlPlugin.BASE_PATH + "datafeeds/" + datafeedId + "/_start?start=2016-06-01T00:00:00Z");
|
||||
MachineLearning.BASE_PATH + "datafeeds/" + datafeedId + "/_start?start=2016-06-01T00:00:00Z");
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
assertThat(responseEntityToString(response), equalTo("{\"started\":true}"));
|
||||
assertBusy(() -> {
|
||||
try {
|
||||
Response getJobResponse = client().performRequest("get",
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats");
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats");
|
||||
String responseAsString = responseEntityToString(getJobResponse);
|
||||
assertThat(responseAsString, containsString("\"processed_record_count\":2"));
|
||||
} catch (Exception e1) {
|
||||
@ -272,23 +274,23 @@ public class DatafeedJobIT extends ESRestTestCase {
|
||||
});
|
||||
|
||||
ResponseException e = expectThrows(ResponseException.class,
|
||||
() -> client().performRequest("delete", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId));
|
||||
() -> client().performRequest("delete", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId));
|
||||
response = e.getResponse();
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(409));
|
||||
assertThat(responseEntityToString(response), containsString("Cannot delete job [" + jobId + "] while datafeed [" + datafeedId
|
||||
+ "] refers to it"));
|
||||
|
||||
response = client().performRequest("post", MlPlugin.BASE_PATH + "datafeeds/" + datafeedId + "/_stop");
|
||||
response = client().performRequest("post", MachineLearning.BASE_PATH + "datafeeds/" + datafeedId + "/_stop");
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
assertThat(responseEntityToString(response), equalTo("{\"acknowledged\":true}"));
|
||||
|
||||
client().performRequest("POST", "/_xpack/ml/anomaly_detectors/" + jobId + "/_close");
|
||||
|
||||
response = client().performRequest("delete", MlPlugin.BASE_PATH + "datafeeds/" + datafeedId);
|
||||
response = client().performRequest("delete", MachineLearning.BASE_PATH + "datafeeds/" + datafeedId);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
assertThat(responseEntityToString(response), equalTo("{\"acknowledged\":true}"));
|
||||
|
||||
response = client().performRequest("delete", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId);
|
||||
response = client().performRequest("delete", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
assertThat(responseEntityToString(response), equalTo("{\"acknowledged\":true}"));
|
||||
}
|
||||
@ -339,7 +341,8 @@ public class DatafeedJobIT extends ESRestTestCase {
|
||||
openJob(client(), jobId);
|
||||
|
||||
startDatafeedAndWaitUntilStopped(datafeedId);
|
||||
Response jobStatsResponse = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats");
|
||||
Response jobStatsResponse = client().performRequest("get",
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats");
|
||||
String jobStatsResponseAsString = responseEntityToString(jobStatsResponse);
|
||||
if (shouldSucceedInput) {
|
||||
assertThat(jobStatsResponseAsString, containsString("\"input_record_count\":2"));
|
||||
@ -357,13 +360,13 @@ public class DatafeedJobIT extends ESRestTestCase {
|
||||
|
||||
private void startDatafeedAndWaitUntilStopped(String datafeedId) throws Exception {
|
||||
Response startDatafeedRequest = client().performRequest("post",
|
||||
MlPlugin.BASE_PATH + "datafeeds/" + datafeedId + "/_start?start=2016-06-01T00:00:00Z&end=2016-06-02T00:00:00Z");
|
||||
MachineLearning.BASE_PATH + "datafeeds/" + datafeedId + "/_start?start=2016-06-01T00:00:00Z&end=2016-06-02T00:00:00Z");
|
||||
assertThat(startDatafeedRequest.getStatusLine().getStatusCode(), equalTo(200));
|
||||
assertThat(responseEntityToString(startDatafeedRequest), equalTo("{\"started\":true}"));
|
||||
assertBusy(() -> {
|
||||
try {
|
||||
Response datafeedStatsResponse = client().performRequest("get",
|
||||
MlPlugin.BASE_PATH + "datafeeds/" + datafeedId + "/_stats");
|
||||
MachineLearning.BASE_PATH + "datafeeds/" + datafeedId + "/_stats");
|
||||
assertThat(responseEntityToString(datafeedStatsResponse), containsString("\"state\":\"stopped\""));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
@ -379,7 +382,7 @@ public class DatafeedJobIT extends ESRestTestCase {
|
||||
+ " \"time_field\":\"time stamp\",\n" + " \"time_format\":\"yyyy-MM-dd'T'HH:mm:ssX\"\n" + " }\n"
|
||||
+ "}";
|
||||
|
||||
return client().performRequest("put", MlPlugin.BASE_PATH + "anomaly_detectors/" + id,
|
||||
return client().performRequest("put", MachineLearning.BASE_PATH + "anomaly_detectors/" + id,
|
||||
Collections.emptyMap(), new StringEntity(job));
|
||||
}
|
||||
|
||||
@ -390,7 +393,7 @@ public class DatafeedJobIT extends ESRestTestCase {
|
||||
}
|
||||
|
||||
public static void openJob(RestClient client, String jobId) throws IOException {
|
||||
Response response = client.performRequest("post", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_open");
|
||||
Response response = client.performRequest("post", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_open");
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
}
|
||||
|
||||
@ -398,14 +401,15 @@ public class DatafeedJobIT extends ESRestTestCase {
|
||||
String job = "{\"description\":\"Nested job\", \"analysis_config\" : {\"bucket_span\":3600,\"detectors\" :"
|
||||
+ "[{\"function\":\"mean\",\"field_name\":\"responsetime.millis\"}]}, \"data_description\" : {\"time_field\":\"time\"}"
|
||||
+ "}";
|
||||
client().performRequest("put", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId, Collections.emptyMap(), new StringEntity(job));
|
||||
client().performRequest("put", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId, Collections.emptyMap(),
|
||||
new StringEntity(job));
|
||||
|
||||
String datafeedId = jobId + "-datafeed";
|
||||
new DatafeedBuilder(datafeedId, jobId, "nested-data", "response").setSource(source).build();
|
||||
openJob(client(), jobId);
|
||||
|
||||
startDatafeedAndWaitUntilStopped(datafeedId);
|
||||
Response jobStatsResponse = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats");
|
||||
Response jobStatsResponse = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats");
|
||||
String jobStatsResponseAsString = responseEntityToString(jobStatsResponse);
|
||||
assertThat(jobStatsResponseAsString, containsString("\"input_record_count\":2"));
|
||||
assertThat(jobStatsResponseAsString, containsString("\"processed_record_count\":2"));
|
||||
@ -455,7 +459,7 @@ public class DatafeedJobIT extends ESRestTestCase {
|
||||
+ (scriptedFields == null ? "" : ",\"script_fields\":" + scriptedFields)
|
||||
+ (aggregations == null ? "" : ",\"aggs\":" + aggregations)
|
||||
+ "}";
|
||||
return client().performRequest("put", MlPlugin.BASE_PATH + "datafeeds/" + datafeedId, Collections.emptyMap(),
|
||||
return client().performRequest("put", MachineLearning.BASE_PATH + "datafeeds/" + datafeedId, Collections.emptyMap(),
|
||||
new StringEntity(datafeedConfig));
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import org.elasticsearch.client.ResponseException;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.job.persistence.AnomalyDetectorsIndex;
|
||||
import org.elasticsearch.xpack.security.authc.support.SecuredString;
|
||||
import org.junit.After;
|
||||
@ -63,7 +63,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
|
||||
public void testGetJob_GivenNoSuchJob() throws Exception {
|
||||
ResponseException e = expectThrows(ResponseException.class,
|
||||
() -> client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/non-existing-job/_stats"));
|
||||
() -> client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/non-existing-job/_stats"));
|
||||
|
||||
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
|
||||
assertThat(e.getMessage(), containsString("No known job with id 'non-existing-job'"));
|
||||
@ -72,7 +72,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
public void testGetJob_GivenJobExists() throws Exception {
|
||||
createFarequoteJob();
|
||||
|
||||
Response response = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/farequote/_stats");
|
||||
Response response = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/farequote/_stats");
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
String responseAsString = responseEntityToString(response);
|
||||
@ -84,7 +84,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
createFarequoteJob();
|
||||
|
||||
// Explicit _all
|
||||
Response response = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/_all");
|
||||
Response response = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/_all");
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
String responseAsString = responseEntityToString(response);
|
||||
@ -92,7 +92,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
assertThat(responseAsString, containsString("\"job_id\":\"farequote\""));
|
||||
|
||||
// Implicit _all
|
||||
response = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors");
|
||||
response = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors");
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
responseAsString = responseEntityToString(response);
|
||||
@ -106,7 +106,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
createFarequoteJob("farequote_3");
|
||||
|
||||
// Explicit _all
|
||||
Response response = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/_all");
|
||||
Response response = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/_all");
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
String responseAsString = responseEntityToString(response);
|
||||
@ -116,7 +116,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
assertThat(responseAsString, containsString("\"job_id\":\"farequote_3\""));
|
||||
|
||||
// Implicit _all
|
||||
response = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors");
|
||||
response = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors");
|
||||
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
responseAsString = responseEntityToString(response);
|
||||
@ -138,7 +138,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
"\"time_field\":\"time\",\n"
|
||||
+ " \"time_format\":\"yyyy-MM-dd HH:mm:ssX\"\n" + " }\n" + "}";
|
||||
|
||||
return client().performRequest("put", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId,
|
||||
return client().performRequest("put", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId,
|
||||
Collections.emptyMap(), new StringEntity(job));
|
||||
}
|
||||
|
||||
@ -148,34 +148,34 @@ public class MlJobIT extends ESRestTestCase {
|
||||
params.put("end", "1400"); // exclusive
|
||||
|
||||
ResponseException e = expectThrows(ResponseException.class,
|
||||
() -> client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/1/results/buckets", params));
|
||||
() -> client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/1/results/buckets", params));
|
||||
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
|
||||
assertThat(e.getMessage(), containsString("No known job with id '1'"));
|
||||
|
||||
addBucketResult("1", "1234", 1);
|
||||
addBucketResult("1", "1235", 1);
|
||||
addBucketResult("1", "1236", 1);
|
||||
Response response = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/1/results/buckets", params);
|
||||
Response response = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/1/results/buckets", params);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
String responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, containsString("\"count\":3"));
|
||||
|
||||
params.put("end", "1235");
|
||||
response = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/1/results/buckets", params);
|
||||
response = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/1/results/buckets", params);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, containsString("\"count\":1"));
|
||||
|
||||
e = expectThrows(ResponseException.class, () -> client().performRequest("get", MlPlugin.BASE_PATH
|
||||
e = expectThrows(ResponseException.class, () -> client().performRequest("get", MachineLearning.BASE_PATH
|
||||
+ "anomaly_detectors/2/results/buckets/1234"));
|
||||
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
|
||||
assertThat(e.getMessage(), containsString("No known job with id '2'"));
|
||||
|
||||
e = expectThrows(ResponseException.class, () -> client().performRequest("get",
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/1/results/buckets/1"));
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/1/results/buckets/1"));
|
||||
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
|
||||
|
||||
response = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/1/results/buckets/1234");
|
||||
response = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/1/results/buckets/1234");
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, not(isEmptyString()));
|
||||
@ -187,20 +187,20 @@ public class MlJobIT extends ESRestTestCase {
|
||||
params.put("end", "1400"); // exclusive
|
||||
|
||||
ResponseException e = expectThrows(ResponseException.class,
|
||||
() -> client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/1/results/records", params));
|
||||
() -> client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/1/results/records", params));
|
||||
assertThat(e.getResponse().getStatusLine().getStatusCode(), equalTo(404));
|
||||
assertThat(e.getMessage(), containsString("No known job with id '1'"));
|
||||
|
||||
addRecordResult("1", "1234", 1, 1);
|
||||
addRecordResult("1", "1235", 1, 2);
|
||||
addRecordResult("1", "1236", 1, 3);
|
||||
Response response = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/1/results/records", params);
|
||||
Response response = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/1/results/records", params);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
String responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, containsString("\"count\":3"));
|
||||
|
||||
params.put("end", "1235");
|
||||
response = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/1/results/records", params);
|
||||
response = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/1/results/records", params);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, containsString("\"count\":1"));
|
||||
@ -217,7 +217,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
String indexName = "non-default-index";
|
||||
String jobConfig = String.format(Locale.ROOT, jobTemplate, indexName);
|
||||
|
||||
Response response = client().performRequest("put", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId, Collections.emptyMap(),
|
||||
Response response = client().performRequest("put", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId, Collections.emptyMap(),
|
||||
new StringEntity(jobConfig));
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
|
||||
@ -234,7 +234,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
|
||||
addBucketResult(indexName, "1234", 1);
|
||||
addBucketResult(indexName, "1236", 1);
|
||||
response = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/results/buckets");
|
||||
response = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/results/buckets");
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, containsString("\"count\":2"));
|
||||
@ -247,9 +247,9 @@ public class MlJobIT extends ESRestTestCase {
|
||||
// test that we can't create another job with the same index_name
|
||||
String jobConfigSameIndexName = String.format(Locale.ROOT, jobTemplate, "new-job-id", indexName);
|
||||
expectThrows(ResponseException.class, () -> client().performRequest("put",
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors", Collections.emptyMap(), new StringEntity(jobConfigSameIndexName)));
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors", Collections.emptyMap(), new StringEntity(jobConfigSameIndexName)));
|
||||
|
||||
response = client().performRequest("delete", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId);
|
||||
response = client().performRequest("delete", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
|
||||
// check index and alias were deleted
|
||||
@ -274,7 +274,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
String responseAsString = responseEntityToString(response);
|
||||
assertThat(responseAsString, containsString(indexName));
|
||||
|
||||
response = client().performRequest("delete", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId);
|
||||
response = client().performRequest("delete", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
|
||||
// check index was deleted
|
||||
@ -285,7 +285,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
|
||||
// check that the job itself is gone
|
||||
expectThrows(ResponseException.class, () ->
|
||||
client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats"));
|
||||
client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats"));
|
||||
}
|
||||
|
||||
public void testDeleteJobAfterMissingIndex() throws Exception {
|
||||
@ -303,7 +303,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
response = client().performRequest("delete", indexName);
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
|
||||
response = client().performRequest("delete", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId);
|
||||
response = client().performRequest("delete", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
|
||||
// check index was deleted
|
||||
@ -313,7 +313,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
assertThat(responseAsString, not(containsString(indexName)));
|
||||
|
||||
expectThrows(ResponseException.class, () ->
|
||||
client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats"));
|
||||
client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats"));
|
||||
}
|
||||
|
||||
public void testMultiIndexDelete() throws Exception {
|
||||
@ -366,7 +366,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
assertThat(responseAsString, containsString("\"count\":1"));
|
||||
|
||||
// Delete
|
||||
response = client().performRequest("delete", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId);
|
||||
response = client().performRequest("delete", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId);
|
||||
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
|
||||
|
||||
client().performRequest("post", "_refresh");
|
||||
@ -389,7 +389,7 @@ public class MlJobIT extends ESRestTestCase {
|
||||
assertThat(responseAsString, containsString("\"count\":0"));
|
||||
|
||||
expectThrows(ResponseException.class, () ->
|
||||
client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats"));
|
||||
client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats"));
|
||||
}
|
||||
|
||||
private Response addBucketResult(String jobId, String timestamp, long bucketSpan) throws Exception {
|
||||
|
@ -13,7 +13,7 @@ import org.elasticsearch.common.util.concurrent.EsExecutors;
|
||||
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.util.QueryPage;
|
||||
import org.elasticsearch.xpack.ml.job.JobManager;
|
||||
import org.elasticsearch.xpack.ml.job.config.AnalysisConfig;
|
||||
@ -153,7 +153,7 @@ public class AutodetectProcessManagerTests extends ESTestCase {
|
||||
ThreadPool threadPool = mock(ThreadPool.class);
|
||||
ThreadPool.Cancellable cancellable = mock(ThreadPool.Cancellable.class);
|
||||
when(threadPool.scheduleWithFixedDelay(any(), any(), any())).thenReturn(cancellable);
|
||||
when(threadPool.executor(MlPlugin.AUTODETECT_PROCESS_THREAD_POOL_NAME))
|
||||
when(threadPool.executor(MachineLearning.AUTODETECT_PROCESS_THREAD_POOL_NAME))
|
||||
.thenReturn(EsExecutors.newDirectExecutorService());
|
||||
AutodetectProcess autodetectProcess = mock(AutodetectProcess.class);
|
||||
when(autodetectProcess.isProcessAlive()).thenReturn(true);
|
||||
|
@ -12,7 +12,8 @@ import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.SecurityIntegTestCase;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.CloseJobAction;
|
||||
import org.elasticsearch.xpack.ml.action.DeleteDatafeedAction;
|
||||
import org.elasticsearch.xpack.ml.action.DeleteJobAction;
|
||||
@ -54,8 +55,8 @@ public abstract class BaseMlIntegTestCase extends SecurityIntegTestCase {
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
Settings.Builder settings = Settings.builder().put(super.nodeSettings(nodeOrdinal));
|
||||
settings.put(MlPlugin.USE_NATIVE_PROCESS_OPTION.getKey(), false);
|
||||
settings.put(MlPlugin.ML_ENABLED.getKey(), true);
|
||||
settings.put(MachineLearning.USE_NATIVE_PROCESS_OPTION.getKey(), false);
|
||||
settings.put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), true);
|
||||
return settings.build();
|
||||
}
|
||||
|
||||
@ -109,7 +110,7 @@ public abstract class BaseMlIntegTestCase extends SecurityIntegTestCase {
|
||||
for (int i = 0; i < numNodes; i++) {
|
||||
internalCluster().stopRandomDataNode();
|
||||
}
|
||||
internalCluster().startNode(Settings.builder().put(MlPlugin.ML_ENABLED.getKey(), false));
|
||||
internalCluster().startNode(Settings.builder().put(XPackSettings.MACHINE_LEARNING_ENABLED.getKey(), false));
|
||||
}
|
||||
|
||||
private void deleteAllDatafeeds(Client client) throws Exception {
|
||||
|
@ -10,7 +10,7 @@ import org.elasticsearch.client.Response;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
@ -30,7 +30,7 @@ public class MlBasicMultiNodeIT extends ESRestTestCase {
|
||||
createFarequoteJob(jobId);
|
||||
|
||||
try {
|
||||
Response response = client().performRequest("post", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_open");
|
||||
Response response = client().performRequest("post", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_open");
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
assertEquals(Collections.singletonMap("opened", true), responseEntityToMap(response));
|
||||
} catch (Exception e) {
|
||||
@ -42,7 +42,7 @@ public class MlBasicMultiNodeIT extends ESRestTestCase {
|
||||
String postData =
|
||||
"{\"airline\":\"AAL\",\"responsetime\":\"132.2046\",\"sourcetype\":\"farequote\",\"time\":\"1403481600\"}\n" +
|
||||
"{\"airline\":\"JZA\",\"responsetime\":\"990.4628\",\"sourcetype\":\"farequote\",\"time\":\"1403481700\"}";
|
||||
Response response = client().performRequest("post", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_data",
|
||||
Response response = client().performRequest("post", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_data",
|
||||
Collections.emptyMap(), new StringEntity(postData));
|
||||
assertEquals(202, response.getStatusLine().getStatusCode());
|
||||
Map<String, Object> responseBody = responseEntityToMap(response);
|
||||
@ -56,15 +56,15 @@ public class MlBasicMultiNodeIT extends ESRestTestCase {
|
||||
assertEquals(1403481600000L, responseBody.get("earliest_record_timestamp"));
|
||||
assertEquals(1403481700000L, responseBody.get("latest_record_timestamp"));
|
||||
|
||||
response = client().performRequest("post", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_flush");
|
||||
response = client().performRequest("post", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_flush");
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
assertEquals(Collections.singletonMap("flushed", true), responseEntityToMap(response));
|
||||
|
||||
response = client().performRequest("post", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_close");
|
||||
response = client().performRequest("post", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_close");
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
assertEquals(Collections.singletonMap("closed", true), responseEntityToMap(response));
|
||||
|
||||
response = client().performRequest("get", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats");
|
||||
response = client().performRequest("get", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId + "/_stats");
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> dataCountsDoc = (Map<String, Object>)
|
||||
@ -79,7 +79,7 @@ public class MlBasicMultiNodeIT extends ESRestTestCase {
|
||||
assertEquals(1403481600000L, dataCountsDoc.get("earliest_record_timestamp"));
|
||||
assertEquals(1403481700000L, dataCountsDoc.get("latest_record_timestamp"));
|
||||
|
||||
response = client().performRequest("delete", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId);
|
||||
response = client().performRequest("delete", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId);
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ public class MlBasicMultiNodeIT extends ESRestTestCase {
|
||||
xContentBuilder.endObject();
|
||||
xContentBuilder.endObject();
|
||||
|
||||
return client().performRequest("put", MlPlugin.BASE_PATH + "anomaly_detectors/" + jobId,
|
||||
return client().performRequest("put", MachineLearning.BASE_PATH + "anomaly_detectors/" + jobId,
|
||||
Collections.emptyMap(), new StringEntity(xContentBuilder.string()));
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import org.apache.http.entity.StringEntity;
|
||||
import org.elasticsearch.client.ResponseException;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@ -47,7 +47,7 @@ public class MlPluginDisabledIT extends ESRestTestCase {
|
||||
xContentBuilder.endObject();
|
||||
|
||||
ResponseException exception = expectThrows(ResponseException.class, () -> client().performRequest("put",
|
||||
MlPlugin.BASE_PATH + "anomaly_detectors/foo", Collections.emptyMap(), new StringEntity(xContentBuilder.string())));
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/foo", Collections.emptyMap(), new StringEntity(xContentBuilder.string())));
|
||||
assertThat(exception.getMessage(), containsString("No handler found for uri [/_xpack/ml/anomaly_detectors/foo] and method [PUT]"));
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||
import org.elasticsearch.xpack.ml.MlPlugin;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.utils.DomainSplitFunction;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
@ -269,8 +269,9 @@ public class PainlessDomainSplitIT extends ESRestTestCase {
|
||||
" }\n" +
|
||||
" }";
|
||||
|
||||
client().performRequest("PUT", MlPlugin.BASE_PATH + "anomaly_detectors/painless", Collections.emptyMap(), new StringEntity(job));
|
||||
client().performRequest("POST", MlPlugin.BASE_PATH + "anomaly_detectors/painless/_open");
|
||||
client().performRequest("PUT", MachineLearning.BASE_PATH + "anomaly_detectors/painless", Collections.emptyMap(),
|
||||
new StringEntity(job));
|
||||
client().performRequest("POST", MachineLearning.BASE_PATH + "anomaly_detectors/painless/_open");
|
||||
|
||||
// Create index to hold data
|
||||
Settings.Builder settings = Settings.builder()
|
||||
@ -321,14 +322,15 @@ public class PainlessDomainSplitIT extends ESRestTestCase {
|
||||
" }\n" +
|
||||
" }";
|
||||
|
||||
client().performRequest("PUT", MlPlugin.BASE_PATH + "datafeeds/painless", Collections.emptyMap(), new StringEntity(body));
|
||||
client().performRequest("POST", MlPlugin.BASE_PATH + "datafeeds/painless/_start");
|
||||
client().performRequest("PUT", MachineLearning.BASE_PATH + "datafeeds/painless", Collections.emptyMap(), new StringEntity(body));
|
||||
client().performRequest("POST", MachineLearning.BASE_PATH + "datafeeds/painless/_start");
|
||||
|
||||
boolean passed = awaitBusy(() -> {
|
||||
try {
|
||||
client().performRequest("POST", "/_refresh");
|
||||
|
||||
Response response = client().performRequest("GET", MlPlugin.BASE_PATH + "anomaly_detectors/painless/results/records");
|
||||
Response response = client().performRequest("GET",
|
||||
MachineLearning.BASE_PATH + "anomaly_detectors/painless/results/records");
|
||||
String responseBody = EntityUtils.toString(response.getEntity());
|
||||
|
||||
if (responseBody.contains("\"count\":2")) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user