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

View File

@ -192,7 +192,7 @@ public class JobManager extends AbstractComponent {
@Override
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) {
throw new ResourceAlreadyExistsException(Messages.getMessage(Messages.JOB_INDEX_ALREADY_EXISTS,
AnomalyDetectorsIndex.jobResultsIndexName(job.getIndexName())));

View File

@ -31,8 +31,6 @@ public class RestPutJobAction extends BaseRestHandler {
String jobId = restRequest.param(Job.ID.getPreferredName());
XContentParser parser = restRequest.contentParser();
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));
}

View File

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