Package com.dianping.cat.message.spi

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


  public DefaultForkedTransaction(String type, String name, MessageManager manager) {
    super(type, name, manager);

    setStandalone(false);

    MessageTree tree = manager.getThreadLocalMessageTree();

    if (tree != null) {
      m_rootMessageId = tree.getRootMessageId();
      m_parentMessageId = tree.getMessageId();
    }
  }
View Full Code Here


    MessageManager manager = getManager();

    manager.setup();
    manager.start(this, false);

    MessageTree tree = manager.getThreadLocalMessageTree();

    if (tree != null) {
      m_forkedMessageId = tree.getMessageId();
      tree.setRootMessageId(m_rootMessageId == null ? m_parentMessageId : m_rootMessageId);
      tree.setParentMessageId(m_parentMessageId);
    }
  }
View Full Code Here

  @Override
  public void bind(String tag, String title) {
    TaggedTransaction t = m_taggedTransactions.get(tag);

    if (t != null) {
      MessageTree tree = getThreadLocalMessageTree();

      if (tree != null) {
        t.start();
        t.bind(tag, tree.getMessageId(), title);
      }
    }
  }
View Full Code Here

      m_length = 1;
    }

    public void add(Message message) {
      if (m_stack.isEmpty()) {
        MessageTree tree = m_tree.copy();

        if (tree.getMessageId() == null) {
          tree.setMessageId(nextMessageId());
        }

        tree.setMessage(message);
        flush(tree);
      } else {
        Transaction parent = m_stack.peek();

        addTransactionChild(message, parent);
View Full Code Here

            current = m_stack.pop();
          }
        }

        if (m_stack.isEmpty()) {
          MessageTree tree = m_tree.copy();

          m_tree.setMessageId(null);
          m_tree.setMessage(null);

          if (m_totalDurationInMicros > 0) {
            adjustForTruncatedTransaction((Transaction) tree.getMessage());
          }

          manager.flush(tree);
          return true;
        }
View Full Code Here

        source.addChild(current);
      }
    }

    public void truncateAndFlush(Context ctx, long timestamp) {
      MessageTree tree = ctx.m_tree;
      Stack<Transaction> stack = ctx.m_stack;
      Message message = tree.getMessage();

      if (message instanceof DefaultTransaction) {
        String id = tree.getMessageId();
        String rootId = tree.getRootMessageId();
        String childId = nextMessageId();
        DefaultTransaction source = (DefaultTransaction) message;
        DefaultTransaction target = new DefaultTransaction(source.getType(), source.getName(),
              DefaultMessageManager.this);

        target.setTimestamp(source.getTimestamp());
        target.setDurationInMicros(source.getDurationInMicros());
        target.addData(source.getData().toString());
        target.setStatus(Message.SUCCESS);

        migrateMessage(stack, source, target, 1);

        for (int i = stack.size() - 1; i >= 0; i--) {
          DefaultTransaction t = (DefaultTransaction) stack.get(i);

          t.setTimestamp(timestamp);
        }

        DefaultEvent next = new DefaultEvent("RemoteCall", "Next");

        next.addData(childId);
        next.setStatus(Message.SUCCESS);
        target.addChild(next);

        // tree is the parent, and m_tree is the child.
        MessageTree t = tree.copy();

        t.setMessage(target);

        ctx.m_tree.setMessageId(childId);
        ctx.m_tree.setParentMessageId(id);
        ctx.m_tree.setRootMessageId(rootId != null ? rootId : id);
View Full Code Here

    m_tag = tag;

    setStandalone(false);

    MessageTree tree = manager.getThreadLocalMessageTree();

    if (tree != null) {
      m_rootMessageId = tree.getRootMessageId();
      m_parentMessageId = tree.getMessageId();
    }
  }
View Full Code Here

      }
    }.build();
  }

  public MessageTree build() {
    MessageTree tree = new DefaultMessageTree();

    tree.setMessage(mockTransaction());

    return tree;
  }
View Full Code Here

    heartbeat.setTimestamp(timestamp);
    return heartbeat;
  }

  private MessageTree newMessageTree() {
    MessageTree tree = new DefaultMessageTree();

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

    return tree;
  }
View Full Code Here

    return transaction;
  }

  @Test
  public void testEncode() throws Exception {
    MessageTree tree = buildMessageTree();
    HtmlMessageCodec codec = (HtmlMessageCodec) lookup(MessageCodec.class, "html");
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    codec.encode(tree, buf);

    String content = Files.forIO().readFrom(HtmlMessageCodecTest.class.getResourceAsStream("MessageTree.txt"),
          "utf-8");
    Assert.assertEquals(content.trim(), tree.toString().trim());
    Assert.assertEquals(1308, buf.readableBytes());
  }
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.