Search in sources :

Example 1 with ControllerServiceHealth

use of org.apache.nifi.minifi.commons.status.controllerservice.ControllerServiceHealth in project nifi-minifi by apache.

the class StatusRequestParser method parseControllerServiceStatusRequest.

static ControllerServiceStatus parseControllerServiceStatusRequest(ControllerServiceNode controllerServiceNode, String statusTypes, FlowController flowController, Logger logger) {
    ControllerServiceStatus controllerServiceStatus = new ControllerServiceStatus();
    String id = controllerServiceNode.getIdentifier();
    controllerServiceStatus.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":
                ControllerServiceHealth controllerServiceHealth = new ControllerServiceHealth();
                controllerServiceHealth.setState(controllerServiceNode.getState().name());
                controllerServiceHealth.setHasBulletins(!bulletinList.isEmpty());
                Collection<ValidationResult> validationResults = controllerServiceNode.getValidationErrors();
                controllerServiceHealth.setValidationErrorList(transformValidationResults(validationResults));
                controllerServiceStatus.setControllerServiceHealth(controllerServiceHealth);
                break;
            case "bulletins":
                controllerServiceStatus.setBulletinList(transformBulletins(bulletinList));
                break;
        }
    }
    return controllerServiceStatus;
}
Also used : ControllerServiceHealth(org.apache.nifi.minifi.commons.status.controllerservice.ControllerServiceHealth) ControllerServiceStatus(org.apache.nifi.minifi.commons.status.controllerservice.ControllerServiceStatus) Bulletin(org.apache.nifi.reporting.Bulletin) BulletinQuery(org.apache.nifi.reporting.BulletinQuery) ValidationResult(org.apache.nifi.components.ValidationResult)

Example 2 with ControllerServiceHealth

use of org.apache.nifi.minifi.commons.status.controllerservice.ControllerServiceHealth in project nifi-minifi by apache.

the class StatusReportPopulator method addControllerServiceStatus.

public static void addControllerServiceStatus(FlowStatusReport flowStatusReport, boolean addHealth, boolean addValidationErrors, boolean addBulletins, boolean populateBulletins) {
    ControllerServiceStatus controllerServiceStatus = new ControllerServiceStatus();
    controllerServiceStatus.setName("mockControllerService");
    if (addBulletins) {
        if (populateBulletins) {
            BulletinStatus bulletinStatus = new BulletinStatus();
            bulletinStatus.setMessage("Bulletin message");
            bulletinStatus.setTimestamp(new Date(1464019245000L));
            controllerServiceStatus.setBulletinList(Collections.singletonList(bulletinStatus));
        } else {
            controllerServiceStatus.setBulletinList(Collections.EMPTY_LIST);
        }
    }
    if (addHealth) {
        ControllerServiceHealth controllerServiceHealth = new ControllerServiceHealth();
        controllerServiceHealth.setState("ENABLED");
        controllerServiceHealth.setHasBulletins(populateBulletins);
        controllerServiceStatus.setControllerServiceHealth(controllerServiceHealth);
        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);
            controllerServiceHealth.setValidationErrorList(validationErrorList);
        } else {
            controllerServiceHealth.setValidationErrorList(Collections.EMPTY_LIST);
        }
    }
    flowStatusReport.setControllerServiceStatusList(Collections.singletonList(controllerServiceStatus));
}
Also used : ControllerServiceHealth(org.apache.nifi.minifi.commons.status.controllerservice.ControllerServiceHealth) ControllerServiceStatus(org.apache.nifi.minifi.commons.status.controllerservice.ControllerServiceStatus) ValidationError(org.apache.nifi.minifi.commons.status.common.ValidationError) BulletinStatus(org.apache.nifi.minifi.commons.status.common.BulletinStatus) Date(java.util.Date) LinkedList(java.util.LinkedList)

Aggregations

ControllerServiceHealth (org.apache.nifi.minifi.commons.status.controllerservice.ControllerServiceHealth)2 ControllerServiceStatus (org.apache.nifi.minifi.commons.status.controllerservice.ControllerServiceStatus)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