@Test public void connectionStatusHealth() throws Exception { populateConnection(); String statusRequest = "connection:all:health"; FlowStatusReport status = StatusConfigReporter.getStatus(mockFlowController, statusRequest, LoggerFactory.getLogger(StatusConfigReporterTest.class)); FlowStatusReport expected = new FlowStatusReport(); expected.setErrorsGeneratingReport(Collections.EMPTY_LIST); addConnectionStatus(expected, true, false); assertEquals(expected, status); }
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) { try { final RequestItem requestItem = new RequestItem(item); switch (requestItem.queryType.toLowerCase().trim()) { case "systemdiagnostics": SystemDiagnosticsStatus systemDiagnosticsStatus = parseSystemDiagnosticsRequest(flowController.getSystemDiagnostics(), requestItem.options); flowStatusReport.setSystemDiagnosticsStatus(systemDiagnosticsStatus); break; case "instance": InstanceStatus instanceStatus = parseInstanceRequest(requestItem.options, flowController, rootGroupStatus); flowStatusReport.setInstanceStatus(instanceStatus); break; case "remoteprocessgroup": if (flowStatusReport.getRemoteProcessGroupStatusList() == null) { List<RemoteProcessGroupStatusBean> remoteProcessGroupStatusList = new LinkedList<>(); flowStatusReport.setRemoteProcessGroupStatusList(remoteProcessGroupStatusList); } handleRemoteProcessGroupRequest(requestItem, rootGroupStatus, flowController, flowStatusReport.getRemoteProcessGroupStatusList(), remoteProcessGroupStatusMap, logger); break; case "processor": if (flowStatusReport.getProcessorStatusList() == null) { List<ProcessorStatusBean> processorStatusList = new LinkedList<>(); flowStatusReport.setProcessorStatusList(processorStatusList); } handleProcessorRequest(requestItem, rootGroupStatus, flowController, flowStatusReport.getProcessorStatusList(), processorStatusMap, logger); break; case "connection": if (flowStatusReport.getConnectionStatusList() == null) { List<ConnectionStatusBean> connectionStatusList = new LinkedList<>(); flowStatusReport.setConnectionStatusList(connectionStatusList); } handleConnectionRequest(requestItem, rootGroupStatus, flowStatusReport.getConnectionStatusList(), connectionStatusMap, logger); break; case "provenancereporting": if (flowStatusReport.getRemoteProcessGroupStatusList() == null) { List<ReportingTaskStatus> reportingTaskStatusList = new LinkedList<>(); flowStatusReport.setReportingTaskStatusList(reportingTaskStatusList); } handleReportingTaskRequest(requestItem, flowController, flowStatusReport.getReportingTaskStatusList(), logger); break; case "controllerservices": if (flowStatusReport.getControllerServiceStatusList() == null) { List<ControllerServiceStatus> controllerServiceStatusList = new LinkedList<>(); flowStatusReport.setControllerServiceStatusList(controllerServiceStatusList); } handleControllerServices(requestItem, 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; }
StatusConfigReporter { 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) { try { final RequestItem requestItem = new RequestItem(item); switch (requestItem.queryType.toLowerCase().trim()) { case "systemdiagnostics": SystemDiagnosticsStatus systemDiagnosticsStatus = parseSystemDiagnosticsRequest(flowController.getSystemDiagnostics(), requestItem.options); flowStatusReport.setSystemDiagnosticsStatus(systemDiagnosticsStatus); break; case "instance": InstanceStatus instanceStatus = parseInstanceRequest(requestItem.options, flowController, rootGroupStatus); flowStatusReport.setInstanceStatus(instanceStatus); break; case "remoteprocessgroup": if (flowStatusReport.getRemoteProcessGroupStatusList() == null) { List<RemoteProcessGroupStatusBean> remoteProcessGroupStatusList = new LinkedList<>(); flowStatusReport.setRemoteProcessGroupStatusList(remoteProcessGroupStatusList); } handleRemoteProcessGroupRequest(requestItem, rootGroupStatus, flowController, flowStatusReport.getRemoteProcessGroupStatusList(), remoteProcessGroupStatusMap, logger); break; case "processor": if (flowStatusReport.getProcessorStatusList() == null) { List<ProcessorStatusBean> processorStatusList = new LinkedList<>(); flowStatusReport.setProcessorStatusList(processorStatusList); } handleProcessorRequest(requestItem, rootGroupStatus, flowController, flowStatusReport.getProcessorStatusList(), processorStatusMap, logger); break; case "connection": if (flowStatusReport.getConnectionStatusList() == null) { List<ConnectionStatusBean> connectionStatusList = new LinkedList<>(); flowStatusReport.setConnectionStatusList(connectionStatusList); } handleConnectionRequest(requestItem, rootGroupStatus, flowStatusReport.getConnectionStatusList(), connectionStatusMap, logger); break; case "provenancereporting": if (flowStatusReport.getRemoteProcessGroupStatusList() == null) { List<ReportingTaskStatus> reportingTaskStatusList = new LinkedList<>(); flowStatusReport.setReportingTaskStatusList(reportingTaskStatusList); } handleReportingTaskRequest(requestItem, flowController, flowStatusReport.getReportingTaskStatusList(), logger); break; case "controllerservices": if (flowStatusReport.getControllerServiceStatusList() == null) { List<ControllerServiceStatus> controllerServiceStatusList = new LinkedList<>(); flowStatusReport.setControllerServiceStatusList(controllerServiceStatusList); } handleControllerServices(requestItem, 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; } }
StatusConfigReporter { 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) { try { final RequestItem requestItem = new RequestItem(item); switch (requestItem.queryType.toLowerCase().trim()) { case "systemdiagnostics": SystemDiagnosticsStatus systemDiagnosticsStatus = parseSystemDiagnosticsRequest(flowController.getSystemDiagnostics(), requestItem.options); flowStatusReport.setSystemDiagnosticsStatus(systemDiagnosticsStatus); break; case "instance": InstanceStatus instanceStatus = parseInstanceRequest(requestItem.options, flowController, rootGroupStatus); flowStatusReport.setInstanceStatus(instanceStatus); break; case "remoteprocessgroup": if (flowStatusReport.getRemoteProcessGroupStatusList() == null) { List<RemoteProcessGroupStatusBean> remoteProcessGroupStatusList = new LinkedList<>(); flowStatusReport.setRemoteProcessGroupStatusList(remoteProcessGroupStatusList); } handleRemoteProcessGroupRequest(requestItem, rootGroupStatus, flowController, flowStatusReport.getRemoteProcessGroupStatusList(), remoteProcessGroupStatusMap, logger); break; case "processor": if (flowStatusReport.getProcessorStatusList() == null) { List<ProcessorStatusBean> processorStatusList = new LinkedList<>(); flowStatusReport.setProcessorStatusList(processorStatusList); } handleProcessorRequest(requestItem, rootGroupStatus, flowController, flowStatusReport.getProcessorStatusList(), processorStatusMap, logger); break; case "connection": if (flowStatusReport.getConnectionStatusList() == null) { List<ConnectionStatusBean> connectionStatusList = new LinkedList<>(); flowStatusReport.setConnectionStatusList(connectionStatusList); } handleConnectionRequest(requestItem, rootGroupStatus, flowStatusReport.getConnectionStatusList(), connectionStatusMap, logger); break; case "provenancereporting": if (flowStatusReport.getRemoteProcessGroupStatusList() == null) { List<ReportingTaskStatus> reportingTaskStatusList = new LinkedList<>(); flowStatusReport.setReportingTaskStatusList(reportingTaskStatusList); } handleReportingTaskRequest(requestItem, flowController, flowStatusReport.getReportingTaskStatusList(), logger); break; case "controllerservices": if (flowStatusReport.getControllerServiceStatusList() == null) { List<ControllerServiceStatus> controllerServiceStatusList = new LinkedList<>(); flowStatusReport.setControllerServiceStatusList(controllerServiceStatusList); } handleControllerServices(requestItem, 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; } private  StatusConfigReporter(); }
StatusConfigReporter { 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) { try { final RequestItem requestItem = new RequestItem(item); switch (requestItem.queryType.toLowerCase().trim()) { case "systemdiagnostics": SystemDiagnosticsStatus systemDiagnosticsStatus = parseSystemDiagnosticsRequest(flowController.getSystemDiagnostics(), requestItem.options); flowStatusReport.setSystemDiagnosticsStatus(systemDiagnosticsStatus); break; case "instance": InstanceStatus instanceStatus = parseInstanceRequest(requestItem.options, flowController, rootGroupStatus); flowStatusReport.setInstanceStatus(instanceStatus); break; case "remoteprocessgroup": if (flowStatusReport.getRemoteProcessGroupStatusList() == null) { List<RemoteProcessGroupStatusBean> remoteProcessGroupStatusList = new LinkedList<>(); flowStatusReport.setRemoteProcessGroupStatusList(remoteProcessGroupStatusList); } handleRemoteProcessGroupRequest(requestItem, rootGroupStatus, flowController, flowStatusReport.getRemoteProcessGroupStatusList(), remoteProcessGroupStatusMap, logger); break; case "processor": if (flowStatusReport.getProcessorStatusList() == null) { List<ProcessorStatusBean> processorStatusList = new LinkedList<>(); flowStatusReport.setProcessorStatusList(processorStatusList); } handleProcessorRequest(requestItem, rootGroupStatus, flowController, flowStatusReport.getProcessorStatusList(), processorStatusMap, logger); break; case "connection": if (flowStatusReport.getConnectionStatusList() == null) { List<ConnectionStatusBean> connectionStatusList = new LinkedList<>(); flowStatusReport.setConnectionStatusList(connectionStatusList); } handleConnectionRequest(requestItem, rootGroupStatus, flowStatusReport.getConnectionStatusList(), connectionStatusMap, logger); break; case "provenancereporting": if (flowStatusReport.getRemoteProcessGroupStatusList() == null) { List<ReportingTaskStatus> reportingTaskStatusList = new LinkedList<>(); flowStatusReport.setReportingTaskStatusList(reportingTaskStatusList); } handleReportingTaskRequest(requestItem, flowController, flowStatusReport.getReportingTaskStatusList(), logger); break; case "controllerservices": if (flowStatusReport.getControllerServiceStatusList() == null) { List<ControllerServiceStatus> controllerServiceStatusList = new LinkedList<>(); flowStatusReport.setControllerServiceStatusList(controllerServiceStatusList); } handleControllerServices(requestItem, 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; } private  StatusConfigReporter(); static FlowStatusReport getStatus(FlowController flowController, String statusRequest, Logger logger); }
StatusConfigReporter { 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) { try { final RequestItem requestItem = new RequestItem(item); switch (requestItem.queryType.toLowerCase().trim()) { case "systemdiagnostics": SystemDiagnosticsStatus systemDiagnosticsStatus = parseSystemDiagnosticsRequest(flowController.getSystemDiagnostics(), requestItem.options); flowStatusReport.setSystemDiagnosticsStatus(systemDiagnosticsStatus); break; case "instance": InstanceStatus instanceStatus = parseInstanceRequest(requestItem.options, flowController, rootGroupStatus); flowStatusReport.setInstanceStatus(instanceStatus); break; case "remoteprocessgroup": if (flowStatusReport.getRemoteProcessGroupStatusList() == null) { List<RemoteProcessGroupStatusBean> remoteProcessGroupStatusList = new LinkedList<>(); flowStatusReport.setRemoteProcessGroupStatusList(remoteProcessGroupStatusList); } handleRemoteProcessGroupRequest(requestItem, rootGroupStatus, flowController, flowStatusReport.getRemoteProcessGroupStatusList(), remoteProcessGroupStatusMap, logger); break; case "processor": if (flowStatusReport.getProcessorStatusList() == null) { List<ProcessorStatusBean> processorStatusList = new LinkedList<>(); flowStatusReport.setProcessorStatusList(processorStatusList); } handleProcessorRequest(requestItem, rootGroupStatus, flowController, flowStatusReport.getProcessorStatusList(), processorStatusMap, logger); break; case "connection": if (flowStatusReport.getConnectionStatusList() == null) { List<ConnectionStatusBean> connectionStatusList = new LinkedList<>(); flowStatusReport.setConnectionStatusList(connectionStatusList); } handleConnectionRequest(requestItem, rootGroupStatus, flowStatusReport.getConnectionStatusList(), connectionStatusMap, logger); break; case "provenancereporting": if (flowStatusReport.getRemoteProcessGroupStatusList() == null) { List<ReportingTaskStatus> reportingTaskStatusList = new LinkedList<>(); flowStatusReport.setReportingTaskStatusList(reportingTaskStatusList); } handleReportingTaskRequest(requestItem, flowController, flowStatusReport.getReportingTaskStatusList(), logger); break; case "controllerservices": if (flowStatusReport.getControllerServiceStatusList() == null) { List<ControllerServiceStatus> controllerServiceStatusList = new LinkedList<>(); flowStatusReport.setControllerServiceStatusList(controllerServiceStatusList); } handleControllerServices(requestItem, 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; } private  StatusConfigReporter(); static FlowStatusReport getStatus(FlowController flowController, String statusRequest, Logger logger);  }