Package com.dianping.cat.message.spi

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


      public void run() {
        for (int i = 0; i < timesPerThread; i++) {
          String id = null;
          try {
            id = "" + serial.incrementAndGet();
            MessageTree mt = new DefaultMessageTree();
            mt.setMessageId(id);
            Assert.assertTrue(bucket.storeById(id, mt));

            MessageTree target = bucket.findById(id);
            Assert.assertEquals(id, target.getMessageId());
          } catch (Throwable e) {
            e.printStackTrace();
            fail.incrementAndGet();
          }
        }
View Full Code Here


      @Override
      public void run() {
        for (int i = 0; i < timesPerThread; i++) {
          try {
            String id = "" + serial.incrementAndGet();
            MessageTree mt = new DefaultMessageTree();
            mt.setMessageId(id);
            boolean success = bucket.storeById(id, mt);
            if (!success) {
              fail.incrementAndGet();
            }
          } catch (Throwable e) {
View Full Code Here

  private void serialRead(final AtomicInteger serial) throws IOException {
    for (int p = 0; p < threadNum; p++) {
      for (int i = 0; i < timesPerThread; i++) {
        String id = "" + serial.incrementAndGet();
        MessageTree target = bucket.findById(id);
        Assert.assertEquals(id, target.getMessageId());
      }
    }
  }
View Full Code Here

  private void serialWrite(AtomicInteger serial) throws IOException {
    for (int p = 0; p < threadNum; p++) {
      for (int i = 0; i < timesPerThread; i++) {
        String id = "" + serial.incrementAndGet();
        MessageTree mt = new DefaultMessageTree();
        mt.setMessageId(id);
        Assert.assertTrue(bucket.storeById(id, mt));
      }
    }
  }
View Full Code Here

  }

  @Test
  public void testProcess() throws Exception {
    for (int i = 1; i <= 100; i++) {
      MessageTree tree = generateMessageTree(i);

      m_analyzer.process(tree);
    }

    CrossReport report = m_analyzer.getReport(m_domain);
View Full Code Here

          "utf-8");
    Assert.assertEquals(expectedCaller.replaceAll("\r", ""), reportCaller.toString().replaceAll("\r", ""));
  }

  protected MessageTree generateMessageTree(int i) {
    MessageTree tree = new DefaultMessageTree();

    tree.setMessageId("" + i);
    tree.setDomain(m_domain);
    tree.setHostName("group001");
    tree.setIpAddress("192.168.1.1");

    DefaultTransaction t;

    if (i % 2 == 0) {
      t = new DefaultTransaction("PigeonCall", "Cat-Test-Call", null);
      DefaultEvent event = new DefaultEvent("PigeonCall.server", "192.168.1.0:3000:class:method1");

      event.setTimestamp(m_timestamp + 5 * 60 * 1000);
      event.setStatus(Message.SUCCESS);
      t.addChild(event);

      DefaultEvent eventApp = new DefaultEvent("PigeonCall.app", "server");

      eventApp.setTimestamp(m_timestamp + 5 * 60 * 1000 + 100);
      eventApp.setStatus(Message.SUCCESS);
      t.addChild(eventApp);
    } else {
      t = new DefaultTransaction("PigeonService", "Cat-Test-Service", null);
      DefaultEvent event = new DefaultEvent("PigeonService.client", "192.168.1.2:3000:class:method2");

      event.setTimestamp(m_timestamp + 5 * 60 * 1000);
      event.setStatus(Message.SUCCESS);
      t.addChild(event);

      DefaultEvent eventApp = new DefaultEvent("PigeonService.app", "client");

      eventApp.setTimestamp(m_timestamp + 5 * 60 * 1000 + 100);
      eventApp.setStatus(Message.SUCCESS);
      t.addChild(eventApp);
    }

    t.complete();
    t.setDurationInMillis(i * 2);
    t.setTimestamp(m_timestamp + 1000);
    tree.setMessage(t);

    return tree;
  }
View Full Code Here

  private volatile boolean m_active = true;

  @Override
  public void analyze(MessageQueue queue) {
    while (!isTimeout() && isActive()) {
      MessageTree tree = queue.poll();

      if (tree != null) {
        try {
          process(tree);
        } catch (Throwable e) {
          m_errors++;

          if (m_errors == 1 || m_errors % 10000 == 0) {
            Cat.logError(e);
          }
        }
      }
    }

    while (true) {
      MessageTree tree = queue.poll();

      if (tree != null) {
        try {
          process(tree);
        } catch (Throwable e) {
View Full Code Here

    }
  }

  private void sendServiceMsg(String method, String server, String serverIp, String client, String clientIp) {
    Transaction t = Cat.newTransaction("PigeonService", method);
    MessageTree tree = Cat.getManager().getThreadLocalMessageTree();
    ((DefaultMessageTree) tree).setDomain(server);
    ((DefaultMessageTree) tree).setIpAddress(serverIp);
    Cat.logEvent("PigeonService.client", clientIp);
    Cat.logEvent("PigeonService.app", client);
    t.setStatus(Transaction.SUCCESS);
View Full Code Here

    t.complete();
  }

  private void sendClientMsg(String method, String client, String clientIp, String server, String serverIp) {
    Transaction t = Cat.newTransaction("PigeonCall", method);
    MessageTree tree = Cat.getManager().getThreadLocalMessageTree();
    ((DefaultMessageTree) tree).setDomain(client);
    ((DefaultMessageTree) tree).setIpAddress(clientIp);
    Cat.logEvent("PigeonCall.server", serverIp);
    Cat.logEvent("PigeonCall.app", server);
    try {
View Full Code Here

    return m_tag;
  }

  @Override
  public void start() {
    MessageTree tree = getManager().getThreadLocalMessageTree();

    if (tree != null && tree.getRootMessageId() == null) {
      tree.setParentMessageId(m_parentMessageId);
      tree.setRootMessageId(m_rootMessageId);
    }
  }
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.