use of org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStatusBean 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.rpg.RemoteProcessGroupStatusBean in project nifi-minifi by apache.
the class StatusReportPopulator method addExpectedRemoteProcessGroupStatus.
public static void addExpectedRemoteProcessGroupStatus(FlowStatusReport flowStatusReport, boolean addHealth, boolean addInputPort, boolean addOutputPort, boolean addStats, boolean addBulletins, boolean populateBulletins) {
RemoteProcessGroupStatusBean expectedRemoteProcessGroupStatus = new RemoteProcessGroupStatusBean();
expectedRemoteProcessGroupStatus.setName("rpg1");
if (addHealth) {
RemoteProcessGroupHealth remoteProcessGroupHealth = new RemoteProcessGroupHealth();
remoteProcessGroupHealth.setTransmissionStatus("Transmitting");
remoteProcessGroupHealth.setHasBulletins(populateBulletins);
remoteProcessGroupHealth.setActivePortCount(1);
remoteProcessGroupHealth.setInactivePortCount(2);
expectedRemoteProcessGroupStatus.setRemoteProcessGroupHealth(remoteProcessGroupHealth);
}
if (addBulletins) {
if (populateBulletins) {
BulletinStatus bulletinStatus = new BulletinStatus();
bulletinStatus.setMessage("Bulletin message");
bulletinStatus.setTimestamp(new Date(1464019245000L));
expectedRemoteProcessGroupStatus.setBulletinList(Collections.singletonList(bulletinStatus));
} else {
expectedRemoteProcessGroupStatus.setBulletinList(Collections.EMPTY_LIST);
}
}
if (addInputPort) {
PortStatus expectedInputPortStatus = new PortStatus();
expectedInputPortStatus.setName("inputPort");
expectedInputPortStatus.setTargetExists(true);
expectedInputPortStatus.setTargetRunning(false);
expectedRemoteProcessGroupStatus.setInputPortStatusList(Collections.singletonList(expectedInputPortStatus));
}
if (addOutputPort) {
PortStatus expectedOutputPortStatus = new PortStatus();
expectedOutputPortStatus.setName("outputPort");
expectedOutputPortStatus.setTargetExists(true);
expectedOutputPortStatus.setTargetRunning(false);
expectedRemoteProcessGroupStatus.setOutputPortStatusList(Collections.singletonList(expectedOutputPortStatus));
}
if (addStats) {
RemoteProcessGroupStats remoteProcessGroupStats = new RemoteProcessGroupStats();
remoteProcessGroupStats.setActiveThreads(3);
remoteProcessGroupStats.setSentContentSize(4L);
remoteProcessGroupStats.setSentCount(5);
expectedRemoteProcessGroupStatus.setRemoteProcessGroupStats(remoteProcessGroupStats);
}
flowStatusReport.setRemoteProcessGroupStatusList(Collections.singletonList(expectedRemoteProcessGroupStatus));
}
use of org.apache.nifi.minifi.commons.status.rpg.RemoteProcessGroupStatusBean 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;
}
Aggregations