Package io.netty.buffer

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


            if (!rpcHeaderRead) {
              // Every connection is expected to send the header.
              if (rpcHeaderBuffer == null) {
                dataLengthBuffer = null;
                dataLengthBuffer = ByteBuffer.allocate(4);
                byteBuf.readBytes(dataLengthBuffer);
                rpcHeaderBuffer = ByteBuffer.allocate(2);
              }
              byteBuf.readBytes(rpcHeaderBuffer);
              if (!rpcHeaderBuffer.hasArray()
                  || rpcHeaderBuffer.remaining() > 0) {
View Full Code Here


                dataLengthBuffer = null;
                dataLengthBuffer = ByteBuffer.allocate(4);
                byteBuf.readBytes(dataLengthBuffer);
                rpcHeaderBuffer = ByteBuffer.allocate(2);
              }
              byteBuf.readBytes(rpcHeaderBuffer);
              if (!rpcHeaderBuffer.hasArray()
                  || rpcHeaderBuffer.remaining() > 0) {
                return;
              }
              int version = rpcHeaderBuffer.get(0);
View Full Code Here

              }
              data = ByteBuffer.allocate(dataLength);
            }

            // read received data
            byteBuf.readBytes(data);
            if (data.remaining() == 0) {
              dataLengthBuffer.clear();
              data.flip();
              boolean isHeaderRead = headerRead;
              call = processOneRpc(data.array());
View Full Code Here

                        }
                        int observableNameLength = byteBuf.readByte();
                        String observableName = null;
                        if (observableNameLength > 0){
                          // read name
                          observableName = new String(byteBuf.readBytes(observableNameLength).array());
                        }
                        int operation = byteBuf.readByte();
                        RemoteRxEvent.Type type = null;
                        Map<String,String> subscribeParams = null;
                        byte[] valueData = null;
View Full Code Here

                        byte[] valueData = null;
                        if (operation == 1){
                          logger.debug("READ request for RemoteRxEvent: next");
                          type = RemoteRxEvent.Type.next;
                          valueData = new byte[byteBuf.readableBytes()];
                            byteBuf.readBytes(valueData);
                        }else if (operation == 2){
                          logger.debug("READ request for RemoteRxEvent: error");
                          type = RemoteRxEvent.Type.error;
                          valueData = new byte[byteBuf.readableBytes()];
                            byteBuf.readBytes(valueData);
View Full Code Here

                            byteBuf.readBytes(valueData);
                        }else if (operation == 2){
                          logger.debug("READ request for RemoteRxEvent: error");
                          type = RemoteRxEvent.Type.error;
                          valueData = new byte[byteBuf.readableBytes()];
                            byteBuf.readBytes(valueData);
                        }else if (operation == 3){
                          logger.debug("READ request for RemoteRxEvent: completed");
                          type = RemoteRxEvent.Type.completed;
                        }else if (operation == 4){
                          logger.debug("READ request for RemoteRxEvent: subscribed");
View Full Code Here

                          // read subscribe parameters
                          int subscribeParamsLength = byteBuf.readInt();
                          if (subscribeParamsLength > 0){
                            // read byte into map
                            byte[] subscribeParamsBytes = new byte[subscribeParamsLength];
                            byteBuf.readBytes(subscribeParamsBytes);
                            subscribeParams = fromBytesToMap(subscribeParamsBytes);
                          }
                        }else if (operation == 5){
                          logger.debug("READ request for RemoteRxEvent: unsubscribed");
                          type = RemoteRxEvent.Type.unsubscribed;
View Full Code Here

   
    public static Collection<Metric> fromDatagram(DatagramPacket msg) throws IOException {
        final ByteBuf bb = msg.content();
        byte[] buf = new byte[bb.readableBytes()];
       
        bb.readBytes(buf);
       
        CodedInputStream in = CodedInputStream.newInstance(buf);
        final int numMetrics = in.readRawVarint32();
        List<Metric> metrics = new ArrayList<Metric>(numMetrics);
       
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

                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

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.