[ML] Also serialize the job id in a update job request.
Relates to elastic/x-pack-elasticsearch#787 and elastic/x-pack-elasticsearch#799 Original commit: elastic/x-pack-elasticsearch@fc64d25bcb
This commit is contained in:
parent
6ddc626c17
commit
d779bf66a5
|
@ -30,11 +30,11 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
|
|||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.ml.MlMetadata;
|
||||
import org.elasticsearch.xpack.ml.job.JobManager;
|
||||
import org.elasticsearch.xpack.ml.job.config.Job;
|
||||
import org.elasticsearch.xpack.ml.job.config.JobState;
|
||||
import org.elasticsearch.xpack.ml.job.config.JobUpdate;
|
||||
import org.elasticsearch.xpack.ml.MlMetadata;
|
||||
import org.elasticsearch.xpack.persistent.PersistentTasks;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -94,17 +94,20 @@ public class UpdateJobAction extends Action<UpdateJobAction.Request, PutJobActio
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
jobId = in.readString();
|
||||
update = new JobUpdate(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(jobId);
|
||||
update.writeTo(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
// only serialize the update, as the job id is specified as part of the url
|
||||
update.toXContent(builder, params);
|
||||
return builder;
|
||||
}
|
||||
|
@ -114,12 +117,13 @@ public class UpdateJobAction extends Action<UpdateJobAction.Request, PutJobActio
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
UpdateJobAction.Request request = (UpdateJobAction.Request) o;
|
||||
return Objects.equals(update, request.update);
|
||||
return Objects.equals(jobId, request.jobId) &&
|
||||
Objects.equals(update, request.update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(update);
|
||||
return Objects.hash(jobId, update);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* 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.action;
|
||||
|
||||
import org.elasticsearch.xpack.ml.job.config.AnalysisLimits;
|
||||
import org.elasticsearch.xpack.ml.job.config.JobUpdate;
|
||||
import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase;
|
||||
|
||||
public class UpdateJobActionRequestTests
|
||||
extends AbstractStreamableTestCase<UpdateJobAction.Request> {
|
||||
|
||||
@Override
|
||||
protected UpdateJobAction.Request createTestInstance() {
|
||||
String jobId = randomAsciiOfLength(10);
|
||||
// no need to randomize JobUpdate this is already tested in: JobUpdateTests
|
||||
JobUpdate.Builder jobUpdate = new JobUpdate.Builder();
|
||||
jobUpdate.setAnalysisLimits(new AnalysisLimits(100L, 100L));
|
||||
return new UpdateJobAction.Request(jobId, jobUpdate.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UpdateJobAction.Request createBlankInstance() {
|
||||
return new UpdateJobAction.Request();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue