Search in sources :

Example 1 with Retry

use of org.elasticsearch.action.bulk.Retry in project elasticsearch by elastic.

the class RetryTests method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    createIndex("source");
    // Build the test data. Don't use indexRandom because that won't work consistently with such small thread pools.
    BulkRequestBuilder bulk = client().prepareBulk();
    for (int i = 0; i < DOC_COUNT; i++) {
        bulk.add(client().prepareIndex("source", "test").setSource("foo", "bar " + i));
    }
    Retry retry = Retry.on(EsRejectedExecutionException.class).policy(BackoffPolicy.exponentialBackoff());
    BulkResponse response = retry.withSyncBackoff(client(), bulk.request());
    assertFalse(response.buildFailureMessage(), response.hasFailures());
    client().admin().indices().prepareRefresh("source").get();
}
Also used : BulkResponse(org.elasticsearch.action.bulk.BulkResponse) BulkRequestBuilder(org.elasticsearch.action.bulk.BulkRequestBuilder) Retry(org.elasticsearch.action.bulk.Retry) EsRejectedExecutionException(org.elasticsearch.common.util.concurrent.EsRejectedExecutionException) Before(org.junit.Before)

Aggregations

BulkRequestBuilder (org.elasticsearch.action.bulk.BulkRequestBuilder)1 BulkResponse (org.elasticsearch.action.bulk.BulkResponse)1 Retry (org.elasticsearch.action.bulk.Retry)1 EsRejectedExecutionException (org.elasticsearch.common.util.concurrent.EsRejectedExecutionException)1 Before (org.junit.Before)1