Search in sources :

Example 6 with AcknowledgedResponse

use of org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.

the class TransportSchemaUpdateAction method updateMapping.

private CompletableFuture<AcknowledgedResponse> updateMapping(Index index, TimeValue timeout, String mappingSource) {
    FutureActionListener<AcknowledgedResponse, AcknowledgedResponse> putMappingListener = FutureActionListener.newInstance();
    PutMappingRequest putMappingRequest = new PutMappingRequest().indices(new String[0]).setConcreteIndex(index).source(mappingSource, XContentType.JSON).timeout(timeout).masterNodeTimeout(timeout);
    nodeClient.execute(PutMappingAction.INSTANCE, putMappingRequest, putMappingListener);
    return putMappingListener;
}
Also used : PutMappingRequest(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest) AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse)

Example 7 with AcknowledgedResponse

use of org.elasticsearch.action.support.master.AcknowledgedResponse in project crate by crate.

the class BlobAdminClient method dropBlobTable.

public CompletableFuture<Long> dropBlobTable(final String tableName) {
    FutureActionListener<AcknowledgedResponse, Long> listener = new FutureActionListener<>(r -> 1L);
    deleteIndexAction.execute(new DeleteIndexRequest(fullIndexName(tableName)), listener);
    return listener;
}
Also used : AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) FutureActionListener(io.crate.action.FutureActionListener)

Example 8 with AcknowledgedResponse

use of 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);
        }
    });
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) AtomicReference(java.util.concurrent.atomic.AtomicReference) IndicesOptions(org.elasticsearch.action.support.IndicesOptions) IOException(java.io.IOException) ClusterBlockException(org.elasticsearch.cluster.block.ClusterBlockException) IndexNotFoundException(org.elasticsearch.index.IndexNotFoundException)

Example 9 with AcknowledgedResponse

use of 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);
}
Also used : RelationNameSwap(io.crate.execution.ddl.RelationNameSwap) Row1(io.crate.data.Row1) OneRowActionListener(io.crate.execution.support.OneRowActionListener) SwapRelationsRequest(io.crate.execution.ddl.SwapRelationsRequest) AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) RelationName(io.crate.metadata.RelationName)

Example 10 with AcknowledgedResponse

use of 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);
}
Also used : Row1(io.crate.data.Row1) OneRowActionListener(io.crate.execution.support.OneRowActionListener) AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) DropUserDefinedFunctionRequest(io.crate.expression.udf.DropUserDefinedFunctionRequest)

Aggregations

AcknowledgedResponse (org.elasticsearch.action.support.master.AcknowledgedResponse)37 IOException (java.io.IOException)11 FutureActionListener (io.crate.action.FutureActionListener)9 ClusterState (org.elasticsearch.cluster.ClusterState)7 Row1 (io.crate.data.Row1)6 Map (java.util.Map)6 DeleteIndexRequest (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)6 ClusterBlockException (org.elasticsearch.cluster.block.ClusterBlockException)6 Metadata (org.elasticsearch.cluster.metadata.Metadata)6 Row (io.crate.data.Row)5 RelationName (io.crate.metadata.RelationName)5 Arrays (java.util.Arrays)5 HashMap (java.util.HashMap)5 List (java.util.List)5 Reference (io.crate.metadata.Reference)4 DataType (io.crate.types.DataType)4 ArrayList (java.util.ArrayList)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 StreamSupport (java.util.stream.StreamSupport)4 ClusterService (org.elasticsearch.cluster.service.ClusterService)4