use of org.apache.nifi.minifi.commons.status.FlowStatusReport in project nifi-minifi by apache.
the class StatusConfigReporterTest method controllerServiceStatusBulletins.
@Test
public void controllerServiceStatusBulletins() throws Exception {
populateControllerService(false, true);
String statusRequest = "controllerServices:bulletins";
FlowStatusReport actual = StatusConfigReporter.getStatus(mockFlowController, statusRequest, LoggerFactory.getLogger(StatusConfigReporterTest.class));
FlowStatusReport expected = new FlowStatusReport();
expected.setErrorsGeneratingReport(Collections.EMPTY_LIST);
addControllerServiceStatus(expected, false, false, true, true);
assertEquals(expected, actual);
}
use of org.apache.nifi.minifi.commons.status.FlowStatusReport in project nifi-minifi by apache.
the class StatusConfigReporterTest method provenanceReportingTaskStatusBulletins.
@Test
public void provenanceReportingTaskStatusBulletins() throws Exception {
populateReportingTask(true, false);
String statusRequest = "provenanceReporting:bulletins";
FlowStatusReport actual = StatusConfigReporter.getStatus(mockFlowController, statusRequest, LoggerFactory.getLogger(StatusConfigReporterTest.class));
FlowStatusReport expected = new FlowStatusReport();
expected.setErrorsGeneratingReport(Collections.EMPTY_LIST);
addReportingTaskStatus(expected, false, false, true, true);
assertEquals(expected, actual);
}
use of org.apache.nifi.minifi.commons.status.FlowStatusReport in project nifi-minifi by apache.
the class StatusConfigReporterTest method instanceStatusBulletins.
@Test
public void instanceStatusBulletins() throws Exception {
populateInstance(true);
String statusRequest = "instance:bulletins";
FlowStatusReport actual = StatusConfigReporter.getStatus(mockFlowController, statusRequest, LoggerFactory.getLogger(StatusConfigReporterTest.class));
FlowStatusReport expected = new FlowStatusReport();
expected.setErrorsGeneratingReport(Collections.EMPTY_LIST);
addInstanceStatus(expected, false, false, true, true);
assertEquals(expected, actual);
}
use of org.apache.nifi.minifi.commons.status.FlowStatusReport in project nifi-minifi by apache.
the class StatusConfigReporterTest method provenanceReportingTaskStatusAll.
@Test
public void provenanceReportingTaskStatusAll() throws Exception {
populateReportingTask(true, true);
String statusRequest = "provenanceReporting:health,bulletins";
FlowStatusReport actual = StatusConfigReporter.getStatus(mockFlowController, statusRequest, LoggerFactory.getLogger(StatusConfigReporterTest.class));
FlowStatusReport expected = new FlowStatusReport();
expected.setErrorsGeneratingReport(Collections.EMPTY_LIST);
addReportingTaskStatus(expected, true, true, true, true);
assertEquals(expected, actual);
}
use of org.apache.nifi.minifi.commons.status.FlowStatusReport in project nifi-minifi by apache.
the class RunMiNiFi method getFlowStatusReport.
public FlowStatusReport getFlowStatusReport(String statusRequest, final int port, final String secretKey, final Logger logger) throws IOException {
logger.debug("Pinging {}", port);
try (final Socket socket = new Socket("localhost", port)) {
final OutputStream out = socket.getOutputStream();
final String commandWithArgs = FLOW_STATUS_REPORT_CMD + " " + secretKey + " " + statusRequest + "\n";
out.write((commandWithArgs).getBytes(StandardCharsets.UTF_8));
logger.debug("Sending command to MiNiFi: {}", commandWithArgs);
out.flush();
logger.debug("Sent FLOW_STATUS_REPORT_CMD to MiNiFi");
socket.setSoTimeout(5000);
final InputStream in = socket.getInputStream();
ObjectInputStream ois = new ObjectInputStream(in);
logger.debug("FLOW_STATUS_REPORT_CMD response received");
Object o = ois.readObject();
ois.close();
out.close();
try {
return FlowStatusReport.class.cast(o);
} catch (ClassCastException e) {
String message = String.class.cast(o);
FlowStatusReport flowStatusReport = new FlowStatusReport();
flowStatusReport.setErrorsGeneratingReport(Collections.singletonList("Failed to get status report from MiNiFi due to:" + message));
return flowStatusReport;
}
} catch (EOFException | ClassNotFoundException | SocketTimeoutException e) {
throw new IllegalStateException("Failed to get the status report from the MiNiFi process. Potentially due to the process currently being down (restarting or otherwise).", e);
}
}
Aggregations