Search in sources :

Example 1 with ReportingTaskHealth

use of org.apache.nifi.minifi.commons.status.reportingTask.ReportingTaskHealth in project nifi-minifi by apache.

the class StatusRequestParser method parseReportingTaskStatusRequest.

static ReportingTaskStatus parseReportingTaskStatusRequest(String id, ReportingTaskNode reportingTaskNode, String statusTypes, FlowController flowController, Logger logger) {
    ReportingTaskStatus reportingTaskStatus = new ReportingTaskStatus();
    reportingTaskStatus.setName(id);
    String[] statusSplits = statusTypes.split(",");
    List<Bulletin> bulletinList = flowController.getBulletinRepository().findBulletins(new BulletinQuery.Builder().sourceIdMatches(id).build());
    for (String statusType : statusSplits) {
        switch(statusType.toLowerCase().trim()) {
            case "health":
                ReportingTaskHealth reportingTaskHealth = new ReportingTaskHealth();
                reportingTaskHealth.setScheduledState(reportingTaskNode.getScheduledState().name());
                reportingTaskHealth.setActiveThreads(reportingTaskNode.getActiveThreadCount());
                reportingTaskHealth.setHasBulletins(!bulletinList.isEmpty());
                Collection<ValidationResult> validationResults = reportingTaskNode.getValidationErrors();
                reportingTaskHealth.setValidationErrorList(transformValidationResults(validationResults));
                reportingTaskStatus.setReportingTaskHealth(reportingTaskHealth);
                break;
            case "bulletins":
                reportingTaskStatus.setBulletinList(transformBulletins(bulletinList));
                break;
        }
    }
    return reportingTaskStatus;
}
Also used : Bulletin(org.apache.nifi.reporting.Bulletin) BulletinQuery(org.apache.nifi.reporting.BulletinQuery) ReportingTaskStatus(org.apache.nifi.minifi.commons.status.reportingTask.ReportingTaskStatus) ValidationResult(org.apache.nifi.components.ValidationResult) ReportingTaskHealth(org.apache.nifi.minifi.commons.status.reportingTask.ReportingTaskHealth)

Example 2 with ReportingTaskHealth

use of org.apache.nifi.minifi.commons.status.reportingTask.ReportingTaskHealth in project nifi-minifi by apache.

the class StatusReportPopulator method addReportingTaskStatus.

public static void addReportingTaskStatus(FlowStatusReport flowStatusReport, boolean addHealth, boolean addValidationErrors, boolean addBulletins, boolean populateBulletins) {
    ReportingTaskStatus reportingTaskStatus = new ReportingTaskStatus();
    reportingTaskStatus.setName("ReportProvenance");
    if (addHealth) {
        ReportingTaskHealth reportingTaskHealth = new ReportingTaskHealth();
        reportingTaskHealth.setActiveThreads(1);
        reportingTaskHealth.setScheduledState("RUNNING");
        reportingTaskHealth.setHasBulletins(populateBulletins);
        if (addValidationErrors) {
            List<ValidationError> validationErrorList = new LinkedList<>();
            ValidationError validationError1 = new ValidationError();
            validationError1.setInput("input");
            validationError1.setSubject("subject");
            validationError1.setReason("is not valid");
            validationErrorList.add(validationError1);
            ValidationError validationError2 = new ValidationError();
            validationError2.setInput("input2");
            validationError2.setSubject("subject2");
            validationError2.setReason("is not valid too");
            validationErrorList.add(validationError2);
            reportingTaskHealth.setValidationErrorList(validationErrorList);
        } else {
            reportingTaskHealth.setValidationErrorList(Collections.EMPTY_LIST);
        }
        reportingTaskStatus.setReportingTaskHealth(reportingTaskHealth);
    }
    if (addBulletins) {
        if (populateBulletins) {
            BulletinStatus bulletinStatus = new BulletinStatus();
            bulletinStatus.setMessage("Bulletin message");
            bulletinStatus.setTimestamp(new Date(1464019245000L));
            reportingTaskStatus.setBulletinList(Collections.singletonList(bulletinStatus));
        } else {
            reportingTaskStatus.setBulletinList(Collections.EMPTY_LIST);
        }
    }
    flowStatusReport.setReportingTaskStatusList(Collections.singletonList(reportingTaskStatus));
}
Also used : ValidationError(org.apache.nifi.minifi.commons.status.common.ValidationError) ReportingTaskStatus(org.apache.nifi.minifi.commons.status.reportingTask.ReportingTaskStatus) BulletinStatus(org.apache.nifi.minifi.commons.status.common.BulletinStatus) LinkedList(java.util.LinkedList) Date(java.util.Date) ReportingTaskHealth(org.apache.nifi.minifi.commons.status.reportingTask.ReportingTaskHealth)

Aggregations

ReportingTaskHealth (org.apache.nifi.minifi.commons.status.reportingTask.ReportingTaskHealth)2 ReportingTaskStatus (org.apache.nifi.minifi.commons.status.reportingTask.ReportingTaskStatus)2 Date (java.util.Date)1 LinkedList (java.util.LinkedList)1 ValidationResult (org.apache.nifi.components.ValidationResult)1 BulletinStatus (org.apache.nifi.minifi.commons.status.common.BulletinStatus)1 ValidationError (org.apache.nifi.minifi.commons.status.common.ValidationError)1 Bulletin (org.apache.nifi.reporting.Bulletin)1 BulletinQuery (org.apache.nifi.reporting.BulletinQuery)1