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


Java RestStatus.SERVICE_UNAVAILABLE属性代码示例

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


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

示例1: testHeadResponse

public void testHeadResponse() throws Exception {
    final String nodeName = "node1";
    final ClusterName clusterName = new ClusterName("cluster1");
    final String clusterUUID = randomAsciiOfLengthBetween(10, 20);
    final boolean available = randomBoolean();
    final RestStatus expectedStatus = available ? RestStatus.OK : RestStatus.SERVICE_UNAVAILABLE;
    final Version version = Version.CURRENT;
    final Build build = Build.CURRENT;

    final MainResponse mainResponse = new MainResponse(nodeName, version, clusterName, clusterUUID, build, available);
    XContentBuilder builder = JsonXContent.contentBuilder();
    RestRequest restRequest = new FakeRestRequest() {
        @Override
        public Method method() {
            return Method.HEAD;
        }
    };

    BytesRestResponse response = RestMainAction.convertMainResponse(mainResponse, restRequest, builder);
    assertNotNull(response);
    assertEquals(expectedStatus, response.status());

    // the empty responses are handled in the HTTP layer so we do
    // not assert on them here
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:RestMainActionTests.java

示例2: convertMainResponse

static BytesRestResponse convertMainResponse(MainResponse response, RestRequest request, XContentBuilder builder) throws IOException {
    RestStatus status = response.isAvailable() ? RestStatus.OK : RestStatus.SERVICE_UNAVAILABLE;

    // Default to pretty printing, but allow ?pretty=false to disable
    if (request.hasParam("pretty") == false) {
        builder.prettyPrint().lfAtEnd();
    }
    response.toXContent(builder, request);
    return new BytesRestResponse(status, builder);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:RestMainAction.java

示例3: testGetResponse

public void testGetResponse() throws Exception {
    final String nodeName = "node1";
    final ClusterName clusterName = new ClusterName("cluster1");
    final String clusterUUID = randomAsciiOfLengthBetween(10, 20);
    final boolean available = randomBoolean();
    final RestStatus expectedStatus = available ? RestStatus.OK : RestStatus.SERVICE_UNAVAILABLE;
    final Version version = Version.CURRENT;
    final Build build = Build.CURRENT;
    final boolean prettyPrint = randomBoolean();

    final MainResponse mainResponse = new MainResponse(nodeName, version, clusterName, clusterUUID, build, available);
    XContentBuilder builder = JsonXContent.contentBuilder();

    Map<String, String> params = new HashMap<>();
    if (prettyPrint == false) {
        params.put("pretty", String.valueOf(prettyPrint));
    }
    RestRequest restRequest = new FakeRestRequest.Builder(xContentRegistry()).withParams(params).build();

    BytesRestResponse response = RestMainAction.convertMainResponse(mainResponse, restRequest, builder);
    assertNotNull(response);
    assertEquals(expectedStatus, response.status());
    assertThat(response.content().length(), greaterThan(0));

    XContentBuilder responseBuilder = JsonXContent.contentBuilder();
    if (prettyPrint) {
        // do this to mimic what the rest layer does
        responseBuilder.prettyPrint().lfAtEnd();
    }
    mainResponse.toXContent(responseBuilder, ToXContent.EMPTY_PARAMS);
    BytesReference xcontentBytes = responseBuilder.bytes();
    assertEquals(xcontentBytes, response.content());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:RestMainActionTests.java

示例4: status

@Override
public RestStatus status() {
    return RestStatus.SERVICE_UNAVAILABLE;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:4,代码来源:MasterNotDiscoveredException.java


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