use of 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.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]))));
}
use of org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class TransportCreatePartitionsActionTest method testCreateBulkIndicesSimple.
@Test
public void testCreateBulkIndicesSimple() throws Exception {
List<String> indices = Arrays.asList("index1", "index2", "index3", "index4");
AcknowledgedResponse response = action.execute(new CreatePartitionsRequest(indices, UUID.randomUUID())).get();
assertThat(response.isAcknowledged(), is(true));
Metadata indexMetadata = internalCluster().clusterService().state().metadata();
for (String index : indices) {
assertThat(indexMetadata.hasIndex(index), is(true));
}
}
use of org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.
the class TransportCreatePartitionsActionTest method testEmpty.
@Test
public void testEmpty() throws Exception {
AcknowledgedResponse response = action.execute(new CreatePartitionsRequest(List.of(), UUID.randomUUID())).get();
assertThat(response.isAcknowledged(), is(true));
}
use of org.elasticsearch.action.support.master.AcknowledgedResponse in project graylog2-server by Graylog2.
the class IndicesAdapterES7 method deleteIndexTemplate.
@Override
public boolean deleteIndexTemplate(String templateName) {
final DeleteIndexTemplateRequest request = new DeleteIndexTemplateRequest(templateName);
final AcknowledgedResponse result = client.execute((c, requestOptions) -> c.indices().deleteTemplate(request, requestOptions), "Unable to delete index template " + templateName);
return result.isAcknowledged();
}
Aggregations