diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndexLifecycleClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndexLifecycleClient.java
index eaeaa147bff85..21fb4a0062402 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndexLifecycleClient.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndexLifecycleClient.java
@@ -20,10 +20,13 @@
package org.elasticsearch.client;
import org.elasticsearch.action.ActionListener;
+import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.protocol.xpack.indexlifecycle.ExplainLifecycleRequest;
import org.elasticsearch.protocol.xpack.indexlifecycle.ExplainLifecycleResponse;
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyRequest;
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyResponse;
+import org.elasticsearch.protocol.xpack.indexlifecycle.StartILMRequest;
+import org.elasticsearch.protocol.xpack.indexlifecycle.StopILMRequest;
import java.io.IOException;
@@ -65,6 +68,60 @@ public void setIndexLifecyclePolicyAsync(SetIndexLifecyclePolicyRequest request,
SetIndexLifecyclePolicyResponse::fromXContent, listener, emptySet());
}
+ /**
+ * Start the Index Lifecycle Management feature.
+ * See
+ * the docs for more.
+ * @param request the request
+ * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
+ * @return the response
+ * @throws IOException in case there is a problem sending the request or parsing back the response
+ */
+ public AcknowledgedResponse startILM(StartILMRequest request, RequestOptions options) throws IOException {
+ return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::startILM, options,
+ AcknowledgedResponse::fromXContent, emptySet());
+ }
+
+ /**
+ * Asynchronously start the Index Lifecycle Management feature.
+ * See
+ * the docs for more.
+ * @param request the request
+ * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
+ * @param listener the listener to be notified upon request completion
+ */
+ public void startILMAsync(StartILMRequest request, RequestOptions options, ActionListener listener) {
+ restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::startILM, options,
+ AcknowledgedResponse::fromXContent, listener, emptySet());
+ }
+
+ /**
+ * Stop the Index Lifecycle Management feature.
+ * See
+ * the docs for more.
+ * @param request the request
+ * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
+ * @return the response
+ * @throws IOException in case there is a problem sending the request or parsing back the response
+ */
+ public AcknowledgedResponse stopILM(StopILMRequest request, RequestOptions options) throws IOException {
+ return restHighLevelClient.performRequestAndParseEntity(request, RequestConverters::stopILM, options,
+ AcknowledgedResponse::fromXContent, emptySet());
+ }
+
+ /**
+ * Asynchronously stop the Index Lifecycle Management feature.
+ * See
+ * the docs for more.
+ * @param request the request
+ * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
+ * @param listener the listener to be notified upon request completion
+ */
+ public void stopILMAsync(StopILMRequest request, RequestOptions options, ActionListener listener) {
+ restHighLevelClient.performRequestAsyncAndParseEntity(request, RequestConverters::stopILM, options,
+ AcknowledgedResponse::fromXContent, listener, emptySet());
+ }
+
/**
* Explain the lifecycle state for an index
* See
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java
index 45491147200c7..577e3f37a324a 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java
@@ -107,10 +107,12 @@
import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.rankeval.RankEvalRequest;
import org.elasticsearch.protocol.xpack.XPackInfoRequest;
-import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
import org.elasticsearch.protocol.xpack.XPackUsageRequest;
import org.elasticsearch.protocol.xpack.indexlifecycle.ExplainLifecycleRequest;
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyRequest;
+import org.elasticsearch.protocol.xpack.indexlifecycle.StartILMRequest;
+import org.elasticsearch.protocol.xpack.indexlifecycle.StopILMRequest;
+import org.elasticsearch.protocol.xpack.license.GetLicenseRequest;
import org.elasticsearch.protocol.xpack.license.PutLicenseRequest;
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
@@ -1170,6 +1172,30 @@ static Request setIndexLifecyclePolicy(SetIndexLifecyclePolicyRequest setPolicyR
return request;
}
+ static Request startILM(StartILMRequest startILMRequest) {
+ Request request = new Request(HttpPost.METHOD_NAME,
+ new EndpointBuilder()
+ .addPathPartAsIs("_ilm")
+ .addPathPartAsIs("start")
+ .build());
+ Params params = new Params(request);
+ params.withMasterTimeout(startILMRequest.masterNodeTimeout());
+ params.withTimeout(startILMRequest.timeout());
+ return request;
+ }
+
+ static Request stopILM(StopILMRequest stopILMRequest) {
+ Request request = new Request(HttpPost.METHOD_NAME,
+ new EndpointBuilder()
+ .addPathPartAsIs("_ilm")
+ .addPathPartAsIs("stop")
+ .build());
+ Params params = new Params(request);
+ params.withMasterTimeout(stopILMRequest.masterNodeTimeout());
+ params.withTimeout(stopILMRequest.timeout());
+ return request;
+ }
+
static Request explainLifecycle(ExplainLifecycleRequest explainLifecycleRequest) {
String[] indices = explainLifecycleRequest.indices() == null ? Strings.EMPTY_ARRAY : explainLifecycleRequest.indices();
Request request = new Request(HttpGet.METHOD_NAME,
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndexLifecycleIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndexLifecycleIT.java
index 661caccd7a20b..faa8e6ef498f4 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndexLifecycleIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndexLifecycleIT.java
@@ -22,14 +22,19 @@
import org.apache.http.HttpEntity;
import org.apache.http.entity.ContentType;
import org.apache.http.nio.entity.NStringEntity;
+import org.apache.http.util.EntityUtils;
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest;
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
+import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.protocol.xpack.indexlifecycle.ExplainLifecycleRequest;
import org.elasticsearch.protocol.xpack.indexlifecycle.ExplainLifecycleResponse;
import org.elasticsearch.protocol.xpack.indexlifecycle.IndexLifecycleExplainResponse;
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyRequest;
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyResponse;
+import org.elasticsearch.protocol.xpack.indexlifecycle.StartILMRequest;
+import org.elasticsearch.protocol.xpack.indexlifecycle.StopILMRequest;
+import org.hamcrest.Matchers;
import java.util.Map;
@@ -106,6 +111,94 @@ public void testSetIndexLifecyclePolicy() throws Exception {
assertThat(settingsResponse.getSetting("baz", "index.lifecycle.name"), equalTo(policy));
}
+ public void testStartStopILM() throws Exception {
+ String policy = randomAlphaOfLength(10);
+
+ // TODO: NORELEASE convert this to using the high level client once there are APIs for it
+ String jsonString = "{\n" +
+ " \"policy\": {\n" +
+ " \"type\": \"timeseries\",\n" +
+ " \"phases\": {\n" +
+ " \"hot\": {\n" +
+ " \"actions\": {\n" +
+ " \"rollover\": {\n" +
+ " \"max_age\": \"50d\"\n" +
+ " } \n" +
+ " }\n" +
+ " },\n" +
+ " \"warm\": {\n" +
+ " \"after\": \"1000s\",\n" +
+ " \"actions\": {\n" +
+ " \"allocate\": {\n" +
+ " \"require\": { \"_name\": \"node-1\" },\n" +
+ " \"include\": {},\n" +
+ " \"exclude\": {}\n" +
+ " },\n" +
+ " \"shrink\": {\n" +
+ " \"number_of_shards\": 1\n" +
+ " },\n" +
+ " \"forcemerge\": {\n" +
+ " \"max_num_segments\": 1000\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"cold\": {\n" +
+ " \"after\": \"2000s\",\n" +
+ " \"actions\": {\n" +
+ " \"allocate\": {\n" +
+ " \"number_of_replicas\": 0\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"delete\": {\n" +
+ " \"after\": \"3000s\",\n" +
+ " \"actions\": {\n" +
+ " \"delete\": {}\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}";
+ HttpEntity entity = new NStringEntity(jsonString, ContentType.APPLICATION_JSON);
+ Request request = new Request("PUT", "/_ilm/" + policy);
+ request.setEntity(entity);
+ client().performRequest(request);
+
+ createIndex("foo", Settings.builder().put("index.lifecycle.name", "bar").build());
+ createIndex("baz", Settings.builder().put("index.lifecycle.name", "eggplant").build());
+ createIndex("squash", Settings.EMPTY);
+
+ // TODO: NORELEASE convert this to using the high level client once
+ // there are APIs for it
+ Request statusReq = new Request("GET", "/_ilm/status");
+ Response statusResponse = client().performRequest(statusReq);
+ String statusResponseString = EntityUtils.toString(statusResponse.getEntity());
+ assertEquals("{\"operation_mode\":\"RUNNING\"}", statusResponseString);
+
+ StopILMRequest stopReq = new StopILMRequest();
+ AcknowledgedResponse stopResponse = execute(stopReq, highLevelClient().indexLifecycle()::stopILM,
+ highLevelClient().indexLifecycle()::stopILMAsync);
+ assertTrue(stopResponse.isAcknowledged());
+
+ // TODO: NORELEASE convert this to using the high level client once there are APIs for it
+ statusReq = new Request("GET", "/_ilm/status");
+ statusResponse = client().performRequest(statusReq);
+ statusResponseString = EntityUtils.toString(statusResponse.getEntity());
+ assertThat(statusResponseString,
+ Matchers.anyOf(equalTo("{\"operation_mode\":\"STOPPING\"}"), equalTo("{\"operation_mode\":\"STOPPED\"}")));
+
+ StartILMRequest startReq = new StartILMRequest();
+ AcknowledgedResponse startResponse = execute(startReq, highLevelClient().indexLifecycle()::startILM,
+ highLevelClient().indexLifecycle()::startILMAsync);
+ assertTrue(startResponse.isAcknowledged());
+
+ // TODO: NORELEASE convert this to using the high level client once there are APIs for it
+ statusReq = new Request("GET", "/_ilm/status");
+ statusResponse = client().performRequest(statusReq);
+ statusResponseString = EntityUtils.toString(statusResponse.getEntity());
+ assertEquals("{\"operation_mode\":\"RUNNING\"}", statusResponseString);
+ }
+
public void testExplainLifecycle() throws Exception {
String policy = randomAlphaOfLength(10);
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java
index a8b0c845dcd36..8172ee38375eb 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java
@@ -128,6 +128,8 @@
import org.elasticsearch.protocol.xpack.XPackInfoRequest;
import org.elasticsearch.protocol.xpack.indexlifecycle.ExplainLifecycleRequest;
import org.elasticsearch.protocol.xpack.indexlifecycle.SetIndexLifecyclePolicyRequest;
+import org.elasticsearch.protocol.xpack.indexlifecycle.StartILMRequest;
+import org.elasticsearch.protocol.xpack.indexlifecycle.StopILMRequest;
import org.elasticsearch.protocol.xpack.watcher.DeleteWatchRequest;
import org.elasticsearch.protocol.xpack.watcher.PutWatchRequest;
import org.elasticsearch.repositories.fs.FsRepository;
@@ -2602,6 +2604,30 @@ public void testSetIndexLifecyclePolicy() throws Exception {
assertThat(request.getParameters(), equalTo(expectedParams));
}
+ public void testStartILM() throws Exception {
+ StartILMRequest req = new StartILMRequest();
+ Map expectedParams = new HashMap<>();
+ setRandomMasterTimeout(req, expectedParams);
+ setRandomTimeout(req::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
+
+ Request request = RequestConverters.startILM(req);
+ assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME));
+ assertThat(request.getEndpoint(), equalTo("/_ilm/start"));
+ assertThat(request.getParameters(), equalTo(expectedParams));
+ }
+
+ public void testStopILM() throws Exception {
+ StopILMRequest req = new StopILMRequest();
+ Map expectedParams = new HashMap<>();
+ setRandomMasterTimeout(req, expectedParams);
+ setRandomTimeout(req::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams);
+
+ Request request = RequestConverters.stopILM(req);
+ assertThat(request.getMethod(), equalTo(HttpPost.METHOD_NAME));
+ assertThat(request.getEndpoint(), equalTo("/_ilm/stop"));
+ assertThat(request.getParameters(), equalTo(expectedParams));
+ }
+
public void testExplainLifecycle() throws Exception {
ExplainLifecycleRequest req = new ExplainLifecycleRequest();
String[] indices = rarely() ? null : randomIndicesNames(0, 10);
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/IndexLifecycleMetadata.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/IndexLifecycleMetadata.java
index b2322dd326823..03690e762ede4 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/IndexLifecycleMetadata.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/IndexLifecycleMetadata.java
@@ -18,6 +18,7 @@
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.XPackPlugin.XPackMetaDataCustom;
import java.io.IOException;
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/GetStatusAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/GetStatusAction.java
index 40765f0aa6650..55cb9b0edb4b5 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/GetStatusAction.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/GetStatusAction.java
@@ -15,7 +15,7 @@
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 org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
import java.io.IOException;
import java.util.Objects;
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/PutOperationModeAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/PutOperationModeAction.java
deleted file mode 100644
index 3098fb02391a5..0000000000000
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/PutOperationModeAction.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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 {
- public static final PutOperationModeAction INSTANCE = new PutOperationModeAction();
- public static final String NAME = "cluster:admin/ilm/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 {
-
- 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);
- }
- }
-
-}
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/StartILMAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/StartILMAction.java
new file mode 100644
index 0000000000000..5d2f066d60b15
--- /dev/null
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/StartILMAction.java
@@ -0,0 +1,25 @@
+/*
+ * 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.support.master.AcknowledgedResponse;
+
+public class StartILMAction extends Action {
+ public static final StartILMAction INSTANCE = new StartILMAction();
+ public static final String NAME = "cluster:admin/ilm/start";
+
+ protected StartILMAction() {
+ super(NAME);
+ }
+
+ @Override
+ public AcknowledgedResponse newResponse() {
+ return new AcknowledgedResponse();
+ }
+
+}
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/StopILMAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/StopILMAction.java
new file mode 100644
index 0000000000000..63adeabb30f90
--- /dev/null
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/StopILMAction.java
@@ -0,0 +1,25 @@
+/*
+ * 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.support.master.AcknowledgedResponse;
+
+public class StopILMAction extends Action {
+ public static final StopILMAction INSTANCE = new StopILMAction();
+ public static final String NAME = "cluster:admin/ilm/stop";
+
+ protected StopILMAction() {
+ super(NAME);
+ }
+
+ @Override
+ public AcknowledgedResponse newResponse() {
+ return new AcknowledgedResponse();
+ }
+
+}
diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycle.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycle.java
index 48acf5c701ee0..e5c57436190b4 100644
--- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycle.java
+++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycle.java
@@ -40,10 +40,11 @@
import org.elasticsearch.xpack.core.indexlifecycle.action.GetStatusAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.MoveToStepAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction;
-import org.elasticsearch.xpack.core.indexlifecycle.action.PutOperationModeAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.RemovePolicyForIndexAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.RetryAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.SetIndexLifecyclePolicyAction;
+import org.elasticsearch.xpack.core.indexlifecycle.action.StartILMAction;
+import org.elasticsearch.xpack.core.indexlifecycle.action.StopILMAction;
import org.elasticsearch.xpack.indexlifecycle.action.RestDeleteLifecycleAction;
import org.elasticsearch.xpack.indexlifecycle.action.RestExplainLifecycleAction;
import org.elasticsearch.xpack.indexlifecycle.action.RestGetLifecycleAction;
@@ -53,7 +54,7 @@
import org.elasticsearch.xpack.indexlifecycle.action.RestRemovePolicyForIndexAction;
import org.elasticsearch.xpack.indexlifecycle.action.RestRetryAction;
import org.elasticsearch.xpack.indexlifecycle.action.RestSetIndexLifecyclePolicyAction;
-import org.elasticsearch.xpack.indexlifecycle.action.RestStartAction;
+import org.elasticsearch.xpack.indexlifecycle.action.RestStartILMAction;
import org.elasticsearch.xpack.indexlifecycle.action.RestStopAction;
import org.elasticsearch.xpack.indexlifecycle.action.TransportDeleteLifecycleAction;
import org.elasticsearch.xpack.indexlifecycle.action.TransportExplainLifecycleAction;
@@ -61,10 +62,11 @@
import org.elasticsearch.xpack.indexlifecycle.action.TransportGetStatusAction;
import org.elasticsearch.xpack.indexlifecycle.action.TransportMoveToStepAction;
import org.elasticsearch.xpack.indexlifecycle.action.TransportPutLifecycleAction;
-import org.elasticsearch.xpack.indexlifecycle.action.TransportPutOperationModeAction;
import org.elasticsearch.xpack.indexlifecycle.action.TransportRemovePolicyForIndexAction;
import org.elasticsearch.xpack.indexlifecycle.action.TransportRetryAction;
import org.elasticsearch.xpack.indexlifecycle.action.TransportSetIndexLifecyclePolicyAction;
+import org.elasticsearch.xpack.indexlifecycle.action.TransportStartILMAction;
+import org.elasticsearch.xpack.indexlifecycle.action.TransportStopILMAction;
import java.time.Clock;
import java.util.ArrayList;
@@ -164,7 +166,7 @@ public List getRestHandlers(Settings settings, RestController restC
new RestMoveToStepAction(settings, restController),
new RestRetryAction(settings, restController),
new RestStopAction(settings, restController),
- new RestStartAction(settings, restController),
+ new RestStartILMAction(settings, restController),
new RestGetStatusAction(settings, restController)
);
}
@@ -183,7 +185,8 @@ public List getRestHandlers(Settings settings, RestController restC
new ActionHandler<>(RemovePolicyForIndexAction.INSTANCE, TransportRemovePolicyForIndexAction.class),
new ActionHandler<>(MoveToStepAction.INSTANCE, TransportMoveToStepAction.class),
new ActionHandler<>(RetryAction.INSTANCE, TransportRetryAction.class),
- new ActionHandler<>(PutOperationModeAction.INSTANCE, TransportPutOperationModeAction.class),
+ new ActionHandler<>(StartILMAction.INSTANCE, TransportStartILMAction.class),
+ new ActionHandler<>(StopILMAction.INSTANCE, TransportStopILMAction.class),
new ActionHandler<>(GetStatusAction.INSTANCE, TransportGetStatusAction.class));
}
diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleService.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleService.java
index 486bc8cce8a94..8c7447be3b471 100644
--- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleService.java
+++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleService.java
@@ -20,10 +20,10 @@
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
+import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy;
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleSettings;
-import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.ShrinkAction;
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
import org.elasticsearch.xpack.core.scheduler.SchedulerEngine;
diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/OperationModeUpdateTask.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/OperationModeUpdateTask.java
index 1956e5bb0e192..871a782a9acea 100644
--- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/OperationModeUpdateTask.java
+++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/OperationModeUpdateTask.java
@@ -10,8 +10,8 @@
import org.elasticsearch.cluster.ClusterStateUpdateTask;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.logging.ESLoggerFactory;
+import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
-import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
public class OperationModeUpdateTask extends ClusterStateUpdateTask {
private static final Logger logger = ESLoggerFactory.getLogger(OperationModeUpdateTask.class);
diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestStartAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestStartILMAction.java
similarity index 68%
rename from x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestStartAction.java
rename to x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestStartILMAction.java
index c097c14a57501..5c36aef33bd7d 100644
--- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestStartAction.java
+++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestStartILMAction.java
@@ -8,16 +8,16 @@
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.protocol.xpack.indexlifecycle.StartILMRequest;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.RestToXContentListener;
-import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
-import org.elasticsearch.xpack.core.indexlifecycle.action.PutOperationModeAction;
+import org.elasticsearch.xpack.core.indexlifecycle.action.StartILMAction;
-public class RestStartAction extends BaseRestHandler {
+public class RestStartILMAction extends BaseRestHandler {
- public RestStartAction(Settings settings, RestController controller) {
+ public RestStartILMAction(Settings settings, RestController controller) {
super(settings);
controller.registerHandler(RestRequest.Method.POST, "/_ilm/start", this);
}
@@ -29,9 +29,9 @@ public String getName() {
@Override
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) {
- PutOperationModeAction.Request request = new PutOperationModeAction.Request(OperationMode.RUNNING);
+ StartILMRequest request = new StartILMRequest();
request.timeout(restRequest.paramAsTime("timeout", request.timeout()));
request.masterNodeTimeout(restRequest.paramAsTime("master_timeout", request.masterNodeTimeout()));
- return channel -> client.execute(PutOperationModeAction.INSTANCE, request, new RestToXContentListener<>(channel));
+ return channel -> client.execute(StartILMAction.INSTANCE, request, new RestToXContentListener<>(channel));
}
}
diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestStopAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestStopAction.java
index 472a8cc8bb4c0..7a5aae6843000 100644
--- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestStopAction.java
+++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestStopAction.java
@@ -8,12 +8,12 @@
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.protocol.xpack.indexlifecycle.StopILMRequest;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.RestToXContentListener;
-import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
-import org.elasticsearch.xpack.core.indexlifecycle.action.PutOperationModeAction;
+import org.elasticsearch.xpack.core.indexlifecycle.action.StopILMAction;
public class RestStopAction extends BaseRestHandler {
@@ -29,9 +29,9 @@ public String getName() {
@Override
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) {
- PutOperationModeAction.Request request = new PutOperationModeAction.Request(OperationMode.STOPPING);
+ StopILMRequest request = new StopILMRequest();
request.timeout(restRequest.paramAsTime("timeout", request.timeout()));
request.masterNodeTimeout(restRequest.paramAsTime("master_timeout", request.masterNodeTimeout()));
- return channel -> client.execute(PutOperationModeAction.INSTANCE, request, new RestToXContentListener<>(channel));
+ return channel -> client.execute(StopILMAction.INSTANCE, request, new RestToXContentListener<>(channel));
}
}
diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportGetStatusAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportGetStatusAction.java
index 5d7b2b159c08e..2e20a8a20ebc9 100644
--- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportGetStatusAction.java
+++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportGetStatusAction.java
@@ -16,10 +16,10 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
-import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.action.GetStatusAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.GetStatusAction.Request;
import org.elasticsearch.xpack.core.indexlifecycle.action.GetStatusAction.Response;
diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportPutLifecycleAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportPutLifecycleAction.java
index e6797137e6559..db8f9ef65f250 100644
--- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportPutLifecycleAction.java
+++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportPutLifecycleAction.java
@@ -19,12 +19,12 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.core.ClientHelper;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicyMetadata;
-import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction;
import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction.Request;
import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction.Response;
diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportStartILMAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportStartILMAction.java
new file mode 100644
index 0000000000000..3d26cf652875d
--- /dev/null
+++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportStartILMAction.java
@@ -0,0 +1,68 @@
+/*
+ * 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.indexlifecycle.action;
+
+import org.elasticsearch.action.ActionListener;
+import org.elasticsearch.action.support.ActionFilters;
+import org.elasticsearch.action.support.master.AcknowledgedResponse;
+import org.elasticsearch.action.support.master.TransportMasterNodeAction;
+import org.elasticsearch.cluster.AckedClusterStateUpdateTask;
+import org.elasticsearch.cluster.ClusterState;
+import org.elasticsearch.cluster.block.ClusterBlockException;
+import org.elasticsearch.cluster.block.ClusterBlockLevel;
+import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
+import org.elasticsearch.cluster.service.ClusterService;
+import org.elasticsearch.common.inject.Inject;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
+import org.elasticsearch.protocol.xpack.indexlifecycle.StartILMRequest;
+import org.elasticsearch.threadpool.ThreadPool;
+import org.elasticsearch.transport.TransportService;
+import org.elasticsearch.xpack.core.indexlifecycle.action.StartILMAction;
+import org.elasticsearch.xpack.indexlifecycle.OperationModeUpdateTask;
+
+public class TransportStartILMAction extends TransportMasterNodeAction {
+
+ @Inject
+ public TransportStartILMAction(Settings settings, TransportService transportService, ClusterService clusterService,
+ ThreadPool threadPool, ActionFilters actionFilters,
+ IndexNameExpressionResolver indexNameExpressionResolver) {
+ super(settings, StartILMAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver,
+ StartILMRequest::new);
+ }
+
+ @Override
+ protected String executor() {
+ return ThreadPool.Names.SAME;
+ }
+
+ @Override
+ protected AcknowledgedResponse newResponse() {
+ return new AcknowledgedResponse();
+ }
+
+ @Override
+ protected void masterOperation(StartILMRequest request, ClusterState state, ActionListener listener) {
+ clusterService.submitStateUpdateTask("ilm_operation_mode_update",
+ new AckedClusterStateUpdateTask(request, listener) {
+ @Override
+ public ClusterState execute(ClusterState currentState) {
+ return (new OperationModeUpdateTask(OperationMode.RUNNING)).execute(currentState);
+ }
+
+ @Override
+ protected AcknowledgedResponse newResponse(boolean acknowledged) {
+ return new AcknowledgedResponse(acknowledged);
+ }
+ });
+ }
+
+ @Override
+ protected ClusterBlockException checkBlock(StartILMRequest request, ClusterState state) {
+ return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
+ }
+}
diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportPutOperationModeAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportStopILMAction.java
similarity index 51%
rename from x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportPutOperationModeAction.java
rename to x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportStopILMAction.java
index 257527076a2c0..992b5b286aee1 100644
--- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportPutOperationModeAction.java
+++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportStopILMAction.java
@@ -8,6 +8,7 @@
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
+import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
import org.elasticsearch.cluster.AckedClusterStateUpdateTask;
import org.elasticsearch.cluster.ClusterState;
@@ -17,21 +18,21 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
+import org.elasticsearch.protocol.xpack.indexlifecycle.StopILMRequest;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
-import org.elasticsearch.xpack.core.indexlifecycle.action.PutOperationModeAction;
-import org.elasticsearch.xpack.core.indexlifecycle.action.PutOperationModeAction.Request;
-import org.elasticsearch.xpack.core.indexlifecycle.action.PutOperationModeAction.Response;
+import org.elasticsearch.xpack.core.indexlifecycle.action.StopILMAction;
import org.elasticsearch.xpack.indexlifecycle.OperationModeUpdateTask;
-public class TransportPutOperationModeAction extends TransportMasterNodeAction {
+public class TransportStopILMAction extends TransportMasterNodeAction {
@Inject
- public TransportPutOperationModeAction(Settings settings, TransportService transportService, ClusterService clusterService,
- ThreadPool threadPool, ActionFilters actionFilters,
- IndexNameExpressionResolver indexNameExpressionResolver) {
- super(settings, PutOperationModeAction.NAME, transportService, clusterService, threadPool, actionFilters,
- indexNameExpressionResolver, Request::new);
+ public TransportStopILMAction(Settings settings, TransportService transportService, ClusterService clusterService,
+ ThreadPool threadPool, ActionFilters actionFilters,
+ IndexNameExpressionResolver indexNameExpressionResolver) {
+ super(settings, StopILMAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver,
+ StopILMRequest::new);
}
@Override
@@ -40,28 +41,28 @@ protected String executor() {
}
@Override
- protected Response newResponse() {
- return new Response();
+ protected AcknowledgedResponse newResponse() {
+ return new AcknowledgedResponse();
}
@Override
- protected void masterOperation(Request request, ClusterState state, ActionListener listener) {
+ protected void masterOperation(StopILMRequest request, ClusterState state, ActionListener listener) {
clusterService.submitStateUpdateTask("ilm_operation_mode_update",
- new AckedClusterStateUpdateTask(request, listener) {
+ new AckedClusterStateUpdateTask(request, listener) {
@Override
public ClusterState execute(ClusterState currentState) {
- return (new OperationModeUpdateTask(request.getMode())).execute(currentState);
+ return (new OperationModeUpdateTask(OperationMode.STOPPING)).execute(currentState);
}
@Override
- protected Response newResponse(boolean acknowledged) {
- return new Response(acknowledged);
+ protected AcknowledgedResponse newResponse(boolean acknowledged) {
+ return new AcknowledgedResponse(acknowledged);
}
});
}
@Override
- protected ClusterBlockException checkBlock(Request request, ClusterState state) {
+ protected ClusterBlockException checkBlock(StopILMRequest request, ClusterState state) {
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
}
}
diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/ExecuteStepsUpdateTaskTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/ExecuteStepsUpdateTaskTests.java
index 79de60d812b61..56100d145eccb 100644
--- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/ExecuteStepsUpdateTaskTests.java
+++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/ExecuteStepsUpdateTaskTests.java
@@ -20,6 +20,7 @@
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.Index;
import org.elasticsearch.node.Node;
+import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy;
@@ -27,7 +28,6 @@
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleSettings;
import org.elasticsearch.xpack.core.indexlifecycle.MockAction;
import org.elasticsearch.xpack.core.indexlifecycle.MockStep;
-import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.Phase;
import org.elasticsearch.xpack.core.indexlifecycle.Step;
import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey;
diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleMetadataTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleMetadataTests.java
index eaf34c0cc4f45..db4e1bd3a431e 100644
--- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleMetadataTests.java
+++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleMetadataTests.java
@@ -16,6 +16,7 @@
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.XContentParser;
+import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
import org.elasticsearch.test.AbstractDiffableSerializationTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.DeleteAction;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
@@ -24,7 +25,6 @@
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy;
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicyMetadata;
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleType;
-import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.Phase;
import org.elasticsearch.xpack.core.indexlifecycle.TestLifecycleType;
diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunnerTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunnerTests.java
index 21f089b8ffa23..70f1c469bbdd7 100644
--- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunnerTests.java
+++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleRunnerTests.java
@@ -22,6 +22,7 @@
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.index.Index;
+import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.AbstractStepTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.AsyncActionStep;
@@ -36,7 +37,6 @@
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleSettings;
import org.elasticsearch.xpack.core.indexlifecycle.MockAction;
import org.elasticsearch.xpack.core.indexlifecycle.MockStep;
-import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.Phase;
import org.elasticsearch.xpack.core.indexlifecycle.RolloverAction;
import org.elasticsearch.xpack.core.indexlifecycle.Step;
diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleServiceTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleServiceTests.java
index 99cfe87ee1767..2d58afa0159c0 100644
--- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleServiceTests.java
+++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/IndexLifecycleServiceTests.java
@@ -24,13 +24,13 @@
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.Index;
+import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy;
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicyMetadata;
import org.elasticsearch.xpack.core.indexlifecycle.LifecycleSettings;
import org.elasticsearch.xpack.core.indexlifecycle.MockAction;
-import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.Phase;
import org.elasticsearch.xpack.core.indexlifecycle.ShrinkAction;
import org.elasticsearch.xpack.core.indexlifecycle.Step;
diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/OperationModeUpdateTaskTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/OperationModeUpdateTaskTests.java
index 1b934c1d928b3..cb0ba186ef30f 100644
--- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/OperationModeUpdateTaskTests.java
+++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/OperationModeUpdateTaskTests.java
@@ -10,9 +10,9 @@
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.collect.ImmutableOpenMap;
+import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
-import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
import java.util.Collections;
diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/PolicyStepsRegistryTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/PolicyStepsRegistryTests.java
index 627ea574382db..9e636f49d5473 100644
--- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/PolicyStepsRegistryTests.java
+++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/PolicyStepsRegistryTests.java
@@ -15,6 +15,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.node.Node;
+import org.elasticsearch.protocol.xpack.indexlifecycle.OperationMode;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xpack.core.indexlifecycle.ErrorStep;
import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata;
@@ -22,7 +23,6 @@
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicyMetadata;
import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicyTests;
import org.elasticsearch.xpack.core.indexlifecycle.MockStep;
-import org.elasticsearch.xpack.core.indexlifecycle.OperationMode;
import org.elasticsearch.xpack.core.indexlifecycle.Step;
import org.mockito.Mockito;
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/OperationMode.java b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/indexlifecycle/OperationMode.java
similarity index 53%
rename from x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/OperationMode.java
rename to x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/indexlifecycle/OperationMode.java
index 51f50c44a7e72..3186c11d33f73 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/OperationMode.java
+++ b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/indexlifecycle/OperationMode.java
@@ -1,9 +1,24 @@
/*
- * 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.
+ * 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.xpack.core.indexlifecycle;
+package org.elasticsearch.protocol.xpack.indexlifecycle;
+
+import org.elasticsearch.action.admin.indices.shrink.ShrinkAction;
/**
* Enum representing the different modes that Index Lifecycle Service can operate in.
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/indexlifecycle/StartILMRequest.java b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/indexlifecycle/StartILMRequest.java
new file mode 100644
index 0000000000000..2e58a0b5581a3
--- /dev/null
+++ b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/indexlifecycle/StartILMRequest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.indexlifecycle;
+
+import org.elasticsearch.action.ActionRequestValidationException;
+import org.elasticsearch.action.support.master.AcknowledgedRequest;
+
+public class StartILMRequest extends AcknowledgedRequest {
+
+ public StartILMRequest() {
+ }
+
+ @Override
+ public ActionRequestValidationException validate() {
+ return null;
+ }
+
+ @Override
+ public int hashCode() {
+ return 64;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (obj.getClass() != getClass()) {
+ return false;
+ }
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/indexlifecycle/StopILMRequest.java b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/indexlifecycle/StopILMRequest.java
new file mode 100644
index 0000000000000..0054ae05de477
--- /dev/null
+++ b/x-pack/protocol/src/main/java/org/elasticsearch/protocol/xpack/indexlifecycle/StopILMRequest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.indexlifecycle;
+
+import org.elasticsearch.action.ActionRequestValidationException;
+import org.elasticsearch.action.support.master.AcknowledgedRequest;
+
+public class StopILMRequest extends AcknowledgedRequest {
+
+ public StopILMRequest() {
+ }
+
+ @Override
+ public ActionRequestValidationException validate() {
+ return null;
+ }
+
+ @Override
+ public int hashCode() {
+ return 75;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (obj.getClass() != getClass()) {
+ return false;
+ }
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/indexlifecycle/OperationModeTests.java b/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/indexlifecycle/OperationModeTests.java
new file mode 100644
index 0000000000000..bc539ee4c6610
--- /dev/null
+++ b/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/indexlifecycle/OperationModeTests.java
@@ -0,0 +1,39 @@
+/*
+ * 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.indexlifecycle;
+
+import org.elasticsearch.test.ESTestCase;
+
+public class OperationModeTests extends ESTestCase {
+
+ public void testIsValidChange() {
+ assertFalse(OperationMode.RUNNING.isValidChange(OperationMode.RUNNING));
+ assertTrue(OperationMode.RUNNING.isValidChange(OperationMode.STOPPING));
+ assertFalse(OperationMode.RUNNING.isValidChange(OperationMode.STOPPED));
+
+ assertTrue(OperationMode.STOPPING.isValidChange(OperationMode.RUNNING));
+ assertFalse(OperationMode.STOPPING.isValidChange(OperationMode.STOPPING));
+ assertTrue(OperationMode.STOPPING.isValidChange(OperationMode.STOPPED));
+
+ assertTrue(OperationMode.STOPPED.isValidChange(OperationMode.RUNNING));
+ assertFalse(OperationMode.STOPPED.isValidChange(OperationMode.STOPPING));
+ assertFalse(OperationMode.STOPPED.isValidChange(OperationMode.STOPPED));
+ }
+}
diff --git a/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/indexlifecycle/StartILMRequestTests.java b/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/indexlifecycle/StartILMRequestTests.java
new file mode 100644
index 0000000000000..5c754ca8a4875
--- /dev/null
+++ b/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/indexlifecycle/StartILMRequestTests.java
@@ -0,0 +1,41 @@
+/*
+ * 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.indexlifecycle;
+
+import org.elasticsearch.test.AbstractStreamableTestCase;
+
+public class StartILMRequestTests extends AbstractStreamableTestCase {
+
+ @Override
+ protected StartILMRequest createBlankInstance() {
+ return new StartILMRequest();
+ }
+
+ @Override
+ protected StartILMRequest createTestInstance() {
+ return new StartILMRequest();
+ }
+
+ public void testValidate() {
+ StartILMRequest request = createTestInstance();
+ assertNull(request.validate());
+ }
+
+}
diff --git a/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/indexlifecycle/StopILMRequestTests.java b/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/indexlifecycle/StopILMRequestTests.java
new file mode 100644
index 0000000000000..9e5640bbd1594
--- /dev/null
+++ b/x-pack/protocol/src/test/java/org/elasticsearch/protocol/xpack/indexlifecycle/StopILMRequestTests.java
@@ -0,0 +1,41 @@
+/*
+ * 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.indexlifecycle;
+
+import org.elasticsearch.test.AbstractStreamableTestCase;
+
+public class StopILMRequestTests extends AbstractStreamableTestCase {
+
+ @Override
+ protected StopILMRequest createBlankInstance() {
+ return new StopILMRequest();
+ }
+
+ @Override
+ protected StopILMRequest createTestInstance() {
+ return new StopILMRequest();
+ }
+
+ public void testValidate() {
+ StopILMRequest request = createTestInstance();
+ assertNull(request.validate());
+ }
+
+}