Search in sources :

Example 21 with OneRowActionListener

use of io.crate.execution.support.OneRowActionListener 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)));
}
Also used : TOKEN_FILTER(io.crate.metadata.FulltextAnalyzerResolver.CustomType.TOKEN_FILTER) TOKENIZER(io.crate.metadata.FulltextAnalyzerResolver.CustomType.TOKENIZER) RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) Settings(org.elasticsearch.common.settings.Settings) Row(io.crate.data.Row) ANALYZER(io.crate.metadata.FulltextAnalyzerResolver.CustomType.ANALYZER) AnalyzedDropAnalyzer(io.crate.analyze.AnalyzedDropAnalyzer) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) CHAR_FILTER(io.crate.metadata.FulltextAnalyzerResolver.CustomType.CHAR_FILTER) VisibleForTesting(io.crate.common.annotations.VisibleForTesting) OneRowActionListener(io.crate.execution.support.OneRowActionListener) FulltextAnalyzerResolver(io.crate.metadata.FulltextAnalyzerResolver) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)

Example 22 with OneRowActionListener

use of io.crate.execution.support.OneRowActionListener in project crate by crate.

the class UpdateSettingsPlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
    Function<? super Symbol, Object> eval = x -> SymbolEvaluator.evaluate(plannerContext.transactionContext(), plannerContext.nodeContext(), x, params, subQueryResults);
    ClusterUpdateSettingsRequest request = isPersistent ? new ClusterUpdateSettingsRequest().persistentSettings(buildSettingsFrom(settings, eval)) : new ClusterUpdateSettingsRequest().transientSettings(buildSettingsFrom(settings, eval));
    OneRowActionListener<ClusterUpdateSettingsResponse> actionListener = new OneRowActionListener<>(consumer, r -> r.isAcknowledged() ? new Row1(1L) : new Row1(0L));
    dependencies.transportActionProvider().transportClusterUpdateSettingsAction().execute(request, actionListener);
}
Also used : CrateSettings(io.crate.metadata.settings.CrateSettings) Collection(java.util.Collection) Function(java.util.function.Function) Lists2(io.crate.common.collections.Lists2) RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) Assignment(io.crate.sql.tree.Assignment) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) Settings(org.elasticsearch.common.settings.Settings) Row(io.crate.data.Row) Symbol(io.crate.expression.symbol.Symbol) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) VisibleForTesting(io.crate.common.annotations.VisibleForTesting) OneRowActionListener(io.crate.execution.support.OneRowActionListener) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) OneRowActionListener(io.crate.execution.support.OneRowActionListener) ClusterUpdateSettingsResponse(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse) ClusterUpdateSettingsRequest(org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)

Example 23 with OneRowActionListener

use of io.crate.execution.support.OneRowActionListener in project crate by crate.

the class GCDangingArtifactsPlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
    OneRowActionListener<AcknowledgedResponse> listener = new OneRowActionListener<>(consumer, r -> r.isAcknowledged() ? new Row1(1L) : new Row1(0L));
    dependencies.transportActionProvider().transportDeleteIndexAction().execute(new DeleteIndexRequest(IndexParts.DANGLING_INDICES_PREFIX_PATTERNS.toArray(new String[0])), listener);
}
Also used : Row1(io.crate.data.Row1) OneRowActionListener(io.crate.execution.support.OneRowActionListener) AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)

Example 24 with OneRowActionListener

use of io.crate.execution.support.OneRowActionListener in project crate by crate.

the class DeletePartitions method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
    ArrayList<String> indexNames = getIndices(plannerContext.transactionContext(), dependencies.nodeContext(), params, subQueryResults);
    DeleteIndexRequest request = new DeleteIndexRequest(indexNames.toArray(new String[0]));
    request.indicesOptions(IndicesOptions.lenientExpandOpen());
    dependencies.transportActionProvider().transportDeleteIndexAction().execute(request, new OneRowActionListener<>(consumer, r -> Row1.ROW_COUNT_UNKNOWN));
}
Also used : IndexParts(io.crate.metadata.IndexParts) TransactionContext(io.crate.metadata.TransactionContext) NodeContext(io.crate.metadata.NodeContext) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) RelationName(io.crate.metadata.RelationName) Function(java.util.function.Function) Lists2(io.crate.common.collections.Lists2) PartitionName(io.crate.metadata.PartitionName) ArrayList(java.util.ArrayList) RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) List(java.util.List) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) Row(io.crate.data.Row) Symbol(io.crate.expression.symbol.Symbol) PlannerContext(io.crate.planner.PlannerContext) DataTypes(io.crate.types.DataTypes) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) IndicesOptions(org.elasticsearch.action.support.IndicesOptions) VisibleForTesting(io.crate.common.annotations.VisibleForTesting) OneRowActionListener(io.crate.execution.support.OneRowActionListener) Row1(io.crate.data.Row1) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)

Example 25 with OneRowActionListener

use of io.crate.execution.support.OneRowActionListener in project crate by crate.

the class DropSnapshotPlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row parameters, SubQueryResults subQueryResult) {
    DeleteSnapshotRequest request = new DeleteSnapshotRequest(dropSnapshot.repository(), dropSnapshot.snapshot());
    var transportDeleteSnapshotAction = dependencies.transportActionProvider().transportDeleteSnapshotAction();
    transportDeleteSnapshotAction.execute(request, new OneRowActionListener<>(consumer, response -> {
        if (!response.isAcknowledged()) {
            LOGGER.info("delete snapshot '{}.{}' not acknowledged", request.repository(), request.snapshot());
        }
        return new Row1(1L);
    }));
}
Also used : RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) Logger(org.apache.logging.log4j.Logger) Row(io.crate.data.Row) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) DeleteSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest) OneRowActionListener(io.crate.execution.support.OneRowActionListener) LogManager(org.apache.logging.log4j.LogManager) AnalyzedDropSnapshot(io.crate.analyze.AnalyzedDropSnapshot) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) DeleteSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest)

Aggregations

Row1 (io.crate.data.Row1)26 OneRowActionListener (io.crate.execution.support.OneRowActionListener)26 Row (io.crate.data.Row)22 RowConsumer (io.crate.data.RowConsumer)22 SubQueryResults (io.crate.planner.operators.SubQueryResults)22 DependencyCarrier (io.crate.planner.DependencyCarrier)19 Plan (io.crate.planner.Plan)19 PlannerContext (io.crate.planner.PlannerContext)19 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)15 Symbol (io.crate.expression.symbol.Symbol)15 Function (java.util.function.Function)15 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)11 NodeContext (io.crate.metadata.NodeContext)10 Settings (org.elasticsearch.common.settings.Settings)10 CoordinatorTxnCtx (io.crate.metadata.CoordinatorTxnCtx)9 List (java.util.List)7 RelationName (io.crate.metadata.RelationName)6 DocTableInfo (io.crate.metadata.doc.DocTableInfo)6 Table (io.crate.sql.tree.Table)6 ArrayList (java.util.ArrayList)5