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

Examples of com.dianping.cat.consumer.problem.model.entity.ProblemReport


public class ProblemDailyGraphTest {

  @Test
  public void test() throws Exception {
    String expeted = Files.forIO().readFrom(getClass().getResourceAsStream("ProblemMergerDaily.xml"), "utf-8");
    ProblemReport report = DefaultSaxParser.parse(expeted);
    ProblemDailyGraphCreator creator = new ProblemDailyGraphCreator();
   
    creator.visitProblemReport(report);

    Assert.assertEquals(2, creator.buildDailyGraph().size());
View Full Code Here


public class ProblemCreateGraphDataTest {

  @Test
  public void testGraph() throws Exception {
    String newXml = Files.forIO().readFrom(getClass().getResourceAsStream("problemModel.xml"), "utf-8");
    ProblemReport report = DefaultSaxParser.parse(newXml);

    ProblemGraphCreator creator = new ProblemGraphCreator();
    List<Graph> graphs = creator.splitReportToGraphs(report.getStartTime(), report.getDomain(), "problem", report);

    Assert.assertEquals("The graphs size", 3, graphs.size());

    Graph graph = graphs.get(0);
View Full Code Here

public class ProblemReportMergerTest {
  @Test
  public void testProblemReportMerge() throws Exception {
    String oldXml = Files.forIO().readFrom(getClass().getResourceAsStream("ProblemReportOld.xml"), "utf-8");
    String newXml = Files.forIO().readFrom(getClass().getResourceAsStream("ProblemReportNew.xml"), "utf-8");
    ProblemReport reportOld = DefaultSaxParser.parse(oldXml);
    ProblemReport reportNew = DefaultSaxParser.parse(newXml);
    String expected = Files.forIO().readFrom(getClass().getResourceAsStream("ProblemReportMergeResult.xml"), "utf-8");
    ProblemReportMerger merger = new ProblemReportMerger(new ProblemReport(reportOld.getDomain()));

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

    Assert.assertEquals("Source report is changed!", newXml.replace("\r", ""), reportNew.toString().replace("\r", ""));
    Assert.assertEquals("Source report is changed!", oldXml.replace("\r", ""), reportOld.toString().replace("\r", ""));
    Assert.assertEquals("Check the merge result!", expected.replace("\r", ""), merger.getProblemReport().toString()
          .replace("\r", ""));

  }
View Full Code Here

  }

  @Test
  public void testMergeList() {
    ProblemReportMerger merger = new ProblemReportMerger(new ProblemReport("cat"));
    List<String> list1 = buildList1();
    merger.mergeList(list1, buildList2(), 10);
    Assert.assertEquals(10, list1.size());

    list1 = buildList1();
View Full Code Here

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

    Assert.assertEquals(expected.replace("\r", ""), xml.replace("\r", ""));
  }
View Full Code Here

  @Test
  public void testProblemReportMergeAll() throws Exception {
    String oldXml = Files.forIO().readFrom(getClass().getResourceAsStream("ProblemReportOld.xml"), "utf-8");
    String newXml = Files.forIO().readFrom(getClass().getResourceAsStream("ProblemReportNew.xml"), "utf-8");
    ProblemReport reportOld = DefaultSaxParser.parse(oldXml);
    ProblemReport reportNew = DefaultSaxParser.parse(newXml);
    String expected = Files.forIO().readFrom(getClass().getResourceAsStream("ProblemReportMergeAllResult.xml"),
          "utf-8");
    ProblemReportMerger merger = new HistoryProblemReportMerger(new ProblemReport(reportOld.getDomain()));

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

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

  }

  @Test
  public void testProblemReportMergerSize() throws Exception {
    String oldXml = Files.forIO().readFrom(getClass().getResourceAsStream("ProblemMobile.xml"), "utf-8");
    ProblemReport reportOld = DefaultSaxParser.parse(oldXml);
    ProblemReportMerger merger = new HistoryProblemReportMerger(new ProblemReport(reportOld.getDomain()));

    for (int i = 0; i < 24; i++) {
      reportOld.accept(merger);
    }
    ProblemReport problemReport = merger.getProblemReport();
    for (Machine machine : problemReport.getMachines().values()) {
      List<Entry> entries = machine.getEntries();
      for (Entry entry : entries) {
        int size = entry.getThreads().size();
        Assert.assertEquals(0, size);
      }
    }
    Assert.assertEquals(true, (double) problemReport.toString().length() / 1024 / 1024 < 1);
  }
View Full Code Here

public class ProblemReportService extends AbstractReportService<ProblemReport> {

  @Override
  public ProblemReport makeReport(String domain, Date start, Date end) {
    ProblemReport report = new ProblemReport(domain);

    report.setStartTime(start);
    report.setEndTime(end);
    return report;
  }
View Full Code Here

    return report;
  }

  @Override
  public ProblemReport queryDailyReport(String domain, Date start, Date end) {
    ProblemReportMerger merger = new ProblemReportMerger(new ProblemReport(domain));
    long startTime = start.getTime();
    long endTime = end.getTime();
    String name = ProblemAnalyzer.ID;

    for (; startTime < endTime; startTime = startTime + TimeHelper.ONE_DAY) {
      try {
        DailyReport report = m_dailyReportDao.findByDomainNamePeriod(domain, name, new Date(startTime),
              DailyReportEntity.READSET_FULL);
        String xml = report.getContent();

        if (xml != null && xml.length() > 0) {
          ProblemReport reportModel = com.dianping.cat.consumer.problem.model.transform.DefaultSaxParser
                .parse(xml);
          reportModel.accept(merger);
        } else {
          ProblemReport reportModel = queryFromDailyBinary(report.getId(), domain);

          reportModel.accept(merger);
        }
      } catch (DalNotFoundException e) {
        //ignore
      } catch (Exception e) {
        Cat.logError(e);
      }
    }
    ProblemReport problemReport = merger.getProblemReport();

    problemReport.setStartTime(start);
    problemReport.setEndTime(end);
    return problemReport;
  }
View Full Code Here

    DailyReportContent content = m_dailyReportContentDao.findByPK(id, DailyReportContentEntity.READSET_FULL);

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

TOP

Related Classes of com.dianping.cat.consumer.problem.model.entity.ProblemReport

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.