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

Examples of com.dianping.cat.consumer.state.model.entity.StateReport


  }

  @Override
  public void doCheckpoint(boolean atEnd) {
    long startTime = getStartTime();
    StateReport stateReport = getReport(Constants.CAT);
    Map<String, StateReport> reports = m_reportManager.getHourlyReports(startTime);

    reports.put(Constants.CAT, stateReport);
    if (atEnd && !isLocalMode()) {
      m_reportManager.storeHourlyReports(startTime, StoragePolicy.FILE_AND_DB);
View Full Code Here


    m_logger = logger;
  }

  @Override
  public StateReport getReport(String domain) {
    StateReport report = new StateReport(Constants.CAT);

    report.setStartTime(new Date(m_startTime));
    report.setEndTime(new Date(m_startTime + MINUTE * 60 - 1));

    Machine machine = buildStateInfo(report.findOrCreateMachine(m_ip));
    StateReport stateReport = m_reportManager.getHourlyReport(getStartTime(), Constants.CAT, true);
    Map<String, ProcessDomain> processDomains = stateReport.findOrCreateMachine(m_ip).getProcessDomains();

    for (Map.Entry<String, ProcessDomain> entry : machine.getProcessDomains().entrySet()) {
      ProcessDomain processDomain = processDomains.get(entry.getKey());

      if (processDomain != null) {
View Full Code Here

    return report;
  }

  @Override
  protected void process(MessageTree tree) {
    StateReport report = m_reportManager.getHourlyReport(getStartTime(), Constants.CAT, true);
    String domain = tree.getDomain();
    String ip = tree.getIpAddress();
    Machine machine = report.findOrCreateMachine(NetworkInterfaceManager.INSTANCE.getLocalHostAddress());

    machine.findOrCreateProcessDomain(domain).addIp(ip);
    if (m_serverConfigManager.validateDomain(domain)) {
      if (!m_projectService.containsDomainInCat(domain)) {
        boolean insert = m_projectService.insertDomain(domain);
View Full Code Here

public class StateReportService extends AbstractReportService<StateReport> {

  @Override
  public StateReport makeReport(String domain, Date start, Date end) {
    StateReport report = new StateReport(domain);

    report.setStartTime(start);
    report.setEndTime(end);
    return report;
  }
View Full Code Here

    return report;
  }

  @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 + TimeHelper.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;
  }
View Full Code Here

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

    if (content != null) {
      return DefaultNativeParser.parse(content.getContent());
    } else {
      return new StateReport(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 StateReport(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 StateReport(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 StateReport(domain);
    }
  }
View Full Code Here

    }
  }

  @Override
  public StateReport queryHourlyReport(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 + 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
              StateReport reportModel = com.dianping.cat.consumer.state.model.transform.DefaultSaxParser
                    .parse(xml);
              reportModel.accept(merger);
            } else {// for new binary storage, binary is same to report id
              StateReport reportModel = queryFromHourlyBinary(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(new Date(end.getTime() - 1));
    return stateReport;
  }
View Full Code Here

TOP

Related Classes of com.dianping.cat.consumer.state.model.entity.StateReport

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.