Package com.dianping.cat.message

Examples of com.dianping.cat.message.Transaction


    if (StringUtils.isEmpty(domain) || date == null) {
      return null;
    }
    date = normalizeDate(date);

    Transaction t = Cat.newTransaction("AlertSummary", domain);

    try {
      StringBuilder builder = new StringBuilder();

      String summaryContent = m_alertSummaryContentGenerator.generateHtml(domain, date);
      builder.append(summaryContent);

      String failureContext = m_failureSummaryContentGenerator.generateHtml(domain, date);
      builder.append(failureContext);

      String alterationContext = m_alterationSummaryContentGenerator.generateHtml(domain, date);
      builder.append(alterationContext);

      t.setStatus(Transaction.SUCCESS);
      return builder.toString();
    } catch (Exception e) {
      t.setStatus(e);
      Cat.logError("generate alert summary fail:" + domain + " " + date, e);
    } finally {
      t.complete();
    }
    return null;
  }
View Full Code Here


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

      try {
        Map<String, ProductLine> productLines = m_productLineConfigManager.getCompany().getProductLines();

        for (ProductLine productLine : productLines.values()) {
          try {
            if (productLine.isNetworkDashboard()) {
              processProductLine(productLine);
            }
          } catch (Exception e) {
            Cat.logError(e);
          }
        }

        t.setStatus(Transaction.SUCCESS);
      } catch (Exception e) {
        t.setStatus(e);
      } finally {
        m_currentReports.clear();
        m_lastReports.clear();
        t.complete();
      }
      long duration = System.currentTimeMillis() - current;

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

    return count;
  }

  public int encodeMessage(Message message, ChannelBuffer buf) {
    if (message instanceof Transaction) {
      Transaction transaction = (Transaction) message;
      List<Message> children = transaction.getChildren();

      if (children.isEmpty()) {
        return encodeLine(transaction, buf, 'A', Policy.WITH_DURATION);
      } else {
        int count = 0;
View Full Code Here

      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) {
          cat.logError(String.valueOf(message), exception);
        } else {
          cat.logError(exception);
        }
        t.setStatus(Message.SUCCESS);
        t.complete();
      } else {
        cat.logError(exception);
      }
    }
  }
View Full Code Here

  public void run() {
    boolean active = true;

    while (active) {
      long current = System.currentTimeMillis();
      Transaction t = Cat.newTransaction("AlertThirdPartyBuilder", TimeHelper.getMinuteStr());

      try {
        buildAlertEntities(current);
        t.setStatus(Transaction.SUCCESS);
      } catch (Exception e) {
        t.setStatus(e);
        m_logger.error(e.getMessage(), e);
      } finally {
        t.complete();
      }

      long duration = System.currentTimeMillis() - current;

      try {
View Full Code Here

  }

  @Override
  public ModelResponse<String> invoke(ModelRequest request) {
    ModelResponse<String> response = new ModelResponse<String>();
    Transaction t = Cat.newTransaction("ModelService", getClass().getSimpleName());

    try {
      ModelPeriod period = request.getPeriod();
      String domain = request.getDomain();
      String report = getReport(request, period, domain);

      response.setModel(report);

      t.addData("period", period);
      t.addData("domain", domain);
      t.setStatus(Message.SUCCESS);
    } catch (Exception e) {
      Cat.logError(e);
      t.setStatus(e);
      response.setException(e);
    } finally {
      t.complete();
    }
    return response;
  }
View Full Code Here

  }

  @Override
  public ModelResponse<String> invoke(ModelRequest request) {
    ModelResponse<String> response = new ModelResponse<String>();
    Transaction t = newTransaction("ModelService", getClass().getSimpleName());

    try {
      URL url = buildUrl(request);

      t.addData(url.toString());

      InputStream in = Urls.forIO().connectTimeout(1000).readTimeout(5000).openStream(url.toExternalForm());
      GZIPInputStream gzip = new GZIPInputStream(in);
      String xml = Files.forIO().readFrom(gzip, "utf-8");

      int len = xml == null ? 0 : xml.length();

      t.addData("length", len);

      if (len > 0) {
        String report = buildModel(xml);

        response.setModel(report);
        t.addData("hit", "true");
      }
      t.setStatus(Message.SUCCESS);
    } catch (Exception e) {
      t.setStatus(Message.SUCCESS);
    } finally {
      t.complete();
    }
    return response;
  }
View Full Code Here

    return count;
  }

  public int encodeMessage(Message message, ChannelBuffer buf) {
    if (message instanceof Transaction) {
      Transaction transaction = (Transaction) message;
      List<Message> children = transaction.getChildren();

      if (children.isEmpty()) {
        return encodeLine(transaction, buf, 'A', Policy.WITH_DURATION);
      } else {
        int count = 0;
View Full Code Here

    Assert.assertEquals(false, manager.isJobMachine());
    Assert.assertEquals(false, manager.isLocalMode());
    Assert.assertEquals(true, manager.isServerService("Service"));
    Assert.assertEquals(false, manager.validateDomain("All"));
   
    Transaction t = new DefaultTransaction("Service", "piegonService:heartTaskService:heartBeat", null);
    Assert.assertEquals(true, manager.discardTransaction(t));

    manager.initialize(null);

    Assert.assertEquals(true, manager.getServerConfig() != null);
View Full Code Here

  }

  @Test
  public void sendCacheTransactionWithMissed() throws Exception {
    for (int i = 0; i < 130; i++) {
      Transaction t = Cat.getProducer().newTransaction("Cache.kvdb", "Method" + i % 10);
      Cat.getProducer().newEvent("Cache.kvdb", "Method" + i % 10 + ":missed");
      t.addData("key and value");

      Transaction t2 = Cat.getProducer().newTransaction("Cache.web", "Method" + i % 10);
      Cat.getProducer().newEvent("Cache.web", "Method" + i % 10 + ":missed");
      t2.addData("key and value");
      Thread.sleep(2);
      t2.complete();
      t.complete();

      Transaction t3 = Cat.getProducer().newTransaction("Cache.memcached", "Method" + i % 10);
      t3.addData("key and value");
      Thread.sleep(3);
      t3.complete();
    }

    Transaction t2 = Cat.getProducer().newTransaction("Cache.web", "Method");
    t2.addData("key and value");
    Thread.sleep(2);
    t2.complete();
    Thread.sleep(1000);
  }
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.