Examples of writableBytes()


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

  /** Serializes the 'type' byte followed by the message itself. */
  public byte[] toByteArray() {
    ByteBuf buf = Unpooled.buffer(encodedLength());
    buf.writeByte(type().id);
    encode(buf);
    assert buf.writableBytes() == 0 : "Writable bytes remain: " + buf.writableBytes();
    return buf.array();
  }
}
View Full Code Here

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

  /** Serializes the 'type' byte followed by the message itself. */
  public byte[] toByteArray() {
    ByteBuf buf = Unpooled.buffer(encodedLength());
    buf.writeByte(type().id);
    encode(buf);
    assert buf.writableBytes() == 0 : "Writable bytes remain: " + buf.writableBytes();
    return buf.array();
  }
}
View Full Code Here

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

    long frameLength = headerLength + bodyLength;
    ByteBuf header = ctx.alloc().heapBuffer(headerLength);
    header.writeLong(frameLength);
    msgType.encode(header);
    in.encode(header);
    assert header.writableBytes() == 0;

    out.add(header);
    if (body != null && bodyLength > 0) {
      out.add(body);
    }
View Full Code Here

Examples of org.iq80.leveldb.util.SliceOutput.writableBytes()

        // Duplicate the random data until we have filled "len" bytes
        Slice dst = Slices.allocate(len);
        SliceOutput sliceOutput = dst.output();
        while (sliceOutput.size() < len) {
            sliceOutput.writeBytes(rawData, 0, Math.min(rawData.length(), sliceOutput.writableBytes()));
        }
        return dst;
    }

    private static Slice generateRandomSlice(Random random, int length)
View Full Code Here

Examples of org.jboss.netty.buffer.BigEndianHeapChannelBuffer.writableBytes()

        int size = message.getSerializedSize();
        ChannelBuffer buffer = new BigEndianHeapChannelBuffer(4 + size + 4);
        buffer.writeBytes("RPC0".getBytes());
        int writerIndex = buffer.writerIndex();
        CodedOutputStream output = CodedOutputStream.newInstance(
                buffer.array(), buffer.writerIndex(), buffer.writableBytes() - 4);
        message.writeTo(output);
        output.checkNoSpaceLeft();

        buffer.writerIndex(writerIndex + size);
        Adler32 checksum = new Adler32();
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBuffer.writableBytes()

        int ret = 0;
        int readBytes = 0;
        boolean failure = true;
        try {
            while ((ret = buffer.writeBytes(ch, buffer.writableBytes())) > 0) {
                readBytes += ret;
                if (!buffer.writable()) {
                    break;
                }
            }
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBuffer.writableBytes()

        SocketAddress remoteAddress = null;
        Throwable exception = null;
        if (channel instanceof ScatteringByteChannel) {
            try {
                while (buf.writable()) {
                    int readBytes = buf.writeBytes((ScatteringByteChannel) channel, buf.writableBytes());
                    if (readBytes == 0) {
                        break;
                    } else if (readBytes < 0) {
                        closed = true;
                        break;
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBuffer.writableBytes()

        int ret = 0;
        int readBytes = 0;
        boolean failure = true;
        try {
            while ((ret = buf.writeBytes(ch, buf.writableBytes())) > 0) {
                readBytes += ret;
                if (!buf.writable()) {
                    break;
                }
            }
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBuffer.writableBytes()

        int ret = 0;
        int readBytes = 0;
        boolean failure = true;
        try {
            while ((ret = preallocatedDirectBuffer.writeBytes(ch, preallocatedDirectBuffer.writableBytes())) > 0) {
                readBytes += ret;
                if (!preallocatedDirectBuffer.writable()) {
                    break;
                }
            }
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBuffer.writableBytes()

    if (null != responseBody && responseBody.length() > 0)
    {
      ChannelBuffer bodyBuffer = ChannelBuffers.wrappedBuffer(responseBody.getBytes(Charset.defaultCharset()));

      _response.setHeader(HttpHeaders.Names.CONTENT_LENGTH, bodyBuffer.writableBytes());
      _response.setContent(bodyBuffer);
      _response.setChunked(false);
    }
    else
    {
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.