use of org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest in project elasticsearch by elastic.
the class RestGetSnapshotsAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
String repository = request.param("repository");
String[] snapshots = request.paramAsStringArray("snapshot", Strings.EMPTY_ARRAY);
GetSnapshotsRequest getSnapshotsRequest = getSnapshotsRequest(repository).snapshots(snapshots);
getSnapshotsRequest.ignoreUnavailable(request.paramAsBoolean("ignore_unavailable", getSnapshotsRequest.ignoreUnavailable()));
getSnapshotsRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getSnapshotsRequest.masterNodeTimeout()));
return channel -> client.admin().cluster().getSnapshots(getSnapshotsRequest, new RestToXContentListener<>(channel));
}
use of org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest in project elasticsearch by elastic.
the class RestSnapshotAction method doCatRequest.
@Override
protected RestChannelConsumer doCatRequest(final RestRequest request, NodeClient client) {
GetSnapshotsRequest getSnapshotsRequest = new GetSnapshotsRequest().repository(request.param("repository")).snapshots(new String[] { GetSnapshotsRequest.ALL_SNAPSHOTS });
getSnapshotsRequest.ignoreUnavailable(request.paramAsBoolean("ignore_unavailable", getSnapshotsRequest.ignoreUnavailable()));
getSnapshotsRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getSnapshotsRequest.masterNodeTimeout()));
return channel -> client.admin().cluster().getSnapshots(getSnapshotsRequest, new RestResponseListener<GetSnapshotsResponse>(channel) {
@Override
public RestResponse buildResponse(GetSnapshotsResponse getSnapshotsResponse) throws Exception {
return RestTable.buildResponse(buildTable(request, getSnapshotsResponse), channel);
}
});
}
use of org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest in project crate by crate.
the class SnapshotRestoreDDLDispatcher method resolveIndexNames.
@VisibleForTesting
static CompletableFuture<List<String>> resolveIndexNames(List<RestoreSnapshotAnalyzedStatement.RestoreTableInfo> restoreTables, boolean ignoreUnavailable, TransportGetSnapshotsAction getSnapshotsAction, String repositoryName) {
Collection<String> resolvedIndices = new HashSet<>();
List<RestoreSnapshotAnalyzedStatement.RestoreTableInfo> toResolveFromSnapshot = new ArrayList<>();
for (RestoreSnapshotAnalyzedStatement.RestoreTableInfo table : restoreTables) {
if (table.hasPartitionInfo()) {
resolvedIndices.add(table.partitionName().asIndexName());
} else if (ignoreUnavailable) {
// If ignoreUnavailable is true, it's cheaper to simply return indexName and the partitioned wildcard instead
// checking if it's a partitioned table or not
resolvedIndices.add(table.tableIdent().indexName());
resolvedIndices.add(PartitionName.templateName(table.tableIdent().schema(), table.tableIdent().name()) + "*");
} else {
// index name needs to be resolved from snapshot
toResolveFromSnapshot.add(table);
}
}
if (toResolveFromSnapshot.isEmpty()) {
return CompletableFuture.completedFuture(ImmutableList.copyOf(resolvedIndices));
}
final CompletableFuture<List<String>> f = new CompletableFuture<>();
getSnapshotsAction.execute(new GetSnapshotsRequest(repositoryName), new ResolveFromSnapshotActionListener(f, toResolveFromSnapshot, resolvedIndices));
return f;
}
Aggregations