Java Code Examples for org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse#getFailedShards()

The following examples show how to use org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse#getFailedShards() . 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: 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);
    }
}