use of org.apache.nifi.minifi.commons.status.connection.ConnectionStatusBean in project nifi-minifi by apache.
the class StatusConfigReporter method getStatus.
public static FlowStatusReport getStatus(FlowController flowController, String statusRequest, Logger logger) throws StatusRequestException {
if (statusRequest == null) {
logger.error("Received a status request which was null");
throw new StatusRequestException("Cannot complete status request because the statusRequest is null");
}
if (flowController == null) {
logger.error("Received a status but the Flow Controller is null");
throw new StatusRequestException("Cannot complete status request because the Flow Controller is null");
}
FlowStatusReport flowStatusReport = new FlowStatusReport();
List<String> errorsGeneratingReport = new LinkedList<>();
flowStatusReport.setErrorsGeneratingReport(errorsGeneratingReport);
String[] itemsToReport = statusRequest.split(";");
ProcessGroupStatus rootGroupStatus = flowController.getControllerStatus();
Map<String, ProcessorStatus> processorStatusMap = null;
Map<String, ConnectionStatus> connectionStatusMap = null;
Map<String, RemoteProcessGroupStatus> remoteProcessGroupStatusMap = null;
for (String item : itemsToReport) {
String[] sections = item.split(":");
try {
switch(sections[0].toLowerCase().trim()) {
case "systemdiagnostics":
SystemDiagnosticsStatus systemDiagnosticsStatus = parseSystemDiagnosticsRequest(flowController.getSystemDiagnostics(), sections[1]);
flowStatusReport.setSystemDiagnosticsStatus(systemDiagnosticsStatus);
break;
case "instance":
InstanceStatus instanceStatus = parseInstanceRequest(sections[1], flowController, rootGroupStatus);
flowStatusReport.setInstanceStatus(instanceStatus);
break;
case "remoteprocessgroup":
if (flowStatusReport.getRemoteProcessGroupStatusList() == null) {
List<RemoteProcessGroupStatusBean> remoteProcessGroupStatusList = new LinkedList<>();
flowStatusReport.setRemoteProcessGroupStatusList(remoteProcessGroupStatusList);
}
handleRemoteProcessGroupRequest(sections, rootGroupStatus, flowController, flowStatusReport.getRemoteProcessGroupStatusList(), remoteProcessGroupStatusMap, logger);
break;
case "processor":
if (flowStatusReport.getProcessorStatusList() == null) {
List<ProcessorStatusBean> processorStatusList = new LinkedList<>();
flowStatusReport.setProcessorStatusList(processorStatusList);
}
handleProcessorRequest(sections, rootGroupStatus, flowController, flowStatusReport.getProcessorStatusList(), processorStatusMap, logger);
break;
case "connection":
if (flowStatusReport.getConnectionStatusList() == null) {
List<ConnectionStatusBean> connectionStatusList = new LinkedList<>();
flowStatusReport.setConnectionStatusList(connectionStatusList);
}
handleConnectionRequest(sections, rootGroupStatus, flowStatusReport.getConnectionStatusList(), connectionStatusMap, logger);
break;
case "provenancereporting":
if (flowStatusReport.getRemoteProcessGroupStatusList() == null) {
List<ReportingTaskStatus> reportingTaskStatusList = new LinkedList<>();
flowStatusReport.setReportingTaskStatusList(reportingTaskStatusList);
}
handleReportingTaskRequest(sections, flowController, flowStatusReport.getReportingTaskStatusList(), logger);
break;
case "controllerservices":
if (flowStatusReport.getControllerServiceStatusList() == null) {
List<ControllerServiceStatus> controllerServiceStatusList = new LinkedList<>();
flowStatusReport.setControllerServiceStatusList(controllerServiceStatusList);
}
handleControllerServices(sections, flowController, flowStatusReport.getControllerServiceStatusList(), logger);
break;
}
} catch (Exception e) {
logger.error("Hit exception while requesting status for item '" + item + "'", e);
errorsGeneratingReport.add("Unable to get status for request '" + item + "' due to:" + e);
}
}
return flowStatusReport;
}
use of org.apache.nifi.minifi.commons.status.connection.ConnectionStatusBean in project nifi-minifi by apache.
the class StatusRequestParser method parseConnectionStatusRequest.
static ConnectionStatusBean parseConnectionStatusRequest(ConnectionStatus inputConnectionStatus, String statusTypes, Logger logger) {
ConnectionStatusBean connectionStatusBean = new ConnectionStatusBean();
connectionStatusBean.setName(inputConnectionStatus.getName());
String[] statusSplits = statusTypes.split(",");
for (String statusType : statusSplits) {
switch(statusType.toLowerCase().trim()) {
case "health":
ConnectionHealth connectionHealth = new ConnectionHealth();
connectionHealth.setQueuedBytes(inputConnectionStatus.getQueuedBytes());
connectionHealth.setQueuedCount(inputConnectionStatus.getQueuedCount());
connectionStatusBean.setConnectionHealth(connectionHealth);
break;
case "stats":
ConnectionStats connectionStats = new ConnectionStats();
connectionStats.setInputBytes(inputConnectionStatus.getInputBytes());
connectionStats.setInputCount(inputConnectionStatus.getInputCount());
connectionStats.setOutputCount(inputConnectionStatus.getOutputCount());
connectionStats.setOutputBytes(inputConnectionStatus.getOutputBytes());
connectionStatusBean.setConnectionStats(connectionStats);
break;
}
}
return connectionStatusBean;
}
use of org.apache.nifi.minifi.commons.status.connection.ConnectionStatusBean in project nifi-minifi by apache.
the class StatusReportPopulator method addConnectionStatus.
public static void addConnectionStatus(FlowStatusReport flowStatusReport, boolean addHealth, boolean addStats) {
ConnectionStatusBean expectedConnectionStatus = new ConnectionStatusBean();
expectedConnectionStatus.setName("connectionId");
if (addHealth) {
ConnectionHealth connectionHealth = new ConnectionHealth();
connectionHealth.setQueuedCount(10);
connectionHealth.setQueuedBytes(100);
expectedConnectionStatus.setConnectionHealth(connectionHealth);
}
if (addStats) {
ConnectionStats expectedConnectionStats = new ConnectionStats();
expectedConnectionStats.setInputCount(1);
expectedConnectionStats.setInputBytes(2);
expectedConnectionStats.setOutputCount(3);
expectedConnectionStats.setOutputBytes(4);
expectedConnectionStatus.setConnectionStats(expectedConnectionStats);
}
flowStatusReport.setConnectionStatusList(Collections.singletonList(expectedConnectionStatus));
}
Aggregations