-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] fix x-pack usage regression caused by index migration (#36936)
Changes the feature usage retrieval to use the job manager rather than directly talking to the cluster state, because jobs can now be either in cluster state or stored in an index This is a follow-up of #36702 / #36698
- Loading branch information
Hendrik Muhs
committed
Dec 31, 2018
1 parent
28df3d9
commit 03c1fa5
Showing
5 changed files
with
136 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/JobManagerHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.ml.job; | ||
|
||
import org.elasticsearch.ElasticsearchException; | ||
|
||
public class JobManagerHolder { | ||
|
||
private final JobManager instance; | ||
|
||
/** | ||
* Create an empty holder which also means that no job manager gets created. | ||
*/ | ||
public JobManagerHolder() { | ||
this.instance = null; | ||
} | ||
|
||
/** | ||
* Create a holder that allows lazy creation of a job manager. | ||
* | ||
*/ | ||
public JobManagerHolder(JobManager jobManager) { | ||
this.instance = jobManager; | ||
} | ||
|
||
public boolean isEmpty() { | ||
return instance == null; | ||
} | ||
|
||
/** | ||
* Get the instance of the held JobManager. | ||
* | ||
* @return job manager instance | ||
* @throws ElasticsearchException if holder has been created with the empty constructor | ||
*/ | ||
public JobManager getJobManager() { | ||
if (instance == null) { | ||
throw new ElasticsearchException("Tried to get job manager although Machine Learning is disabled"); | ||
} | ||
return instance; | ||
} | ||
} |
Oops, something went wrong.