-
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.
add APIs to Maintenance Mode in ILM (#31410)
- POST _xpack/index_lifecycle/_stop - issues a request to be placed into STOPPED mode (maintenance mode). This is not immediate, since we must first verify that it is safe to go from STOPPING -> STOPPED. - POST _xpack/index_lifecycle/_start - issues a request to be placed back into RUNNING mode (immediately) - GET _xpack/index_lifecycle/_status - get back the current mode our lifecycle management is in - update task was hardened to support uninstalled metadata - if no metadata is installed, the start/stop actions will install metadata and proceed to try and change it (default start mode is RUNNING) - rename MAINTENANCE -> STOPPED, MAINTENANCE_REQUESTED -> STOPPING, NORMAL -> RUNNING follow-up to #31164.
- Loading branch information
Showing
23 changed files
with
677 additions
and
80 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
112 changes: 112 additions & 0 deletions
112
...ore/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/GetStatusAction.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 GetStatusAction extends Action<GetStatusAction.Response> { | ||
public static final GetStatusAction INSTANCE = new GetStatusAction(); | ||
public static final String NAME = "cluster:admin/xpack/index_lifecycle/operation_mode/get"; | ||
|
||
protected GetStatusAction() { | ||
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/PutOperationModeAction.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 PutOperationModeAction extends Action<PutOperationModeAction.Response> { | ||
public static final PutOperationModeAction INSTANCE = new PutOperationModeAction(); | ||
public static final String NAME = "cluster:admin/xpack/index_lifecycle/operation_mode/set"; | ||
|
||
protected PutOperationModeAction() { | ||
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.