Search in sources :

Example 1 with CreatePartitionsRequest

use of org.elasticsearch.action.admin.indices.create.CreatePartitionsRequest in project crate by crate.

the class ShardingUpsertExecutor method createPartitions.

private CompletableFuture<AcknowledgedResponse> createPartitions(Map<String, List<ShardedRequests.ItemAndRoutingAndSourceInfo<ShardUpsertRequest.Item>>> itemsByMissingIndex) {
    FutureActionListener<AcknowledgedResponse, AcknowledgedResponse> listener = FutureActionListener.newInstance();
    createPartitionsAction.execute(new CreatePartitionsRequest(itemsByMissingIndex.keySet(), jobId), listener);
    return listener;
}
Also used : CreatePartitionsRequest(org.elasticsearch.action.admin.indices.create.CreatePartitionsRequest) AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse)

Example 2 with CreatePartitionsRequest

use of org.elasticsearch.action.admin.indices.create.CreatePartitionsRequest in project crate by crate.

the class InsertFromValues method createIndices.

private static CompletableFuture<AcknowledgedResponse> createIndices(TransportCreatePartitionsAction createPartitionsAction, Set<String> indices, ClusterService clusterService, UUID jobId) {
    Metadata metadata = clusterService.state().getMetadata();
    List<String> indicesToCreate = new ArrayList<>();
    for (var index : indices) {
        if (IndexParts.isPartitioned(index) && metadata.hasIndex(index) == false) {
            indicesToCreate.add(index);
        }
    }
    if (indicesToCreate.isEmpty()) {
        return CompletableFuture.completedFuture(new AcknowledgedResponse(true));
    }
    FutureActionListener<AcknowledgedResponse, AcknowledgedResponse> listener = new FutureActionListener<>(r -> r);
    createPartitionsAction.execute(new CreatePartitionsRequest(indicesToCreate, jobId), listener);
    return listener;
}
Also used : CreatePartitionsRequest(org.elasticsearch.action.admin.indices.create.CreatePartitionsRequest) Metadata(org.elasticsearch.cluster.metadata.Metadata) IntArrayList(com.carrotsearch.hppc.IntArrayList) ArrayList(java.util.ArrayList) AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) FutureActionListener(io.crate.action.FutureActionListener)

Aggregations

CreatePartitionsRequest (org.elasticsearch.action.admin.indices.create.CreatePartitionsRequest)2 AcknowledgedResponse (org.elasticsearch.action.support.master.AcknowledgedResponse)2 IntArrayList (com.carrotsearch.hppc.IntArrayList)1 FutureActionListener (io.crate.action.FutureActionListener)1 ArrayList (java.util.ArrayList)1 Metadata (org.elasticsearch.cluster.metadata.Metadata)1