diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoRequest.java deleted file mode 100644 index d09b134462731..0000000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoRequest.java +++ /dev/null @@ -1,80 +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.protocol.xpack.migration; - -import org.elasticsearch.action.ActionRequestValidationException; -import org.elasticsearch.action.IndicesRequest; -import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.action.support.master.MasterNodeReadRequest; -import org.elasticsearch.common.Strings; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Objects; - -public class IndexUpgradeInfoRequest extends MasterNodeReadRequest implements IndicesRequest.Replaceable { - - private String[] indices = Strings.EMPTY_ARRAY; - private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, true, true, true); - - public IndexUpgradeInfoRequest(String... indices) { - indices(indices); - } - - public IndexUpgradeInfoRequest(StreamInput in) throws IOException { - super(in); - indices = in.readStringArray(); - indicesOptions = IndicesOptions.readIndicesOptions(in); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeStringArray(indices); - indicesOptions.writeIndicesOptions(out); - } - - @Override - public String[] indices() { - return indices; - } - - @Override - public IndexUpgradeInfoRequest indices(String... indices) { - this.indices = Objects.requireNonNull(indices, "indices cannot be null"); - return this; - } - - @Override - public IndicesOptions indicesOptions() { - return indicesOptions; - } - - public void indicesOptions(IndicesOptions indicesOptions) { - this.indicesOptions = indicesOptions; - } - - @Override - public ActionRequestValidationException validate() { - return null; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - IndexUpgradeInfoRequest request = (IndexUpgradeInfoRequest) o; - return Arrays.equals(indices, request.indices) && - Objects.equals(indicesOptions.toString(), request.indicesOptions.toString()); - } - - @Override - public int hashCode() { - return Objects.hash(Arrays.hashCode(indices), indicesOptions.toString()); - } -} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoResponse.java deleted file mode 100644 index a698529f9eb57..0000000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoResponse.java +++ /dev/null @@ -1,74 +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.protocol.xpack.migration; - -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.common.ParseField; -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 java.io.IOException; -import java.util.Map; -import java.util.Objects; - -public class IndexUpgradeInfoResponse extends ActionResponse implements ToXContentObject { - - private static final ParseField INDICES = new ParseField("indices"); - private static final ParseField ACTION_REQUIRED = new ParseField("action_required"); - - private Map actions; - - public IndexUpgradeInfoResponse(StreamInput in) throws IOException { - super(in); - actions = in.readMap(StreamInput::readString, UpgradeActionRequired::readFromStream); - } - - public IndexUpgradeInfoResponse(Map actions) { - this.actions = actions; - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - out.writeMap(actions, StreamOutput::writeString, (out1, value) -> value.writeTo(out1)); - } - - public Map getActions() { - return actions; - } - - @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject(); - { - builder.startObject(INDICES.getPreferredName()); - for (Map.Entry entry : actions.entrySet()) { - builder.startObject(entry.getKey()); - { - builder.field(ACTION_REQUIRED.getPreferredName(), entry.getValue().toString()); - } - builder.endObject(); - } - builder.endObject(); - } - builder.endObject(); - return builder; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - IndexUpgradeInfoResponse response = (IndexUpgradeInfoResponse) o; - return Objects.equals(actions, response.actions); - } - - @Override - public int hashCode() { - return Objects.hash(actions); - } -} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java index fe0cd7d13cbff..011bd108ea28a 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java @@ -207,8 +207,6 @@ import org.elasticsearch.xpack.core.transform.transforms.TimeSyncConfig; import org.elasticsearch.xpack.core.transform.transforms.TransformState; import org.elasticsearch.xpack.core.transform.transforms.TransformTaskParams; -import org.elasticsearch.xpack.core.upgrade.actions.IndexUpgradeAction; -import org.elasticsearch.xpack.core.upgrade.actions.IndexUpgradeInfoAction; import org.elasticsearch.xpack.core.vectors.VectorsFeatureSetUsage; import org.elasticsearch.xpack.core.votingonly.VotingOnlyNodeFeatureSetUsage; import org.elasticsearch.xpack.core.watcher.WatcherFeatureSetUsage; @@ -350,9 +348,6 @@ public List> getClientActions() { CreateApiKeyAction.INSTANCE, InvalidateApiKeyAction.INSTANCE, GetApiKeyAction.INSTANCE, - // upgrade - IndexUpgradeInfoAction.INSTANCE, - IndexUpgradeAction.INSTANCE, // watcher PutWatchAction.INSTANCE, DeleteWatchAction.INSTANCE, diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/upgrade/actions/IndexUpgradeAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/upgrade/actions/IndexUpgradeAction.java deleted file mode 100644 index 26d8dbbb619ff..0000000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/upgrade/actions/IndexUpgradeAction.java +++ /dev/null @@ -1,147 +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.upgrade.actions; - -import org.elasticsearch.action.ActionRequestValidationException; -import org.elasticsearch.action.IndicesRequest; -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.action.support.master.MasterNodeReadOperationRequestBuilder; -import org.elasticsearch.action.support.master.MasterNodeReadRequest; -import org.elasticsearch.client.ElasticsearchClient; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.index.reindex.BulkByScrollResponse; -import org.elasticsearch.tasks.CancellableTask; -import org.elasticsearch.tasks.Task; -import org.elasticsearch.tasks.TaskId; - -import java.io.IOException; -import java.util.Map; -import java.util.Objects; - -import static org.elasticsearch.action.ValidateActions.addValidationError; -import static org.elasticsearch.xpack.core.upgrade.IndexUpgradeServiceFields.UPGRADE_INDEX_OPTIONS; - -public class IndexUpgradeAction extends ActionType { - - public static final IndexUpgradeAction INSTANCE = new IndexUpgradeAction(); - public static final String NAME = "cluster:admin/xpack/upgrade"; - - private IndexUpgradeAction() { - super(NAME, BulkByScrollResponse::new); - } - - public static class Request extends MasterNodeReadRequest implements IndicesRequest { - - private String index = null; - - /** - * Should this task store its result? - */ - private boolean shouldStoreResult; - - // for serialization - public Request() { - - } - - public Request(String index) { - this.index = index; - } - - public Request(StreamInput in) throws IOException { - super(in); - index = in.readString(); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - super.writeTo(out); - out.writeString(index); - } - - public String index() { - return index; - } - - /** - * Sets the index. - */ - public final Request index(String index) { - this.index = index; - return this; - } - - @Override - public String[] indices() { - return new String[]{index}; - } - - @Override - public IndicesOptions indicesOptions() { - return UPGRADE_INDEX_OPTIONS; - } - - /** - * Should this task store its result after it has finished? - */ - public Request setShouldStoreResult(boolean shouldStoreResult) { - this.shouldStoreResult = shouldStoreResult; - return this; - } - - @Override - public boolean getShouldStoreResult() { - return shouldStoreResult; - } - - @Override - public ActionRequestValidationException validate() { - ActionRequestValidationException validationException = null; - if (index == null) { - validationException = addValidationError("index is missing", validationException); - } - return validationException; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Request request = (Request) o; - return Objects.equals(index, request.index); - } - - @Override - public int hashCode() { - return Objects.hash(index); - } - - @Override - public Task createTask(long id, String type, String action, TaskId parentTaskId, Map headers) { - return new CancellableTask(id, type, action, getDescription(), parentTaskId, headers) { - @Override - public boolean shouldCancelChildrenOnCancellation() { - return true; - } - }; - } - } - - public static class RequestBuilder extends MasterNodeReadOperationRequestBuilder { - - public RequestBuilder(ElasticsearchClient client) { - super(client, INSTANCE, new Request()); - } - - public RequestBuilder setIndex(String index) { - request.index(index); - return this; - } - } - -} \ No newline at end of file diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/upgrade/actions/IndexUpgradeInfoAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/upgrade/actions/IndexUpgradeInfoAction.java deleted file mode 100644 index ff45e56ab3a95..0000000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/upgrade/actions/IndexUpgradeInfoAction.java +++ /dev/null @@ -1,41 +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.upgrade.actions; - -import org.elasticsearch.action.ActionType; -import org.elasticsearch.action.support.IndicesOptions; -import org.elasticsearch.action.support.master.MasterNodeReadOperationRequestBuilder; -import org.elasticsearch.client.ElasticsearchClient; -import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoRequest; -import org.elasticsearch.protocol.xpack.migration.IndexUpgradeInfoResponse; - -public class IndexUpgradeInfoAction extends ActionType { - - public static final IndexUpgradeInfoAction INSTANCE = new IndexUpgradeInfoAction(); - public static final String NAME = "cluster:admin/xpack/upgrade/info"; - - private IndexUpgradeInfoAction() { - super(NAME, IndexUpgradeInfoResponse::new); - } - - public static class RequestBuilder - extends MasterNodeReadOperationRequestBuilder { - - public RequestBuilder(ElasticsearchClient client) { - super(client, INSTANCE, new IndexUpgradeInfoRequest()); - } - - public RequestBuilder setIndices(String... indices) { - request.indices(indices); - return this; - } - - public RequestBuilder setIndicesOptions(IndicesOptions indicesOptions) { - request.indicesOptions(indicesOptions); - return this; - } - } -}