Search in sources :

Example 16 with FlowStatusReport

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

the class RunMiNiFi method statusReport.

public FlowStatusReport statusReport(String statusRequest) throws IOException {
    final Logger logger = cmdLogger;
    final Status status = getStatus(logger);
    final Properties props = loadProperties(logger);
    List<String> problemsGeneratingReport = new LinkedList<>();
    if (!status.isProcessRunning()) {
        problemsGeneratingReport.add("MiNiFi process is not running");
    }
    if (!status.isRespondingToPing()) {
        problemsGeneratingReport.add("MiNiFi process is not responding to pings");
    }
    if (!problemsGeneratingReport.isEmpty()) {
        FlowStatusReport flowStatusReport = new FlowStatusReport();
        flowStatusReport.setErrorsGeneratingReport(problemsGeneratingReport);
        return flowStatusReport;
    }
    return getFlowStatusReport(statusRequest, status.getPort(), props.getProperty("secret.key"), logger);
}
Also used : FlowStatusReport(org.apache.nifi.minifi.commons.status.FlowStatusReport) Logger(org.slf4j.Logger) Properties(java.util.Properties) LinkedList(java.util.LinkedList)

Example 17 with FlowStatusReport

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

the class BootstrapListener method writeStatusReport.

private void writeStatusReport(String flowStatusRequestString, final OutputStream out) throws IOException, StatusRequestException {
    ObjectOutputStream oos = new ObjectOutputStream(out);
    FlowStatusReport flowStatusReport = minifi.getMinifiServer().getStatusReport(flowStatusRequestString);
    oos.writeObject(flowStatusReport);
    oos.close();
}
Also used : FlowStatusReport(org.apache.nifi.minifi.commons.status.FlowStatusReport) ObjectOutputStream(java.io.ObjectOutputStream)

Example 18 with FlowStatusReport

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

the class StatusConfigReporterTest method connectionAndProcessorStatusHealth.

@Test
public void connectionAndProcessorStatusHealth() throws Exception {
    populateConnection();
    populateProcessor(false, false);
    String statusRequest = "connection:connectionId:health; processor:UpdateAttributeProcessorId:health";
    FlowStatusReport actual = StatusConfigReporter.getStatus(mockFlowController, statusRequest, LoggerFactory.getLogger(StatusConfigReporterTest.class));
    FlowStatusReport expected = new FlowStatusReport();
    addConnectionStatus(expected, true, false);
    addProcessorStatus(expected, true, false, false, false, false);
    expected.setErrorsGeneratingReport(Collections.EMPTY_LIST);
    assertEquals(expected, actual);
}
Also used : FlowStatusReport(org.apache.nifi.minifi.commons.status.FlowStatusReport) Test(org.junit.Test)

Example 19 with FlowStatusReport

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

the class StatusConfigReporterTest method statusEverything.

@Test
public void statusEverything() throws Exception {
    when(bulletinRepo.findBulletins(anyObject())).thenReturn(Collections.emptyList());
    populateControllerService(true, false);
    populateInstance(true);
    populateSystemDiagnostics();
    populateReportingTask(false, true);
    populateConnection();
    populateProcessor(true, false);
    populateRemoteProcessGroup(false, true);
    String statusRequest = "controllerServices:bulletins,health; processor:all:health,stats,bulletins; instance:bulletins,health,stats ; systemDiagnostics:garbagecollection, heap, " + "processorstats, contentrepositoryusage, flowfilerepositoryusage; connection:all:health,stats; provenanceReporting:health,bulletins; remoteProcessGroup:all:health, " + "bulletins, inputPorts, outputPorts, stats";
    FlowStatusReport actual = StatusConfigReporter.getStatus(mockFlowController, statusRequest, LoggerFactory.getLogger(StatusConfigReporterTest.class));
    FlowStatusReport expected = new FlowStatusReport();
    expected.setErrorsGeneratingReport(Collections.EMPTY_LIST);
    addControllerServiceStatus(expected, true, true, true, false);
    addInstanceStatus(expected, true, true, true, true);
    addSystemDiagnosticStatus(expected, true, true, true, true, true);
    addReportingTaskStatus(expected, true, true, true, false);
    addConnectionStatus(expected, true, true);
    addProcessorStatus(expected, true, true, true, true, false);
    addExpectedRemoteProcessGroupStatus(expected, true, true, true, true, true, false);
    assertEquals(expected, actual);
}
Also used : FlowStatusReport(org.apache.nifi.minifi.commons.status.FlowStatusReport) Test(org.junit.Test)

Example 20 with FlowStatusReport

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

the class StatusConfigReporterTest method processorStatusWithValidationErrors.

@Test
public void processorStatusWithValidationErrors() throws Exception {
    populateProcessor(true, false);
    String statusRequest = "processor:all:health";
    FlowStatusReport actual = StatusConfigReporter.getStatus(mockFlowController, statusRequest, LoggerFactory.getLogger(StatusConfigReporterTest.class));
    FlowStatusReport expected = new FlowStatusReport();
    expected.setErrorsGeneratingReport(Collections.EMPTY_LIST);
    addProcessorStatus(expected, true, true, false, false, false);
    assertEquals(expected, actual);
}
Also used : FlowStatusReport(org.apache.nifi.minifi.commons.status.FlowStatusReport) Test(org.junit.Test)

Aggregations

FlowStatusReport (org.apache.nifi.minifi.commons.status.FlowStatusReport)34 Test (org.junit.Test)29 LinkedList (java.util.LinkedList)2 Logger (org.slf4j.Logger)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 EOFException (java.io.EOFException)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 OutputStream (java.io.OutputStream)1 Field (java.lang.reflect.Field)1 Socket (java.net.Socket)1 SocketTimeoutException (java.net.SocketTimeoutException)1 Properties (java.util.Properties)1 TeeInputStream (org.apache.commons.io.input.TeeInputStream)1 ConnectionStatus (org.apache.nifi.controller.status.ConnectionStatus)1 ProcessGroupStatus (org.apache.nifi.controller.status.ProcessGroupStatus)1