Remove the overwrite option from PUT job (elastic/elasticsearch#855)

Original commit: elastic/x-pack-elasticsearch@0f7e0d35a9
This commit is contained in:
David Kyle 2017-02-03 09:54:47 +00:00 committed by GitHub
parent 53a5e19c70
commit b940dbf6d9
4 changed files with 3 additions and 21 deletions

View File

@ -63,7 +63,6 @@ public class PutJobAction extends Action<PutJobAction.Request, PutJobAction.Resp
} }
private Job job; private Job job;
private boolean overwrite;
public Request(Job job) { public Request(Job job) {
this.job = job; this.job = job;
@ -76,14 +75,6 @@ public class PutJobAction extends Action<PutJobAction.Request, PutJobAction.Resp
return job; return job;
} }
public boolean isOverwrite() {
return overwrite;
}
public void setOverwrite(boolean overwrite) {
this.overwrite = overwrite;
}
@Override @Override
public ActionRequestValidationException validate() { public ActionRequestValidationException validate() {
return null; return null;
@ -93,14 +84,12 @@ public class PutJobAction extends Action<PutJobAction.Request, PutJobAction.Resp
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
job = new Job(in); job = new Job(in);
overwrite = in.readBoolean();
} }
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
job.writeTo(out); job.writeTo(out);
out.writeBoolean(overwrite);
} }
@Override @Override
@ -114,13 +103,12 @@ public class PutJobAction extends Action<PutJobAction.Request, PutJobAction.Resp
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Request request = (Request) o; Request request = (Request) o;
return overwrite == request.overwrite && return Objects.equals(job, request.job);
Objects.equals(job, request.job);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(job, overwrite); return Objects.hash(job);
} }
@Override @Override

View File

@ -192,7 +192,7 @@ public class JobManager extends AbstractComponent {
@Override @Override
public ClusterState execute(ClusterState currentState) throws Exception { public ClusterState execute(ClusterState currentState) throws Exception {
ClusterState cs = updateClusterState(job, request.isOverwrite(), currentState); ClusterState cs = updateClusterState(job, false, currentState);
if (currentState.metaData().index(AnomalyDetectorsIndex.jobResultsIndexName(job.getIndexName())) != null) { if (currentState.metaData().index(AnomalyDetectorsIndex.jobResultsIndexName(job.getIndexName())) != null) {
throw new ResourceAlreadyExistsException(Messages.getMessage(Messages.JOB_INDEX_ALREADY_EXISTS, throw new ResourceAlreadyExistsException(Messages.getMessage(Messages.JOB_INDEX_ALREADY_EXISTS,
AnomalyDetectorsIndex.jobResultsIndexName(job.getIndexName()))); AnomalyDetectorsIndex.jobResultsIndexName(job.getIndexName())));

View File

@ -31,8 +31,6 @@ public class RestPutJobAction extends BaseRestHandler {
String jobId = restRequest.param(Job.ID.getPreferredName()); String jobId = restRequest.param(Job.ID.getPreferredName());
XContentParser parser = restRequest.contentParser(); XContentParser parser = restRequest.contentParser();
PutJobAction.Request putJobRequest = PutJobAction.Request.parseRequest(jobId, parser); PutJobAction.Request putJobRequest = PutJobAction.Request.parseRequest(jobId, parser);
boolean overwrite = restRequest.paramAsBoolean("overwrite", false);
putJobRequest.setOverwrite(overwrite);
return channel -> client.execute(PutJobAction.INSTANCE, putJobRequest, new RestToXContentListener<>(channel)); return channel -> client.execute(PutJobAction.INSTANCE, putJobRequest, new RestToXContentListener<>(channel));
} }

View File

@ -9,10 +9,6 @@
"type": "string", "type": "string",
"required": true, "required": true,
"description": "The ID of the job to create" "description": "The ID of the job to create"
},
"overwrite": {
"type": "boolean",
"description": "Overwrite an existing job"
} }
} }
}, },