use of io.crate.analyze.SnapshotSettings.IGNORE_UNAVAILABLE in project crate by crate.
the class RestoreSnapshotPlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row parameters, SubQueryResults subQueryResults) {
BoundRestoreSnapshot stmt = bind(restoreSnapshot, plannerContext.transactionContext(), dependencies.nodeContext(), parameters, subQueryResults, dependencies.schemas());
var settings = stmt.settings();
boolean ignoreUnavailable = IGNORE_UNAVAILABLE.get(settings);
var transportActionProvider = dependencies.transportActionProvider();
resolveIndexNames(restoreSnapshot.repository(), stmt.restoreTables(), ignoreUnavailable, transportActionProvider.transportGetSnapshotsAction()).whenComplete((ResolveIndicesAndTemplatesContext ctx, Throwable t) -> {
if (t == null) {
String[] indexNames = ctx.resolvedIndices().toArray(new String[0]);
String[] templateNames = stmt.includeTables() && stmt.restoreTables().isEmpty() ? new String[] { ALL_TEMPLATES } : ctx.resolvedTemplates().toArray(new String[0]);
// ignore_unavailable as set by statement
IndicesOptions indicesOptions = IndicesOptions.fromOptions(ignoreUnavailable, true, true, false, IndicesOptions.lenientExpandOpen());
RestoreSnapshotRequest request = new RestoreSnapshotRequest(restoreSnapshot.repository(), restoreSnapshot.snapshot()).indices(indexNames).templates(templateNames).indicesOptions(indicesOptions).settings(settings).waitForCompletion(WAIT_FOR_COMPLETION.get(settings)).includeIndices(stmt.includeTables()).includeAliases(stmt.includeTables()).includeCustomMetadata(stmt.includeCustomMetadata()).customMetadataTypes(stmt.customMetadataTypes()).includeGlobalSettings(stmt.includeGlobalSettings()).globalSettings(stmt.globalSettings());
transportActionProvider.transportRestoreSnapshotAction().execute(request, new OneRowActionListener<>(consumer, r -> new Row1(r == null ? -1L : 1L)));
}
});
}
Aggregations