Package com.dianping.cat.message.spi

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


    try {
      m_descriptor.ensureOpen(0, 24);
      m_reader.ensureOpen(m_descriptor.getReaderIndex(), m_descriptor.getQueueSize());

      while (true) {
        MessageTree tree = m_reader.next();

        if (tree == null) {
          break;
        }
View Full Code Here


      event.complete();
      return event;
    }

    public MessageTree next() throws InterruptedException {
      MessageTree tree = null;
      List<String> list = new ArrayList<String>(16);
      StringBuilder sb = new StringBuilder(1024);
      String childId = null;
      int step = 0;

      while (true) {
        sb.setLength(0);
        readLine(sb);

        if (sb.length() == 0) {
          break;
        }

        String line = sb.toString();

        list.clear();
        Splitters.by('\t').split(line, list);

        int size = list.size();
        int index = 0;

        switch (step) {
        case 0:
          if (size >= 3) {
            String id = list.get(index++);
            String parentId = list.get(index++);
            String rootId = list.get(index++);

            childId = id;
            tree = m_messageManager.getThreadLocalMessageTree().copy();
            tree.setMessageId(parentId);
            tree.setParentMessageId(rootId);
            tree.setRootMessageId(rootId);
            tree.setDomain(getDomainByMessageId(id, tree.getDomain()));
            step++;
          }
          break;
        case 1:
          if (size >= 13) {
            String name = list.get(index++);
            String status = list.get(index++);
            String url = list.get(index++);
            String requestHeaderLen = list.get(index++);
            String upstreamUrl = list.get(index++);
            String responseHeaderLen = list.get(index++);
            String responseBodyLen = list.get(index++);
            String responseBodyBlocks = list.get(index++);
            long t0 = toLong(list.get(index++));
            long t1 = toLong(list.get(index++));
            long t2 = toLong(list.get(index++));
            long t3 = toLong(list.get(index++));
            long t4 = toLong(list.get(index++));

            DefaultTransaction t = new DefaultTransaction(name, url, m_messageManager);

            t.addChild(newEvent(name + ".Status", status, null));
            t.addChild(newEvent("RemoteCall", upstreamUrl, childId));

            t.addData("_m", (t1 - t0) + "," + (t2 - t1) + "," + (t3 - t2) + "," + (t4 - t3));
            t.addData("in", requestHeaderLen);
            t.addData("out", responseHeaderLen + "," + responseBodyLen);
            t.addData("blocks", responseBodyBlocks);
            t.addData("url", upstreamUrl);

            if ("200".equals(status)) {
              t.setStatus(Message.SUCCESS);
            } else {
              t.setStatus(status);
            }

            t.setDurationInMillis(t4 - t0);
            t.setCompleted(true);
            tree.setMessage(t);
            step++;
          }

          break;
        default:
View Full Code Here

    while (m_active) {
      ChannelFuture future = m_manager.getChannel();

      if (checkWritable(future)) {
        try {
          MessageTree tree = m_queue.poll();

          if (tree != null) {
            sendInternal(tree);
            tree.setMessage(null);
          }

        } catch (Throwable t) {
          m_logger.error("Error when sending message over TCP socket!", t);
        }
View Full Code Here

  private Logger m_logger;

  @Override
  public MessageTree decode(ChannelBuffer buf) {
    MessageTree tree = new DefaultMessageTree();

    decode(buf, tree);
    return tree;
  }
View Full Code Here

    if (info != null) {
      MessageProducer cat = Cat.getProducer();
      Throwable exception = info.getThrowable();
      Object message = event.getMessage();
      MessageTree tree = Cat.getManager().getThreadLocalMessageTree();

      if (tree == null) {
        Transaction t = cat.newTransaction("System", "Log4jException");

        if (message != null) {
View Full Code Here

  private String m_threadName;

  @Override
  public MessageTree copy() {
    MessageTree tree = new DefaultMessageTree();

    tree.setDomain(m_domain);
    tree.setHostName(m_hostName);
    tree.setIpAddress(m_ipAddress);
    tree.setMessageId(m_messageId);
    tree.setParentMessageId(m_parentMessageId);
    tree.setRootMessageId(m_rootMessageId);
    tree.setSessionToken(m_sessionToken);
    tree.setThreadGroupName(m_threadGroupName);
    tree.setThreadId(m_threadId);
    tree.setThreadName(m_threadName);
    tree.setMessage(m_message);

    return tree;
  }
View Full Code Here

    if (messageId == null) {
      return null;
    }

    MessageTree tree = m_localBucketManager.loadMessage(messageId);

    if (tree != null) {
      return toString(request, tree);
    }
View Full Code Here

    if (messageId == null) {
      return null;
    }

    MessageTree tree = m_bucketManager.loadMessage(messageId);

    if (tree != null) {
      ChannelBuffer buf = ChannelBuffers.dynamicBuffer(8192);

      if (tree.getMessage() instanceof Transaction && request.getProperty("waterfall", "false").equals("true")) {
        // to work around a plexus injection bug
        MessageCodec codec = lookup(MessageCodec.class, "waterfall");

        codec.encode(tree, buf);
      } else {
View Full Code Here

    return tree;
  }

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

    tree.setDomain("cat");
    tree.setHostName("group001");
    tree.setIpAddress("192.168.1.1");

    DefaultTransaction t = new DefaultTransaction("A", "n" + i % 2, null);
    DefaultTransaction t2 = new DefaultTransaction("A-1", "n" + i % 3, null);

    if (i % 2 == 0) {
      t2.setStatus("ERROR");
    } else {
      t2.setStatus(Message.SUCCESS);
    }

    t2.complete();
    t2.setDurationInMillis(i);

    t.addChild(t2);

    if (i % 2 == 0) {
      t.setStatus("ERROR");
    } else {
      t.setStatus(Message.SUCCESS);
    }

    t.complete();
    t.setDurationInMillis(i * 2);
    long timestamp = 1385467200000L;

    t.setTimestamp(timestamp + 1000);
    t2.setTimestamp(timestamp + 2000);
    tree.setMessage(t);
    tree.setMessageId("Cat-0a010680-384852-" + i);

    return tree;
  }
View Full Code Here

      public void run() {
        for (int i = 0; i < timesPerThread; i++) {
          String id = null;
          try {
            id = "" + serial.incrementAndGet();
            MessageTree mt = new DefaultMessageTree();
            mt.setMessageId(id);
            MessageTree target = bucket.findById(id);
            Assert.assertEquals(id, target.getMessageId());
          } catch (Throwable e) {
            e.printStackTrace();
            fail.incrementAndGet();
          }
        }
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.