Package io.netty.buffer

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


    RedisReplyDecoder redisDecoder = new RedisReplyDecoder(false);
    ByteBuf cb = Unpooled.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


        if (totalLength > MAX_MESSAGE_SIZE_BYTES) {
            throw new IOException("message too large: " + totalLength + " bytes");
        }

        if (in.readableBytes() < totalLength - lengthFieldLength) {
            in.resetReaderIndex();
            return null; // retry
        }
        in = in.readSlice(totalLength - lengthFieldLength);
        int readable = in.readableBytes();
        if (readable != totalLength - lengthFieldLength) {
View Full Code Here

            ByteBuf buf = getContent();
            assertNotNull(buf);
            if (!buf.isReadable()) {
                return null;
            }
            buf.resetReaderIndex();
            byte[] b = new byte[getContent().readableBytes()];
            buf.readBytes(b);
            buf.resetReaderIndex();
            return new String(b, "UTF-8");
        }
View Full Code Here

                return null;
            }
            buf.resetReaderIndex();
            byte[] b = new byte[getContent().readableBytes()];
            buf.readBytes(b);
            buf.resetReaderIndex();
            return new String(b, "UTF-8");
        }

        public String content() throws UnsupportedEncodingException, InterruptedException {
            await(FullContentReceived);
View Full Code Here

            } else {
                ObjectMapper m = new ObjectMapper();
                try {
                    return m.readValue(new ByteBufInputStream(buf), type);
                } catch (JsonParseException | JsonMappingException ex) {
                    buf.resetReaderIndex();
                    String data = bufToString(buf);
                    throw new IOException(ex.getMessage() + " - data: " + data, ex);
                }
            }
        }
View Full Code Here

           
            // try get the message class
            Class<? extends GWMessage> messageClazz = getByHeader(header);
           
            // failcheck
            if (messageClazz == null) { buf.resetReaderIndex(); return; }
           
            // try retrieve the serialization filter
            NettySerializationFilter filter = GWMessageSerializationRegistry.getFilter(messageClazz);
           
            // failcheck
View Full Code Here

           
            // try retrieve the serialization filter
            NettySerializationFilter filter = GWMessageSerializationRegistry.getFilter(messageClazz);
           
            // failcheck
            if (filter == null) { buf.resetReaderIndex(); return; }
           
            // try create the message
            Message message;
            try
            {
View Full Code Here

            }
            catch (InstantiationException | IllegalAccessException ex)
            {
                LOGGER.error("Could not create an instance of an message.", ex);
               
                buf.resetReaderIndex();
                return;
            }
           
            // dont forget to initialize the message
            message.init(ctx.channel());
View Full Code Here

            message.init(ctx.channel());
           
            // try serialize the message
            if (!filter.deserialize(buf, message))
            {
                buf.resetReaderIndex();
                return;
            }
           
            // finally add the message
            result.add(message);
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.