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;
}
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));
}
Aggregations