Package io.netty.buffer

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


    public DelegationTransfer transfer(TransferBuffer buffer) {
      ByteBuf buf = ByteBuf.class.cast(buffer.getBuffer());
      try {
        this.lock.lock();
        int readable = buf.readableBytes();
        buf.readBytes(this.output, readable);
        this.readable.addAndGet(readable);
        return this;
      } catch (Exception e) {
        DegelationTransferBuilder.this.log.error(e);
        Trace.trace(DegelationTransferBuilder.this.log, e);
View Full Code Here


        } else {
            return;
        }

        ByteBuffer nioBuf = ByteBuffer.allocateDirect(buf.readableBytes());
        buf.readBytes(nioBuf);
        nioBuf.flip();

        MsgHdr message = posix.allocateMsgHdr();
        message.setIov(new ByteBuffer[]{nioBuf});
View Full Code Here

                metaBuffer.writeInt(bodyOffset); //TODO - reconsider how frequently this shortcut is placed on disk
                metaBuffer.writeInt(out.snapshotLength);
                bodyOffset += out.snapshotLength;
            }
            while (metaBuffer.readableBytes() > 0) {
                metaBuffer.readBytes(openWriteFile, metaBuffer.readableBytes());
            }
            metaBuffer.release();
            /* write bytes for each stream id */
            for (TempData out : streamsWithData) {
                synchronized (out.stream) {     // need less confusing variable names for concurrency
View Full Code Here

    }

    @Override
    public int read(long pos, byte[] buffer, int offset, int length) throws IOException {
      ByteBuf local = buf.slice( (int) pos, (int) Math.min( buf.capacity() - pos, length));
      local.readBytes(buffer, offset, buf.capacity());
      return buf.capacity();
    }

    @Override
    public void readFully(long pos, byte[] buffer) throws IOException {
View Full Code Here

                if (ByteBuf.class.isAssignableFrom(msg.getClass())) {
                    ByteBuf byteBuf = (ByteBuf) msg;
                    if (byteBuf.isReadable()) {
                        int readableBytes = byteBuf.readableBytes();
                        byte[] msgToPass = new byte[readableBytes];
                        byteBuf.readBytes(msgToPass);
                        handled = true;
                        ctx.fireChannelRead(msgToPass);
                    }
                }
                if (!handled) {
View Full Code Here

      // Skip written length
      buffer.skipBytes(4);

      byte[] array = new byte[buffer.readableBytes()];
      buffer.readBytes(array);
      return array;
    }

    throw createCoercionException(val.getClass(), byte[].class);
  }
View Full Code Here

            return;
        }

        ByteBuf uncompressed = in;
        byte[] inAry = new byte[uncompressed.readableBytes()];
        uncompressed.readBytes(inAry);

        int sizeEstimate = (int) Math.ceil(inAry.length * 1.001) + 12;
        out.ensureWritable(sizeEstimate);

        synchronized (deflater) {
View Full Code Here

                metaBuffer.writeInt(bodyOffset); //TODO - reconsider how frequently this shortcut is placed on disk
                metaBuffer.writeInt(out.snapshotLength);
                bodyOffset += out.snapshotLength;
            }
            while (metaBuffer.readableBytes() > 0) {
                metaBuffer.readBytes(openWriteFile, metaBuffer.readableBytes());
            }
            metaBuffer.release();
            /* write bytes for each stream id */
            for (TempData out : streamsWithData) {
                synchronized (out.stream) {     // need less confusing variable names for concurrency
View Full Code Here

                metaBuffer.writeInt(bodyOffset); //TODO - reconsider how frequently this shortcut is placed on disk
                metaBuffer.writeInt(out.snapshotLength);
                bodyOffset += out.snapshotLength;
            }
            while (metaBuffer.readableBytes() > 0) {
                metaBuffer.readBytes(openWriteFile, metaBuffer.readableBytes());
            }
            metaBuffer.release();
            /* write bytes for each stream id */
            for (TempData out : streamsWithData) {
                synchronized (out.stream) {     // need less confusing variable names for concurrency
View Full Code Here

          Call call = null;
          errorClass = null;
          error = null;
          try {
            if (dataLengthBuffer.remaining() > 0 && byteBuf.isReadable()) {
              byteBuf.readBytes(dataLengthBuffer);
              if (dataLengthBuffer.remaining() > 0 && byteBuf.isReadable()) {
                return;
              }
            } else {
              return;
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.