use of io.crate.analyze.SnapshotSettings.WAIT_FOR_COMPLETION in project crate by crate.
the class CreateSnapshotPlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row parameters, SubQueryResults subQueryResults) {
CreateSnapshotRequest request = createRequest(createSnapshot, plannerContext.transactionContext(), dependencies.nodeContext(), parameters, subQueryResults, dependencies.schemas());
var transportCreateSnapshotAction = dependencies.transportActionProvider().transportCreateSnapshotAction();
transportCreateSnapshotAction.execute(request, new OneRowActionListener<>(consumer, response -> {
SnapshotInfo snapshotInfo = response.getSnapshotInfo();
if (// if wait_for_completion is false, the snapshotInfo is null
snapshotInfo != null && snapshotInfo.state() == SnapshotState.FAILED) {
// fail request if snapshot creation failed
String reason = response.getSnapshotInfo().reason().replaceAll("Index", "Table").replaceAll("Indices", "Tables");
consumer.accept(null, new CreateSnapshotException(createSnapshot.snapshot(), reason));
return new Row1(-1L);
} else {
return new Row1(1L);
}
}));
}
Aggregations