-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
add APIs to Maintenance Mode in ILM #31410
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3fba65f
add APIs to Maintenance Mode in ILM
talevy 7100a55
Merge branch 'index-lifecycle' into ilm-maintenance-api
talevy 41a8ed3
refactor to leverage new APIs and remove notion of maintenace_mode
talevy b172873
Merge branch 'index-lifecycle' into ilm-maintenance-api
talevy fdd78e5
rename and fix tests
talevy 703bab7
Merge branch 'index-lifecycle' into ilm-maintenance-api
talevy 29e47a7
Merge branch 'index-lifecycle' into ilm-maintenance-api
talevy 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 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
112 changes: 112 additions & 0 deletions
112
...java/org/elasticsearch/xpack/core/indexlifecycle/action/GetOperationModeStatusAction.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,112 @@ | ||
/* | ||
* 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.core.indexlifecycle.action; | ||
|
||
import org.elasticsearch.action.Action; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.ActionResponse; | ||
import org.elasticsearch.action.support.master.AcknowledgedRequest; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.common.xcontent.ToXContentObject; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class GetOperationModeStatusAction extends Action<GetOperationModeStatusAction.Response> { | ||
public static final GetOperationModeStatusAction INSTANCE = new GetOperationModeStatusAction(); | ||
public static final String NAME = "cluster:admin/xpack/index_lifecycle/operation_mode/get"; | ||
|
||
protected GetOperationModeStatusAction() { | ||
super(NAME); | ||
} | ||
|
||
@Override | ||
public Response newResponse() { | ||
return new Response(); | ||
} | ||
|
||
public static class Response extends ActionResponse implements ToXContentObject { | ||
|
||
private OperationMode mode; | ||
|
||
public Response() { | ||
} | ||
|
||
public Response(OperationMode mode) { | ||
this.mode = mode; | ||
} | ||
|
||
public OperationMode getMode() { | ||
return mode; | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.field("operation_mode", mode); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
mode = in.readEnum(OperationMode.class); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeEnum(mode); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(mode); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (obj.getClass() != getClass()) { | ||
return false; | ||
} | ||
Response other = (Response) obj; | ||
return Objects.equals(mode, other.mode); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return Strings.toString(this, true, true); | ||
} | ||
|
||
} | ||
|
||
public static class Request extends AcknowledgedRequest<Request> { | ||
|
||
public Request() { | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
} | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
.../main/java/org/elasticsearch/xpack/core/indexlifecycle/action/SetOperationModeAction.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,98 @@ | ||
/* | ||
* 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.core.indexlifecycle.action; | ||
|
||
import org.elasticsearch.action.Action; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.support.master.AcknowledgedRequest; | ||
import org.elasticsearch.action.support.master.AcknowledgedResponse; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.common.xcontent.ToXContentObject; | ||
import org.elasticsearch.xpack.core.indexlifecycle.OperationMode; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class SetOperationModeAction extends Action<SetOperationModeAction.Response> { | ||
public static final SetOperationModeAction INSTANCE = new SetOperationModeAction(); | ||
public static final String NAME = "cluster:admin/xpack/index_lifecycle/operation_mode/set"; | ||
|
||
protected SetOperationModeAction() { | ||
super(NAME); | ||
} | ||
|
||
@Override | ||
public Response newResponse() { | ||
return new Response(); | ||
} | ||
|
||
public static class Response extends AcknowledgedResponse implements ToXContentObject { | ||
|
||
public Response() { | ||
} | ||
|
||
public Response(boolean acknowledged) { | ||
super(acknowledged); | ||
} | ||
} | ||
|
||
public static class Request extends AcknowledgedRequest<Request> { | ||
|
||
private OperationMode mode; | ||
|
||
public Request(OperationMode mode) { | ||
this.mode = mode; | ||
} | ||
|
||
public Request() { | ||
} | ||
|
||
public OperationMode getMode() { | ||
return mode; | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
if (mode == OperationMode.STOPPED) { | ||
ActionRequestValidationException exception = new ActionRequestValidationException(); | ||
exception.addValidationError("cannot directly stop index-lifecycle"); | ||
return exception; | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
mode = in.readEnum(OperationMode.class); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeEnum(mode); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(mode); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (obj.getClass() != getClass()) { | ||
return false; | ||
} | ||
Request other = (Request) obj; | ||
return Objects.equals(mode, other.mode); | ||
} | ||
} | ||
|
||
} |
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.
Maybe to be consistent with the naming of the other APIs in Elasticsearch we should call this
Put
instead ofSet
?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 suppose this felt weird since I am not PUTing a resty resource, especially since it is being exposed by APIs that do not necessarily ever set a specific operation-mode directly, like
STOPPED
.Given all of ^, I also view this as a pedantic argument that loses in the battle of consistency 😄. So I will rename