当前位置: 首页>>代码示例>>Java>>正文


Java RestBuilderListener类代码示例

本文整理汇总了Java中org.elasticsearch.rest.action.RestBuilderListener的典型用法代码示例。如果您正苦于以下问题:Java RestBuilderListener类的具体用法?Java RestBuilderListener怎么用?Java RestBuilderListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RestBuilderListener类属于org.elasticsearch.rest.action包,在下文中一共展示了RestBuilderListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareRequest

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    FlushRequest flushRequest = new FlushRequest(Strings.splitStringByCommaToArray(request.param("index")));
    flushRequest.indicesOptions(IndicesOptions.fromRequest(request, flushRequest.indicesOptions()));
    flushRequest.force(request.paramAsBoolean("force", flushRequest.force()));
    flushRequest.waitIfOngoing(request.paramAsBoolean("wait_if_ongoing", flushRequest.waitIfOngoing()));
    return channel -> client.admin().indices().flush(flushRequest, new RestBuilderListener<FlushResponse>(channel) {
        @Override
        public RestResponse buildResponse(FlushResponse response, XContentBuilder builder) throws Exception {
            builder.startObject();
            buildBroadcastShardsHeader(builder, request, response);
            builder.endObject();
            return new BytesRestResponse(OK, builder);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:RestFlushAction.java

示例2: prepareRequest

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    ForceMergeRequest mergeRequest = new ForceMergeRequest(Strings.splitStringByCommaToArray(request.param("index")));
    mergeRequest.indicesOptions(IndicesOptions.fromRequest(request, mergeRequest.indicesOptions()));
    mergeRequest.maxNumSegments(request.paramAsInt("max_num_segments", mergeRequest.maxNumSegments()));
    mergeRequest.onlyExpungeDeletes(request.paramAsBoolean("only_expunge_deletes", mergeRequest.onlyExpungeDeletes()));
    mergeRequest.flush(request.paramAsBoolean("flush", mergeRequest.flush()));
    return channel -> client.admin().indices().forceMerge(mergeRequest, new RestBuilderListener<ForceMergeResponse>(channel) {
        @Override
        public RestResponse buildResponse(ForceMergeResponse response, XContentBuilder builder) throws Exception {
            builder.startObject();
            buildBroadcastShardsHeader(builder, request, response);
            builder.endObject();
            return new BytesRestResponse(OK, builder);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:RestForceMergeAction.java

示例3: prepareRequest

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {

    final RecoveryRequest recoveryRequest = new RecoveryRequest(Strings.splitStringByCommaToArray(request.param("index")));
    recoveryRequest.detailed(request.paramAsBoolean("detailed", false));
    recoveryRequest.activeOnly(request.paramAsBoolean("active_only", false));
    recoveryRequest.indicesOptions(IndicesOptions.fromRequest(request, recoveryRequest.indicesOptions()));

    return channel -> client.admin().indices().recoveries(recoveryRequest, new RestBuilderListener<RecoveryResponse>(channel) {
        @Override
        public RestResponse buildResponse(RecoveryResponse response, XContentBuilder builder) throws Exception {
            response.detailed(recoveryRequest.detailed());
            builder.startObject();
            response.toXContent(builder, request);
            builder.endObject();
            return new BytesRestResponse(OK, builder);
        }
    });

}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:RestRecoveryAction.java

示例4: prepareRequest

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    ClearIndicesCacheRequest clearIndicesCacheRequest = new ClearIndicesCacheRequest(
            Strings.splitStringByCommaToArray(request.param("index")));
    clearIndicesCacheRequest.indicesOptions(IndicesOptions.fromRequest(request, clearIndicesCacheRequest.indicesOptions()));
    fromRequest(request, clearIndicesCacheRequest);
    return channel ->
            client.admin().indices().clearCache(clearIndicesCacheRequest, new RestBuilderListener<ClearIndicesCacheResponse>(channel) {
        @Override
        public RestResponse buildResponse(ClearIndicesCacheResponse response, XContentBuilder builder) throws Exception {
            builder.startObject();
            buildBroadcastShardsHeader(builder, request, response);
            builder.endObject();
            return new BytesRestResponse(OK, builder);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:RestClearIndicesCacheAction.java

示例5: prepareRequest

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    IndicesSegmentsRequest indicesSegmentsRequest = new IndicesSegmentsRequest(
            Strings.splitStringByCommaToArray(request.param("index")));
    indicesSegmentsRequest.verbose(request.paramAsBoolean("verbose", false));
    indicesSegmentsRequest.indicesOptions(IndicesOptions.fromRequest(request, indicesSegmentsRequest.indicesOptions()));
    return channel ->
        client.admin().indices().segments(indicesSegmentsRequest, new RestBuilderListener<IndicesSegmentResponse>(channel) {
            @Override
            public RestResponse buildResponse(IndicesSegmentResponse response, XContentBuilder builder) throws Exception {
                builder.startObject();
                buildBroadcastShardsHeader(builder, request, response);
                response.toXContent(builder, request);
                builder.endObject();
                return new BytesRestResponse(OK, builder);
            }
        });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:RestIndicesSegmentsAction.java

示例6: prepareRequest

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    IndicesShardStoresRequest indicesShardStoresRequest = new IndicesShardStoresRequest(
            Strings.splitStringByCommaToArray(request.param("index")));
    if (request.hasParam("status")) {
        indicesShardStoresRequest.shardStatuses(Strings.splitStringByCommaToArray(request.param("status")));
    }
    indicesShardStoresRequest.indicesOptions(IndicesOptions.fromRequest(request, indicesShardStoresRequest.indicesOptions()));
    return channel ->
        client.admin()
            .indices()
            .shardStores(indicesShardStoresRequest, new RestBuilderListener<IndicesShardStoresResponse>(channel) {
                @Override
                public RestResponse buildResponse(
                    IndicesShardStoresResponse response,
                    XContentBuilder builder) throws Exception {
                    builder.startObject();
                    response.toXContent(builder, request);
                    builder.endObject();
                    return new BytesRestResponse(OK, builder);
                }
            });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:RestIndicesShardStoresAction.java

示例7: handlePost

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
private RestChannelConsumer handlePost(final RestRequest request, NodeClient client) {
    UpgradeRequest upgradeReq = new UpgradeRequest(Strings.splitStringByCommaToArray(request.param("index")));
    upgradeReq.indicesOptions(IndicesOptions.fromRequest(request, upgradeReq.indicesOptions()));
    upgradeReq.upgradeOnlyAncientSegments(request.paramAsBoolean("only_ancient_segments", false));
    return channel -> client.admin().indices().upgrade(upgradeReq, new RestBuilderListener<UpgradeResponse>(channel) {
        @Override
        public RestResponse buildResponse(UpgradeResponse response, XContentBuilder builder) throws Exception {
            builder.startObject();
            buildBroadcastShardsHeader(builder, request, response);
            builder.startObject("upgraded_indices");
            for (Map.Entry<String, Tuple<Version, String>> entry : response.versions().entrySet()) {
                builder.startObject(entry.getKey());
                builder.field("upgrade_version", entry.getValue().v1());
                builder.field("oldest_lucene_segment_version", entry.getValue().v2());
                builder.endObject();
            }
            builder.endObject();
            builder.endObject();
            return new BytesRestResponse(OK, builder);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:RestUpgradeAction.java

示例8: listTasksResponseListener

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
/**
 * Standard listener for extensions of {@link ListTasksResponse} that supports {@code group_by=nodes}.
 */
public static <T extends ListTasksResponse> ActionListener<T> listTasksResponseListener(
            Supplier<DiscoveryNodes> nodesInCluster,
            String groupBy,
            final RestChannel channel) {
    if ("nodes".equals(groupBy)) {
        return new RestBuilderListener<T>(channel) {
            @Override
            public RestResponse buildResponse(T response, XContentBuilder builder) throws Exception {
                builder.startObject();
                response.toXContentGroupedByNode(builder, channel.request(), nodesInCluster.get());
                builder.endObject();
                return new BytesRestResponse(RestStatus.OK, builder);
            }
        };
    } else if ("parents".equals(groupBy)) {
        return new RestToXContentListener<>(channel);
    } else {
        throw new IllegalArgumentException("[group_by] must be one of [nodes] or [parents] but was [" + groupBy + "]");
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:RestListTasksAction.java

示例9: prepareRequest

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    final String[] repositories = request.paramAsStringArray("repository", Strings.EMPTY_ARRAY);
    GetRepositoriesRequest getRepositoriesRequest = getRepositoryRequest(repositories);
    getRepositoriesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getRepositoriesRequest.masterNodeTimeout()));
    getRepositoriesRequest.local(request.paramAsBoolean("local", getRepositoriesRequest.local()));
    settingsFilter.addFilterSettingParams(request);
    return channel ->
            client.admin().cluster().getRepositories(getRepositoriesRequest, new RestBuilderListener<GetRepositoriesResponse>(channel) {
                @Override
                public RestResponse buildResponse(GetRepositoriesResponse response, XContentBuilder builder) throws Exception {
                    builder.startObject();
                    for (RepositoryMetaData repositoryMetaData : response.repositories()) {
                        RepositoriesMetaData.toXContent(repositoryMetaData, builder, request);
                    }
                    builder.endObject();

                    return new BytesRestResponse(OK, builder);
                }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:RestGetRepositoriesAction.java

示例10: prepareRequest

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    ClusterAllocationExplainRequest req;
    if (request.hasContentOrSourceParam() == false) {
        // Empty request signals "explain the first unassigned shard you find"
        req = new ClusterAllocationExplainRequest();
    } else {
        try (XContentParser parser = request.contentOrSourceParamParser()) {
            req = ClusterAllocationExplainRequest.parse(parser);
        }
    }

    req.includeYesDecisions(request.paramAsBoolean("include_yes_decisions", false));
    req.includeDiskInfo(request.paramAsBoolean("include_disk_info", false));
    return channel -> client.admin().cluster().allocationExplain(req,
        new RestBuilderListener<ClusterAllocationExplainResponse>(channel) {
            @Override
            public RestResponse buildResponse(ClusterAllocationExplainResponse response, XContentBuilder builder) throws IOException {
                response.getExplanation().toXContent(builder, ToXContent.EMPTY_PARAMS);
                return new BytesRestResponse(RestStatus.OK, builder);
            }
        });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:RestClusterAllocationExplainAction.java

示例11: storeModel

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
public RestChannelConsumer storeModel(Client client, String id, String model) {
    PutStoredScriptRequestBuilder storedScriptRequestBuilder;
    try {
        storedScriptRequestBuilder = client.admin().cluster().preparePutStoredScript().setScriptLang(PMMLModelScriptEngineService.NAME)
                .setSource(jsonBuilder().startObject().field("script", model).endObject().bytes());
    } catch (IOException e) {
        throw new ElasticsearchException("cannot store model", e);
    }
    if (id != null) {
        storedScriptRequestBuilder.setId(id);
    }
    return channel -> {
        storedScriptRequestBuilder.execute(new RestBuilderListener<PutStoredScriptResponse>(channel) {
            @Override
            public RestResponse buildResponse(PutStoredScriptResponse response, XContentBuilder builder) throws Exception {
                builder.startObject();
                builder.field("acknowledged", response.isAcknowledged());
                builder.field("id", id);
                builder.endObject();
                return new BytesRestResponse(OK, builder);
            }
        });
    };
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:25,代码来源:RestStoreModelAction.java

示例12: prepareRequest

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
    String id = request.param("id");
    final PrepareSpecRequest prepareSpecRequest = new PrepareSpecRequest();
    if (request.content() == null) {
        throw new ElasticsearchException("prepare spec request must have a body");
    }
    prepareSpecRequest.source(new String(BytesReference.toBytes(request.content()), Charset.defaultCharset()));
    if (id != null) {
        prepareSpecRequest.id(id);
    }
    return channel -> {
        client.execute(PrepareSpecAction.INSTANCE, prepareSpecRequest, new RestBuilderListener<PrepareSpecResponse>(channel) {
            @Override
            public RestResponse buildResponse(PrepareSpecResponse response, XContentBuilder builder) throws Exception {
                builder.startObject();
                response.toXContent(builder, request);
                builder.endObject();
                return new BytesRestResponse(OK, builder);
            }
        });
    };

}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:25,代码来源:RestPrepareSpecAction.java

示例13: prepareRequest

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
    TrainModelRequestBuilder trainModelRequestBuilder = new TrainModelRequestBuilder(client);
    trainModelRequestBuilder.setModelId(request.param("id"));
    try {
        trainModelRequestBuilder.source(request.content());
    } catch (IOException ex) {
        throw new IllegalArgumentException(ex);
    }

    return channel -> {
        trainModelRequestBuilder.execute(new RestBuilderListener<TrainModelResponse>(channel) {
            @Override
            public RestResponse buildResponse(TrainModelResponse response, XContentBuilder builder) throws Exception {
                builder.startObject();
                response.toXContent(builder, request);
                builder.endObject();
                return new BytesRestResponse(OK, builder);
            }
        });
    };
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:23,代码来源:RestTrainModelAction.java

示例14: prepareRequest

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
@Override
protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
    final AllTermsRequest allTermsRequest = new AllTermsRequest();
    allTermsRequest.index(request.param("index"));
    allTermsRequest.field(request.param("field"));
    allTermsRequest.size(request.paramAsInt("size", 10));
    allTermsRequest.from(request.param("from"));
    allTermsRequest.minDocFreq(request.paramAsLong("min_doc_freq", 0));

    return channel -> {
        client.execute(AllTermsAction.INSTANCE, allTermsRequest, new RestBuilderListener<AllTermsResponse>(channel) {
            @Override
            public RestResponse buildResponse(AllTermsResponse response, XContentBuilder builder) throws Exception {
                builder.startObject();
                response.toXContent(builder, request);
                builder.endObject();
                return new BytesRestResponse(OK, builder);
            }
        });
    };
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:22,代码来源:RestAllTermsAction.java

示例15: prepareRequest

import org.elasticsearch.rest.action.RestBuilderListener; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, NodeClient client) throws IOException {
    String id = request.param("id");

    GetStoredScriptRequest getRequest = new GetStoredScriptRequest(id, Script.DEFAULT_TEMPLATE_LANG);

    return channel -> client.admin().cluster().getStoredScript(getRequest, new RestBuilderListener<GetStoredScriptResponse>(channel) {
        @Override
        public RestResponse buildResponse(GetStoredScriptResponse response, XContentBuilder builder) throws Exception {
            builder.startObject();
            builder.field(_ID_PARSE_FIELD.getPreferredName(), id);

            builder.field(StoredScriptSource.LANG_PARSE_FIELD.getPreferredName(), Script.DEFAULT_TEMPLATE_LANG);

            StoredScriptSource source = response.getSource();
            boolean found = source != null;
            builder.field(FOUND_PARSE_FIELD.getPreferredName(), found);

            if (found) {
                builder.field(StoredScriptSource.TEMPLATE_PARSE_FIELD.getPreferredName(), source.getCode());
            }

            builder.endObject();

            return new BytesRestResponse(found ? RestStatus.OK : RestStatus.NOT_FOUND, builder);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:RestGetSearchTemplateAction.java


注:本文中的org.elasticsearch.rest.action.RestBuilderListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。