mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-27 10:28:28 +00:00
[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:
parent
58a4bad12f
commit
26da573e94
@ -287,6 +287,7 @@ public class DatafeedUpdate implements ToXContentObject {
|
||||
this.delayedDataCheckConfig = config.delayedDataCheckConfig;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Builder setJobId(String jobId) {
|
||||
this.jobId = jobId;
|
||||
return this;
|
||||
|
@ -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,
|
||||
|
@ -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) {
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user