-
Notifications
You must be signed in to change notification settings - Fork 25.6k
HLRC: adding machine learning delete job #32820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
benwtrent
merged 6 commits into
elastic:master
from
benwtrent:feature/hlrc-ml-delete-job
Aug 16, 2018
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4b4c5a7
HLRC: adding machine learning delete job
benwtrent ade68e6
Fixing whitespace
benwtrent 7395363
Merge branch 'master' into feature/hlrc-ml-delete-job
benwtrent 7d4dae9
Moving docs and tests around
benwtrent 0e42388
Unifying ml asciidoc file naming convention
benwtrent 6c05b10
Merge branch 'master' into feature/hlrc-ml-delete-job
benwtrent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| [[java-rest-high-x-pack-ml-delete-job]] | ||
| === Delete Job API | ||
|
|
||
| [[java-rest-high-x-pack-machine-learning-delete-job-request]] | ||
| ==== Delete Job Request | ||
|
|
||
| A `DeleteJobRequest` object requires a non-null `jobId` and can optionally set `force`. | ||
| Can be executed as follows: | ||
|
|
||
| ["source","java",subs="attributes,callouts,macros"] | ||
| --------------------------------------------------- | ||
| include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-request] | ||
| --------------------------------------------------- | ||
| <1> Use to forcefully delete an opened job; | ||
| this method is quicker than closing and deleting the job. | ||
| Defaults to `false` | ||
|
|
||
| [[java-rest-high-x-pack-machine-learning-delete-job-response]] | ||
| ==== Delete Job Response | ||
|
|
||
| The returned `DeleteJobResponse` object indicates the acknowledgement of the request: | ||
| ["source","java",subs="attributes,callouts,macros"] | ||
| --------------------------------------------------- | ||
| include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-response] | ||
| --------------------------------------------------- | ||
| <1> `isAcknowledged` was the deletion request acknowledged or not | ||
|
|
||
| [[java-rest-high-x-pack-machine-learning-delete-job-async]] | ||
| ==== Delete Job Asynchronously | ||
|
|
||
| This request can also be made asynchronously. | ||
| ["source","java",subs="attributes,callouts,macros"] | ||
| --------------------------------------------------- | ||
| include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-request-async] | ||
| --------------------------------------------------- | ||
| <1> The `DeleteJobRequest` to execute and the `ActionListener` to alert on completion or error. | ||
|
|
||
| The deletion request returns immediately. Once the request is completed, the `ActionListener` is | ||
| called back using the `onResponse` or `onFailure`. The latter indicates some failure occurred when | ||
| making the request. | ||
|
|
||
| A typical listener for a `DeleteJobRequest` could be defined as follows: | ||
|
|
||
| ["source","java",subs="attributes,callouts,macros"] | ||
| --------------------------------------------------- | ||
| include-tagged::{doc-tests}/MlClientDocumentationIT.java[x-pack-delete-ml-job-request-listener] | ||
| --------------------------------------------------- | ||
| <1> The action to be taken when it is completed | ||
| <2> What to do when a failure occurs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/ml/DeleteJobRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * Licensed to Elasticsearch under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.elasticsearch.protocol.xpack.ml; | ||
|
|
||
| import org.elasticsearch.action.ActionRequest; | ||
| import org.elasticsearch.action.ActionRequestValidationException; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| public class DeleteJobRequest extends ActionRequest { | ||
|
|
||
| private String jobId; | ||
| private boolean force; | ||
|
|
||
| public DeleteJobRequest(String jobId) { | ||
| this.jobId = Objects.requireNonNull(jobId, "[job_id] must not be null"); | ||
| } | ||
|
|
||
| public String getJobId() { | ||
| return jobId; | ||
| } | ||
|
|
||
| public void setJobId(String jobId) { | ||
| this.jobId = Objects.requireNonNull(jobId, "[job_id] must not be null"); | ||
| } | ||
|
|
||
| public boolean isForce() { | ||
| return force; | ||
| } | ||
|
|
||
| public void setForce(boolean force) { | ||
| this.force = force; | ||
| } | ||
|
|
||
| @Override | ||
| public ActionRequestValidationException validate() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(jobId, force); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object obj) { | ||
| if (this == obj) { | ||
| return true; | ||
| } | ||
|
|
||
| if (obj == null || obj.getClass() != getClass()) { | ||
| return false; | ||
| } | ||
|
|
||
| DeleteJobRequest other = (DeleteJobRequest) obj; | ||
| return Objects.equals(jobId, other.jobId) && Objects.equals(force, other.force); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should consistently use hyphens or underscores for all our doc files. Looking at what the other teams have done, there's no consistent choice, but files do seem to consistently use one or the other within the same directory. So please can you choose and rename one of the files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good @droberts195