private void sendLogAggregationReportInternal( LogAggregationStatus logAggregationStatus, String diagnosticMessage) { LogAggregationReport report = Records.newRecord(LogAggregationReport.class); report.setApplicationId(appId); report.setDiagnosticMessage(diagnosticMessage); report.setLogAggregationStatus(logAggregationStatus); this.context.getLogAggregationStatusForApps().add(report); }
private void updateLogAggregationDiagnosticMessages(NodeId nodeId, LogAggregationReport report) { if (report.getDiagnosticMessage() != null && !report.getDiagnosticMessage().isEmpty()) { if (report.getLogAggregationStatus() == LogAggregationStatus.RUNNING ) { List<String> diagnostics = logAggregationDiagnosticsForNMs.get(nodeId); diagnostics.add(report.getDiagnosticMessage()); this.logAggregationStatus.get(nodeId).setDiagnosticMessage( StringUtils.join(diagnostics, "\n")); } else if (report.getLogAggregationStatus() == LogAggregationStatus.RUNNING_WITH_FAILURE) { List<String> failureMessages = failureMessages.add(report.getDiagnosticMessage());
private void handleLogAggregationStatus( List<LogAggregationReport> logAggregationReportsForApps) { for (LogAggregationReport report : logAggregationReportsForApps) { RMApp rmApp = this.context.getRMApps().get(report.getApplicationId()); if (rmApp != null) { ((RMAppImpl)rmApp).aggregateLogReport(this.nodeId, report); } } }
@Override public Map<NodeId, LogAggregationReport> getLogAggregationReportsForApp() { try { this.readLock.lock(); if (!isLogAggregationFinished() && isAppInFinalState(this) && systemClock.getTime() > this.logAggregationStartTime + this.logAggregationStatusTimeout) { for (Entry<NodeId, LogAggregationReport> output : logAggregationStatus.entrySet()) { if (!output.getValue().getLogAggregationStatus() .equals(LogAggregationStatus.TIME_OUT) && !output.getValue().getLogAggregationStatus() .equals(LogAggregationStatus.SUCCEEDED) && !output.getValue().getLogAggregationStatus() .equals(LogAggregationStatus.FAILED)) { output.getValue().setLogAggregationStatus( LogAggregationStatus.TIME_OUT); } } } return Collections.unmodifiableMap(logAggregationStatus); } finally { this.readLock.unlock(); } }
.entrySet()) { Assert.assertEquals(LogAggregationStatus.NOT_START, report.getValue() .getLogAggregationStatus()); "node1 logAggregation status updated at " + System.currentTimeMillis(); LogAggregationReport report1 = LogAggregationReport.newInstance(appId, LogAggregationStatus.RUNNING, messageForNode1_1); node1ReportForApp.add(report1); "node2 logAggregation status updated at " + System.currentTimeMillis(); LogAggregationReport report2 = LogAggregationReport.newInstance(appId, LogAggregationStatus.RUNNING, messageForNode2_1); node2ReportForApp.add(report2); if (report.getKey().equals(node1.getNodeID())) { Assert.assertEquals(LogAggregationStatus.RUNNING, report.getValue() .getLogAggregationStatus()); Assert.assertEquals(messageForNode1_1, report.getValue() .getDiagnosticMessage()); } else if (report.getKey().equals(node2.getNodeID())) { Assert.assertEquals(LogAggregationStatus.RUNNING, report.getValue() .getLogAggregationStatus()); Assert.assertEquals(messageForNode2_1, report.getValue() .getDiagnosticMessage()); } else { "node1 logAggregation status updated at " + System.currentTimeMillis();
public List<LogAggregationReport> pullCachedLogAggregationReports() { List<LogAggregationReport> reports = new ArrayList<>(); if (disabled) { LOG.warn("The log aggregation is disabled." + "There is no cached log aggregation status."); return reports; } // When we pull cached Log aggregation reports for all application in // this NM, we should make sure that we need to block all of the // updateLogAggregationStatus calls. So, the writeLocker is used here. this.writeLocker.lock(); try { for(Entry<ApplicationId, AppLogAggregationStatusForRMRecovery> tracker : recoveryStatuses.entrySet()) { AppLogAggregationStatusForRMRecovery current = tracker.getValue(); LogAggregationReport report = LogAggregationReport.newInstance( tracker.getKey(), current.getLogAggregationStatus(), current.getDiagnosis()); reports.add(report); } return reports; } finally { this.writeLocker.unlock(); } }
LogAggregationStatus status = report.getValue() == null ? null : report.getValue() .getLogAggregationStatus(); String message = report.getValue() == null ? null : report.getValue() .getDiagnosticMessage(); String failureMessage = report.getValue() == null ? null : ((RMAppImpl)rmApp)
private boolean isLogAggregationFinishedForNM(LogAggregationReport report) { return report.getLogAggregationStatus() == LogAggregationStatus.SUCCEEDED || report.getLogAggregationStatus() == LogAggregationStatus.FAILED; }
if (report.getLogAggregationStatus() != LogAggregationStatus.RUNNING || curReport.getLogAggregationStatus() != LogAggregationStatus.RUNNING_WITH_FAILURE) { if (curReport.getLogAggregationStatus() == LogAggregationStatus.TIME_OUT && report.getLogAggregationStatus() == LogAggregationStatus.RUNNING) { report.setLogAggregationStatus( LogAggregationStatus.RUNNING_WITH_FAILURE); curReport.setLogAggregationStatus(report .getLogAggregationStatus());
public void transition(RMAppImpl app, RMAppEvent event) { RMAppRunningOnNodeEvent nodeAddedEvent = (RMAppRunningOnNodeEvent) event; // if final state already stored, notify RMNode if (isAppInFinalState(app)) { app.handler.handle( new RMNodeCleanAppEvent(nodeAddedEvent.getNodeId(), nodeAddedEvent .getApplicationId())); return; } // otherwise, add it to ranNodes for further process app.ranNodes.add(nodeAddedEvent.getNodeId()); if (!app.logAggregationStatus.containsKey(nodeAddedEvent.getNodeId())) { app.logAggregationStatus.put(nodeAddedEvent.getNodeId(), LogAggregationReport.newInstance(app.applicationId, app.logAggregationEnabled ? LogAggregationStatus.NOT_START : LogAggregationStatus.DISABLED, "")); } }; }
private void updateLogAggregationStatus(NodeId nodeId) { LogAggregationStatus status = this.logAggregationStatus.get(nodeId).getLogAggregationStatus(); if (status.equals(LogAggregationStatus.SUCCEEDED)) { this.logAggregationSucceed++; this.logAggregationStatus.entrySet().iterator(); it.hasNext();) { Map.Entry<NodeId, LogAggregationReport> entry = it.next(); if (entry.getValue().getLogAggregationStatus() .equals(LogAggregationStatus.SUCCEEDED)) { it.remove();
@Public @Unstable public static LogAggregationReport newInstance(ApplicationId appId, LogAggregationStatus status, String diagnosticMessage) { LogAggregationReport report = Records.newRecord(LogAggregationReport.class); report.setApplicationId(appId); report.setLogAggregationStatus(status); report.setDiagnosticMessage(diagnosticMessage); return report; }
rmApp.aggregateLogReport(nodeId1, LogAggregationReport.newInstance( rmApp.getApplicationId(), LogAggregationStatus.NOT_START, "")); rmApp.aggregateLogReport(nodeId2, LogAggregationReport.newInstance( rmApp.getApplicationId(), LogAggregationStatus.NOT_START, "")); rmApp.aggregateLogReport(nodeId3, LogAggregationReport.newInstance( rmApp.getApplicationId(), LogAggregationStatus.NOT_START, "")); rmApp.aggregateLogReport(nodeId4, LogAggregationReport.newInstance( rmApp.getApplicationId(), LogAggregationStatus.NOT_START, "")); Assert.assertEquals(LogAggregationStatus.NOT_START, rmApp.getLogAggregationStatusForAppReport()); rmApp.aggregateLogReport(nodeId1, LogAggregationReport.newInstance( rmApp.getApplicationId(), LogAggregationStatus.NOT_START, "")); rmApp.aggregateLogReport(nodeId2, LogAggregationReport.newInstance( rmApp.getApplicationId(), LogAggregationStatus.RUNNING, "")); rmApp.aggregateLogReport(nodeId3, LogAggregationReport.newInstance( rmApp.getApplicationId(), LogAggregationStatus.SUCCEEDED, "")); rmApp.aggregateLogReport(nodeId4, LogAggregationReport.newInstance( rmApp.getApplicationId(), LogAggregationStatus.SUCCEEDED, "")); Assert.assertEquals(LogAggregationStatus.RUNNING, rmApp.aggregateLogReport(nodeId1, LogAggregationReport.newInstance( rmApp.getApplicationId(), LogAggregationStatus.SUCCEEDED, "")); rmApp.aggregateLogReport(nodeId2, LogAggregationReport.newInstance( rmApp.getApplicationId(), LogAggregationStatus.TIME_OUT, "")); rmApp.aggregateLogReport(nodeId3, LogAggregationReport.newInstance( rmApp.getApplicationId(), LogAggregationStatus.SUCCEEDED, "")); rmApp.aggregateLogReport(nodeId4, LogAggregationReport.newInstance( rmApp.getApplicationId(), LogAggregationStatus.SUCCEEDED, ""));
int logRunningWithFailure = 0; for (Entry<NodeId, LogAggregationReport> report : reports.entrySet()) { switch (report.getValue().getLogAggregationStatus()) { case NOT_START: logNotStartCount++;
private void sendLogAggregationReportInternal( LogAggregationStatus logAggregationStatus, String diagnosticMessage, boolean finalized) { LogAggregationReport report = Records.newRecord(LogAggregationReport.class); report.setApplicationId(appId); report.setDiagnosticMessage(diagnosticMessage); report.setLogAggregationStatus(logAggregationStatus); this.context.getLogAggregationStatusForApps().add(report); this.context.getNMLogAggregationStatusTracker().updateLogAggregationStatus( appId, logAggregationStatus, System.currentTimeMillis(), diagnosticMessage, finalized); }