Examples of resetReaderIndex()


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

        int warmUpCount = 999;

        long ledger = getValidLedgerId(servers);
        for(long entry = 0; entry < warmUpCount; entry++) {
            ChannelBuffer toSend = ChannelBuffers.buffer(size);
            toSend.resetReaderIndex();
            toSend.resetWriterIndex();
            toSend.writeLong(ledger);
            toSend.writeLong(entry);
            toSend.writerIndex(toSend.capacity());
            bc.addEntry(new InetSocketAddress(addr, port), ledger, new byte[20],
View Full Code Here

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

        LOG.info("Benchmarking latency");
        int entryCount = 5000;
        long startTime = System.nanoTime();
        for(long entry = 0; entry < entryCount; entry++) {
            ChannelBuffer toSend = ChannelBuffers.buffer(size);
            toSend.resetReaderIndex();
            toSend.resetWriterIndex();
            toSend.writeLong(ledger);
            toSend.writeLong(entry);
            toSend.writerIndex(toSend.capacity());
            lc.resetComplete();
View Full Code Here

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

        LOG.info("Benchmarking throughput");
        startTime = System.currentTimeMillis();
        tc = new ThroughputCallback();
        for(long entry = 0; entry < entryCount; entry++) {
            ChannelBuffer toSend = ChannelBuffers.buffer(size);
            toSend.resetReaderIndex();
            toSend.resetWriterIndex();
            toSend.writeLong(ledger);
            toSend.writeLong(entry);
            toSend.writerIndex(toSend.capacity());
            bc.addEntry(new InetSocketAddress(addr, port), ledger, new byte[20],
View Full Code Here

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

      buf.markReaderIndex();
      // read the size of the message
      buf.readInt();
      DefaultMessageTree result = (DefaultMessageTree) codec.decode(buf);
      buf.resetReaderIndex();
      result.setBuffer(buf);
    }
  }

  public MessageTree buildMessage() {
View Full Code Here

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

    long current = System.currentTimeMillis();
    for (int i = 0; i < count; i++) {
      MessageTree tree2 = new DefaultMessageTree();
      codec.decode(buf, tree2);
      buf.resetReaderIndex();
    }
    System.out.println("Cost:" + (System.currentTimeMillis() - current));

    Thread.sleep(1000);
  }
View Full Code Here

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

    long current = System.currentTimeMillis();
    for (int i = 0; i < count; i++) {
      MessageTree tree2 = new DefaultMessageTree();
      codec.decode(buf, tree2);
      buf.resetReaderIndex();
    }
    System.out.println("Cost:" + (System.currentTimeMillis() - current));

    Thread.sleep(1000);
  }
View Full Code Here

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

    RedisDecoder redisDecoder = new RedisDecoder();
    ChannelBuffer cb = ChannelBuffers.wrappedBuffer(multiBulkReply);
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 100000; j++) {
        Reply receive = redisDecoder.receive(cb);
        cb.resetReaderIndex();
      }
      long end = System.currentTimeMillis();
      long diff = end - start;
      System.out.println(diff + " " + ((double)diff)/100000);
      start = end;
View Full Code Here

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

        short magic = headerBuffer.readUnsignedByte();

        // magic should be 0x80
        if (magic != 0x80) {
            headerBuffer.resetReaderIndex();

            throw new MalformedCommandException("binary request payload is invalid, magic byte incorrect");
        }

        short opcode = headerBuffer.readUnsignedByte();
View Full Code Here

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

    body.markReaderIndex();

    inputSupplier = new InputSupplier<InputStream>() {
      @Override
      public InputStream getInput() throws IOException {
        body.resetReaderIndex();
        return new ChannelBufferInputStream(body);
      }
    };
  }
View Full Code Here

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

                                                    TApplicationException.INTERNAL_ERROR,
                                                    "Task timed out while executing."
                                            );
                                            // Create a temporary transport to send the exception
                                            ChannelBuffer duplicateBuffer = message.getBuffer().duplicate();
                                            duplicateBuffer.resetReaderIndex();
                                            TNiftyTransport temporaryTransport = new TNiftyTransport(
                                                    ctx.getChannel(),
                                                    duplicateBuffer,
                                                    message.getTransportType());
                                            TProtocolPair protocolPair = duplexProtocolFactory.getProtocolPair(
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.