-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ML: Add upgrade mode docs, hlrc, and fix bug (#37942)
* ML: Add upgrade mode docs, hlrc, and fix bug * [DOCS] Fixes build error and edits text * adjusting docs * Update docs/reference/ml/apis/set-upgrade-mode.asciidoc Co-Authored-By: benwtrent <[email protected]> * Update set-upgrade-mode.asciidoc * Update set-upgrade-mode.asciidoc
- Loading branch information
Showing
13 changed files
with
407 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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 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
93 changes: 93 additions & 0 deletions
93
client/rest-high-level/src/main/java/org/elasticsearch/client/ml/SetUpgradeModeRequest.java
This file contains 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,93 @@ | ||
/* | ||
* 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.client.ml; | ||
|
||
import org.elasticsearch.action.ActionRequest; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.unit.TimeValue; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Sets ML into upgrade_mode | ||
*/ | ||
public class SetUpgradeModeRequest extends ActionRequest { | ||
|
||
|
||
public static final ParseField ENABLED = new ParseField("enabled"); | ||
public static final ParseField TIMEOUT = new ParseField("timeout"); | ||
|
||
private boolean enabled; | ||
private TimeValue timeout; | ||
|
||
/** | ||
* Create a new request | ||
* | ||
* @param enabled whether to enable `upgrade_mode` or not | ||
*/ | ||
public SetUpgradeModeRequest(boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
public void setEnabled(boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
public TimeValue getTimeout() { | ||
return timeout; | ||
} | ||
|
||
/** | ||
* How long to wait for the request to be completed | ||
* | ||
* @param timeout default value of 30 seconds | ||
*/ | ||
public void setTimeout(TimeValue timeout) { | ||
this.timeout = timeout; | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(enabled, timeout); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (this == other) { | ||
return true; | ||
} | ||
|
||
if (other == null || getClass() != other.getClass()) { | ||
return false; | ||
} | ||
|
||
SetUpgradeModeRequest that = (SetUpgradeModeRequest) other; | ||
return Objects.equals(enabled, that.enabled) && Objects.equals(timeout, that.timeout); | ||
} | ||
} |
This file contains 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 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 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 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,40 @@ | ||
-- | ||
:api: set-upgrade-mode | ||
:request: SetUpgradeModeRequest | ||
:response: AcknowledgedResponse | ||
-- | ||
[id="{upid}-{api}"] | ||
=== Set Upgrade Mode API | ||
|
||
The Set Upgrade Mode API temporarily halts all {ml} job and {dfeed} tasks when `enabled=true`. Their | ||
reported states remain unchanged. Consequently, when exiting upgrade mode the halted {ml} jobs and | ||
{dfeeds} will return to their previous state. | ||
|
||
It accepts a +{request}+ object and responds with a +{response}+ object. | ||
|
||
When `enabled=true`, no new jobs can be opened, and no job or {dfeed} tasks will | ||
be running. Be sure to set `enabled=false` once upgrade actions are completed. | ||
|
||
[id="{upid}-{api}-request"] | ||
==== Set Upgrade Mode Request | ||
|
||
A +{request}+ object gets created setting the desired `enabled` state. | ||
|
||
["source","java",subs="attributes,callouts,macros"] | ||
-------------------------------------------------- | ||
include-tagged::{doc-tests-file}[{api}-request] | ||
-------------------------------------------------- | ||
<1> Constructing a new request referencing enabling upgrade mode | ||
<2> Optionally setting the `timeout` value for how long the | ||
execution should wait. | ||
|
||
[id="{upid}-{api}-response"] | ||
==== Set Upgrade Mode Response | ||
|
||
["source","java",subs="attributes,callouts,macros"] | ||
-------------------------------------------------- | ||
include-tagged::{doc-tests-file}[{api}-response] | ||
-------------------------------------------------- | ||
<1> `isAcknowledged()` from the +{response}+ indicates if the setting was set successfully. | ||
|
||
include::../execution.asciidoc[] |
This file contains 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
Oops, something went wrong.