From c24dc07346166827991439191e45d8fbdc2b2d69 Mon Sep 17 00:00:00 2001 From: Colin Goodheart-Smithe Date: Tue, 10 Apr 2018 09:28:03 +0100 Subject: [PATCH] Removes unused and unneeded code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Various classes had some code that was not used and is not going to be needed so this change cleans up those classes so we don’t have dead code hanging around --- .../ClusterStateActionStep.java | 4 -- .../core/indexlifecycle/DeleteAction.java | 3 -- .../core/indexlifecycle/ReadOnlyAction.java | 2 - .../xpack/core/indexlifecycle/StepResult.java | 49 ------------------- .../UpdateReplicaSettingsStepTests.java | 3 -- .../indexlifecycle/PolicyStepsRegistry.java | 21 -------- 6 files changed, 82 deletions(-) delete mode 100644 x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/StepResult.java diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ClusterStateActionStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ClusterStateActionStep.java index eab126e4a2e..9af0ba64443 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ClusterStateActionStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ClusterStateActionStep.java @@ -16,8 +16,4 @@ public abstract class ClusterStateActionStep extends Step { public abstract ClusterState performAction(Index index, ClusterState clusterState); - public boolean indexSurvives() { - return true; - } - } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteAction.java index 9465b289688..4068e8c6a39 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/DeleteAction.java @@ -5,12 +5,10 @@ */ package org.elasticsearch.xpack.core.indexlifecycle; -import org.apache.logging.log4j.Logger; import org.elasticsearch.client.Client; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -25,7 +23,6 @@ import java.util.List; public class DeleteAction implements LifecycleAction { public static final String NAME = "delete"; - private static final Logger logger = ESLoggerFactory.getLogger(DeleteAction.class); private static final ObjectParser PARSER = new ObjectParser<>(NAME, DeleteAction::new); public static DeleteAction parse(XContentParser parser) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ReadOnlyAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ReadOnlyAction.java index 991042ede64..1f75ae65103 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ReadOnlyAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/ReadOnlyAction.java @@ -9,7 +9,6 @@ import org.elasticsearch.client.Client; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ConstructingObjectParser; import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -17,7 +16,6 @@ import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; import java.util.Collections; import java.util.List; -import java.util.Objects; /** * A {@link LifecycleAction} which force-merges the index. diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/StepResult.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/StepResult.java deleted file mode 100644 index 1da68c1aac9..00000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/StepResult.java +++ /dev/null @@ -1,49 +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; - - -import org.elasticsearch.cluster.ClusterState; - -public class StepResult { - private final String message; - private final Exception exception; - private final ClusterState clusterState; - private final boolean complete; - private final boolean indexSurvived; - - public StepResult(String message, Exception exception, ClusterState clusterState, boolean indexSurvived, boolean complete) { - this.message = message; - this.exception = exception; - this.clusterState = clusterState; - this.indexSurvived = indexSurvived; - this.complete = complete; - } - - public StepResult(StepResult result, ClusterState newClusterState) { - this(result.getMessage(), result.getException(), newClusterState, result.indexSurvived(), result.isComplete()); - } - - public String getMessage() { - return message; - } - - public Exception getException() { - return exception; - } - - public ClusterState getClusterState() { - return clusterState; - } - - public boolean indexSurvived() { - return indexSurvived; - } - - public boolean isComplete() { - return complete; - } -} diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/UpdateReplicaSettingsStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/UpdateReplicaSettingsStepTests.java index 30661ce9330..68da1f53f05 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/UpdateReplicaSettingsStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/UpdateReplicaSettingsStepTests.java @@ -6,8 +6,6 @@ package org.elasticsearch.xpack.core.indexlifecycle; -import com.carrotsearch.randomizedtesting.annotations.Repeat; - import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -18,7 +16,6 @@ import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.EqualsHashCodeTestUtils; import org.elasticsearch.xpack.core.indexlifecycle.Step.StepKey; -@Repeat(iterations = 1000, useConstantSeed = false) public class UpdateReplicaSettingsStepTests extends ESTestCase { public UpdateReplicaSettingsStep createRandomInstance() { diff --git a/x-pack/plugin/index-lifecycle/src/main/java/org/elasticsearch/xpack/indexlifecycle/PolicyStepsRegistry.java b/x-pack/plugin/index-lifecycle/src/main/java/org/elasticsearch/xpack/indexlifecycle/PolicyStepsRegistry.java index 86d7d23fa7a..3d0cdb5fe3d 100644 --- a/x-pack/plugin/index-lifecycle/src/main/java/org/elasticsearch/xpack/indexlifecycle/PolicyStepsRegistry.java +++ b/x-pack/plugin/index-lifecycle/src/main/java/org/elasticsearch/xpack/indexlifecycle/PolicyStepsRegistry.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.xpack.indexlifecycle; -import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.Diff; @@ -13,11 +12,9 @@ import org.elasticsearch.cluster.DiffableUtils; import org.elasticsearch.xpack.core.indexlifecycle.LifecyclePolicy; import org.elasticsearch.xpack.core.indexlifecycle.Step; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.SortedMap; import java.util.TreeMap; import java.util.function.LongSupplier; @@ -109,22 +106,4 @@ public class PolicyStepsRegistry { return firstStepMap.get(policy); } - @Override - public int hashCode() { - return Objects.hash(lifecyclePolicyMap, firstStepMap, stepMap); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - PolicyStepsRegistry other = (PolicyStepsRegistry) obj; - return Objects.equals(lifecyclePolicyMap, other.lifecyclePolicyMap) - && Objects.equals(firstStepMap, other.firstStepMap) && Objects.equals(stepMap, other.stepMap); - } - }