Search in sources :

Example 41 with Bulletin

use of org.apache.nifi.reporting.Bulletin in project nifi by apache.

the class FlowController method createEventReporter.

private static EventReporter createEventReporter(final BulletinRepository bulletinRepository) {
    return new EventReporter() {

        private static final long serialVersionUID = 1L;

        @Override
        public void reportEvent(final Severity severity, final String category, final String message) {
            final Bulletin bulletin = BulletinFactory.createBulletin(category, severity.name(), message);
            bulletinRepository.addBulletin(bulletin);
        }
    };
}
Also used : Bulletin(org.apache.nifi.reporting.Bulletin) Severity(org.apache.nifi.reporting.Severity) EventReporter(org.apache.nifi.events.EventReporter)

Example 42 with Bulletin

use of org.apache.nifi.reporting.Bulletin in project nifi by apache.

the class BulletinFactory method createBulletin.

public static Bulletin createBulletin(final String category, final String severity, final String message) {
    final Bulletin bulletin = new SystemBulletin(currentId.getAndIncrement());
    bulletin.setCategory(category);
    bulletin.setLevel(severity);
    bulletin.setMessage(message);
    bulletin.setSourceType(ComponentType.FLOW_CONTROLLER);
    return bulletin;
}
Also used : Bulletin(org.apache.nifi.reporting.Bulletin)

Example 43 with Bulletin

use of org.apache.nifi.reporting.Bulletin in project nifi-minifi by apache.

the class StatusRequestParser method parseInstanceRequest.

static InstanceStatus parseInstanceRequest(String statusTypes, FlowController flowController, ProcessGroupStatus rootGroupStatus) {
    InstanceStatus instanceStatus = new InstanceStatus();
    flowController.getAllControllerServices();
    List<Bulletin> bulletinList = flowController.getBulletinRepository().findBulletinsForController();
    String[] statusSplits = statusTypes.split(",");
    for (String statusType : statusSplits) {
        switch(statusType.toLowerCase().trim()) {
            case "health":
                InstanceHealth instanceHealth = new InstanceHealth();
                instanceHealth.setQueuedCount(rootGroupStatus.getQueuedCount());
                instanceHealth.setQueuedContentSize(rootGroupStatus.getQueuedContentSize());
                instanceHealth.setHasBulletins(!bulletinList.isEmpty());
                instanceHealth.setActiveThreads(rootGroupStatus.getActiveThreadCount());
                instanceStatus.setInstanceHealth(instanceHealth);
                break;
            case "bulletins":
                instanceStatus.setBulletinList(transformBulletins(flowController.getBulletinRepository().findBulletinsForController()));
                break;
            case "stats":
                InstanceStats instanceStats = new InstanceStats();
                instanceStats.setBytesRead(rootGroupStatus.getBytesRead());
                instanceStats.setBytesWritten(rootGroupStatus.getBytesWritten());
                instanceStats.setBytesSent(rootGroupStatus.getBytesSent());
                instanceStats.setFlowfilesSent(rootGroupStatus.getFlowFilesSent());
                instanceStats.setBytesTransferred(rootGroupStatus.getBytesTransferred());
                instanceStats.setFlowfilesTransferred(rootGroupStatus.getFlowFilesTransferred());
                instanceStats.setBytesReceived(rootGroupStatus.getBytesReceived());
                instanceStats.setFlowfilesReceived(rootGroupStatus.getFlowFilesReceived());
                instanceStatus.setInstanceStats(instanceStats);
                break;
        }
    }
    return instanceStatus;
}
Also used : Bulletin(org.apache.nifi.reporting.Bulletin) InstanceStats(org.apache.nifi.minifi.commons.status.instance.InstanceStats) InstanceStatus(org.apache.nifi.minifi.commons.status.instance.InstanceStatus) InstanceHealth(org.apache.nifi.minifi.commons.status.instance.InstanceHealth)

Example 44 with Bulletin

use of org.apache.nifi.reporting.Bulletin in project nifi-minifi by apache.

the class StatusRequestParser method parseRemoteProcessGroupStatusRequest.

static RemoteProcessGroupStatusBean parseRemoteProcessGroupStatusRequest(RemoteProcessGroupStatus inputRemoteProcessGroupStatus, String statusTypes, FlowController flowController) {
    RemoteProcessGroupStatusBean remoteProcessGroupStatusBean = new RemoteProcessGroupStatusBean();
    remoteProcessGroupStatusBean.setName(inputRemoteProcessGroupStatus.getName());
    String rootGroupId = flowController.getRootGroupId();
    String[] statusSplits = statusTypes.split(",");
    List<Bulletin> bulletinList = flowController.getBulletinRepository().findBulletins(new BulletinQuery.Builder().sourceIdMatches(inputRemoteProcessGroupStatus.getId()).build());
    for (String statusType : statusSplits) {
        switch(statusType.toLowerCase().trim()) {
            case "health":
                RemoteProcessGroupHealth remoteProcessGroupHealth = new RemoteProcessGroupHealth();
                remoteProcessGroupHealth.setTransmissionStatus(inputRemoteProcessGroupStatus.getTransmissionStatus().name());
                remoteProcessGroupHealth.setActivePortCount(inputRemoteProcessGroupStatus.getActiveRemotePortCount());
                remoteProcessGroupHealth.setInactivePortCount(inputRemoteProcessGroupStatus.getInactiveRemotePortCount());
                remoteProcessGroupHealth.setHasBulletins(!bulletinList.isEmpty());
                remoteProcessGroupStatusBean.setRemoteProcessGroupHealth(remoteProcessGroupHealth);
                break;
            case "bulletins":
                remoteProcessGroupStatusBean.setBulletinList(transformBulletins(bulletinList));
                break;
            case "inputports":
                remoteProcessGroupStatusBean.setInputPortStatusList(getPortStatusList(inputRemoteProcessGroupStatus, flowController, rootGroupId, RemoteProcessGroup::getInputPorts));
                break;
            case "outputports":
                remoteProcessGroupStatusBean.setOutputPortStatusList(getPortStatusList(inputRemoteProcessGroupStatus, flowController, rootGroupId, RemoteProcessGroup::getOutputPorts));
                break;
            case "stats":
                RemoteProcessGroupStats remoteProcessGroupStats = new RemoteProcessGroupStats();
                remoteProcessGroupStats.setActiveThreads(inputRemoteProcessGroupStatus.getActiveThreadCount());
                remoteProcessGroupStats.setSentContentSize(inputRemoteProcessGroupStatus.getSentContentSize());
                remoteProcessGroupStats.setSentCount(inputRemoteProcessGroupStatus.getSentCount());
                remoteProcessGroupStatusBean.setRemoteProcessGroupStats(remoteProcessGroupStats);
                break;
        }
    }
    return remoteProcessGroupStatusBean;
}
Also used : RemoteProcessGroupStatusBean(org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStatusBean) Bulletin(org.apache.nifi.reporting.Bulletin) RemoteProcessGroupStats(org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStats) BulletinQuery(org.apache.nifi.reporting.BulletinQuery) RemoteProcessGroupHealth(org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupHealth)

Example 45 with Bulletin

use of org.apache.nifi.reporting.Bulletin 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)

Aggregations

Bulletin (org.apache.nifi.reporting.Bulletin)45 ArrayList (java.util.ArrayList)29 BulletinQuery (org.apache.nifi.reporting.BulletinQuery)28 Date (java.util.Date)27 ProcessGroup (org.apache.nifi.groups.ProcessGroup)27 BulletinEntity (org.apache.nifi.web.api.entity.BulletinEntity)27 ValidationResult (org.apache.nifi.components.ValidationResult)26 Arrays (java.util.Arrays)24 Collection (java.util.Collection)24 Collections (java.util.Collections)24 Comparator (java.util.Comparator)24 HashMap (java.util.HashMap)24 HashSet (java.util.HashSet)24 LinkedHashMap (java.util.LinkedHashMap)24 LinkedHashSet (java.util.LinkedHashSet)24 List (java.util.List)24 Map (java.util.Map)24 Set (java.util.Set)24 Function (java.util.function.Function)24 Supplier (java.util.function.Supplier)24