/** * Specifies what type of requested indices to ignore and wildcard indices expressions * For example indices that don't exist. * * @param indicesOptions the desired behaviour regarding indices to ignore and indices wildcard expressions * @return the request itself */ public CloseIndexRequestBuilder setIndicesOptions(IndicesOptions indicesOptions) { request.indicesOptions(indicesOptions); return this; } }
@Override public CloseIndexRequestBuilder newRequestBuilder(ElasticsearchClient client) { return new CloseIndexRequestBuilder(client, this); } }
/** * Creates a close index request. * * @param index The index to close * @return The delete index request * @see org.elasticsearch.client.IndicesAdminClient#close(org.elasticsearch.action.admin.indices.close.CloseIndexRequest) */ public static CloseIndexRequest closeIndexRequest(String index) { return new CloseIndexRequest(index); }
@Override protected void masterOperation(final CloseIndexRequest request, final ClusterState state, final ActionListener<AcknowledgedResponse> listener) { final Index[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, request); if (concreteIndices == null || concreteIndices.length == 0) { listener.onResponse(new AcknowledgedResponse(true)); return; } CloseIndexClusterStateUpdateRequest updateRequest = new CloseIndexClusterStateUpdateRequest() .ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout()) .indices(concreteIndices); indexStateService.closeIndices(updateRequest, new ActionListener<ClusterStateUpdateResponse>() { @Override public void onResponse(ClusterStateUpdateResponse response) { listener.onResponse(new AcknowledgedResponse(response.isAcknowledged())); } @Override public void onFailure(Exception t) { logger.debug(() -> new ParameterizedMessage("failed to close indices [{}]", (Object) concreteIndices), t); listener.onFailure(t); } }); } }
@Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { CloseIndexRequest closeIndexRequest = new CloseIndexRequest(Strings.splitStringByCommaToArray(request.param("index"))); closeIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", closeIndexRequest.masterNodeTimeout())); closeIndexRequest.timeout(request.paramAsTime("timeout", closeIndexRequest.timeout())); closeIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, closeIndexRequest.indicesOptions())); return channel -> client.admin().indices().close(closeIndexRequest, new RestToXContentListener<>(channel)); }
/** * Sets the indices to be closed * * @param indices the indices to be closed * @return the request itself */ public CloseIndexRequestBuilder setIndices(String... indices) { request.indices(indices); return this; }
@Override public ClusterState execute(ClusterState currentState) { return closeIndices(currentState, request.indices(), indicesAsString); } });
public CloseIndexRequestBuilder(ElasticsearchClient client, CloseIndexAction action, String... indices) { super(client, action, new CloseIndexRequest(indices)); }
@Override protected void doExecute(Task task, CloseIndexRequest request, ActionListener<AcknowledgedResponse> listener) { destructiveOperations.failDestructive(request.indices()); if (closeIndexEnabled == false) { throw new IllegalStateException("closing indices is disabled - set [" + CLUSTER_INDICES_CLOSE_ENABLE_SETTING.getKey() + ": true] to enable it. NOTE: closed indices still consume a significant amount of diskspace"); } super.doExecute(task, request, listener); }
/** * Specifies what type of requested indices to ignore and wildcard indices expressions * For example indices that don't exist. * * @param indicesOptions the desired behaviour regarding indices to ignore and indices wildcard expressions * @return the request itself */ public CloseIndexRequestBuilder setIndicesOptions(IndicesOptions indicesOptions) { request.indicesOptions(indicesOptions); return this; } }
@Override public CloseIndexRequestBuilder prepareClose(String... indices) { return new CloseIndexRequestBuilder(this, CloseIndexAction.INSTANCE, indices); }
public void closeIndices(final CloseIndexClusterStateUpdateRequest request, final ActionListener<ClusterStateUpdateResponse> listener) { if (request.indices() == null || request.indices().length == 0) { throw new IllegalArgumentException("Index name is required"); } final String indicesAsString = Arrays.toString(request.indices()); clusterService.submitStateUpdateTask("close-indices " + indicesAsString, new AckedClusterStateUpdateTask<ClusterStateUpdateResponse>(Priority.URGENT, request, listener) { @Override protected ClusterStateUpdateResponse newResponse(boolean acknowledged) { return new ClusterStateUpdateResponse(acknowledged); } @Override public ClusterState execute(ClusterState currentState) { return closeIndices(currentState, request.indices(), indicesAsString); } }); }
public CloseIndexRequestBuilder(ElasticsearchClient client, CloseIndexAction action) { super(client, action, new CloseIndexRequest()); }
/** * Sets the indices to be closed * * @param indices the indices to be closed * @return the request itself */ public CloseIndexRequestBuilder setIndices(String... indices) { request.indices(indices); return this; }
@Override public CloseIndexRequestBuilder newRequestBuilder(ElasticsearchClient client) { return new CloseIndexRequestBuilder(client, this); } }
/** * Creates a close index request. * * @param index The index to close * @return The delete index request * @see org.elasticsearch.client.IndicesAdminClient#close(org.elasticsearch.action.admin.indices.close.CloseIndexRequest) */ public static CloseIndexRequest closeIndexRequest(String index) { return new CloseIndexRequest(index); }
/** * Sets the indices to be closed * * @param indices the indices to be closed * @return the request itself */ public CloseIndexRequestBuilder setIndices(String... indices) { request.indices(indices); return this; }
@Override public CloseIndexRequestBuilder newRequestBuilder(ElasticsearchClient client) { return new CloseIndexRequestBuilder(client, this); } }
/** * Creates a close index request. * * @param index The index to close * @return The delete index request * @see org.elasticsearch.client.IndicesAdminClient#close(org.elasticsearch.action.admin.indices.close.CloseIndexRequest) */ public static CloseIndexRequest closeIndexRequest(String index) { return new CloseIndexRequest(index); }
/** * Creates a close index request. * * @param index The index to close * @return The delete index request * @see org.elasticsearch.client.IndicesAdminClient#close(org.elasticsearch.action.admin.indices.close.CloseIndexRequest) */ public static CloseIndexRequest closeIndexRequest(String index) { return new CloseIndexRequest(index); }