Examples of retain()


Examples of io.netty.buffer.ByteBuf.retain()

    // read the protobuf body into a buffer.
    checkTag(is, RpcEncoder.PROTOBUF_BODY_TAG);
    final int pBodyLength = readRawVarint32(is);
    final ByteBuf pBody = buffer.slice(buffer.readerIndex(), pBodyLength);
    buffer.skipBytes(pBodyLength);
    pBody.retain();
    if (RpcConstants.EXTRA_DEBUGGING) logger.debug("Read protobuf body of length {} into buffer {}.", pBodyLength, pBody);

    if(RpcConstants.EXTRA_DEBUGGING) logger.debug("post protobufbody read index {}", buffer.readerIndex());
   
    ByteBuf dBody = null;
View Full Code Here

Examples of io.netty.buffer.ByteBuf.retain()

      if(RpcConstants.EXTRA_DEBUGGING) logger.debug("Reading raw body, buffer has {} bytes available, is available {}.", buffer.readableBytes(), is.available());
      checkTag(is, RpcEncoder.RAW_BODY_TAG);
      dBodyLength = readRawVarint32(is);
      if(buffer.readableBytes() != dBodyLength) throw new CorruptedFrameException(String.format("Expected to receive a raw body of %d bytes but received a buffer with %d bytes.", dBodyLength, buffer.readableBytes()));
      dBody = buffer.slice();
      dBody.retain();
      if(RpcConstants.EXTRA_DEBUGGING) logger.debug("Read raw body of {}", dBody);
     
    }else{
      if(RpcConstants.EXTRA_DEBUGGING) logger.debug("No need to read raw body, no readable bytes left.");
    }
View Full Code Here

Examples of io.netty.buffer.ByteBuf.retain()

            if (buffer.readableBytes() < frameLength)
                return;

            // extract body
            ByteBuf body = buffer.slice(idx, (int) bodyLength);
            body.retain();
           
            idx += bodyLength;
            buffer.readerIndex(idx);

            Connection connection = ctx.channel().attr(Connection.attributeKey).get();
View Full Code Here

Examples of io.netty.buffer.ByteBuf.retain()

                        .getContentTransferEncoding(), fileUpload.getCharset(),
                        definedSize);

                ByteBuf data = fileUpload.getByteBuf();
                if (data != null && data.isReadable()) {
                    diskFileUpload.addContent(data.retain(), false);
                }
                // release old upload
                fileUpload.release();

                fileUpload = diskFileUpload;
View Full Code Here

Examples of io.netty.buffer.ByteBuf.retain()

            files.put(data.getName(), values);
          }
          try {
            FileUpload nettyFileUpload = (FileUpload) data;
            final ByteBuf byteBuf = nettyFileUpload.getByteBuf();
            byteBuf.retain();
            context.onClose(new Action<RequestOutcome>() {
              @Override
              public void execute(RequestOutcome thing) throws Exception {
                byteBuf.release();
              }
View Full Code Here

Examples of io.netty.buffer.CompositeByteBuf.retain()

                compressed.addComponent(msg);
                compressed.writerIndex(compressed.writerIndex() + msg.readableBytes());
            }
            assertThat(compressed, is(notNullValue()));

            decoder.writeInbound(compressed.retain());
            assertFalse(compressed.isReadable());
            final CompositeByteBuf decompressed = Unpooled.compositeBuffer();
            while ((msg = decoder.readInbound()) != null) {
                decompressed.addComponent(msg);
                decompressed.writerIndex(decompressed.writerIndex() + msg.readableBytes());
View Full Code Here

Examples of io.netty.buffer.DrillBuf.retain()

  public DrillBuf getBuffer(boolean clear) {
    DrillBuf bufferHandle = this.buffer;

    if (clear) {
      /* Increment the ref count for this buffer */
      bufferHandle.retain();

      /* We are passing ownership of the buffer to the
       * caller. clear the buffer from within our selection vector
       */
      clear();
View Full Code Here

Examples of io.netty.handler.codec.dns.DnsResponse.retain()

                    cache(q, res);
                    promises.set(queryId, null);

                    Promise<DnsResponse> qPromise = qCtx.promise();
                    if (qPromise.setUncancellable()) {
                        qPromise.setSuccess(res.retain());
                    }
                } else {
                    qCtx.retry(res.sender(),
                               "response code: " + res.header().responseCode() +
                               " with " + res.answers().size() + " answer(s) and " +
View Full Code Here

Examples of io.netty.handler.codec.http.DefaultFullHttpRequest.retain()

    @Test
    public void invalidHttpMethod() throws Exception {
        final SockJsConfig config = SockJsConfig.withPrefix("/echo").build();
        final EmbeddedChannel ch = webSocketChannel(config);
        final FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, POST, "dummy");
        request.retain();
        ch.writeInbound(request);
        final HttpResponse response = decode(ch);
        assertThat(response.getStatus(), is(METHOD_NOT_ALLOWED));
        assertThat(response.headers().get(ALLOW), is(GET.toString()));
    }
View Full Code Here

Examples of io.netty.handler.codec.http.DefaultFullHttpRequest.retain()

    @Test
    public void nonUpgradeRequest() throws Exception {
        final SockJsConfig config = SockJsConfig.withPrefix("/echo").build();
        final EmbeddedChannel ch = webSocketChannel(config);
        final FullHttpRequest request = new DefaultFullHttpRequest(HTTP_1_1, GET, "/websocket");
        request.retain();
        ch.writeInbound(request);
        final FullHttpResponse response = decodeFullHttpResponse(ch);
        assertThat(response.getStatus(), is(BAD_REQUEST));
        assertThat(response.headers().get(CONTENT_TYPE), is(Transports.CONTENT_TYPE_PLAIN));
        assertThat(response.content().toString(CharsetUtil.UTF_8), equalTo("Can \"Upgrade\" only to \"WebSocket\"."));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.