Package com.dianping.cat.consumer.dependency

Examples of com.dianping.cat.consumer.dependency.DependencyReportMerger


    DependencyReport reportOld = DefaultSaxParser.parse(oldXml);
    DependencyReport reportNew = DefaultSaxParser.parse(newXml);
    String expected = Files.forIO().readFrom(getClass().getResourceAsStream("result.xml"), "utf-8");
    DependencyReport result = DefaultSaxParser.parse(expected);

    DependencyReportMerger merger = new DependencyReportMerger(new DependencyReport(reportOld.getDomain()));

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

    Assert.assertEquals("Check the merge result!", result.toString(), merger.getDependencyReport().toString());
  }
View Full Code Here


  @Override
  protected DependencyReport merge(ModelRequest request, List<ModelResponse<DependencyReport>> responses) {
    if (responses.size() == 0) {
      return null;
    }
    DependencyReportMerger merger = new DependencyReportMerger(new DependencyReport(request.getDomain()));
    for (ModelResponse<DependencyReport> response : responses) {
      DependencyReport model = response.getModel();

      if (model != null) {
        model.accept(merger);
      }
    }

    return merger.getDependencyReport();
  }
View Full Code Here

    }
  }

  @Override
  public DependencyReport queryHourlyReport(String domain, Date start, Date end) {
    DependencyReportMerger merger = new DependencyReportMerger(new DependencyReport(domain));
    long startTime = start.getTime();
    long endTime = end.getTime();
    String name = DependencyAnalyzer.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) {
              DependencyReport reportModel = com.dianping.cat.consumer.dependency.model.transform.DefaultSaxParser
                    .parse(xml);
              reportModel.accept(merger);
            } else {
              DependencyReport reportModel = queryFromHourlyBinary(report.getId(), domain);
              reportModel.accept(merger);
            }
          } catch (DalNotFoundException e) {
            //ignore
          } catch (Exception e) {
            Cat.logError(e);
          }
        }
      }
    }
    DependencyReport dependencyReport = merger.getDependencyReport();

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

    Set<String> domains = queryAllDomainNames(start, end, DependencyAnalyzer.ID);
View Full Code Here

  public static final String TUAN_TOU = "TuanGou";
 
  private Segment buildAllSegmentsInfo(DependencyReport report) {
    Segment result = new Segment();
    Map<Integer, Segment> segments = report.getSegments();
    DependencyReportMerger merger = new DependencyReportMerger(null);

    for (Segment segment : segments.values()) {
      Map<String, Dependency> dependencies = segment.getDependencies();
      Map<String, Index> indexs = segment.getIndexs();

      for (Index index : indexs.values()) {
        Index temp = result.findOrCreateIndex(index.getName());
        merger.mergeIndex(temp, index);
      }
      for (Dependency dependency : dependencies.values()) {
        Dependency temp = result.findOrCreateDependency(dependency.getKey());

        merger.mergeDependency(temp, dependency);
      }
    }
    return result;
  }
View Full Code Here

TOP

Related Classes of com.dianping.cat.consumer.dependency.DependencyReportMerger

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.