Пример #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
  public void merge(Domain domain, TypeDetailInfo info) {
    domain.setTotalCount(domain.getTotalCount() + info.getTotalCount());
    domain.setFailureCount(domain.getFailureCount() + info.getFailureCount());
    domain.setSum(domain.getSum() + info.getSum());

    if (domain.getTotalCount() > 0) {
      domain.setAvg(domain.getSum() / domain.getTotalCount());
      domain.setFailurePercent(domain.getFailureCount() * 1.0 / domain.getTotalCount());
    }
  }
Пример #3
0
 private boolean validataService(TypeDetailInfo typeInfo) {
   return typeInfo.getProjectName().equalsIgnoreCase(ProjectInfo.ALL_SERVER)
       || typeInfo.getProjectName().equalsIgnoreCase("UnknownProject");
 }