Examples of flip()


Examples of java.nio.Buffer.flip()

    buf = factory.newInstance();
    buf.position(5);
    buf.mark();
    buf.position(6);
    h.check(buf.flip(), buf, "flip: buf.flip()");
    checkStatus(h, buf, "flip", 10, 6, true, 6, 0);
    try
      {
        buf.reset();
        h.check(false, "flip: mark not invalidated");
View Full Code Here

Examples of java.nio.ByteBuffer.flip()

    DynamicByteBuffer dbb = (DynamicByteBuffer) key.attachment();
    logger.debug("pending data about to be written");
    ByteBuffer toSend = dbb.getByteBuffer();
    SocketChannel channel = ((SocketChannel) key.channel());
    try {
      toSend.flip()// prepare for write
      long bytesWritten = channel.write(toSend);
      if (IOLoop.INSTANCE.hasKeepAliveTimeout(channel)) {
        prolongKeepAliveTimeout(channel);
      }
      logger.debug("sent {} bytes to wire", bytesWritten);
View Full Code Here

Examples of java.nio.ByteBuffer.flip()

      clientChannel.read(buffer);
    } catch (IOException e) {
      logger.warn("Could not read buffer: {}", e.getMessage());
      Closeables.closeQuietly(clientChannel);
    }
    buffer.flip();
   
    return doGetHttpRequest(key, clientChannel, buffer);
  }
 
  private HttpRequest doGetHttpRequest(SelectionKey key, SocketChannel clientChannel, ByteBuffer buffer) {
View Full Code Here

Examples of java.nio.ByteBuffer.flip()

                results.put(byteArray1, i, byte1Max - i);
            }
            else if (j < byte2Max) {
                results.put(byteArray2, j, byte2Max - j);
            }
            results.flip();
            return new ByteBufferStreamable(results);
        }
       
        @Override
        public void writeTo(DataOutputStream out) throws IOException {
View Full Code Here

Examples of java.nio.ByteBuffer.flip()

        oprBuf.putInt(bFilePath.length); // #1
        oprBuf.put(bFilePath); // #2
        oprBuf.putLong(startOffset); // #3
        oprBuf.putLong(endOffset); // #4
        oprBuf.put((byte) (_bigEndian ? 1 : 0)); // # 5 is big endian?
        oprBuf.flip();
        NIOUtils.writeFully(channel, oprBuf);
    }

    public static final class ReadRequestMessage extends RequestMessage {
View Full Code Here

Examples of java.nio.ByteBuffer.flip()

        oprBuf.put(bFilePath); // #2
        oprBuf.putInt(size); // #3
        for(int i = 0; i < size; i++) {
            oprBuf.putLong(idxs[i]); // #4
        }
        oprBuf.flip();
        NIOUtils.writeFully(channel, oprBuf);
    }

    public static final class TrackReadRequestMessage extends RequestMessage {
View Full Code Here

Examples of java.nio.ByteBuffer.flip()

                fileChannel.read(tmpBuf, offset);
            } catch (IOException e) {
                LOG.error(e);
                throw e;
            }
            tmpBuf.flip();
            final int length = tmpBuf.getInt();
            tmpBuf.rewind();
            IoBuffer ioBuf = IoBuffer.wrap(tmpBuf);
            out.write(ioBuf);
            // attempt zero-copy sendfile
View Full Code Here

Examples of java.nio.ByteBuffer.flip()

    private byte[] recvResponse(final ByteChannel channel, final ByteBuffer rcvBuf)
            throws IOException {
        ByteBuffer tmpBuf = ByteBuffer.allocate(4);
        NIOUtils.readFully(channel, tmpBuf, 4);
        tmpBuf.flip();
        int datalen = tmpBuf.getInt();

        final ByteBuffer buf = truncateBuffer(rcvBuf, datalen);
        NIOUtils.readFully(channel, buf, datalen);
        buf.flip();
View Full Code Here

Examples of java.nio.ByteBuffer.flip()

        tmpBuf.flip();
        int datalen = tmpBuf.getInt();

        final ByteBuffer buf = truncateBuffer(rcvBuf, datalen);
        NIOUtils.readFully(channel, buf, datalen);
        buf.flip();
        if(ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
            buf.order(ByteOrder.BIG_ENDIAN);
        }
        final byte[] b = new byte[datalen];
        buf.get(b);
View Full Code Here

Examples of java.nio.ByteBuffer.flip()

          total_read += bytes_read;
         
          break;
        }
       
        payload_buffer.flip();
       
        messages.add( new GenericMessage( msg_type, msg_desc, new DirectByteBuffer( payload_buffer ), false ));
       
        buffers[1= null;
      }
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.