use of org.opensearch.action.admin.indices.flush.SyncedFlushResponse in project fesen-httpclient by codelibs.
the class Elasticsearch7ClientTest method test_synced_flush.
@Test
void test_synced_flush() throws Exception {
final String index = "test_synced_flush";
CountDownLatch latch = new CountDownLatch(1);
client.admin().indices().prepareCreate(index).execute().actionGet();
client.admin().indices().prepareSyncedFlush(index).execute(wrap(res -> {
assertEquals(RestStatus.OK, res.restStatus());
latch.countDown();
}, e -> {
e.printStackTrace();
try {
fail();
} finally {
latch.countDown();
}
}));
latch.await();
{
SyncedFlushResponse syncedFlushResponse = client.admin().indices().prepareSyncedFlush(index).execute().actionGet();
assertEquals(RestStatus.OK, syncedFlushResponse.restStatus());
}
}
use of org.opensearch.action.admin.indices.flush.SyncedFlushResponse in project fesen-httpclient by codelibs.
the class HttpSyncedFlushAction method execute.
public void execute(final SyncedFlushRequest request, final ActionListener<SyncedFlushResponse> listener) {
if (client.getEngineInfo().getType() == EngineType.ELASTICSEARCH8) {
listener.onFailure(new OpenSearchException("Synced-flush is deprecated."));
return;
}
getCurlRequest(request).execute(response -> {
try (final XContentParser parser = createParser(response)) {
final SyncedFlushResponse syncedFlushResponse = getSyncedFlushResponse(parser);
listener.onResponse(syncedFlushResponse);
} catch (final Exception e) {
listener.onFailure(toOpenSearchException(response, e));
}
}, e -> unwrapOpenSearchException(listener, e));
}
use of org.opensearch.action.admin.indices.flush.SyncedFlushResponse in project fesen-httpclient by codelibs.
the class OpenSearchClientTest method test_synced_flush.
@Test
void test_synced_flush() throws Exception {
final String index = "test_synced_flush";
CountDownLatch latch = new CountDownLatch(1);
client.admin().indices().prepareCreate(index).execute().actionGet();
client.admin().indices().prepareSyncedFlush(index).execute(wrap(res -> {
assertEquals(RestStatus.OK, res.restStatus());
latch.countDown();
}, e -> {
e.printStackTrace();
try {
fail();
} finally {
latch.countDown();
}
}));
latch.await();
{
SyncedFlushResponse syncedFlushResponse = client.admin().indices().prepareSyncedFlush(index).execute().actionGet();
assertEquals(RestStatus.OK, syncedFlushResponse.restStatus());
}
}
Aggregations