@Override public ProblemReport getReport(String domain) { ProblemReport report = m_reportManager.getHourlyReport(getStartTime(), domain, false); report.getDomainNames().addAll(m_reportManager.getDomains(getStartTime())); return report; }
@Override public ProblemReport makeReport(String domain, long startTime, long duration) { ProblemReport report = new ProblemReport(domain); report.setStartTime(new Date(startTime)); report.setEndTime(new Date(startTime + duration - 1)); return report; }
@Override public void process(MessageTree tree) { String domain = tree.getDomain(); ProblemReport report = m_reportManager.getHourlyReport(getStartTime(), domain, true); report.addIp(tree.getIpAddress()); Machine machine = report.findOrCreateMachine(tree.getIpAddress()); for (ProblemHandler handler : m_handlers) { handler.handle(machine, tree); } }
@Test public void testProcess() throws Exception { for (int i = 1; i <= 100; i++) { MessageTree tree = generateMessageTree(i); m_analyzer.process(tree); } ProblemReport report = m_analyzer.getReport(m_domain); String expected = Files.forIO().readFrom(getClass().getResourceAsStream("problem_analyzer.xml"), "utf-8"); Assert.assertEquals(expected.replaceAll("\r", ""), report.toString().replaceAll("\r", "")); }
@Override public boolean createHourlyTask(ProblemReport report) { String domain = report.getDomain(); if (m_manager.validateDomain(domain)) { return m_taskManager.createTask( report.getStartTime(), domain, ProblemAnalyzer.ID, TaskProlicy.ALL); } else if (m_manager.isCrashLog(domain)) { return m_taskManager.createTask( report.getStartTime(), domain, ProblemAnalyzer.ID, TaskProlicy.ALL_EXCLUED_HOURLY); } else { return true; } }
@Override public ProblemReport mergeReport(ProblemReport old, ProblemReport other) { ProblemReportMerger merger = new ProblemReportMerger(old); other.accept(merger); return old; }
@Override protected ProblemReport merge( ModelRequest request, List<ModelResponse<ProblemReport>> responses) { if (responses.size() == 0) { return null; } ProblemReportMerger merger = new ProblemReportMerger(new ProblemReport(request.getDomain())); for (ModelResponse<ProblemReport> response : responses) { if (response != null) { ProblemReport model = response.getModel(); if (model != null) { model.accept(merger); } } } return merger.getProblemReport(); }
@Override public void beforeSave(Map<String, ProblemReport> reports) { for (ProblemReport report : reports.values()) { Set<String> domainNames = report.getDomainNames(); domainNames.clear(); domainNames.addAll(reports.keySet()); } if (reports.size() > 0) { ProblemReport all = createAggregatedReport(reports); reports.put(all.getDomain(), all); } ProblemReport frontEnd = reports.get(Constants.FRONT_END); if (frontEnd != null) { reports.put(Constants.FRONT_END, rebuildFrontEndReport(frontEnd)); } }
@Override public void beforeSave(Map<String, ProblemReport> reports) { for (ProblemReport report : reports.values()) { Set<String> domainNames = report.getDomainNames(); domainNames.clear(); domainNames.addAll(reports.keySet()); } try { ProblemReportURLFilter problemReportURLFilter = new ProblemReportURLFilter(); for (Entry<String, ProblemReport> entry : reports.entrySet()) { ProblemReport report = entry.getValue(); problemReportURLFilter.visitProblemReport(report); } } catch (Exception e) { Cat.logError(e); } }
public ProblemReport createAggregatedReport(Map<String, ProblemReport> reports) { ProblemReport report = new ProblemReport(Constants.ALL); ProblemReportAllBuilder visitor = new ProblemReportAllBuilder(report); try { for (ProblemReport temp : reports.values()) { if (m_manager.validateDomain(temp.getDomain())) { report.getIps().add(temp.getDomain()); report.getDomainNames().add(temp.getDomain()); visitor.visitProblemReport(temp); } } } catch (Exception e) { Cat.logError(e); } return report; }
@Override public String getDomain(ProblemReport report) { return report.getDomain(); }
@Override public String buildXml(ProblemReport report) { return report.toString(); }
public ProblemReport rebuildFrontEndReport(ProblemReport report) { m_problemReportAggregation.refreshRule(); report.accept(m_problemReportAggregation); return m_problemReportAggregation.getReport(); }
@Override public void visitMachine(Machine machine) { m_currentMachine = m_report.findOrCreateMachine(machine.getIp()); super.visitMachine(machine); }
@Override public void visitProblemReport(ProblemReport problemReport) { m_domain = problemReport.getDomain(); m_report = new ProblemReport(); m_report.getIps().addAll(problemReport.getIps()); m_report.getDomainNames().addAll(problemReport.getDomainNames()); m_report.setDomain(problemReport.getDomain()); m_report.setStartTime(problemReport.getStartTime()); m_report.setEndTime(problemReport.getEndTime()); super.visitProblemReport(problemReport); }