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

Examples of com.dianping.cat.consumer.top.model.entity.TopReport


    super(TopAnalyzer.ID);
  }

  @Override
  protected TopReport getReport(ModelRequest request, ModelPeriod period, String domain) throws Exception {
    TopReport report = super.getReport(request, period, domain);

    if (report == null && period.isLast()) {
      long startTime = request.getStartTime();
      report = getReportFromLocalDisk(startTime, domain);
   
      if (report == null) {
        report = new TopReport(domain);
        report.setStartTime(new Date(startTime));
        report.setEndTime(new Date(startTime + TimeHelper.ONE_HOUR - 1));
      }
    }
    return report;
  }
View Full Code Here


public class TopReportVisitorTest extends ComponentTestCase {

  @Test
  public void test() throws Exception {
    String topReportXml = Files.forIO().readFrom(getClass().getResourceAsStream("topReport.xml"), "utf-8");
    TopReport topReport = com.dianping.cat.consumer.top.model.transform.DefaultSaxParser.parse(topReportXml);

    String expectedAlertReportXml = Files.forIO()
          .readFrom(getClass().getResourceAsStream("alertReport.xml"), "utf-8");

    ExceptionConfigMock exceptionConfigManager = new ExceptionConfigMock();
    AlertReport alertReport = new AlertReport(Constants.CAT);
    TopReportVisitor visitor = new TopReportVisitor().setReport(alertReport).setExceptionConfigManager(
        exceptionConfigManager);

    alertReport.setStartTime(topReport.getStartTime());
    alertReport.setEndTime(topReport.getEndTime());
    visitor.visitTopReport(topReport);

    Assert.assertEquals("Check the report result!", expectedAlertReportXml.replace("\r", ""), alertReport.toString()
          .replace("\r", ""));
  }
View Full Code Here

    String domain = Constants.CAT;
    ModelRequest request = new ModelRequest(domain, payload.getDate());

    if (m_service.isEligable(request)) {
      ModelResponse<TopReport> response = m_service.invoke(request);
      TopReport report = response.getModel();

      if (report == null || report.getDomains().size() == 0) {
        report = m_reportService.queryTopReport(domain, new Date(payload.getDate()), new Date(payload.getDate()
              + TimeHelper.ONE_HOUR));
      }
      return report;
    } else {
View Full Code Here

    Model model = new Model(ctx);
    Payload payload = ctx.getPayload();

    normalize(model, payload);

    TopReport report = getReport(payload);
    int minuteCount = payload.getMinuteCounts();

    if (!payload.getPeriod().isCurrent()) {
      minuteCount = 60;
    } else {
View Full Code Here

  private static final long DURATION = TimeHelper.ONE_MINUTE;

  private static final int ALERT_PERIOD = 1;

  private TopMetric buildTopMetric(Date date) {
    TopReport topReport = queryTopReport(date);
    TopMetric topMetric = new TopMetric(ALERT_PERIOD, Integer.MAX_VALUE, m_exceptionConfigManager);

    topMetric.setStart(date).setEnd(new Date(date.getTime() + TimeHelper.ONE_MINUTE));
    topMetric.visitTopReport(topReport);
    return topMetric;
View Full Code Here

    String date = String.valueOf(start.getTime());
    ModelRequest request = new ModelRequest(domain, start.getTime()).setProperty("date", date);

    if (m_topService.isEligable(request)) {
      ModelResponse<TopReport> response = m_topService.invoke(request);
      TopReport report = response.getModel();

      return report;
    } else {
      throw new RuntimeException("Internal error: no eligable top service registered for " + request + "!");
    }
View Full Code Here

    Date end = new Date(start.getTime() + TimeHelper.ONE_HOUR);

    alertReport.setStartTime(start);
    alertReport.setEndTime(end);

    TopReport topReport = m_reportService.queryTopReport(Constants.CAT, start, end);
    visitor.visitTopReport(topReport);

    HourlyReport report = new HourlyReport();
    report.setContent("");
    report.setCreationDate(new Date());
View Full Code Here

public class TopReportMergerTest {
  @Test
  public void testTopReportMerge() throws Exception {
    String oldXml = Files.forIO().readFrom(getClass().getResourceAsStream("top_analyzer.xml"), "utf-8");
    String newXml = Files.forIO().readFrom(getClass().getResourceAsStream("top_analyzer.xml"), "utf-8");
    TopReport reportOld = DefaultSaxParser.parse(oldXml);
    TopReport reportNew = DefaultSaxParser.parse(newXml);
    String expected = Files.forIO().readFrom(getClass().getResourceAsStream("top_analyzer_merger.xml"), "utf-8");
    TopReportMerger merger = new TopReportMerger(new TopReport(reportOld.getDomain()));

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

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

    m_analyzer.initialize(date.getTime(), Constants.HOUR, Constants.MINUTE * 5);
  }

  @Test
  public void testProcess() throws Exception {
    TopReport report = m_analyzer.getReport(m_domain);

    String expected = Files.forIO().readFrom(getClass().getResourceAsStream("top_analyzer.xml"), "utf-8");
    Assert.assertEquals(expected.replaceAll("\r", ""), report.toString().replaceAll("\r", ""));
  }
View Full Code Here

TOP

Related Classes of com.dianping.cat.consumer.top.model.entity.TopReport

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.