use of io.crate.planner.DependencyCarrier 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);
}
}));
}
use of io.crate.planner.DependencyCarrier in project crate by crate.
the class CreateRepositoryPlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row parameters, SubQueryResults subQueryResults) {
PutRepositoryRequest request = createRequest(createRepository, plannerContext.transactionContext(), dependencies.nodeContext(), parameters, subQueryResults, dependencies.repositoryParamValidator());
dependencies.repositoryService().execute(request).whenComplete(new OneRowActionListener<>(consumer, rCount -> new Row1(rCount == null ? -1 : rCount)));
}
use of io.crate.planner.DependencyCarrier in project crate by crate.
the class AlterTablePlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) throws Exception {
BoundAlterTable stmt = bind(alterTable, plannerContext.transactionContext(), dependencies.nodeContext(), params, subQueryResults);
dependencies.alterTableOperation().executeAlterTable(stmt).whenComplete(new OneRowActionListener<>(consumer, rCount -> new Row1(rCount == null ? -1 : rCount)));
}
use of io.crate.planner.DependencyCarrier in project crate by crate.
the class DeleteAllPartitions method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier executor, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
if (partitions.isEmpty()) {
consumer.accept(InMemoryBatchIterator.of(new Row1(0L), SentinelRow.SENTINEL), null);
} else {
/*
* table is partitioned, in case of concurrent "delete from partitions"
* it could be that some partitions are already deleted,
* so ignore it if some are missing
*/
DeleteIndexRequest deleteIndexRequest = new DeleteIndexRequest(partitions().toArray(new String[0])).indicesOptions(IndicesOptions.lenientExpandOpen());
executor.transportActionProvider().transportDeleteIndexAction().execute(deleteIndexRequest, new OneRowActionListener<>(consumer, r -> Row1.ROW_COUNT_UNKNOWN));
}
}
use of io.crate.planner.DependencyCarrier in project crate by crate.
the class DropAnalyzerPlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
ClusterUpdateSettingsRequest request = createRequest(dropAnalyzer.name(), dependencies.fulltextAnalyzerResolver());
dependencies.transportActionProvider().transportClusterUpdateSettingsAction().execute(request, new OneRowActionListener<>(consumer, r -> new Row1(1L)));
}
Aggregations