Package com.dianping.cat.consumer.heartbeat

Examples of com.dianping.cat.consumer.heartbeat.HeartbeatReportMerger


    }
  }

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

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

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


  @Test
  public void testModel() throws Exception {
    String newXml = Files.forIO().readFrom(getClass().getResourceAsStream("heartbeat.xml"), "utf-8");
    HeartbeatReport reportOld = DefaultSaxParser.parse(newXml);
    HeartbeatReportMerger merger = new HeartbeatReportMerger(new HeartbeatReport(reportOld.getDomain()));

    reportOld.accept(merger);
    Assert.assertEquals(newXml.replaceAll("\r", ""), reportOld.toString().replaceAll("\r", ""));
  }
View Full Code Here

  @Override
  protected HeartbeatReport merge(ModelRequest request, List<ModelResponse<HeartbeatReport>> responses) {
    if (responses.size() == 0) {
      return null;
    }
    HeartbeatReportMerger merger = new HeartbeatReportMerger(new HeartbeatReport(request.getDomain()));

    for (ModelResponse<HeartbeatReport> response : responses) {
      if (response != null) {
        HeartbeatReport model = response.getModel();

        if (model != null) {
          model.accept(merger);
        }
      }
    }
    return merger.getHeartbeatReport();
  }
View Full Code Here

TOP

Related Classes of com.dianping.cat.consumer.heartbeat.HeartbeatReportMerger

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.