Package com.dianping.cat.consumer.cross.model.entity

Examples of com.dianping.cat.consumer.cross.model.entity.CrossReport


    long historyTime = payload.getHistoryEndDate().getTime() - payload.getHistoryStartDate().getTime();

    String domain = payload.getDomain();
    switch (payload.getAction()) {
    case HOURLY_PROJECT:
      CrossReport projectReport = getHourlyReport(payload);
      ProjectInfo projectInfo = new ProjectInfo(payload.getHourDuration());

      projectInfo.setHostinfoService(m_hostinfoService);
      projectInfo.setClientIp(model.getIpAddress()).setCallSortBy(model.getCallSort())
            .setServiceSortBy(model.getServiceSort());
      projectInfo.visitCrossReport(projectReport);
      model.setProjectInfo(projectInfo);
      model.setReport(projectReport);

      List<TypeDetailInfo> hourlyDetails = projectInfo.getServiceProjectsInfo();

      if (projectInfo.getCallerProjectsInfo().isEmpty()) {
        for (TypeDetailInfo info : hourlyDetails) {
          String projectName = info.getProjectName();
          if (projectName.equalsIgnoreCase(payload.getDomain()) || projectName.equalsIgnoreCase("UnknownProject")
                || projectName.equalsIgnoreCase(ProjectInfo.ALL_CLIENT)) {
            continue;
          }
          ProjectInfo temp = buildCallProjectInfo(projectName, payload.getPeriod(),
                String.valueOf(payload.getDate()), payload.getHourDuration());

          TypeDetailInfo detail = temp.getAllCallProjectInfo().get(domain);

          if (detail != null) {
            detail.setProjectName(projectName);
            projectInfo.addCallerProjectInfo(projectName, detail);
          }
        }
      }
      break;
    case HOURLY_HOST:
      CrossReport hostReport = getHourlyReport(payload);
      HostInfo hostInfo = new HostInfo(payload.getHourDuration());

      hostInfo.setHostinfoService(m_hostinfoService);
      hostInfo.setClientIp(model.getIpAddress()).setCallSortBy(model.getCallSort())
            .setServiceSortBy(model.getServiceSort());
      hostInfo.setProjectName(payload.getProjectName());
      hostInfo.visitCrossReport(hostReport);
      model.setReport(hostReport);
      model.setHostInfo(hostInfo);
      break;
    case HOURLY_METHOD:
      CrossReport methodReport = getHourlyReport(payload);
      MethodInfo methodInfo = new MethodInfo(payload.getHourDuration());

      methodInfo.setHostinfoService(m_hostinfoService);
      methodInfo.setClientIp(model.getIpAddress()).setCallSortBy(model.getCallSort())
            .setServiceSortBy(model.getServiceSort()).setRemoteProject(payload.getProjectName());
      methodInfo.setRemoteIp(payload.getRemoteIp()).setQuery(model.getQueryName());
      methodInfo.visitCrossReport(methodReport);
      model.setReport(methodReport);
      model.setMethodInfo(methodInfo);
      break;
    case HISTORY_PROJECT:
      CrossReport historyProjectReport = getSummarizeReport(payload);
      ProjectInfo historyProjectInfo = new ProjectInfo(historyTime);

      historyProjectInfo.setHostinfoService(m_hostinfoService);
      historyProjectInfo.setClientIp(model.getIpAddress()).setCallSortBy(model.getCallSort())
            .setServiceSortBy(model.getServiceSort());
      historyProjectInfo.visitCrossReport(historyProjectReport);
      model.setProjectInfo(historyProjectInfo);
      model.setReport(historyProjectReport);

      List<TypeDetailInfo> historyDetails = historyProjectInfo.getServiceProjectsInfo();

      if (historyProjectInfo.getCallerProjectsInfo().isEmpty()) {
        for (TypeDetailInfo info : historyDetails) {
          String projectName = info.getProjectName();
          if (projectName.equalsIgnoreCase(payload.getDomain()) || projectName.equalsIgnoreCase("UnknownProject")
                || projectName.equalsIgnoreCase(ProjectInfo.ALL_CLIENT)) {
            continue;
          }
          Date start = payload.getHistoryStartDate();
          Date end = payload.getHistoryEndDate();
          ProjectInfo temp = buildHistoryCallProjectInfo(projectName, start, end);

          TypeDetailInfo detail = temp.getAllCallProjectInfo().get(domain);

          if (detail != null) {
            detail.setProjectName(projectName);
            historyProjectInfo.addCallerProjectInfo(projectName, detail);
          }
        }
      }
      break;
    case HISTORY_HOST:
      CrossReport historyHostReport = getSummarizeReport(payload);
      HostInfo historyHostInfo = new HostInfo(historyTime);

      historyHostInfo.setHostinfoService(m_hostinfoService);
      historyHostInfo.setClientIp(model.getIpAddress()).setCallSortBy(model.getCallSort())
            .setServiceSortBy(model.getServiceSort());
      historyHostInfo.setProjectName(payload.getProjectName());
      historyHostInfo.visitCrossReport(historyHostReport);
      model.setReport(historyHostReport);
      model.setHostInfo(historyHostInfo);
      break;
    case HISTORY_METHOD:
      CrossReport historyMethodReport = getSummarizeReport(payload);
      MethodInfo historyMethodInfo = new MethodInfo(historyTime);

      historyMethodInfo.setHostinfoService(m_hostinfoService);
      historyMethodInfo.setClientIp(model.getIpAddress()).setCallSortBy(model.getCallSort())
            .setServiceSortBy(model.getServiceSort()).setRemoteProject(payload.getProjectName());
      historyMethodInfo.setRemoteIp(payload.getRemoteIp()).setQuery(model.getQueryName());
      historyMethodInfo.visitCrossReport(historyMethodReport);
      model.setReport(historyMethodReport);
      model.setMethodInfo(historyMethodInfo);
      break;

    case METHOD_QUERY:
      String method = payload.getMethod();
      CrossMethodVisitor info = new CrossMethodVisitor(method, m_hostinfoService);
      String reportType = payload.getReportType();
      CrossReport queryReport = null;

      if (reportType != null
            && (reportType.equals("day") || reportType.equals("week") || reportType.equals("month"))) {
        queryReport = getSummarizeReport(payload);
      } else {
View Full Code Here


      if (reports == null && createIfNotExist) {
        reports = new ConcurrentHashMap<String, CrossReport>();
        m_reports.put(startTime, reports);
      }

      CrossReport report = reports.get(domain);

      if (report == null && createIfNotExist) {
        report = m_delegate.makeReport(domain, startTime, HOUR);
        reports.put(domain, report);
      }
View Full Code Here

public class CrossReportMergerTest {
  @Test
  public void testCrossReportMerge() throws Exception {
    String oldXml = Files.forIO().readFrom(getClass().getResourceAsStream("CrossReportOld.xml"), "utf-8");
    String newXml = Files.forIO().readFrom(getClass().getResourceAsStream("CrossReportNew.xml"), "utf-8");
    CrossReport reportOld = DefaultSaxParser.parse(oldXml);
    CrossReport reportNew = DefaultSaxParser.parse(newXml);
    String expected = Files.forIO().readFrom(getClass().getResourceAsStream("CrossReportMergeResult.xml"), "utf-8");
    CrossReportMerger merger = new CrossReportMerger(new CrossReport(reportOld.getDomain()));

    reportOld.accept(merger);
    reportNew.accept(merger);

    Assert.assertEquals("Check the merge result!", expected.replaceAll("\r", ""), merger.getCrossReport()
          .toString().replaceAll("\r", ""));
    Assert.assertEquals("Source report is changed!", newXml.replaceAll("\r", ""),
          reportNew.toString().replaceAll("\r", ""));
    Assert.assertEquals("Source report is changed!", oldXml.replaceAll("\r", ""),
          reportOld.toString().replaceAll("\r", ""));
  }
View Full Code Here

    DailyReportContent content = m_dailyReportContentDao.findByPK(id, DailyReportContentEntity.READSET_FULL);

    if (content != null) {
      return DefaultNativeParser.parse(content.getContent());
    } else {
      return new CrossReport(domain);
    }
  }
View Full Code Here

    HourlyReportContent content = m_hourlyReportContentDao.findByPK(id, HourlyReportContentEntity.READSET_FULL);

    if (content != null) {
      return DefaultNativeParser.parse(content.getContent());
    } else {
      return new CrossReport(domain);
    }
  }
View Full Code Here

    MonthlyReportContent content = m_monthlyReportContentDao.findByPK(id, MonthlyReportContentEntity.READSET_FULL);

    if (content != null) {
      return DefaultNativeParser.parse(content.getContent());
    } else {
      return new CrossReport(domain);
    }
  }
View Full Code Here

    WeeklyReportContent content = m_weeklyReportContentDao.findByPK(id, WeeklyReportContentEntity.READSET_FULL);

    if (content != null) {
      return DefaultNativeParser.parse(content.getContent());
    } else {
      return new CrossReport(domain);
    }
  }
View Full Code Here

    }
  }

  @Override
  public CrossReport queryHourlyReport(String domain, Date start, Date end) {
    CrossReportMerger merger = new CrossReportMerger(new CrossReport(domain));
    long startTime = start.getTime();
    long endTime = end.getTime();
    String name = CrossAnalyzer.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) {// for old xml storage
              CrossReport reportModel = com.dianping.cat.consumer.cross.model.transform.DefaultSaxParser
                    .parse(xml);
              reportModel.accept(merger);
            } else {// for new binary storage, binary is same to report id
              CrossReport reportModel = queryFromHourlyBinary(report.getId(), domain);

              reportModel.accept(merger);
            }
          } catch (DalNotFoundException e) {
            //ignore
          } catch (Exception e) {
            Cat.logError(e);
          }
        }
      }
    }
    CrossReport crossReport = merger.getCrossReport();

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

    Set<String> domains = queryAllDomainNames(start, end, CrossAnalyzer.ID);
    crossReport.getDomainNames().addAll(domains);
    return crossReport;
  }
View Full Code Here

    } catch (DalNotFoundException e) {
      //ignore
    } catch (Exception e) {
      Cat.logError(e);
    }
    return new CrossReport(domain);
  }
View Full Code Here

    } catch (DalNotFoundException e) {
      //ignore
    } catch (Exception e) {
      Cat.logError(e);
    }
    return new CrossReport(domain);
  }
View Full Code Here

TOP

Related Classes of com.dianping.cat.consumer.cross.model.entity.CrossReport

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.