Skip to content

Commit 88c0a0b

Browse files
committed
tostring
1 parent 7f9c32c commit 88c0a0b

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

server/src/main/java/org/elasticsearch/cluster/SnapshotDeletionsPending.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121

2222
import java.io.IOException;
2323
import java.util.ArrayList;
24-
import java.util.Comparator;
2524
import java.util.Iterator;
2625
import java.util.List;
2726
import java.util.Objects;
28-
import java.util.Set;
2927
import java.util.function.Consumer;
3028

3129
import static java.util.Collections.unmodifiableList;
@@ -116,7 +114,7 @@ public Version getMinimalSupportedVersion() {
116114
return Version.CURRENT.minimumCompatibilityVersion();
117115
}
118116

119-
public SnapshotDeletionsPending withRemovedSnapshots(Set<SnapshotId> snapshotIds) {
117+
public SnapshotDeletionsPending withRemovedSnapshots(List<SnapshotId> snapshotIds) {
120118
if (snapshotIds == null || snapshotIds.isEmpty()) {
121119
return this;
122120
}
@@ -142,23 +140,19 @@ public SnapshotDeletionsPending withRemovedSnapshots(Set<SnapshotId> snapshotIds
142140
public String toString() {
143141
final StringBuilder builder = new StringBuilder("SnapshotDeletionsPending[");
144142
boolean prepend = true;
145-
146143
final Iterator<Entry> iterator = entries.stream().iterator();
147144
while (iterator.hasNext()) {
148145
if (prepend == false) {
149146
builder.append(',');
150147
}
151-
final Entry entry = iterator.next();
152-
builder.append('[').append(entry.repositoryName).append('/').append(entry.repositoryUuid).append(']');
153-
builder.append('[').append(entry.snapshotId).append(',').append(entry.creationTime).append(']');
154-
builder.append('\n');
148+
builder.append(iterator.next());
155149
prepend = false;
156150
}
157151
builder.append(']');
158152
return builder.toString();
159153
}
160154

161-
public static class Entry implements Writeable, ToXContentObject, Comparable<Entry> {
155+
public static class Entry implements Writeable, ToXContentObject {
162156

163157
private final String repositoryName;
164158
private final String repositoryUuid;
@@ -233,11 +227,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
233227
}
234228

235229
@Override
236-
public int compareTo(final Entry other) {
237-
return Comparator.comparingLong(Entry::getCreationTime)
238-
.reversed()
239-
.thenComparing(Entry::getSnapshotId)
240-
.compare(this, other);
230+
public String toString() {
231+
return '[' + repositoryName + '/' + repositoryUuid + ',' + snapshotId + ',' + creationTime + ']';
241232
}
242233
}
243234

server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
7070
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
7171
import org.elasticsearch.common.util.concurrent.CountDown;
72-
import org.elasticsearch.common.util.set.Sets;
7372
import org.elasticsearch.core.Nullable;
7473
import org.elasticsearch.core.TimeValue;
7574
import org.elasticsearch.core.Tuple;
@@ -1438,7 +1437,7 @@ private class SnapshotsToDeleteRunnable extends AbstractRunnable {
14381437

14391438
@Override
14401439
protected void doRun() throws Exception {
1441-
final Set<SnapshotId> missingSnapshots = ConcurrentCollections.newConcurrentSet();
1440+
final List<SnapshotId> missingSnapshots = new CopyOnWriteArrayList<>();
14421441
final CountDown countDown = new CountDown(snapshotIdsToDelete.size());
14431442

14441443
for (SnapshotId snapshotId : snapshotIdsToDelete) {
@@ -2782,7 +2781,7 @@ protected SnapshotDeletionsInProgress filterDeletions(SnapshotDeletionsInProgres
27822781
@Override
27832782
protected SnapshotDeletionsPending filterPendingDeletions(@Nullable SnapshotDeletionsPending pendingDeletions) {
27842783
return pendingDeletions != null
2785-
? pendingDeletions.withRemovedSnapshots(Sets.newHashSet(deleteEntry.getSnapshots()))
2784+
? pendingDeletions.withRemovedSnapshots(deleteEntry.getSnapshots())
27862785
: null;
27872786
}
27882787

0 commit comments

Comments
 (0)