Browse Source

Remove unused upgrade actions (#62552)

These actions were almost completely removed in #40075 but a couple of
classes were left in place. This commit completes their removal.
David Turner 5 years ago
parent
commit
dea172a739

+ 0 - 80
x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoRequest.java

@@ -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<IndexUpgradeInfoRequest> 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());
-    }
-}

+ 0 - 74
x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/migration/IndexUpgradeInfoResponse.java

@@ -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<String, UpgradeActionRequired> actions;
-
-    public IndexUpgradeInfoResponse(StreamInput in) throws IOException {
-        super(in);
-        actions = in.readMap(StreamInput::readString, UpgradeActionRequired::readFromStream);
-    }
-
-    public IndexUpgradeInfoResponse(Map<String, UpgradeActionRequired> actions) {
-        this.actions = actions;
-    }
-
-    @Override
-    public void writeTo(StreamOutput out) throws IOException {
-        out.writeMap(actions, StreamOutput::writeString, (out1, value) -> value.writeTo(out1));
-    }
-
-    public Map<String, UpgradeActionRequired> getActions() {
-        return actions;
-    }
-
-    @Override
-    public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
-        builder.startObject();
-        {
-            builder.startObject(INDICES.getPreferredName());
-            for (Map.Entry<String, UpgradeActionRequired> 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);
-    }
-}

+ 0 - 5
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java

@@ -208,8 +208,6 @@ import org.elasticsearch.xpack.core.transform.transforms.SyncConfig;
 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;
@@ -351,9 +349,6 @@ public class XPackClientPlugin extends Plugin implements ActionPlugin, NetworkPl
                 CreateApiKeyAction.INSTANCE,
                 InvalidateApiKeyAction.INSTANCE,
                 GetApiKeyAction.INSTANCE,
-                // upgrade
-                IndexUpgradeInfoAction.INSTANCE,
-                IndexUpgradeAction.INSTANCE,
                 // watcher
                 PutWatchAction.INSTANCE,
                 DeleteWatchAction.INSTANCE,

+ 0 - 147
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/upgrade/actions/IndexUpgradeAction.java

@@ -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<BulkByScrollResponse> {
-
-    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<Request> 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<String, String> headers) {
-            return new CancellableTask(id, type, action, getDescription(), parentTaskId, headers) {
-                @Override
-                public boolean shouldCancelChildrenOnCancellation() {
-                    return true;
-                }
-            };
-        }
-    }
-
-    public static class RequestBuilder extends MasterNodeReadOperationRequestBuilder<Request, BulkByScrollResponse, RequestBuilder> {
-
-        public RequestBuilder(ElasticsearchClient client) {
-            super(client, INSTANCE, new Request());
-        }
-
-        public RequestBuilder setIndex(String index) {
-            request.index(index);
-            return this;
-        }
-    }
-
-}

+ 0 - 41
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/upgrade/actions/IndexUpgradeInfoAction.java

@@ -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<IndexUpgradeInfoResponse> {
-
-    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<IndexUpgradeInfoRequest, IndexUpgradeInfoResponse, RequestBuilder> {
-
-        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;
-        }
-    }
-}