Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.DynamicChannelBuffer


{
  private final ChannelBuffer _buffer;

  public SimpleResponseBytesAggregatorHandler(ByteOrder byteOrder)
  {
    _buffer = new DynamicChannelBuffer(byteOrder, 1000);
  }
View Full Code Here


  {
    private final ChannelBuffer _buffer;

    public SimpleResponseBytesAggregatorHandler(ByteOrder byteOrder)
    {
      _buffer = new DynamicChannelBuffer(byteOrder, 1000);
    }
View Full Code Here

    private ChannelBuffer buf;

    @Before
    public void startUp() {
        byte[] bytes = PAYLOAD.getBytes();
        buf = new DynamicChannelBuffer(bytes.length);
        buf.writeBytes(bytes);
    }
View Full Code Here

        return new ObjectInputStream(is);
    }

    @Converter
    public static ChannelBuffer toByteBuffer(byte[] bytes) {
        ChannelBuffer buf = new DynamicChannelBuffer(bytes.length);
        buf.writeBytes(bytes);
        return buf;
    }
View Full Code Here

        return new ObjectInputStream(is);
    }

    @Converter
    public static ChannelBuffer toByteBuffer(byte[] bytes) {
        ChannelBuffer buf = new DynamicChannelBuffer(bytes.length);

        buf.writeBytes(bytes);
        return buf;
    }
View Full Code Here

        return new ObjectInputStream(is);
    }

    @Converter
    public static ChannelBuffer toByteBuffer(byte[] bytes) {
        ChannelBuffer buf = new DynamicChannelBuffer(bytes.length);

        buf.writeBytes(bytes);
        return buf;
    }
View Full Code Here

    @Override
    protected Object encode(ChannelHandlerContext ctx, Channel channel,
                            Object message) throws Exception {
        if (message instanceof SyncMessage) {
            ChannelBuffer buf = new DynamicChannelBuffer(512);
            ChannelBufferOutputStream os = new ChannelBufferOutputStream(buf);
            TCompactProtocol thriftProtocol =
                    new TCompactProtocol(new TIOStreamTransport(os));
            ((SyncMessage) message).write(thriftProtocol);

            ChannelBuffer len = ChannelBuffers.buffer(4);
            len.writeInt(buf.readableBytes());
            return ChannelBuffers.wrappedBuffer(len, buf);
        }
        return message;
    }
View Full Code Here

  @Test
  public void testCodePerformance() throws Exception {
    MessageCodec codec = lookup(MessageCodec.class, ID);
    MessageTree tree = buildMessage();
    ChannelBuffer buf = new DynamicChannelBuffer(10240);
    codec.encode(tree, buf);

    int count = 5000000;
    for (int i = 0; i < count; i++) {

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

  @Test
  public void testCodePerformance() throws Exception {
    MessageCodec codec = lookup(MessageCodec.class, ID);
    MessageTree tree = buildMessage();
    ChannelBuffer buf = new DynamicChannelBuffer(10240);
    codec.encode(tree, buf);
    MessageTree result = new DefaultMessageTree();
    codec.decode(buf, result);
    Assert.assertEquals(tree.toString(), result.toString());
  }
View Full Code Here

            // make this garbage free (eg. reuse output buffers). To do that,
            // we probably need to patch netty. It brings this buffer all the
            // way down to it's deepest dungeons, and then eventually copies it into
            // kernel space. We need to know when that has happened and reuse the buffer.
            // Perhaps introduce a ring buffer to rotate used buffers back up here?
            final DynamicChannelBuffer content = new DynamicChannelBuffer(
                    1000);
            Serializer serializer = serializationFactory.getSerializer(content);
            serializationStrategy.serialize(data, serializer);
            serializer.flush();
           
            response.setHeader(HttpHeaders.Names.CONTENT_TYPE, serializer.getContentType().toString());
            response.setHeader(HttpHeaders.Names.CONTENT_LENGTH, content.writerIndex());
            response.setContent(content);
        }

        ChannelFuture future = channel.write(response);
View Full Code Here

TOP

Related Classes of org.jboss.netty.buffer.DynamicChannelBuffer

Copyright © 2018 www.massapicom. 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.