Package com.dianping.cat.message.spi

Examples of com.dianping.cat.message.spi.MessageTree


            bucket = (HdfsMessageBucket) lookup(MessageBucket.class, HdfsMessageBucket.ID);
            bucket.initialize(dataFile);
            m_buckets.put(dataFile, bucket);
          }
          if (bucket != null) {
            MessageTree tree = bucket.findById(messageId);

            if (tree != null && tree.getMessageId().equals(messageId)) {
              t.addData("path", dataFile);
              return tree;
            }
          }
        } catch (Exception e) {
View Full Code Here


    uploader.setSleepPeriod(0);
    Thread.sleep(30 * 100 * 1000);
  }

  private MessageTree newMessageTree(int i, long timestamp) {
    MessageTree tree = new DefaultMessageTree();

    tree.setDomain("domain");
    tree.setHostName("hostName" + i);
    tree.setIpAddress("ipAddress" + i);
    tree.setMessageId(String.valueOf(i));
    tree.setParentMessageId("parentMessageId" + i);
    tree.setRootMessageId("rootMessageId" + i);
    tree.setSessionToken("sessionToken");
    tree.setThreadGroupName("threadGroupName");
    tree.setThreadId("threadId" + i);
    tree.setThreadName("threadName");

    tree.setMessage(newTransaction("type", "name" + i, timestamp, "0", 123456 + i, "data" + i));
    return tree;
  }
View Full Code Here

  @Override
  public MessageTree findByIndex(int index) throws IOException {
    try {
      byte[] data = m_reader.readMessage(index);
      ChannelBuffer buf = ChannelBuffers.dynamicBuffer(data.length);
      MessageTree tree = new DefaultMessageTree();

      buf.writeBytes(data);
      m_codec.decode(buf, tree);
      m_lastAccessTime = System.currentTimeMillis();
      return tree;
View Full Code Here

import com.dianping.cat.storage.dump.MessageBucketManager;

@RunWith(JUnit4.class)
public class HdfsMessageBucketManagerTest extends ComponentTestCase {
  private MessageTree newMessageTree(String id, int i, long timestamp) {
    MessageTree tree = new DefaultMessageTree();

    tree.setDomain("target");
    tree.setHostName("localhost");
    tree.setIpAddress("127.0.0.1");
    tree.setMessageId(id);
    tree.setParentMessageId("parentMessageId" + i);
    tree.setRootMessageId("rootMessageId" + i);
    tree.setSessionToken("sessionToken");
    tree.setThreadGroupName("threadGroupName");
    tree.setThreadId("threadId" + i);
    tree.setThreadName("threadName");

    tree.setMessage(newTransaction("type", "name" + i, timestamp, "0", 123456 + i, "data" + i));
    return tree;
  }
View Full Code Here

    factory.setIpAddress("7f000001");
    factory.initialize("source");
    localManager.setBaseDir(new File("target/bucket/hdfs/dump")); // make local and hdfs base dir same

    for (int i = 0; i < num; i++) {
      MessageTree tree = newMessageTree(factory.getNextId(), i, now + i * 10L);
      MessageId id = MessageId.parse(tree.getMessageId());
      localManager.storeMessage(tree,id);
    }

    for (int i = 0; i < num; i++) {
      String messageId = "source-7f000001-373203-" + i;
      MessageTree tree = hdfsManager.loadMessage(messageId);

      Assert.assertNotNull("Message " + i + " not found.", tree);
      Assert.assertEquals(messageId, tree.getMessageId());
    }
  }
View Full Code Here

    }

    // please stop CAT server when you run this test case
    Assert.assertEquals("One message should be in the queue.", 1, m_queue.size());

    MessageTree tree = m_queue.poll();
    Message m = tree.getMessage();

    Assert.assertTrue(Transaction.class.isAssignableFrom(m.getClass()));

    Transaction trans = (Transaction) m;
View Full Code Here

  public static final String ID = "plain-text";

  @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++) {
View Full Code Here

        return t;
      }
    }.build();

    MessageTree tree = new DefaultMessageTree();
    tree.setDomain("cat");
    tree.setHostName("test");
    tree.setIpAddress("test");
    tree.setThreadGroupName("test");
    tree.setThreadId("test");
    tree.setThreadName("test");
    tree.setMessage(message);
    return tree;
  }
View Full Code Here

  private int count = 100000;

  @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

    Thread.sleep(1000);
  }

  @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));
View Full Code Here

TOP

Related Classes of com.dianping.cat.message.spi.MessageTree

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.