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


Java RestResponse类代码示例

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


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

示例1: testXContentBuilderClosedInBuildResponse

import org.elasticsearch.rest.RestResponse; //导入依赖的package包/类
public void testXContentBuilderClosedInBuildResponse() throws Exception {
    AtomicReference<XContentBuilder> builderAtomicReference = new AtomicReference<>();
    RestBuilderListener<TransportResponse.Empty> builderListener =
        new RestBuilderListener<Empty>(new FakeRestChannel(new FakeRestRequest(), randomBoolean(), 1)) {
            @Override
            public RestResponse buildResponse(Empty empty, XContentBuilder builder) throws Exception {
                builderAtomicReference.set(builder);
                builder.close();
                return new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY);
            }
    };

    builderListener.buildResponse(Empty.INSTANCE);
    assertNotNull(builderAtomicReference.get());
    assertTrue(builderAtomicReference.get().generator().isClosed());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:RestBuilderListenerTests.java

示例2: prepareRequest

import org.elasticsearch.rest.RestResponse; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    TypesExistsRequest typesExistsRequest = new TypesExistsRequest(
            Strings.splitStringByCommaToArray(request.param("index")), Strings.splitStringByCommaToArray(request.param("type"))
    );
    typesExistsRequest.local(request.paramAsBoolean("local", typesExistsRequest.local()));
    typesExistsRequest.indicesOptions(IndicesOptions.fromRequest(request, typesExistsRequest.indicesOptions()));
    return channel -> client.admin().indices().typesExists(typesExistsRequest, new RestResponseListener<TypesExistsResponse>(channel) {
        @Override
        public RestResponse buildResponse(TypesExistsResponse response) throws Exception {
            if (response.isExists()) {
                return new BytesRestResponse(OK, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY);
            } else {
                return new BytesRestResponse(NOT_FOUND, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY);
            }
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:RestTypesExistsAction.java

示例3: prepareRequest

import org.elasticsearch.rest.RestResponse; //导入依赖的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

示例4: prepareRequest

import org.elasticsearch.rest.RestResponse; //导入依赖的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

示例5: prepareRequest

import org.elasticsearch.rest.RestResponse; //导入依赖的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

示例6: prepareRequest

import org.elasticsearch.rest.RestResponse; //导入依赖的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

示例7: prepareRequest

import org.elasticsearch.rest.RestResponse; //导入依赖的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

示例8: prepareRequest

import org.elasticsearch.rest.RestResponse; //导入依赖的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

示例9: handlePost

import org.elasticsearch.rest.RestResponse; //导入依赖的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

示例10: listTasksResponseListener

import org.elasticsearch.rest.RestResponse; //导入依赖的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

示例11: prepareRequest

import org.elasticsearch.rest.RestResponse; //导入依赖的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

示例12: prepareRequest

import org.elasticsearch.rest.RestResponse; //导入依赖的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

示例13: prepareRequest

import org.elasticsearch.rest.RestResponse; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    String[] nodesIds = Strings.splitStringByCommaToArray(request.param("nodeId"));
    NodesHotThreadsRequest nodesHotThreadsRequest = new NodesHotThreadsRequest(nodesIds);
    nodesHotThreadsRequest.threads(request.paramAsInt("threads", nodesHotThreadsRequest.threads()));
    nodesHotThreadsRequest.ignoreIdleThreads(request.paramAsBoolean("ignore_idle_threads", nodesHotThreadsRequest.ignoreIdleThreads()));
    nodesHotThreadsRequest.type(request.param("type", nodesHotThreadsRequest.type()));
    nodesHotThreadsRequest.interval(TimeValue.parseTimeValue(request.param("interval"), nodesHotThreadsRequest.interval(), "interval"));
    nodesHotThreadsRequest.snapshots(request.paramAsInt("snapshots", nodesHotThreadsRequest.snapshots()));
    nodesHotThreadsRequest.timeout(request.param("timeout"));
    return channel -> client.admin().cluster().nodesHotThreads(
            nodesHotThreadsRequest,
            new RestResponseListener<NodesHotThreadsResponse>(channel) {
                @Override
                public RestResponse buildResponse(NodesHotThreadsResponse response) throws Exception {
                    StringBuilder sb = new StringBuilder();
                    for (NodeHotThreads node : response.getNodes()) {
                        sb.append("::: ").append(node.getNode().toString()).append("\n");
                        Strings.spaceify(3, node.getHotThreads(), sb);
                        sb.append('\n');
                    }
                    return new BytesRestResponse(RestStatus.OK, sb.toString());
                }
            });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:RestNodesHotThreadsAction.java

示例14: doCatRequest

import org.elasticsearch.rest.RestResponse; //导入依赖的package包/类
@Override
protected RestChannelConsumer doCatRequest(final RestRequest request, NodeClient client) {
    final String matchPattern = request.hasParam("name") ? request.param("name") : null;
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().metaData(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));

    return channel -> client.admin().cluster().state(clusterStateRequest, new RestResponseListener<ClusterStateResponse>(channel) {
        @Override
        public RestResponse buildResponse(ClusterStateResponse clusterStateResponse) throws Exception {
            return RestTable.buildResponse(buildTable(request, clusterStateResponse, matchPattern), channel);
        }
    });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:RestTemplatesAction.java

示例15: doCatRequest

import org.elasticsearch.rest.RestResponse; //导入依赖的package包/类
@Override
protected RestChannelConsumer doCatRequest(final RestRequest request, NodeClient client) {
    GetSnapshotsRequest getSnapshotsRequest = new GetSnapshotsRequest()
            .repository(request.param("repository"))
            .snapshots(new String[]{GetSnapshotsRequest.ALL_SNAPSHOTS});

    getSnapshotsRequest.ignoreUnavailable(request.paramAsBoolean("ignore_unavailable", getSnapshotsRequest.ignoreUnavailable()));

    getSnapshotsRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getSnapshotsRequest.masterNodeTimeout()));

    return channel ->
        client.admin().cluster().getSnapshots(getSnapshotsRequest, new RestResponseListener<GetSnapshotsResponse>(channel) {
            @Override
            public RestResponse buildResponse(GetSnapshotsResponse getSnapshotsResponse) throws Exception {
                return RestTable.buildResponse(buildTable(request, getSnapshotsResponse), channel);
            }
        });
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:RestSnapshotAction.java


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