use of org.elasticsearch.cluster.RestoreInProgress.ShardRestoreStatus in project elasticsearch by elastic.
the class RestoreService method updateRestoreStateWithDeletedIndices.
public static RestoreInProgress updateRestoreStateWithDeletedIndices(RestoreInProgress oldRestore, Set<Index> deletedIndices) {
boolean changesMade = false;
final List<RestoreInProgress.Entry> entries = new ArrayList<>();
for (RestoreInProgress.Entry entry : oldRestore.entries()) {
ImmutableOpenMap.Builder<ShardId, ShardRestoreStatus> shardsBuilder = null;
for (ObjectObjectCursor<ShardId, ShardRestoreStatus> cursor : entry.shards()) {
ShardId shardId = cursor.key;
if (deletedIndices.contains(shardId.getIndex())) {
changesMade = true;
if (shardsBuilder == null) {
shardsBuilder = ImmutableOpenMap.builder(entry.shards());
}
shardsBuilder.put(shardId, new ShardRestoreStatus(null, RestoreInProgress.State.FAILURE, "index was deleted"));
}
}
if (shardsBuilder != null) {
ImmutableOpenMap<ShardId, ShardRestoreStatus> shards = shardsBuilder.build();
entries.add(new RestoreInProgress.Entry(entry.snapshot(), overallState(RestoreInProgress.State.STARTED, shards), entry.indices(), shards));
} else {
entries.add(entry);
}
}
if (changesMade) {
return new RestoreInProgress(entries.toArray(new RestoreInProgress.Entry[entries.size()]));
} else {
return oldRestore;
}
}
use of org.elasticsearch.cluster.RestoreInProgress.ShardRestoreStatus in project crate by crate.
the class RestoreService method updateRestoreStateWithDeletedIndices.
public static RestoreInProgress updateRestoreStateWithDeletedIndices(RestoreInProgress oldRestore, Set<Index> deletedIndices) {
boolean changesMade = false;
RestoreInProgress.Builder builder = new RestoreInProgress.Builder();
for (RestoreInProgress.Entry entry : oldRestore) {
ImmutableOpenMap.Builder<ShardId, ShardRestoreStatus> shardsBuilder = null;
for (ObjectObjectCursor<ShardId, ShardRestoreStatus> cursor : entry.shards()) {
ShardId shardId = cursor.key;
if (deletedIndices.contains(shardId.getIndex())) {
changesMade = true;
if (shardsBuilder == null) {
shardsBuilder = ImmutableOpenMap.builder(entry.shards());
}
shardsBuilder.put(shardId, new ShardRestoreStatus(null, RestoreInProgress.State.FAILURE, "index was deleted"));
}
}
if (shardsBuilder != null) {
ImmutableOpenMap<ShardId, ShardRestoreStatus> shards = shardsBuilder.build();
builder.add(new RestoreInProgress.Entry(entry.uuid(), entry.snapshot(), overallState(RestoreInProgress.State.STARTED, shards), entry.indices(), shards));
} else {
builder.add(entry);
}
}
if (changesMade) {
return builder.build();
} else {
return oldRestore;
}
}
Aggregations