예제 #1
0
  @Override
  public boolean buildHourlyTask(String name, String domain, Date start) {
    BugReport bugReport = new BugReport(Constants.CAT);
    ProblemReportVisitor visitor = new ProblemReportVisitor().setReport(bugReport);
    Date end = new Date(start.getTime() + TimeUtil.ONE_HOUR);
    Set<String> domains = m_reportService.queryAllDomainNames(start, end, ProblemAnalyzer.ID);

    for (String domainName : domains) {
      if (validateDomain(domainName)) {
        ProblemReport problemReport = m_reportService.queryProblemReport(domainName, start, end);
        visitor.visitProblemReport(problemReport);
      }
    }

    for (Domain d : bugReport.getDomains().values()) {
      d.setProblemUrl(
          String.format(
              "http://%s/cat/r/p?domain=%s&date=%s",
              getDomainName(), d.getId(), m_hourly_formate.format(start)));
    }
    HourlyReport report = new HourlyReport();

    report.setContent("");
    report.setCreationDate(new Date());
    report.setDomain(domain);
    report.setIp(NetworkInterfaceManager.INSTANCE.getLocalHostAddress());
    report.setName(name);
    report.setPeriod(start);
    report.setType(1);
    byte[] binaryContent = DefaultNativeBuilder.build(bugReport);
    return m_reportService.insertHourlyReport(report, binaryContent);
  }
예제 #2
0
  private BugReport queryHourlyReportsByDuration(String name, String domain, Date start, Date end) {
    long startTime = start.getTime();
    long endTime = end.getTime();
    BugReportMerger merger = new BugReportMerger(new BugReport(domain));

    for (; startTime < endTime; startTime = startTime + TimeUtil.ONE_HOUR) {
      Date date = new Date(startTime);
      BugReport reportModel =
          m_reportService.queryBugReport(
              domain, date, new Date(date.getTime() + TimeUtil.ONE_HOUR));

      reportModel.accept(merger);
    }
    com.dianping.cat.home.bug.entity.BugReport bugReport = merger.getBugReport();

    return bugReport;
  }
예제 #3
0
  private BugReport queryDailyReportsByDuration(String domain, Date start, Date end) {
    long startTime = start.getTime();
    long endTime = end.getTime();
    HistoryBugReportMerger merger = new HistoryBugReportMerger(new BugReport(domain));

    for (; startTime < endTime; startTime += TimeUtil.ONE_DAY) {
      try {
        BugReport reportModel =
            m_reportService.queryBugReport(
                domain, new Date(startTime), new Date(startTime + TimeUtil.ONE_DAY));
        reportModel.accept(merger);
      } catch (Exception e) {
        Cat.logError(e);
      }
    }
    BugReport bugReport = merger.getBugReport();
    bugReport.setStartTime(start);
    bugReport.setEndTime(end);
    return bugReport;
  }
예제 #4
0
  @Override
  public boolean buildMonthlyTask(String name, String domain, Date period) {
    BugReport bugReport =
        queryDailyReportsByDuration(domain, period, TaskHelper.nextMonthStart(period));

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

    report.setContent("");
    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.insertMonthlyReport(report, binaryContent);
  }