|
|
@@ -11,7 +11,6 @@ package org.elasticsearch.cluster;
|
|
|
import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.cluster.ClusterState.Custom;
|
|
|
import org.elasticsearch.common.Strings;
|
|
|
-import org.elasticsearch.common.collect.ImmutableOpenMap;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
import org.elasticsearch.common.io.stream.Writeable;
|
|
|
@@ -251,7 +250,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
List<String> dataStreams,
|
|
|
long startTime,
|
|
|
long repositoryStateId,
|
|
|
- ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards,
|
|
|
+ Map<ShardId, ShardSnapshotStatus> shards,
|
|
|
Map<String, Object> userMetadata,
|
|
|
Version version,
|
|
|
List<SnapshotFeatureInfo> featureStates
|
|
|
@@ -302,12 +301,12 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
Collections.emptyList(),
|
|
|
startTime,
|
|
|
repositoryStateId,
|
|
|
- ImmutableOpenMap.of(),
|
|
|
+ Map.of(),
|
|
|
null,
|
|
|
Collections.emptyMap(),
|
|
|
version,
|
|
|
source,
|
|
|
- ImmutableOpenMap.of()
|
|
|
+ Map.of()
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -326,7 +325,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private static boolean hasFailures(ImmutableOpenMap<RepositoryShardId, ShardSnapshotStatus> clones) {
|
|
|
+ private static boolean hasFailures(Map<RepositoryShardId, ShardSnapshotStatus> clones) {
|
|
|
for (ShardSnapshotStatus value : clones.values()) {
|
|
|
if (value.state().failed()) {
|
|
|
return true;
|
|
|
@@ -685,7 +684,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
/**
|
|
|
* Map of {@link RepositoryShardId} to {@link ShardSnapshotStatus} tracking the state of each shard operation in this entry.
|
|
|
*/
|
|
|
- private final ImmutableOpenMap<RepositoryShardId, ShardSnapshotStatus> shardStatusByRepoShardId;
|
|
|
+ private final Map<RepositoryShardId, ShardSnapshotStatus> shardStatusByRepoShardId;
|
|
|
|
|
|
@Nullable
|
|
|
private final Map<String, Object> userMetadata;
|
|
|
@@ -723,7 +722,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
userMetadata,
|
|
|
version,
|
|
|
null,
|
|
|
- ImmutableOpenMap.of()
|
|
|
+ Map.of()
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -742,7 +741,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
Map<String, Object> userMetadata,
|
|
|
Version version,
|
|
|
@Nullable SnapshotId source,
|
|
|
- ImmutableOpenMap<RepositoryShardId, ShardSnapshotStatus> shardStatusByRepoShardId
|
|
|
+ Map<RepositoryShardId, ShardSnapshotStatus> shardStatusByRepoShardId
|
|
|
) {
|
|
|
this.state = state;
|
|
|
this.snapshot = snapshot;
|
|
|
@@ -762,9 +761,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
assert shardStatusByRepoShardId == null || shardStatusByRepoShardId.isEmpty()
|
|
|
: "Provided explict repo shard id statuses [" + shardStatusByRepoShardId + "] but no source";
|
|
|
final Map<String, Index> res = Maps.newMapWithExpectedSize(indices.size());
|
|
|
- final ImmutableOpenMap.Builder<RepositoryShardId, ShardSnapshotStatus> byRepoShardIdBuilder = ImmutableOpenMap.builder(
|
|
|
- shards.size()
|
|
|
- );
|
|
|
+ final Map<RepositoryShardId, ShardSnapshotStatus> byRepoShardIdBuilder = Maps.newHashMapWithExpectedSize(shards.size());
|
|
|
for (Map.Entry<ShardId, ShardSnapshotStatus> entry : shards.entrySet()) {
|
|
|
final ShardId shardId = entry.getKey();
|
|
|
final IndexId indexId = indices.get(shardId.getIndexName());
|
|
|
@@ -773,12 +770,12 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
assert existing == null || existing.equals(index) : "Conflicting indices [" + existing + "] and [" + index + "]";
|
|
|
byRepoShardIdBuilder.put(new RepositoryShardId(indexId, shardId.id()), entry.getValue());
|
|
|
}
|
|
|
- this.shardStatusByRepoShardId = byRepoShardIdBuilder.build();
|
|
|
- snapshotIndices = Map.copyOf(res);
|
|
|
+ this.shardStatusByRepoShardId = Map.copyOf(byRepoShardIdBuilder);
|
|
|
+ this.snapshotIndices = Map.copyOf(res);
|
|
|
} else {
|
|
|
assert shards.isEmpty();
|
|
|
this.shardStatusByRepoShardId = shardStatusByRepoShardId;
|
|
|
- snapshotIndices = Map.of();
|
|
|
+ this.snapshotIndices = Map.of();
|
|
|
}
|
|
|
assert assertShardsConsistent(this.source, this.state, this.indices, this.shards, this.shardStatusByRepoShardId);
|
|
|
}
|
|
|
@@ -801,17 +798,14 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
indices = Collections.unmodifiableMap(idx);
|
|
|
}
|
|
|
final long startTime = in.readLong();
|
|
|
- final ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards = in.readImmutableOpenMap(
|
|
|
- ShardId::new,
|
|
|
- ShardSnapshotStatus::readFrom
|
|
|
- );
|
|
|
+ final Map<ShardId, ShardSnapshotStatus> shards = in.readImmutableMap(ShardId::new, ShardSnapshotStatus::readFrom);
|
|
|
final long repositoryStateId = in.readLong();
|
|
|
final String failure = in.readOptionalString();
|
|
|
final Map<String, Object> userMetadata = in.readMap();
|
|
|
final Version version = Version.readVersion(in);
|
|
|
final List<String> dataStreams = in.readStringList();
|
|
|
final SnapshotId source = in.readOptionalWriteable(SnapshotId::new);
|
|
|
- final ImmutableOpenMap<RepositoryShardId, ShardSnapshotStatus> clones = in.readImmutableOpenMap(
|
|
|
+ final Map<RepositoryShardId, ShardSnapshotStatus> clones = in.readImmutableMap(
|
|
|
RepositoryShardId::new,
|
|
|
ShardSnapshotStatus::readFrom
|
|
|
);
|
|
|
@@ -840,7 +834,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
State state,
|
|
|
Map<String, IndexId> indices,
|
|
|
Map<ShardId, ShardSnapshotStatus> shards,
|
|
|
- ImmutableOpenMap<RepositoryShardId, ShardSnapshotStatus> statusByRepoShardId
|
|
|
+ Map<RepositoryShardId, ShardSnapshotStatus> statusByRepoShardId
|
|
|
) {
|
|
|
if ((state == State.INIT || state == State.ABORTED) && shards.isEmpty()) {
|
|
|
return true;
|
|
|
@@ -895,7 +889,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
userMetadata,
|
|
|
version,
|
|
|
source,
|
|
|
- source == null ? ImmutableOpenMap.of() : shardStatusByRepoShardId
|
|
|
+ source == null ? Map.of() : shardStatusByRepoShardId
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -943,13 +937,13 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
userMetadata,
|
|
|
version,
|
|
|
source,
|
|
|
- ImmutableOpenMap.of()
|
|
|
+ Map.of()
|
|
|
);
|
|
|
}
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
- public Entry withClones(ImmutableOpenMap<RepositoryShardId, ShardSnapshotStatus> updatedClones) {
|
|
|
+ public Entry withClones(Map<RepositoryShardId, ShardSnapshotStatus> updatedClones) {
|
|
|
if (updatedClones.equals(shardStatusByRepoShardId)) {
|
|
|
return this;
|
|
|
}
|
|
|
@@ -964,7 +958,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
featureStates,
|
|
|
startTime,
|
|
|
repositoryStateId,
|
|
|
- ImmutableOpenMap.of(),
|
|
|
+ Map.of(),
|
|
|
failure,
|
|
|
userMetadata,
|
|
|
version,
|
|
|
@@ -985,7 +979,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
*/
|
|
|
@Nullable
|
|
|
public Entry abort() {
|
|
|
- final ImmutableOpenMap.Builder<ShardId, ShardSnapshotStatus> shardsBuilder = ImmutableOpenMap.builder();
|
|
|
+ final Map<ShardId, ShardSnapshotStatus> shardsBuilder = new HashMap<>();
|
|
|
boolean completed = true;
|
|
|
boolean allQueued = true;
|
|
|
for (Map.Entry<ShardId, ShardSnapshotStatus> shardEntry : shards.entrySet()) {
|
|
|
@@ -1016,12 +1010,12 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
featureStates,
|
|
|
startTime,
|
|
|
repositoryStateId,
|
|
|
- shardsBuilder.build(),
|
|
|
+ Map.copyOf(shardsBuilder),
|
|
|
ABORTED_FAILURE_TEXT,
|
|
|
userMetadata,
|
|
|
version,
|
|
|
source,
|
|
|
- ImmutableOpenMap.of()
|
|
|
+ Map.of()
|
|
|
);
|
|
|
}
|
|
|
|
|
|
@@ -1033,7 +1027,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
* @param shards new shard snapshot states
|
|
|
* @return new snapshot entry
|
|
|
*/
|
|
|
- public Entry withShardStates(ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards) {
|
|
|
+ public Entry withShardStates(Map<ShardId, ShardSnapshotStatus> shards) {
|
|
|
if (completed(shards.values())) {
|
|
|
return new Entry(
|
|
|
snapshot,
|
|
|
@@ -1058,7 +1052,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
* Same as {@link #withShardStates} but does not check if the snapshot completed and thus is only to be used when starting new
|
|
|
* shard snapshots on data nodes for a running snapshot.
|
|
|
*/
|
|
|
- public Entry withStartedShards(ImmutableOpenMap<ShardId, ShardSnapshotStatus> shards) {
|
|
|
+ public Entry withStartedShards(Map<ShardId, ShardSnapshotStatus> shards) {
|
|
|
final SnapshotsInProgress.Entry updated = new Entry(
|
|
|
snapshot,
|
|
|
includeGlobalState,
|
|
|
@@ -1305,7 +1299,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
|
|
|
out.writeStringCollection(dataStreams);
|
|
|
out.writeOptionalWriteable(source);
|
|
|
if (source == null) {
|
|
|
- out.writeMap(ImmutableOpenMap.of());
|
|
|
+ out.writeMap(Map.of());
|
|
|
} else {
|
|
|
out.writeMap(shardStatusByRepoShardId);
|
|
|
}
|