use of org.opensearch.client.RethrottleRequest in project OpenSearch by opensearch-project.
the class CRUDDocumentationIT method testReindexRethrottle.
@SuppressWarnings("unused")
public void testReindexRethrottle() throws Exception {
RestHighLevelClient client = highLevelClient();
TaskId taskId = new TaskId("oTUltX4IQMOUUVeiohTt8A:124");
{
// tag::rethrottle-disable-request
// <1>
RethrottleRequest request = new RethrottleRequest(taskId);
// end::rethrottle-disable-request
}
{
// tag::rethrottle-request
// <1>
RethrottleRequest request = new RethrottleRequest(taskId, 100.0f);
// end::rethrottle-request
}
{
RethrottleRequest request = new RethrottleRequest(taskId);
// tag::rethrottle-request-execution
// <1>
client.reindexRethrottle(request, RequestOptions.DEFAULT);
// <2>
client.updateByQueryRethrottle(request, RequestOptions.DEFAULT);
// <3>
client.deleteByQueryRethrottle(request, RequestOptions.DEFAULT);
// end::rethrottle-request-execution
}
ActionListener<ListTasksResponse> listener;
// tag::rethrottle-request-async-listener
listener = new ActionListener<ListTasksResponse>() {
@Override
public void onResponse(ListTasksResponse response) {
// <1>
}
@Override
public void onFailure(Exception e) {
// <2>
}
};
// end::rethrottle-request-async-listener
// Replace the empty listener by a blocking listener in test
final CountDownLatch latch = new CountDownLatch(3);
listener = new LatchedActionListener<>(listener, latch);
RethrottleRequest request = new RethrottleRequest(taskId);
// tag::rethrottle-execute-async
client.reindexRethrottleAsync(request, RequestOptions.DEFAULT, // <1>
listener);
client.updateByQueryRethrottleAsync(request, RequestOptions.DEFAULT, // <2>
listener);
client.deleteByQueryRethrottleAsync(request, RequestOptions.DEFAULT, // <3>
listener);
// end::rethrottle-execute-async
assertTrue(latch.await(30L, TimeUnit.SECONDS));
}
Aggregations