Package com.dianping.cat.message.spi.codec

Examples of com.dianping.cat.message.spi.codec.PlainTextMessageCodec$BufferHelper


  @Test
  public void test() throws InterruptedException {
    MessageTree tree = buildMessages();

    PlainTextMessageCodec codec = new PlainTextMessageCodec();
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer(8192);

    codec.encode(tree, buf);

    buf.readInt();
    MessageTree tree2 = new DefaultMessageTree();
    codec.decode(buf, tree2);

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


  @Test
  public void testMany() throws InterruptedException {
    MessageTree tree = buildMessages();

    PlainTextMessageCodec codec = new PlainTextMessageCodec();
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer(8192);

    codec.encode(tree, buf);

    buf.readInt();
    buf.markReaderIndex();

    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

    m_threadName = threadName;
  }

  @Override
  public String toString() {
    PlainTextMessageCodec codec = new PlainTextMessageCodec();
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer(8192);

    codec.encode(this, buf);
    buf.readInt(); // get rid of length
    codec.reset();
    return buf.toString(Charset.forName("utf-8"));
  }
View Full Code Here

    m_type = type;
  }

  @Override
  public String toString() {
    PlainTextMessageCodec codec = new PlainTextMessageCodec();
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();

    codec.encodeMessage(this, buf);
    codec.reset();
    return buf.toString(Charset.forName("utf-8"));
  }
View Full Code Here

TOP

Related Classes of com.dianping.cat.message.spi.codec.PlainTextMessageCodec$BufferHelper

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.