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


Java BytesArray.EMPTY属性代码示例

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


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

示例1: testXContentBuilderClosedInBuildResponse

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,代码行数:16,代码来源:RestBuilderListenerTests.java

示例2: testXContentBuilderNotClosedInBuildResponseAssertionsDisabled

public void testXContentBuilderNotClosedInBuildResponseAssertionsDisabled() 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);
                return new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY);
            }

            @Override
            boolean assertBuilderClosed(XContentBuilder xContentBuilder) {
                // don't check the actual builder being closed so we can test auto close
                return true;
            }
    };

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

示例3: LocalRestRequest

public LocalRestRequest(final String uri, final Method method) {
    this.headers = new HashMap<>();
    if (uri.startsWith("\"") && uri.endsWith("\"")) {
        this.uri = uri.substring(1, uri.length()-1);
    } else {
        this.uri = uri;
    }
    this.method = method;
    this.params = new HashMap<>();
    this.content = BytesArray.EMPTY;

    int pathEndPos = this.uri.indexOf('?');
    if (pathEndPos < 0) {
        this.rawPath = this.uri;
    } else {
        this.rawPath = this.uri.substring(0, pathEndPos);
        RestUtils.decodeQueryString(this.uri, pathEndPos + 1, params);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:LocalRestRequest.java

示例4: NettyHttpRequest

public NettyHttpRequest(org.jboss.netty.handler.codec.http.HttpRequest request, Channel channel) {
    this.request = request;
    this.channel = channel;
    this.params = new HashMap<>();
    if (request.getContent().readable()) {
        this.content = new ChannelBufferBytesReference(request.getContent());
    } else {
        this.content = BytesArray.EMPTY;
    }

    String uri = request.getUri();
    int pathEndPos = uri.indexOf('?');
    if (pathEndPos < 0) {
        this.rawPath = uri;
    } else {
        this.rawPath = uri.substring(0, pathEndPos);
        RestUtils.decodeQueryString(uri, pathEndPos + 1, params);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:NettyHttpRequest.java

示例5: Netty4HttpRequest

Netty4HttpRequest(NamedXContentRegistry xContentRegistry, FullHttpRequest request, Channel channel) {
    super(xContentRegistry, request.uri(), new HttpHeadersMap(request.headers()));
    this.request = request;
    this.channel = channel;
    if (request.content().isReadable()) {
        this.content = Netty4Utils.toBytesReference(request.content());
    } else {
        this.content = BytesArray.EMPTY;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:Netty4HttpRequest.java

示例6: BytesRestResponse

public BytesRestResponse(RestChannel channel, RestStatus status, Exception e) throws IOException {
    this.status = status;
    if (channel.request().method() == RestRequest.Method.HEAD) {
        this.content = BytesArray.EMPTY;
        this.contentType = TEXT_CONTENT_TYPE;
    } else {
        try (XContentBuilder builder = build(channel, status, e)) {
            this.content = builder.bytes();
            this.contentType = builder.contentType().mediaType();
        }
    }
    if (e instanceof ElasticsearchException) {
        copyHeaders(((ElasticsearchException) e));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:BytesRestResponse.java

示例7: readBytesReference

/**
 * Reads a bytes reference from this stream, might hold an actual reference to the underlying
 * bytes of the stream.
 */
public BytesReference readBytesReference(int length) throws IOException {
    if (length == 0) {
        return BytesArray.EMPTY;
    }
    byte[] bytes = new byte[length];
    readBytes(bytes, 0, length);
    return new BytesArray(bytes, 0, length);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:StreamInput.java

示例8: testXContentBuilderNotClosedInBuildResponseAssertionsEnabled

public void testXContentBuilderNotClosedInBuildResponseAssertionsEnabled() throws Exception {
    assumeTrue("tests are not being run with assertions", RestBuilderListener.class.desiredAssertionStatus());

    RestBuilderListener<TransportResponse.Empty> builderListener =
        new RestBuilderListener<Empty>(new FakeRestChannel(new FakeRestRequest(), randomBoolean(), 1)) {
            @Override
            public RestResponse buildResponse(Empty empty, XContentBuilder builder) throws Exception {
                return new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY);
            }
    };

    AssertionError error = expectThrows(AssertionError.class, () -> builderListener.buildResponse(Empty.INSTANCE));
    assertEquals("callers should ensure the XContentBuilder is closed themselves", error.getMessage());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:RestBuilderListenerTests.java

示例9: CrateThrowableRestResponse

public CrateThrowableRestResponse(RestChannel channel, Throwable t) throws IOException {
    status = (t instanceof ElasticsearchException) ?
            ((ElasticsearchException) t).status() :
            RestStatus.INTERNAL_SERVER_ERROR;
    if (channel.request().method() == RestRequest.Method.HEAD) {
        this.content = BytesArray.EMPTY;
        this.contentType = BytesRestResponse.TEXT_CONTENT_TYPE;
    } else {
        XContentBuilder builder = convert(channel, t);
        this.content = builder.bytes();
        this.contentType = builder.contentType().restContentType();
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:CrateThrowableRestResponse.java

示例10: BytesRestResponse

public BytesRestResponse(RestChannel channel, RestStatus status, Throwable t) throws IOException {
    this.status = status;
    if (channel.request().method() == RestRequest.Method.HEAD) {
        this.content = BytesArray.EMPTY;
        this.contentType = TEXT_CONTENT_TYPE;
    } else {
        XContentBuilder builder = convert(channel, status, t);
        this.content = builder.bytes();
        this.contentType = builder.contentType().restContentType();
    }
    if (t instanceof ElasticsearchException) {
        copyHeaders(((ElasticsearchException) t));
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:14,代码来源:BytesRestResponse.java


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