[ML] The Machine Learning class no longer needs to be a plugin (elastic/x-pack-elasticsearch#712)
Now machine learning is simply a feature of X-Pack, so I have made the MachineLearning class more like the other feature classes. It no longer extends Plugin and its createComponents() method takes an InternalClient rather than a generic Client. Original commit: elastic/x-pack-elasticsearch@704860147c
This commit is contained in:
parent
e972f0216d
commit
1c52495c5a
|
@ -376,7 +376,6 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, I
|
||||||
filters.add("xpack.notification.hipchat.account.*.auth_token");
|
filters.add("xpack.notification.hipchat.account.*.auth_token");
|
||||||
filters.addAll(security.getSettingsFilter());
|
filters.addAll(security.getSettingsFilter());
|
||||||
filters.addAll(MonitoringSettings.getSettingsFilter());
|
filters.addAll(MonitoringSettings.getSettingsFilter());
|
||||||
filters.addAll(machineLearning.getSettingsFilter());
|
|
||||||
if (transportClientMode == false) {
|
if (transportClientMode == false) {
|
||||||
for (XPackExtension extension : extensionsService.getExtensions()) {
|
for (XPackExtension extension : extensionsService.getExtensions()) {
|
||||||
filters.addAll(extension.getSettingsFilter());
|
filters.addAll(extension.getSettingsFilter());
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.ml;
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.action.ActionRequest;
|
import org.elasticsearch.action.ActionRequest;
|
||||||
import org.elasticsearch.action.ActionResponse;
|
import org.elasticsearch.action.ActionResponse;
|
||||||
import org.elasticsearch.client.Client;
|
|
||||||
import org.elasticsearch.cluster.NamedDiff;
|
import org.elasticsearch.cluster.NamedDiff;
|
||||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||||
import org.elasticsearch.cluster.metadata.MetaData;
|
import org.elasticsearch.cluster.metadata.MetaData;
|
||||||
|
@ -27,7 +26,6 @@ import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||||
import org.elasticsearch.env.Environment;
|
import org.elasticsearch.env.Environment;
|
||||||
import org.elasticsearch.license.XPackLicenseState;
|
import org.elasticsearch.license.XPackLicenseState;
|
||||||
import org.elasticsearch.plugins.ActionPlugin;
|
import org.elasticsearch.plugins.ActionPlugin;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
|
||||||
import org.elasticsearch.rest.RestController;
|
import org.elasticsearch.rest.RestController;
|
||||||
import org.elasticsearch.rest.RestHandler;
|
import org.elasticsearch.rest.RestHandler;
|
||||||
import org.elasticsearch.script.ScriptService;
|
import org.elasticsearch.script.ScriptService;
|
||||||
|
@ -134,6 +132,7 @@ import org.elasticsearch.xpack.persistent.PersistentTasks;
|
||||||
import org.elasticsearch.xpack.persistent.RemovePersistentTaskAction;
|
import org.elasticsearch.xpack.persistent.RemovePersistentTaskAction;
|
||||||
import org.elasticsearch.xpack.persistent.StartPersistentTaskAction;
|
import org.elasticsearch.xpack.persistent.StartPersistentTaskAction;
|
||||||
import org.elasticsearch.xpack.persistent.UpdatePersistentTaskStatusAction;
|
import org.elasticsearch.xpack.persistent.UpdatePersistentTaskStatusAction;
|
||||||
|
import org.elasticsearch.xpack.security.InternalClient;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -145,7 +144,7 @@ import java.util.function.Supplier;
|
||||||
|
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
|
|
||||||
public class MachineLearning extends Plugin implements ActionPlugin {
|
public class MachineLearning implements ActionPlugin {
|
||||||
public static final String NAME = "ml";
|
public static final String NAME = "ml";
|
||||||
public static final String BASE_PATH = "/_xpack/ml/";
|
public static final String BASE_PATH = "/_xpack/ml/";
|
||||||
public static final String THREAD_POOL_NAME = NAME;
|
public static final String THREAD_POOL_NAME = NAME;
|
||||||
|
@ -177,7 +176,6 @@ public class MachineLearning extends Plugin implements ActionPlugin {
|
||||||
this.tribeNodeClient = XPackPlugin.isTribeClientNode(settings);
|
this.tribeNodeClient = XPackPlugin.isTribeClientNode(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Setting<?>> getSettings() {
|
public List<Setting<?>> getSettings() {
|
||||||
return Collections.unmodifiableList(
|
return Collections.unmodifiableList(
|
||||||
Arrays.asList(AUTODETECT_PROCESS,
|
Arrays.asList(AUTODETECT_PROCESS,
|
||||||
|
@ -190,14 +188,12 @@ public class MachineLearning extends Plugin implements ActionPlugin {
|
||||||
AutodetectProcessManager.MAX_RUNNING_JOBS_PER_NODE));
|
AutodetectProcessManager.MAX_RUNNING_JOBS_PER_NODE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Settings additionalSettings() {
|
public Settings additionalSettings() {
|
||||||
if (enabled == false || this.transportClientMode || this.tribeNode || this.tribeNodeClient) {
|
if (enabled == false || this.transportClientMode || this.tribeNode || this.tribeNodeClient) {
|
||||||
return super.additionalSettings();
|
return Settings.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings.Builder additionalSettings = Settings.builder();
|
Settings.Builder additionalSettings = Settings.builder();
|
||||||
additionalSettings.put(super.additionalSettings());
|
|
||||||
Boolean allocationEnabled = ML_ENABLED.get(settings);
|
Boolean allocationEnabled = ML_ENABLED.get(settings);
|
||||||
if (allocationEnabled != null && allocationEnabled) {
|
if (allocationEnabled != null && allocationEnabled) {
|
||||||
// Copy max_running_jobs setting to node attribute, so that we use this information when assigning job tasks to nodes:
|
// Copy max_running_jobs setting to node attribute, so that we use this information when assigning job tasks to nodes:
|
||||||
|
@ -207,7 +203,6 @@ public class MachineLearning extends Plugin implements ActionPlugin {
|
||||||
return additionalSettings.build();
|
return additionalSettings.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
|
public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
// Custom metadata
|
// Custom metadata
|
||||||
|
@ -228,7 +223,6 @@ public class MachineLearning extends Plugin implements ActionPlugin {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<NamedXContentRegistry.Entry> getNamedXContent() {
|
public List<NamedXContentRegistry.Entry> getNamedXContent() {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
// Custom metadata
|
// Custom metadata
|
||||||
|
@ -249,8 +243,7 @@ public class MachineLearning extends Plugin implements ActionPlugin {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Collection<Object> createComponents(InternalClient internalClient, ClusterService clusterService, ThreadPool threadPool,
|
||||||
public Collection<Object> createComponents(Client client, ClusterService clusterService, ThreadPool threadPool,
|
|
||||||
ResourceWatcherService resourceWatcherService, ScriptService scriptService,
|
ResourceWatcherService resourceWatcherService, ScriptService scriptService,
|
||||||
NamedXContentRegistry xContentRegistry) {
|
NamedXContentRegistry xContentRegistry) {
|
||||||
if (this.transportClientMode || this.tribeNodeClient) {
|
if (this.transportClientMode || this.tribeNodeClient) {
|
||||||
|
@ -266,11 +259,11 @@ public class MachineLearning extends Plugin implements ActionPlugin {
|
||||||
return Collections.singletonList(mlLifeCycleService);
|
return Collections.singletonList(mlLifeCycleService);
|
||||||
}
|
}
|
||||||
|
|
||||||
JobResultsPersister jobResultsPersister = new JobResultsPersister(settings, client);
|
JobResultsPersister jobResultsPersister = new JobResultsPersister(settings, internalClient);
|
||||||
JobProvider jobProvider = new JobProvider(client, settings);
|
JobProvider jobProvider = new JobProvider(internalClient, settings);
|
||||||
JobDataCountsPersister jobDataCountsPersister = new JobDataCountsPersister(settings, client);
|
JobDataCountsPersister jobDataCountsPersister = new JobDataCountsPersister(settings, internalClient);
|
||||||
|
|
||||||
Auditor auditor = new Auditor(client, clusterService);
|
Auditor auditor = new Auditor(internalClient, clusterService);
|
||||||
JobManager jobManager = new JobManager(settings, jobProvider, jobResultsPersister, clusterService, auditor);
|
JobManager jobManager = new JobManager(settings, jobProvider, jobResultsPersister, clusterService, auditor);
|
||||||
AutodetectProcessFactory autodetectProcessFactory;
|
AutodetectProcessFactory autodetectProcessFactory;
|
||||||
NormalizerProcessFactory normalizerProcessFactory;
|
NormalizerProcessFactory normalizerProcessFactory;
|
||||||
|
@ -281,7 +274,7 @@ public class MachineLearning extends Plugin implements ActionPlugin {
|
||||||
// This will only only happen when path.home is not set, which is disallowed in production
|
// This will only only happen when path.home is not set, which is disallowed in production
|
||||||
throw new ElasticsearchException("Failed to create native process controller for Machine Learning");
|
throw new ElasticsearchException("Failed to create native process controller for Machine Learning");
|
||||||
}
|
}
|
||||||
autodetectProcessFactory = new NativeAutodetectProcessFactory(jobProvider, env, settings, nativeController, client);
|
autodetectProcessFactory = new NativeAutodetectProcessFactory(jobProvider, env, settings, nativeController, internalClient);
|
||||||
normalizerProcessFactory = new NativeNormalizerProcessFactory(env, settings, nativeController);
|
normalizerProcessFactory = new NativeNormalizerProcessFactory(env, settings, nativeController);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// This also should not happen in production, as the MachineLearningFeatureSet should have
|
// This also should not happen in production, as the MachineLearningFeatureSet should have
|
||||||
|
@ -297,12 +290,13 @@ public class MachineLearning extends Plugin implements ActionPlugin {
|
||||||
}
|
}
|
||||||
NormalizerFactory normalizerFactory = new NormalizerFactory(normalizerProcessFactory,
|
NormalizerFactory normalizerFactory = new NormalizerFactory(normalizerProcessFactory,
|
||||||
threadPool.executor(MachineLearning.THREAD_POOL_NAME));
|
threadPool.executor(MachineLearning.THREAD_POOL_NAME));
|
||||||
AutodetectProcessManager autodetectProcessManager = new AutodetectProcessManager(settings, client, threadPool,
|
AutodetectProcessManager autodetectProcessManager = new AutodetectProcessManager(settings, internalClient, threadPool,
|
||||||
jobManager, jobProvider, jobResultsPersister, jobDataCountsPersister, autodetectProcessFactory,
|
jobManager, jobProvider, jobResultsPersister, jobDataCountsPersister, autodetectProcessFactory,
|
||||||
normalizerFactory);
|
normalizerFactory);
|
||||||
DatafeedJobRunner datafeedJobRunner = new DatafeedJobRunner(threadPool, client, clusterService, jobProvider,
|
DatafeedJobRunner datafeedJobRunner = new DatafeedJobRunner(threadPool, internalClient, clusterService, jobProvider,
|
||||||
System::currentTimeMillis, auditor);
|
System::currentTimeMillis, auditor);
|
||||||
PersistentActionService persistentActionService = new PersistentActionService(Settings.EMPTY, threadPool, clusterService, client);
|
PersistentActionService persistentActionService = new PersistentActionService(Settings.EMPTY, threadPool, clusterService,
|
||||||
|
internalClient);
|
||||||
PersistentActionRegistry persistentActionRegistry = new PersistentActionRegistry(Settings.EMPTY);
|
PersistentActionRegistry persistentActionRegistry = new PersistentActionRegistry(Settings.EMPTY);
|
||||||
InvalidLicenseEnforcer invalidLicenseEnforcer =
|
InvalidLicenseEnforcer invalidLicenseEnforcer =
|
||||||
new InvalidLicenseEnforcer(settings, licenseState, threadPool, datafeedJobRunner, autodetectProcessManager);
|
new InvalidLicenseEnforcer(settings, licenseState, threadPool, datafeedJobRunner, autodetectProcessManager);
|
||||||
|
@ -312,15 +306,15 @@ public class MachineLearning extends Plugin implements ActionPlugin {
|
||||||
jobProvider,
|
jobProvider,
|
||||||
jobManager,
|
jobManager,
|
||||||
autodetectProcessManager,
|
autodetectProcessManager,
|
||||||
new MachineLearningTemplateRegistry(settings, clusterService, client, threadPool),
|
new MachineLearningTemplateRegistry(settings, clusterService, internalClient, threadPool),
|
||||||
new MlInitializationService(settings, threadPool, clusterService, client),
|
new MlInitializationService(settings, threadPool, clusterService, internalClient),
|
||||||
jobDataCountsPersister,
|
jobDataCountsPersister,
|
||||||
datafeedJobRunner,
|
datafeedJobRunner,
|
||||||
persistentActionService,
|
persistentActionService,
|
||||||
persistentActionRegistry,
|
persistentActionRegistry,
|
||||||
new PersistentTaskClusterService(Settings.EMPTY, persistentActionRegistry, clusterService),
|
new PersistentTaskClusterService(Settings.EMPTY, persistentActionRegistry, clusterService),
|
||||||
auditor,
|
auditor,
|
||||||
new CloseJobService(client, threadPool, clusterService),
|
new CloseJobService(internalClient, threadPool, clusterService),
|
||||||
invalidLicenseEnforcer
|
invalidLicenseEnforcer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -424,7 +418,6 @@ public class MachineLearning extends Plugin implements ActionPlugin {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ExecutorBuilder<?>> getExecutorBuilders(Settings settings) {
|
public List<ExecutorBuilder<?>> getExecutorBuilders(Settings settings) {
|
||||||
if (false == enabled || tribeNode || tribeNodeClient) {
|
if (false == enabled || tribeNode || tribeNodeClient) {
|
||||||
return emptyList();
|
return emptyList();
|
||||||
|
|
Loading…
Reference in New Issue