use of org.elasticsearch.client.RethrottleRequest in project pancm_project by xuwujing.
the class EsHighLevelRestTest2 method rethrottleByQuery.
/**
* 用于更改正在运行的重索引、逐查询更新或逐查询删除任务的当前节流,或完全禁用任务的节流。
* @throws IOException
*/
private static void rethrottleByQuery() throws IOException {
TaskId taskId = new TaskId("1");
// 用于更改正在运行的重索引、逐查询更新或逐查询删除任务的当前节流,或完全禁用任务的节流。
// 并且将请求将任务的节流更改为每秒100个请求
RethrottleRequest request = new RethrottleRequest(taskId, 100.0f);
// 同步设置需要更改的流
// client.reindexRethrottle(request, RequestOptions.DEFAULT);
// client.updateByQueryRethrottle(request, RequestOptions.DEFAULT);
// client.deleteByQueryRethrottle(request, RequestOptions.DEFAULT);
ActionListener<ListTasksResponse> listener = new ActionListener<ListTasksResponse>() {
@Override
public void onResponse(ListTasksResponse response) {
System.out.println("====" + response.getTasks().toString());
}
@Override
public void onFailure(Exception e) {
System.out.println("====---" + e.getMessage());
}
};
// 异步设置要更改的流
client.reindexRethrottleAsync(request, RequestOptions.DEFAULT, listener);
client.updateByQueryRethrottleAsync(request, RequestOptions.DEFAULT, listener);
client.deleteByQueryRethrottleAsync(request, RequestOptions.DEFAULT, listener);
System.out.println("已成功设置!");
}
use of org.elasticsearch.client.RethrottleRequest in project spring-data-elasticsearch by spring-projects.
the class RequestConverters method rethrottle.
private static Request rethrottle(RethrottleRequest rethrottleRequest, String firstPathPart) {
String endpoint = new EndpointBuilder().addPathPart(firstPathPart).addPathPart(rethrottleRequest.getTaskId().toString()).addPathPart("_rethrottle").build();
Request request = new Request(HttpMethod.POST.name(), endpoint);
Params params = new Params(request).withRequestsPerSecond(rethrottleRequest.getRequestsPerSecond());
// we set "group_by" to "none" because this is the response format we can parse back
params.putParam("group_by", "none");
return request;
}
Aggregations