From 0dd06cf7a574b23490b771190d4fe512b362fada Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Thu, 11 Jul 2019 21:56:36 +0200 Subject: [PATCH] Remove Dead Code Around Snapshots (#44109) (#44236) * Just some random spots that have become unused with recent cleanups --- .../cluster/RestoreInProgress.java | 11 ++------- .../cluster/SnapshotDeletionsInProgress.java | 4 ---- .../cluster/SnapshotsInProgress.java | 23 +++++++------------ .../elasticsearch/snapshots/SnapshotId.java | 16 ------------- .../elasticsearch/snapshots/SnapshotInfo.java | 11 --------- 5 files changed, 10 insertions(+), 55 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/RestoreInProgress.java b/server/src/main/java/org/elasticsearch/cluster/RestoreInProgress.java index 57a38f9faea..63c2ea52597 100644 --- a/server/src/main/java/org/elasticsearch/cluster/RestoreInProgress.java +++ b/server/src/main/java/org/elasticsearch/cluster/RestoreInProgress.java @@ -460,9 +460,6 @@ public class RestoreInProgress extends AbstractNamedDiffable implements this.entries = entriesBuilder.build(); } - /** - * {@inheritDoc} - */ @Override public void writeTo(StreamOutput out) throws IOException { out.writeVInt(entries.size()); @@ -485,14 +482,11 @@ public class RestoreInProgress extends AbstractNamedDiffable implements } } - /** - * {@inheritDoc} - */ @Override public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { builder.startArray("snapshots"); for (ObjectCursor entry : entries.values()) { - toXContent(entry.value, builder, params); + toXContent(entry.value, builder); } builder.endArray(); return builder; @@ -503,9 +497,8 @@ public class RestoreInProgress extends AbstractNamedDiffable implements * * @param entry restore operation metadata * @param builder XContent builder - * @param params serialization parameters */ - public void toXContent(Entry entry, XContentBuilder builder, ToXContent.Params params) throws IOException { + public void toXContent(Entry entry, XContentBuilder builder) throws IOException { builder.startObject(); builder.field("snapshot", entry.snapshot().getSnapshotId().getName()); builder.field("repository", entry.snapshot().getRepository()); diff --git a/server/src/main/java/org/elasticsearch/cluster/SnapshotDeletionsInProgress.java b/server/src/main/java/org/elasticsearch/cluster/SnapshotDeletionsInProgress.java index 0134b798c72..8e702fbdcee 100644 --- a/server/src/main/java/org/elasticsearch/cluster/SnapshotDeletionsInProgress.java +++ b/server/src/main/java/org/elasticsearch/cluster/SnapshotDeletionsInProgress.java @@ -44,10 +44,6 @@ public class SnapshotDeletionsInProgress extends AbstractNamedDiffable i // the list of snapshot deletion request entries private final List entries; - public SnapshotDeletionsInProgress() { - this(Collections.emptyList()); - } - private SnapshotDeletionsInProgress(List entries) { this.entries = Collections.unmodifiableList(entries); } diff --git a/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java b/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java index b933c856fe0..a4e585c2f05 100644 --- a/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java +++ b/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java @@ -315,24 +315,21 @@ public class SnapshotsInProgress extends AbstractNamedDiffable implement } public enum State { - INIT((byte) 0, false, false), - STARTED((byte) 1, false, false), - SUCCESS((byte) 2, true, false), - FAILED((byte) 3, true, true), - ABORTED((byte) 4, false, true), - MISSING((byte) 5, true, true), - WAITING((byte) 6, false, false); + INIT((byte) 0, false), + STARTED((byte) 1, false), + SUCCESS((byte) 2, true), + FAILED((byte) 3, true), + ABORTED((byte) 4, false), + MISSING((byte) 5, true), + WAITING((byte) 6, false); private final byte value; private final boolean completed; - private final boolean failed; - - State(byte value, boolean completed, boolean failed) { + State(byte value, boolean completed) { this.value = value; this.completed = completed; - this.failed = failed; } public byte value() { @@ -343,10 +340,6 @@ public class SnapshotsInProgress extends AbstractNamedDiffable implement return completed; } - public boolean failed() { - return failed; - } - public static State fromValue(byte value) { switch (value) { case 0: diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotId.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotId.java index 59e1d960bcb..4a03ebc032f 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotId.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotId.java @@ -24,7 +24,6 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentParser; import java.io.IOException; import java.util.Objects; @@ -129,19 +128,4 @@ public final class SnapshotId implements Comparable, Writeable, ToXC builder.endObject(); return builder; } - - public static SnapshotId fromXContent(XContentParser parser) throws IOException { - String name = null; - String uuid = null; - while (parser.nextToken() != XContentParser.Token.END_OBJECT) { - String currentFieldName = parser.currentName(); - parser.nextToken(); - if (NAME.equals(currentFieldName)) { - name = parser.text(); - } else if (UUID.equals(currentFieldName)) { - uuid = parser.text(); - } - } - return new SnapshotId(name, uuid); - } } diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java index d6e889c599f..e18baadcda2 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java @@ -320,17 +320,6 @@ public final class SnapshotInfo implements Comparable, ToXContent, } } - /** - * Gets a new {@link SnapshotInfo} instance for a snapshot that is incompatible with the - * current version of the cluster. - */ - public static SnapshotInfo incompatible(SnapshotId snapshotId) { - return new SnapshotInfo(snapshotId, Collections.emptyList(), SnapshotState.INCOMPATIBLE, - "the snapshot is incompatible with the current version of Elasticsearch and its exact version is unknown", - null, 0L, 0L, 0, 0, - Collections.emptyList(), null, null); - } - /** * Gets a new {@link SnapshotInfo} instance from the given {@link SnapshotInfo} with * all information stripped out except the snapshot id, state, and indices.