Skip to content

Commit

Permalink
Do not stash environment in machine learning (elastic#54371)
Browse files Browse the repository at this point in the history
Today the machine learning plugin stashes a copy of the environment in
its constructor, and uses the stashed copy to construct its components
even though it is provided with an environment to create these
components. What is more, the environment it creates in its constructor
is not fully initialized, as it does not have the final copy of the
settings, but the environment passed in while creating components
does. This commit removes that stashed copy of the environment.
  • Loading branch information
jasontedor authored Mar 28, 2020
1 parent a0f7c4a commit 3595195
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@ public Set<DiscoveryNodeRole> getRoles() {
private static final Logger logger = LogManager.getLogger(MachineLearning.class);

private final Settings settings;
private final Environment env;
private final boolean enabled;

private final SetOnce<AutodetectProcessManager> autodetectProcessManager = new SetOnce<>();
Expand All @@ -431,7 +430,6 @@ public Set<DiscoveryNodeRole> getRoles() {
public MachineLearning(Settings settings, Path configPath) {
this.settings = settings;
this.enabled = XPackSettings.MACHINE_LEARNING_ENABLED.get(settings);
this.env = new Environment(settings, configPath);
}

protected XPackLicenseState getLicenseState() { return XPackPlugin.getSharedLicenseState(); }
Expand Down Expand Up @@ -550,7 +548,7 @@ public Collection<Object> createComponents(Client client, ClusterService cluster
JobConfigProvider jobConfigProvider = new JobConfigProvider(client, xContentRegistry);
DatafeedConfigProvider datafeedConfigProvider = new DatafeedConfigProvider(client, xContentRegistry);
UpdateJobProcessNotifier notifier = new UpdateJobProcessNotifier(client, clusterService, threadPool);
JobManager jobManager = new JobManager(env,
JobManager jobManager = new JobManager(environment,
settings,
jobResultsProvider,
jobResultsPersister,
Expand Down Expand Up @@ -613,7 +611,7 @@ public Collection<Object> createComponents(Client client, ClusterService cluster
}
NormalizerFactory normalizerFactory = new NormalizerFactory(normalizerProcessFactory,
threadPool.executor(MachineLearning.UTILITY_THREAD_POOL_NAME));
AutodetectProcessManager autodetectProcessManager = new AutodetectProcessManager(env, settings, client, threadPool,
AutodetectProcessManager autodetectProcessManager = new AutodetectProcessManager(environment, settings, client, threadPool,
xContentRegistry, anomalyDetectionAuditor, clusterService, jobManager, jobResultsProvider, jobResultsPersister,
jobDataCountsPersister, autodetectProcessFactory, normalizerFactory, nativeStorageProvider, indexNameExpressionResolver);
this.autodetectProcessManager.set(autodetectProcessManager);
Expand Down

0 comments on commit 3595195

Please sign in to comment.