org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse Java Examples

The following examples show how to use org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticIndexer.java    From Stargraph with MIT License 6 votes vote down vote up
@Override
protected void afterLoad() throws InterruptedException {
    if (bulkProcessor != null) {
        logger.info(marker, "Waiting for transport to serialize all remaining documents.");

        if (!bulkProcessor.awaitClose(120, TimeUnit.MINUTES)) {
            logger.warn(marker, "Closing time expired BEFORE sending all documents!");
        }

        logger.info(marker, "Optimizing index for reading..");
        ForceMergeResponse res = esClient.prepareForceMerge().get();
        if (res.getFailedShards() != 0) {
            logger.warn(marker, "An error was detected during optimization. Check logs.");
        }

        if (!indexRequests.isEmpty()) {
            logger.error(marker, "Still pending {} index requests!?", indexRequests.size()); // should not happen
            indexRequests.clear();
        }
    }
}
 
Example #2
Source File: RestForceMergeAction.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    ForceMergeRequest mergeRequest = new ForceMergeRequest(Strings.splitStringByCommaToArray(request.param("index")));
    mergeRequest.indicesOptions(IndicesOptions.fromRequest(request, mergeRequest.indicesOptions()));
    mergeRequest.maxNumSegments(request.paramAsInt("max_num_segments", mergeRequest.maxNumSegments()));
    mergeRequest.onlyExpungeDeletes(request.paramAsBoolean("only_expunge_deletes", mergeRequest.onlyExpungeDeletes()));
    mergeRequest.flush(request.paramAsBoolean("flush", mergeRequest.flush()));
    client.admin().indices().forceMerge(mergeRequest, new RestBuilderListener<ForceMergeResponse>(channel) {
        @Override
        public RestResponse buildResponse(ForceMergeResponse response, XContentBuilder builder) throws Exception {
            builder.startObject();
            buildBroadcastShardsHeader(builder, request, response);
            builder.endObject();
            return new BytesRestResponse(OK, builder);
        }
    });
}
 
Example #3
Source File: ElasticIndexer.java    From Stargraph with MIT License 5 votes vote down vote up
@Override
protected void doFlush() {
    bulkProcessor.flush();
    try {
        //TODO: Figure out why flushing is not always being honored without delaying.
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
    ForceMergeResponse res = esClient.prepareForceMerge().get();
    if (res.getFailedShards() > 0) {
        logger.warn("Flush request failure detected on {}", kbId);
    }
}
 
Example #4
Source File: ElasticsearchClusterRunner.java    From elasticsearch-cluster-runner with Apache License 2.0 5 votes vote down vote up
public ForceMergeResponse forceMerge(final BuilderCallback<ForceMergeRequestBuilder> builder) {
    waitForRelocation();
    final ForceMergeResponse actionGet = builder.apply(client().admin().indices().prepareForceMerge()).execute().actionGet();
    final ShardOperationFailedException[] shardFailures = actionGet.getShardFailures();
    if (shardFailures != null && shardFailures.length != 0) {
        final StringBuilder buf = new StringBuilder(100);
        for (final ShardOperationFailedException shardFailure : shardFailures) {
            buf.append(shardFailure.toString()).append('\n');
        }
        onFailure(buf.toString(), actionGet);
    }
    return actionGet;
}
 
Example #5
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public ActionFuture<ForceMergeResponse> forceMerge(final ForceMergeRequest request) {
    return execute(ForceMergeAction.INSTANCE, request);
}
 
Example #6
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void forceMerge(final ForceMergeRequest request, final ActionListener<ForceMergeResponse> listener) {
    execute(ForceMergeAction.INSTANCE, request, listener);
}
 
Example #7
Source File: ElasticsearchClusterRunner.java    From elasticsearch-cluster-runner with Apache License 2.0 4 votes vote down vote up
public ForceMergeResponse forceMerge() {
    return forceMerge(-1, false, true);
}
 
Example #8
Source File: ElasticsearchClusterRunner.java    From elasticsearch-cluster-runner with Apache License 2.0 4 votes vote down vote up
public ForceMergeResponse forceMerge(final int maxNumSegments, final boolean onlyExpungeDeletes, final boolean flush) {
    return forceMerge(builder -> builder.setMaxNumSegments(maxNumSegments).setOnlyExpungeDeletes(onlyExpungeDeletes).setFlush(flush));
}
 
Example #9
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public ActionFuture<ForceMergeResponse> forceMerge(final ForceMergeRequest request) {
    return execute(ForceMergeAction.INSTANCE, request);
}
 
Example #10
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void forceMerge(final ForceMergeRequest request, final ActionListener<ForceMergeResponse> listener) {
    execute(ForceMergeAction.INSTANCE, request, listener);
}
 
Example #11
Source File: IndicesAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Explicitly force merge one or more indices into a the number of segments.
 *
 * @param request The optimize request
 * @return A result future
 * @see org.elasticsearch.client.Requests#forceMergeRequest(String...)
 */
ActionFuture<ForceMergeResponse> forceMerge(ForceMergeRequest request);
 
Example #12
Source File: IndicesAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Explicitly force merge one or more indices into a the number of segments.
 *
 * @param request  The force merge request
 * @param listener A listener to be notified with a result
 * @see org.elasticsearch.client.Requests#forceMergeRequest(String...)
 */
void forceMerge(ForceMergeRequest request, ActionListener<ForceMergeResponse> listener);
 
Example #13
Source File: IndicesAdminClient.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * Explicitly force merge one or more indices into a the number of segments.
 *
 * @param request The optimize request
 * @return A result future
 * @see org.elasticsearch.client.Requests#forceMergeRequest(String...)
 */
ActionFuture<ForceMergeResponse> forceMerge(ForceMergeRequest request);
 
Example #14
Source File: IndicesAdminClient.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * Explicitly force merge one or more indices into a the number of segments.
 *
 * @param request  The force merge request
 * @param listener A listener to be notified with a result
 * @see org.elasticsearch.client.Requests#forceMergeRequest(String...)
 */
void forceMerge(ForceMergeRequest request, ActionListener<ForceMergeResponse> listener);