use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class TransportRenameTableAction method masterOperation.
@Override
protected void masterOperation(RenameTableRequest request, ClusterState state, ActionListener<AcknowledgedResponse> listener) throws Exception {
AtomicReference<String[]> newIndexNames = new AtomicReference<>(null);
ActionListener<AcknowledgedResponse> waitForShardsListener = ActionListeners.waitForShards(listener, activeShardsObserver, request.timeout(), () -> logger.info("Renamed a relation, but the operation timed out waiting for enough shards to become available"), newIndexNames::get);
clusterService.submitStateUpdateTask("rename-table", new AckedClusterStateUpdateTask<AcknowledgedResponse>(Priority.HIGH, request, waitForShardsListener) {
@Override
public ClusterState execute(ClusterState currentState) throws Exception {
ClusterState updatedState = executor.execute(currentState, request);
IndicesOptions openIndices = IndicesOptions.fromOptions(true, true, true, false, true, true, false);
newIndexNames.set(indexNameExpressionResolver.concreteIndexNames(updatedState, openIndices, request.targetTableIdent().indexNameOrAlias()));
return updatedState;
}
@Override
protected AcknowledgedResponse newResponse(boolean acknowledged) {
return new AcknowledgedResponse(acknowledged);
}
});
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class SwapTablePlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
boolean dropSource = Objects.requireNonNull(DataTypes.BOOLEAN.sanitizeValue(SymbolEvaluator.evaluate(plannerContext.transactionContext(), dependencies.nodeContext(), swapTable.dropSource(), params, subQueryResults)), SwapTableAnalyzer.DROP_SOURCE + " option must be true or false, not null");
RelationName source = swapTable.source().ident();
SwapRelationsRequest request = new SwapRelationsRequest(Collections.singletonList(new RelationNameSwap(source, swapTable.target().ident())), dropSource ? Collections.singletonList(source) : emptyList());
OneRowActionListener<AcknowledgedResponse> listener = new OneRowActionListener<>(consumer, r -> r.isAcknowledged() ? new Row1(1L) : new Row1(0L));
dependencies.swapRelationsAction().execute(request, listener);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class DropFunctionPlan method executeOrFail.
@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) throws Exception {
DropUserDefinedFunctionRequest request = new DropUserDefinedFunctionRequest(analyzedDropFunction.schema(), analyzedDropFunction.name(), analyzedDropFunction.argumentTypes(), analyzedDropFunction.ifExists());
OneRowActionListener<AcknowledgedResponse> listener = new OneRowActionListener<>(consumer, r -> new Row1(1L));
dependencies.dropFunctionAction().execute(request, listener);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class TransportAnalyzeAction method publishTableStats.
private CompletableFuture<AcknowledgedResponse> publishTableStats(Map<RelationName, Stats> newTableStats) {
List<DiscoveryNode> nodesOn41OrAfter = StreamSupport.stream(clusterService.state().nodes().spliterator(), false).filter(x -> x.getVersion().onOrAfter(Version.V_4_1_0)).collect(Collectors.toList());
var listener = new FutureActionListener<AcknowledgedResponse, AcknowledgedResponse>(x -> x);
var multiListener = new MultiActionListener<>(nodesOn41OrAfter.size(), Collectors.reducing(new AcknowledgedResponse(true), (resp1, resp2) -> new AcknowledgedResponse(resp1.isAcknowledged() && resp2.isAcknowledged())), listener);
var responseHandler = new ActionListenerResponseHandler<>(multiListener, AcknowledgedResponse::new, ThreadPool.Names.SAME);
PublishTableStatsRequest request = new PublishTableStatsRequest(newTableStats);
for (DiscoveryNode node : nodesOn41OrAfter) {
transportService.sendRequest(node, RECEIVE_TABLE_STATS, request, responseHandler);
}
return listener;
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class TransportAnalyzeAction method fetchSamplesThenGenerateAndPublishStats.
@SuppressWarnings("unchecked")
public CompletableFuture<AcknowledgedResponse> fetchSamplesThenGenerateAndPublishStats() {
ArrayList<CompletableFuture<Map.Entry<RelationName, Stats>>> futures = new ArrayList<>();
for (SchemaInfo schema : schemas) {
if (!(schema instanceof DocSchemaInfo)) {
continue;
}
for (TableInfo table : schema.getTables()) {
List<Reference> primitiveColumns = StreamSupport.stream(table.spliterator(), false).filter(x -> !x.column().isSystemColumn()).filter(x -> DataTypes.isPrimitive(x.valueType())).map(x -> table.getReadReference(x.column())).collect(Collectors.toList());
futures.add(fetchSamples(table.ident(), primitiveColumns).thenApply(samples -> Map.entry(table.ident(), createTableStats(samples, primitiveColumns))));
}
}
return CompletableFutures.allAsList(futures).thenCompose(entries -> publishTableStats(Map.ofEntries(entries.toArray(new Map.Entry[0]))));
}
Aggregations