Package com.dianping.cat.message

Examples of com.dianping.cat.message.Transaction


        m_logger.error("Error when handling message! Raw buffer: " + raw, e);
      }
    }

    private void decodeMessageWithMonitor(ChannelBuffer buf) {
      Transaction t = Cat.newTransaction("Decode", "Thread-" + m_index);

      decodeMessage(buf);

      t.setStatus(Transaction.SUCCESS);
      t.complete();
    }
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);
    t.complete();
  }
View Full Code Here

    t.setStatus(Transaction.SUCCESS);
    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 {
      Thread.sleep(100);
    } catch (InterruptedException e) {
    }
    t.setStatus(Transaction.SUCCESS);
    t.complete();
  }
View Full Code Here

    return count;
  }

  protected int encodeMessage(MessageTree tree, Message message, ChannelBuffer buf, int level, LineCounter counter) {
    if (message instanceof Transaction) {
      Transaction transaction = (Transaction) message;
      List<Message> children = transaction.getChildren();

      if (children.isEmpty()) {
        if (transaction.getDurationInMillis() < 0) {
          return encodeLine(tree, transaction, buf, 't', Policy.WITHOUT_STATUS, level, counter);
        } else {
          return encodeLine(tree, transaction, buf, 'A', Policy.WITH_DURATION, level, counter);
        }
      } else {
View Full Code Here

    if (message instanceof Transaction) {
      int count = 0;
      int index = buf.writerIndex();
      BufferHelper helper = m_bufferHelper;
      Transaction t = (Transaction) message;
      Locator locator = new Locator();
      Ruler ruler = new Ruler((int) t.getDurationInMicros());

      ruler.setWidth(1400);
      ruler.setHeight(18 * calculateLines(t) + 10);
      ruler.setOffsetX(200);
      ruler.setOffsetY(10);
View Full Code Here

      }
    }

    buildClasspath();
    MessageProducer cat = Cat.getProducer();
    Transaction reboot = cat.newTransaction("System", "Reboot");

    reboot.setStatus(Message.SUCCESS);
    cat.logEvent("Reboot", NetworkInterfaceManager.INSTANCE.getLocalHostAddress(), Message.SUCCESS, null);
    reboot.complete();

    while (m_active) {
      long start = MilliSecondTimer.currentTimeMillis();

      if (m_manager.isCatEnabled()) {
        Transaction t = cat.newTransaction("System", "Status");
        Heartbeat h = cat.newHeartbeat("Heartbeat", m_ipAddress);
        StatusInfo status = new StatusInfo();

        t.addData("dumpLocked", m_manager.isDumpLocked());
        try {
          StatusInfoCollector statusInfoCollector = new StatusInfoCollector(m_statistics, m_jars);

          status.accept(statusInfoCollector.setDumpLocked(m_manager.isDumpLocked()));

          buildExtensionData(status);
          h.addData(status.toString());
          h.setStatus(Message.SUCCESS);
        } catch (Throwable e) {
          h.setStatus(e);
          cat.logError(e);
        } finally {
          h.complete();
        }
        t.setStatus(Message.SUCCESS);
        t.complete();
      }
      long elapsed = MilliSecondTimer.currentTimeMillis() - start;

      if (elapsed < m_interval) {
        try {
View Full Code Here

      Thread.sleep(5000);
    } catch (InterruptedException e) {
      active = false;
    }
    while (active) {
      Transaction t = Cat.newTransaction("AlertThirdParty", TimeHelper.getMinuteStr());
      long current = System.currentTimeMillis();
     
      try {
        List<ThirdPartyAlertEntity> alertEntities = new ArrayList<ThirdPartyAlertEntity>();

        while (m_entities.size() > 0) {
          ThirdPartyAlertEntity entity = m_entities.poll(5, TimeUnit.MILLISECONDS);

          alertEntities.add(entity);
        }
        Map<String, List<ThirdPartyAlertEntity>> domain2AlertMap = buildDomain2AlertMap(alertEntities);

        for (Entry<String, List<ThirdPartyAlertEntity>> entry : domain2AlertMap.entrySet()) {
          String domain = entry.getKey();
          List<ThirdPartyAlertEntity> thirdPartyAlerts = entry.getValue();
          AlertEntity entity = new AlertEntity();

          entity.setDate(new Date()).setContent(thirdPartyAlerts.toString()).setLevel(AlertLevel.WARNING);
          entity.setMetric(getName()).setType(getName()).setGroup(domain);

          m_sendManager.addAlert(entity);
        }
        t.setStatus(Transaction.SUCCESS);
      } catch (Exception e) {
        t.setStatus(e);
        Cat.logError(e);
      } finally {
        t.complete();
      }
      long duration = System.currentTimeMillis() - current;

      try {
        if (duration < DURATION) {
View Full Code Here

      Thread.sleep(5000);
    } catch (InterruptedException e) {
      active = false;
    }
    while (active) {
      Transaction t = Cat.newTransaction("AlertApp", TimeHelper.getMinuteStr());
      long current = System.currentTimeMillis();

      try {
        MonitorRules monitorRules = m_appRuleConfigManager.getMonitorRules();
        Map<String, Rule> rules = monitorRules.getRules();

        for (Entry<String, Rule> entry : rules.entrySet()) {
          try {
            processRule(entry.getValue());
          } catch (Exception e) {
            Cat.logError(e);
          }
        }
        t.setStatus(Transaction.SUCCESS);
      } catch (Exception e) {
        t.setStatus(e);
        Cat.logError(e);
      } finally {
        t.complete();
      }
      long duration = System.currentTimeMillis() - current;

      try {
        if (duration < DURATION) {
View Full Code Here

        }

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

        addTransactionChild(message, parent);
      }
    }
View Full Code Here

     * @param transaction
     * @return true if message is flushed, false otherwise
     */
    public boolean end(DefaultMessageManager manager, Transaction transaction) {
      if (!m_stack.isEmpty()) {
        Transaction current = m_stack.pop();

        if (transaction == current) {
          m_validator.validate(m_stack.isEmpty() ? null : m_stack.peek(), current);
        } else {
          while (transaction != current && !m_stack.empty()) {
View Full Code Here

TOP

Related Classes of com.dianping.cat.message.Transaction

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.