[ML] [7.x] Only emit deprecation warning if there was actual change of a datafeed's job_id. (#44755)

* Only emit deprecation warning if there was actual change of a datafeed's job_id.
* Add @Deprecated annotation to DatafeedUpdate.Builder#setJobId method
This commit is contained in:
Przemysław Witek 2019-07-24 10:03:25 +02:00 committed by GitHub
parent 58a4bad12f
commit 26da573e94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 3 deletions

View File

@ -287,6 +287,7 @@ public class DatafeedUpdate implements ToXContentObject {
this.delayedDataCheckConfig = config.delayedDataCheckConfig;
}
@Deprecated
public Builder setJobId(String jobId) {
this.jobId = jobId;
return this;

View File

@ -478,6 +478,11 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase {
DatafeedConfig datafeedConfig = DatafeedConfig.builder(datafeedId, jobId).setIndices("some_data_index").build();
execute(new PutDatafeedRequest(datafeedConfig), machineLearningClient::putDatafeed, machineLearningClient::putDatafeedAsync);
DatafeedUpdate datafeedUpdateWithUnchangedJobId = DatafeedUpdate.builder(datafeedId).setJobId(jobId).build();
execute(new UpdateDatafeedRequest(datafeedUpdateWithUnchangedJobId),
machineLearningClient::updateDatafeed,
machineLearningClient::updateDatafeedAsync);
DatafeedUpdate datafeedUpdateWithChangedJobId = DatafeedUpdate.builder(datafeedId).setJobId(anotherJobId).build();
WarningFailureException exception = expectThrows(
WarningFailureException.class,

View File

@ -110,9 +110,6 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
this.scrollSize = scrollSize;
this.chunkingConfig = chunkingConfig;
this.delayedDataCheckConfig = delayedDataCheckConfig;
if (jobId != null) {
deprecationLogger.deprecated(DEPRECATION_MESSAGE_ON_JOB_ID_UPDATE);
}
}
public DatafeedUpdate(StreamInput in) throws IOException {
@ -304,6 +301,9 @@ public class DatafeedUpdate implements Writeable, ToXContentObject {
DatafeedConfig.Builder builder = new DatafeedConfig.Builder(datafeedConfig);
if (jobId != null) {
if (datafeedConfig.getJobId() != null && datafeedConfig.getJobId().equals(jobId) == false) {
deprecationLogger.deprecated(DEPRECATION_MESSAGE_ON_JOB_ID_UPDATE);
}
builder.setJobId(jobId);
}
if (queryDelay != null) {

View File

@ -215,6 +215,16 @@ setup:
"indexes":["index-foo"],
"scroll_size": 2000
}
- match: { job_id: "datafeeds-crud-1" }
- do:
ml.update_datafeed:
datafeed_id: test-datafeed-1
body: >
{
"job_id": "datafeeds-crud-1"
}
- match: { job_id: "datafeeds-crud-1" }
- do:
warnings: