Search in sources :

Example 1 with RethrottleRequest

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("已成功设置!");
}
Also used : RethrottleRequest(org.elasticsearch.client.RethrottleRequest) TaskId(org.elasticsearch.tasks.TaskId) ActionListener(org.elasticsearch.action.ActionListener) ListTasksResponse(org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse) IOException(java.io.IOException)

Example 2 with RethrottleRequest

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;
}
Also used : ExplainRequest(org.elasticsearch.action.explain.ExplainRequest) GetMappingsRequest(org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest) SearchTemplateRequest(org.elasticsearch.script.mustache.SearchTemplateRequest) DeleteRequest(org.elasticsearch.action.delete.DeleteRequest) IndexRequest(org.elasticsearch.action.index.IndexRequest) DeleteByQueryRequest(org.elasticsearch.index.reindex.DeleteByQueryRequest) FieldCapabilitiesRequest(org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest) CountRequest(org.elasticsearch.client.core.CountRequest) IndexTemplatesExistRequest(org.elasticsearch.client.indices.IndexTemplatesExistRequest) GetStoredScriptRequest(org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest) GetRequest(org.elasticsearch.action.get.GetRequest) RankEvalRequest(org.elasticsearch.index.rankeval.RankEvalRequest) GetAliasesRequest(org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest) IndicesAliasesRequest(org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest) AbstractBulkByScrollRequest(org.elasticsearch.index.reindex.AbstractBulkByScrollRequest) DeleteIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest) ClusterHealthRequest(org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest) GetSettingsRequest(org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest) PutStoredScriptRequest(org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequest) ClearScrollRequest(org.elasticsearch.action.search.ClearScrollRequest) PutIndexTemplateRequest(org.elasticsearch.client.indices.PutIndexTemplateRequest) DeleteStoredScriptRequest(org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest) MultiGetRequest(org.elasticsearch.action.get.MultiGetRequest) SearchRequest(org.elasticsearch.action.search.SearchRequest) OpenIndexRequest(org.elasticsearch.action.admin.indices.open.OpenIndexRequest) MultiSearchRequest(org.elasticsearch.action.search.MultiSearchRequest) CreateIndexRequest(org.elasticsearch.action.admin.indices.create.CreateIndexRequest) RefreshRequest(org.elasticsearch.action.admin.indices.refresh.RefreshRequest) UpdateByQueryRequest(org.elasticsearch.index.reindex.UpdateByQueryRequest) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) GetIndexRequest(org.elasticsearch.action.admin.indices.get.GetIndexRequest) GetIndexTemplatesRequest(org.elasticsearch.client.indices.GetIndexTemplatesRequest) GetFieldMappingsRequest(org.elasticsearch.client.indices.GetFieldMappingsRequest) UpdateRequest(org.elasticsearch.action.update.UpdateRequest) DocWriteRequest(org.elasticsearch.action.DocWriteRequest) Request(org.elasticsearch.client.Request) AnalyzeRequest(org.elasticsearch.client.indices.AnalyzeRequest) CloseIndexRequest(org.elasticsearch.action.admin.indices.close.CloseIndexRequest) RethrottleRequest(org.elasticsearch.client.RethrottleRequest) FlushRequest(org.elasticsearch.action.admin.indices.flush.FlushRequest) PutMappingRequest(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest) SearchScrollRequest(org.elasticsearch.action.search.SearchScrollRequest) BulkRequest(org.elasticsearch.action.bulk.BulkRequest) ReindexRequest(org.elasticsearch.index.reindex.ReindexRequest)

Aggregations

RethrottleRequest (org.elasticsearch.client.RethrottleRequest)2 IOException (java.io.IOException)1 ActionListener (org.elasticsearch.action.ActionListener)1 DocWriteRequest (org.elasticsearch.action.DocWriteRequest)1 ClusterHealthRequest (org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest)1 ListTasksResponse (org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse)1 DeleteStoredScriptRequest (org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest)1 GetStoredScriptRequest (org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest)1 PutStoredScriptRequest (org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequest)1 IndicesAliasesRequest (org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest)1 GetAliasesRequest (org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest)1 CloseIndexRequest (org.elasticsearch.action.admin.indices.close.CloseIndexRequest)1 CreateIndexRequest (org.elasticsearch.action.admin.indices.create.CreateIndexRequest)1 DeleteIndexRequest (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)1 FlushRequest (org.elasticsearch.action.admin.indices.flush.FlushRequest)1 GetIndexRequest (org.elasticsearch.action.admin.indices.get.GetIndexRequest)1 GetMappingsRequest (org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest)1 PutMappingRequest (org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest)1 OpenIndexRequest (org.elasticsearch.action.admin.indices.open.OpenIndexRequest)1 RefreshRequest (org.elasticsearch.action.admin.indices.refresh.RefreshRequest)1