Package com.dianping.cat.consumer.transaction.model.entity

Examples of com.dianping.cat.consumer.transaction.model.entity.TransactionReport


    WeeklyReportContent content = m_weeklyReportContentDao.findByPK(id, WeeklyReportContentEntity.READSET_FULL);

    if (content != null) {
      return DefaultNativeParser.parse(content.getContent());
    } else {
      return new TransactionReport(domain);
    }
  }
View Full Code Here


    }
  }

  @Override
  public TransactionReport queryHourlyReport(String domain, Date start, Date end) {
    TransactionReportMerger merger = new TransactionReportMerger(new TransactionReport(domain));
    long startTime = start.getTime();
    long endTime = end.getTime();
    String name = TransactionAnalyzer.ID;

    for (; startTime < endTime; startTime = startTime + TimeHelper.ONE_HOUR) {
      List<HourlyReport> reports = null;
      try {
        reports = m_hourlyReportDao.findAllByDomainNamePeriod(new Date(startTime), domain, name,
              HourlyReportEntity.READSET_FULL);
      } catch (DalException e) {
        Cat.logError(e);
      }
      if (reports != null) {
        for (HourlyReport report : reports) {
          String xml = report.getContent();

          try {
            if (xml != null && xml.length() > 0) {// for old xml storage
              TransactionReport reportModel = com.dianping.cat.consumer.transaction.model.transform.DefaultSaxParser
                    .parse(xml);
              reportModel.accept(merger);
            } else {// for new binary storage, binary is same to report id
              TransactionReport reportModel = queryFromHourlyBinary(report.getId(), domain);

              reportModel.accept(merger);
            }
          } catch (DalNotFoundException e) {
            // ignore
          } catch (Exception e) {
            Cat.logError(e);
          }
        }
      }
    }
    TransactionReport transactionReport = merger.getTransactionReport();

    transactionReport.setStartTime(start);
    transactionReport.setEndTime(new Date(end.getTime() - 1));

    Set<String> domains = queryAllDomainNames(start, end, TransactionAnalyzer.ID);
    transactionReport.getDomainNames().addAll(domains);
    return transactionReport;
  }
View Full Code Here

    } catch (DalNotFoundException e) {
      // ignore
    } catch (Exception e) {
      Cat.logError(e);
    }
    return new TransactionReport(domain);
  }
View Full Code Here

    } catch (DalNotFoundException e) {
      // ignore
    } catch (Exception e) {
      Cat.logError(e);
    }
    return new TransactionReport(domain);
  }
View Full Code Here

  private final int MAX_URL_NUM = 399;

  @Test
  public void whether_url_has_max_names() throws Exception {
    String source = Files.forIO().readFrom(getClass().getResourceAsStream("transaction_report_filter.xml"), "utf-8");
    TransactionReport report = DefaultSaxParser.parse(source);

    TransactionType type = report.findMachine("10.1.77.193").findType("URL");

    for (int i = 0; i < 3500; i++) {
      type.addName(new TransactionName("Test" + i));
    }

    TransactionReportCountFilter f1 = new TransactionReportCountFilter();
    String filterReport = f1.buildXml(report);
    TransactionReport newReport = DefaultSaxParser.parse(filterReport);

    int newSize = newReport.findMachine("10.1.77.193").findType("URL").getNames().size();

    Assert.assertEquals(MAX_URL_NUM, newSize);

  }
View Full Code Here

public class TransactionReportTypeAggergatorTest {

  @Test
  public void test() throws Exception {
    TransactionReport report1 = parse("transaction_report_aggergator1.xml");
    TransactionReport report2 = parse("transaction_report_aggergator2.xml");
    TransactionReport report3 = parse("transaction_report_aggergator3.xml");
    TransactionReport report4 = parse("transaction_report_aggergator4.xml");
    TransactionReport result = new TransactionReport("All");
    TransactionReportTypeAggregator aggergator = new TransactionReportTypeAggregator(result);
   
    aggergator.visitTransactionReport(report1);
    aggergator.visitTransactionReport(report2);
    aggergator.visitTransactionReport(report3);
    aggergator.visitTransactionReport(report4);
   
    String expected = Files.forIO().readFrom(getClass().getResourceAsStream("transaction_report_aggergatorAll.xml"), "utf-8");
    Assert.assertEquals(expected.replaceAll("\\r", ""), result.toString().replaceAll("\\r", ""));
  }
View Full Code Here

public class TransactionReportTest {
  @Test
  public void testXml() throws Exception {
    String source = Files.forIO().readFrom(getClass().getResourceAsStream("transaction_report.xml"), "utf-8");
    TransactionReport report = DefaultSaxParser.parse(source);
    String xml = new DefaultXmlBuilder().buildXml(report);
    String expected = source;

    Assert.assertEquals("XML is not well parsed!", expected.replace("\r", ""), xml.replace("\r", ""));
  }
View Full Code Here

      MessageTree tree = generateMessageTree(i);

      m_analyzer.process(tree);
    }

    TransactionReport report = m_analyzer.getReport(m_domain);

    report.accept(new TransactionStatisticsComputer());

    String expected = Files.forIO().readFrom(getClass().getResourceAsStream("transaction_analyzer.xml"), "utf-8");
    Assert.assertEquals(expected.replaceAll("\r", ""), report.toString().replaceAll("\r", ""));
  }
View Full Code Here

public class TransactionReportMergerTest {
  @Test
  public void testTransactionReportMerge() throws Exception {
    String oldXml = Files.forIO().readFrom(getClass().getResourceAsStream("transaction_report_old.xml"), "utf-8");
    String newXml = Files.forIO().readFrom(getClass().getResourceAsStream("transaction_report_new.xml"), "utf-8");
    TransactionReport reportOld = DefaultSaxParser.parse(oldXml);
    TransactionReport reportNew = DefaultSaxParser.parse(newXml);
    String expected = Files.forIO().readFrom(getClass().getResourceAsStream("transaction_report_mergeResult.xml"),
          "utf-8");
    TransactionReportMerger merger = new TransactionReportMerger(new TransactionReport(reportOld.getDomain()));

    reportOld.accept(merger);
    reportNew.accept(merger);

    Assert.assertEquals("Check the merge result!", expected.replace("\r", ""), merger.getTransactionReport()
          .toString().replace("\r", ""));
    Assert.assertEquals("Source report is changed!", newXml.replace("\r", ""), reportNew.toString().replace("\r", ""));
  }
View Full Code Here

      MockTransactionReportManager transactionManager = (MockTransactionReportManager) lookup(ReportManager.class,
            "transaction");

      String xml = Files.forIO().readFrom(TransactionAnalyzerTest.class.getResourceAsStream("transaction_real.xml"),
            "utf-8");
      TransactionReport transactionReport = transactionDelegate.parseXml(xml);
      rebuildTransactionReport(transactionReport);
      transactionManager.setReport(transactionReport);

      ProblemAnalyzer problemAnalyzer = (ProblemAnalyzer) lookup(MessageAnalyzer.class, ProblemAnalyzer.ID);
      ProblemDelegate problemDelegate = (ProblemDelegate) lookup(ReportDelegate.class, "problem");
View Full Code Here

TOP

Related Classes of com.dianping.cat.consumer.transaction.model.entity.TransactionReport

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.