Пример #1
0
  @Override
  public boolean buildHourlyTask(String name, String domain, Date start) {
    ServiceReport serviceReport = new ServiceReport(Constants.CAT);
    Date end = new Date(start.getTime() + TimeHelper.ONE_HOUR);
    Set<String> domains = m_reportService.queryAllDomainNames(start, end, CrossAnalyzer.ID);

    for (String domainName : domains) {
      if (m_configManger.validateDomain(domainName)) {
        CrossReport crossReport = m_crossReportService.queryReport(domainName, start, end);
        ProjectInfo projectInfo = new ProjectInfo(TimeHelper.ONE_HOUR);

        projectInfo.setClientIp(Constants.ALL);
        projectInfo.visitCrossReport(crossReport);
        Collection<TypeDetailInfo> callInfos = projectInfo.getCallProjectsInfo();

        for (TypeDetailInfo typeInfo : callInfos) {
          if (!validataService(typeInfo)) {
            merge(serviceReport.findOrCreateDomain(typeInfo.getProjectName()), typeInfo);
          }
        }
      }
    }
    HourlyReport report = new HourlyReport();

    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(serviceReport);
    return m_reportService.insertHourlyReport(report, binaryContent);
  }
Пример #2
0
  @Override
  public boolean buildMonthlyTask(String name, String domain, Date period) {
    ServiceReport serviceReport =
        queryDailyReportsByDuration(domain, period, TaskHelper.nextMonthStart(period));
    MonthlyReport report = new MonthlyReport();

    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.insertMonthlyReport(report, binaryContent);
  }
Пример #3
0
  private ServiceReport queryHourlyReportsByDuration(
      String name, String domain, Date start, Date end) {
    long startTime = start.getTime();
    long endTime = end.getTime();
    ServiceReportMerger merger = new ServiceReportMerger(new ServiceReport(domain));

    for (; startTime < endTime; startTime = startTime + TimeHelper.ONE_HOUR) {
      Date date = new Date(startTime);
      ServiceReport reportModel =
          m_reportService.queryReport(domain, date, new Date(date.getTime() + TimeHelper.ONE_HOUR));

      reportModel.accept(merger);
    }

    ServiceReport serviceReport = merger.getServiceReport();

    serviceReport.setStartTime(start);
    serviceReport.setEndTime(end);
    return serviceReport;
  }
Пример #4
0
  private ServiceReport queryDailyReportsByDuration(String domain, Date start, Date end) {
    long startTime = start.getTime();
    long endTime = end.getTime();
    ServiceReportMerger merger = new ServiceReportMerger(new ServiceReport(domain));

    for (; startTime < endTime; startTime += TimeHelper.ONE_DAY) {
      try {
        ServiceReport reportModel =
            m_reportService.queryReport(
                domain, new Date(startTime), new Date(startTime + TimeHelper.ONE_DAY));
        reportModel.accept(merger);
      } catch (Exception e) {
        Cat.logError(e);
      }
    }
    ServiceReport serviceReport = merger.getServiceReport();

    serviceReport.setStartTime(start);
    serviceReport.setEndTime(end);
    return serviceReport;
  }