Search in sources :

Example 1 with DeleteSnapshotRequest

use of org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest in project crate by crate.

the class SnapshotRestoreDDLDispatcher method dispatch.

public CompletableFuture<Long> dispatch(final DropSnapshotAnalyzedStatement statement) {
    final CompletableFuture<Long> future = new CompletableFuture<>();
    final String repositoryName = statement.repository();
    final String snapshotName = statement.snapshot();
    transportActionProvider.transportDeleteSnapshotAction().execute(new DeleteSnapshotRequest(repositoryName, snapshotName), new ActionListener<DeleteSnapshotResponse>() {

        @Override
        public void onResponse(DeleteSnapshotResponse response) {
            if (!response.isAcknowledged()) {
                LOGGER.info("delete snapshot '{}.{}' not acknowledged", repositoryName, snapshotName);
            }
            future.complete(1L);
        }

        @Override
        public void onFailure(Throwable e) {
            future.completeExceptionally(e);
        }
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) DeleteSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest) DeleteSnapshotResponse(org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotResponse)

Example 2 with DeleteSnapshotRequest

use of org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest in project elasticsearch by elastic.

the class RestDeleteSnapshotAction method prepareRequest.

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    DeleteSnapshotRequest deleteSnapshotRequest = deleteSnapshotRequest(request.param("repository"), request.param("snapshot"));
    deleteSnapshotRequest.masterNodeTimeout(request.paramAsTime("master_timeout", deleteSnapshotRequest.masterNodeTimeout()));
    return channel -> client.admin().cluster().deleteSnapshot(deleteSnapshotRequest, new AcknowledgedRestListener<>(channel));
}
Also used : BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) Requests.deleteSnapshotRequest(org.elasticsearch.client.Requests.deleteSnapshotRequest) Settings(org.elasticsearch.common.settings.Settings) DELETE(org.elasticsearch.rest.RestRequest.Method.DELETE) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) IOException(java.io.IOException) DeleteSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest) RestController(org.elasticsearch.rest.RestController) AcknowledgedRestListener(org.elasticsearch.rest.action.AcknowledgedRestListener) DeleteSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest)

Example 3 with DeleteSnapshotRequest

use of org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest 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

DeleteSnapshotRequest (org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest)3 AnalyzedDropSnapshot (io.crate.analyze.AnalyzedDropSnapshot)1 Row (io.crate.data.Row)1 Row1 (io.crate.data.Row1)1 RowConsumer (io.crate.data.RowConsumer)1 OneRowActionListener (io.crate.execution.support.OneRowActionListener)1 DependencyCarrier (io.crate.planner.DependencyCarrier)1 Plan (io.crate.planner.Plan)1 PlannerContext (io.crate.planner.PlannerContext)1 SubQueryResults (io.crate.planner.operators.SubQueryResults)1 IOException (java.io.IOException)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 DeleteSnapshotResponse (org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotResponse)1 Requests.deleteSnapshotRequest (org.elasticsearch.client.Requests.deleteSnapshotRequest)1 NodeClient (org.elasticsearch.client.node.NodeClient)1 Settings (org.elasticsearch.common.settings.Settings)1 BaseRestHandler (org.elasticsearch.rest.BaseRestHandler)1 RestController (org.elasticsearch.rest.RestController)1