示例#1
0
  @Override
  public StateReport queryDailyReport(String domain, Date start, Date end) {
    StateReportMerger merger = new StateReportMerger(new StateReport(domain));
    long startTime = start.getTime();
    long endTime = end.getTime();
    String name = StateAnalyzer.ID;

    for (; startTime < endTime; startTime = startTime + TimeUtil.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) {
          StateReport reportModel =
              com.dianping.cat.consumer.state.model.transform.DefaultSaxParser.parse(xml);
          reportModel.accept(merger);
        } else {
          StateReport reportModel = queryFromDailyBinary(report.getId(), domain);

          reportModel.accept(merger);
        }
      } catch (DalNotFoundException e) {
        // ignore
      } catch (Exception e) {
        Cat.logError(e);
      }
    }
    StateReport stateReport = merger.getStateReport();

    stateReport.setStartTime(start);
    stateReport.setEndTime(end);
    return stateReport;
  }
示例#2
0
  @Override
  public HeavyReport queryDailyReport(String domain, Date start, Date end) {
    HeavyReportMerger merger = new HeavyReportMerger(new HeavyReport(domain));
    long startTime = start.getTime();
    long endTime = end.getTime();
    String name = Constants.REPORT_HEAVY;

    for (; startTime < endTime; startTime = startTime + TimeHelper.ONE_DAY) {
      try {
        DailyReport report =
            m_dailyReportDao.findByDomainNamePeriod(
                domain, name, new Date(startTime), DailyReportEntity.READSET_FULL);
        HeavyReport reportModel = queryFromDailyBinary(report.getId(), domain);

        reportModel.accept(merger);
      } catch (DalNotFoundException e) {
        // ignore
      } catch (Exception e) {
        Cat.logError(e);
      }
    }
    HeavyReport heavyReport = merger.getHeavyReport();

    heavyReport.setStartTime(start);
    heavyReport.setEndTime(end);
    return heavyReport;
  }
示例#3
0
  @Override
  public boolean buildDailyTask(String name, String domain, Date period) {
    ServiceReport serviceReport =
        queryHourlyReportsByDuration(name, domain, period, TaskHelper.tomorrowZero(period));
    DailyReport report = new DailyReport();

    report.setCreationDate(new Date());
    report.setDomain(domain);
    report.setIp(NetworkInterfaceManager.INSTANCE.getLocalHostAddress());
    report.setName(name);
    report.setPeriod(period);
    report.setType(1);
    byte[] binaryContent = DefaultNativeBuilder.build(serviceReport);

    return m_reportService.insertDailyReport(report, binaryContent);
  }
示例#4
0
  @Override
  public boolean buildDailyTask(String name, String domain, Date period) {
    BugReport bugReport =
        queryHourlyReportsByDuration(name, domain, period, TaskHelper.tomorrowZero(period));

    for (Domain d : bugReport.getDomains().values()) {
      d.setProblemUrl(
          String.format(
              "http://%s/cat/r/p?op=history&reportType=day&domain=%s&date=%s",
              getDomainName(), d.getId(), m_daily_formate.format(period)));
    }
    DailyReport report = new DailyReport();

    report.setContent(bugReport.toString());
    report.setCreationDate(new Date());
    report.setDomain(domain);
    report.setIp(NetworkInterfaceManager.INSTANCE.getLocalHostAddress());
    report.setName(name);
    report.setPeriod(period);
    report.setType(1);
    byte[] binaryContent = DefaultNativeBuilder.build(bugReport);
    return m_reportService.insertDailyReport(report, binaryContent);
  }