Java Code Examples for org.apache.nifi.controller.status.ProcessorStatus#setId()
The following examples show how to use
org.apache.nifi.controller.status.ProcessorStatus#setId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSiteToSiteStatusReportingTask.java From nifi with Apache License 2.0 | 5 votes |
public static ProcessorStatus generateProcessorStatus(String id, String namePrefix) { ProcessorStatus pStatus = new ProcessorStatus(); pStatus.setId(id); pStatus.setName(namePrefix + "-" + UUID.randomUUID().toString()); pStatus.setActiveThreadCount(0); pStatus.setAverageLineageDuration(1l); pStatus.setBytesRead(2l); pStatus.setBytesReceived(3l); pStatus.setBytesSent(4l); pStatus.setBytesWritten(5l); pStatus.setFlowFilesReceived(6); pStatus.setFlowFilesRemoved(7); pStatus.setFlowFilesSent(8); pStatus.setInputBytes(9l); pStatus.setInputCount(10); pStatus.setInvocations(11); pStatus.setOutputBytes(12l); pStatus.setOutputCount(13); pStatus.setProcessingNanos(14l); pStatus.setType(null); pStatus.setTerminatedThreadCount(1); pStatus.setRunStatus(RunStatus.Running); pStatus.setCounters(new HashMap<String, Long>() {{ put("counter1", 10L); put("counter2", 5L); }}); return pStatus; }
Example 2
Source File: TestNiFiFlowAnalyzer.java From nifi with Apache License 2.0 | 5 votes |
private ProcessorStatus createProcessor(ProcessGroupStatus pgStatus, String type) { final ProcessorStatus processor = new ProcessorStatus(); processor.setName(type); processor.setId(nextComponentId()); processor.setGroupId(pgStatus.getId()); pgStatus.getProcessorStatus().add(processor); return processor; }
Example 3
Source File: FlowController.java From localization_nifi with Apache License 2.0 | 4 votes |
private ProcessorStatus getProcessorStatus(final RepositoryStatusReport report, final ProcessorNode procNode, final Predicate<Authorizable> isAuthorized) { final boolean isProcessorAuthorized = isAuthorized.evaluate(procNode); final ProcessorStatus status = new ProcessorStatus(); status.setId(procNode.getIdentifier()); status.setGroupId(procNode.getProcessGroup().getIdentifier()); status.setName(isProcessorAuthorized ? procNode.getName() : procNode.getIdentifier()); status.setType(isProcessorAuthorized ? procNode.getComponentType() : "Processor"); final FlowFileEvent entry = report.getReportEntries().get(procNode.getIdentifier()); if (entry == null) { status.setInputBytes(0L); status.setInputCount(0); status.setOutputBytes(0L); status.setOutputCount(0); status.setBytesWritten(0L); status.setBytesRead(0L); status.setProcessingNanos(0); status.setInvocations(0); status.setAverageLineageDuration(0L); status.setFlowFilesRemoved(0); } else { final int processedCount = entry.getFlowFilesOut(); final long numProcessedBytes = entry.getContentSizeOut(); status.setOutputBytes(numProcessedBytes); status.setOutputCount(processedCount); final int inputCount = entry.getFlowFilesIn(); final long inputBytes = entry.getContentSizeIn(); status.setInputBytes(inputBytes); status.setInputCount(inputCount); final long readBytes = entry.getBytesRead(); status.setBytesRead(readBytes); final long writtenBytes = entry.getBytesWritten(); status.setBytesWritten(writtenBytes); status.setProcessingNanos(entry.getProcessingNanoseconds()); status.setInvocations(entry.getInvocations()); status.setAverageLineageDuration(entry.getAverageLineageMillis()); status.setFlowFilesReceived(entry.getFlowFilesReceived()); status.setBytesReceived(entry.getBytesReceived()); status.setFlowFilesSent(entry.getFlowFilesSent()); status.setBytesSent(entry.getBytesSent()); status.setFlowFilesRemoved(entry.getFlowFilesRemoved()); } // Determine the run status and get any validation error... only validating while STOPPED // is a trade-off we are willing to make, even though processor validity could change due to // environmental conditions (property configured with a file path and the file being externally // removed). This saves on validation costs that would be unnecessary most of the time. if (ScheduledState.DISABLED.equals(procNode.getScheduledState())) { status.setRunStatus(RunStatus.Disabled); } else if (ScheduledState.RUNNING.equals(procNode.getScheduledState())) { status.setRunStatus(RunStatus.Running); } else if (!procNode.isValid()) { status.setRunStatus(RunStatus.Invalid); } else { status.setRunStatus(RunStatus.Stopped); } status.setActiveThreadCount(processScheduler.getActiveThreadCount(procNode)); return status; }
Example 4
Source File: StatusConfigReporterTest.java From nifi-minifi with Apache License 2.0 | 4 votes |
private void populateProcessor(boolean validationErrors, boolean addBulletins) { if (addBulletins) { addBulletins("Bulletin message", "UpdateAttributeProcessorId"); } ProcessorStatus processorStatus = new ProcessorStatus(); processorStatus.setType("org.apache.nifi.processors.attributes.UpdateAttribute"); processorStatus.setId("UpdateAttributeProcessorId"); processorStatus.setName("UpdateAttributeProcessorName"); processorStatus.setRunStatus(RunStatus.Stopped); processorStatus.setActiveThreadCount(1); processorStatus.setFlowFilesReceived(2); processorStatus.setBytesRead(3); processorStatus.setBytesWritten(4); processorStatus.setFlowFilesSent(5); processorStatus.setInvocations(6); processorStatus.setProcessingNanos(7); Collection<ProcessorStatus> statusCollection = new ArrayList<>(); statusCollection.add(processorStatus); mockProcessorEmptyValidation(processorStatus.getId(), processGroup); when(rootGroupStatus.getProcessorStatus()).thenReturn(statusCollection); ProcessorNode processorNode = mock(ProcessorNode.class); when(processGroup.getProcessor(processorStatus.getId())).thenReturn(processorNode); if (validationErrors) { ValidationResult validationResult = new ValidationResult.Builder() .input("input") .subject("subject") .explanation("is not valid") .build(); ValidationResult validationResult2 = new ValidationResult.Builder() .input("input2") .subject("subject2") .explanation("is not valid too") .build(); List<ValidationResult> validationResultList = new ArrayList<>(); validationResultList.add(validationResult); validationResultList.add(validationResult2); when(processorNode.getValidationErrors()).thenReturn(validationResultList); } else { when(processorNode.getValidationErrors()).thenReturn(Collections.EMPTY_LIST); } }
Example 5
Source File: TestQueryNiFiReportingTask.java From nifi with Apache License 2.0 | 4 votes |
@Before public void setup() { mockRecordSinkService = new MockRecordSinkService(); status = new ProcessGroupStatus(); status.setId("1234"); status.setFlowFilesReceived(5); status.setBytesReceived(10000); status.setFlowFilesSent(10); status.setBytesRead(20000L); status.setBytesSent(20000); status.setQueuedCount(100); status.setQueuedContentSize(1024L); status.setBytesWritten(80000L); status.setActiveThreadCount(5); // create a processor status with processing time ProcessorStatus procStatus = new ProcessorStatus(); procStatus.setId("proc"); procStatus.setProcessingNanos(123456789); Collection<ProcessorStatus> processorStatuses = new ArrayList<>(); processorStatuses.add(procStatus); status.setProcessorStatus(processorStatuses); ConnectionStatus root1ConnectionStatus = new ConnectionStatus(); root1ConnectionStatus.setId("root1"); root1ConnectionStatus.setQueuedCount(1000); root1ConnectionStatus.setBackPressureObjectThreshold(1000); ConnectionStatus root2ConnectionStatus = new ConnectionStatus(); root2ConnectionStatus.setId("root2"); root2ConnectionStatus.setQueuedCount(500); root2ConnectionStatus.setBackPressureObjectThreshold(1000); Collection<ConnectionStatus> rootConnectionStatuses = new ArrayList<>(); rootConnectionStatuses.add(root1ConnectionStatus); rootConnectionStatuses.add(root2ConnectionStatus); status.setConnectionStatus(rootConnectionStatuses); // create a group status with processing time ProcessGroupStatus groupStatus1 = new ProcessGroupStatus(); groupStatus1.setProcessorStatus(processorStatuses); groupStatus1.setBytesRead(1234L); // Create a nested group status with a connection ProcessGroupStatus groupStatus2 = new ProcessGroupStatus(); groupStatus2.setProcessorStatus(processorStatuses); groupStatus2.setBytesRead(12345L); ConnectionStatus nestedConnectionStatus = new ConnectionStatus(); nestedConnectionStatus.setId("nested"); nestedConnectionStatus.setQueuedCount(1001); Collection<ConnectionStatus> nestedConnectionStatuses = new ArrayList<>(); nestedConnectionStatuses.add(nestedConnectionStatus); groupStatus2.setConnectionStatus(nestedConnectionStatuses); Collection<ProcessGroupStatus> nestedGroupStatuses = new ArrayList<>(); nestedGroupStatuses.add(groupStatus2); groupStatus1.setProcessGroupStatus(nestedGroupStatuses); ProcessGroupStatus groupStatus3 = new ProcessGroupStatus(); groupStatus3.setBytesRead(1L); ConnectionStatus nestedConnectionStatus2 = new ConnectionStatus(); nestedConnectionStatus2.setId("nested2"); nestedConnectionStatus2.setQueuedCount(3); Collection<ConnectionStatus> nestedConnectionStatuses2 = new ArrayList<>(); nestedConnectionStatuses2.add(nestedConnectionStatus2); groupStatus3.setConnectionStatus(nestedConnectionStatuses2); Collection<ProcessGroupStatus> nestedGroupStatuses2 = new ArrayList<>(); nestedGroupStatuses2.add(groupStatus3); Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>(); groupStatuses.add(groupStatus1); groupStatuses.add(groupStatus3); status.setProcessGroupStatus(groupStatuses); }
Example 6
Source File: TestMetricsEventReportingTask.java From nifi with Apache License 2.0 | 4 votes |
@Before public void setup() { status = new ProcessGroupStatus(); actionHandler = new MockPropertyContextActionHandler(); status.setId("1234"); status.setFlowFilesReceived(5); status.setBytesReceived(10000); status.setFlowFilesSent(10); status.setBytesRead(20000L); status.setBytesSent(20000); status.setQueuedCount(100); status.setQueuedContentSize(1024L); status.setBytesWritten(80000L); status.setActiveThreadCount(5); // create a processor status with processing time ProcessorStatus procStatus = new ProcessorStatus(); procStatus.setId("proc"); procStatus.setProcessingNanos(123456789); Collection<ProcessorStatus> processorStatuses = new ArrayList<>(); processorStatuses.add(procStatus); status.setProcessorStatus(processorStatuses); ConnectionStatusPredictions connectionStatusPredictions = new ConnectionStatusPredictions(); connectionStatusPredictions.setPredictedTimeToCountBackpressureMillis(1000); connectionStatusPredictions.setPredictedTimeToBytesBackpressureMillis(1000); connectionStatusPredictions.setNextPredictedQueuedCount(1000000000); connectionStatusPredictions.setNextPredictedQueuedBytes(1000000000000000L); ConnectionStatus root1ConnectionStatus = new ConnectionStatus(); root1ConnectionStatus.setId("root1"); root1ConnectionStatus.setQueuedCount(1000); root1ConnectionStatus.setPredictions(connectionStatusPredictions); ConnectionStatus root2ConnectionStatus = new ConnectionStatus(); root2ConnectionStatus.setId("root2"); root2ConnectionStatus.setQueuedCount(500); root2ConnectionStatus.setPredictions(connectionStatusPredictions); Collection<ConnectionStatus> rootConnectionStatuses = new ArrayList<>(); rootConnectionStatuses.add(root1ConnectionStatus); rootConnectionStatuses.add(root2ConnectionStatus); status.setConnectionStatus(rootConnectionStatuses); // create a group status with processing time ProcessGroupStatus groupStatus1 = new ProcessGroupStatus(); groupStatus1.setProcessorStatus(processorStatuses); groupStatus1.setBytesRead(1234L); // Create a nested group status with a connection ProcessGroupStatus groupStatus2 = new ProcessGroupStatus(); groupStatus2.setProcessorStatus(processorStatuses); groupStatus2.setBytesRead(12345L); ConnectionStatus nestedConnectionStatus = new ConnectionStatus(); nestedConnectionStatus.setId("nested"); nestedConnectionStatus.setQueuedCount(1001); Collection<ConnectionStatus> nestedConnectionStatuses = new ArrayList<>(); nestedConnectionStatuses.add(nestedConnectionStatus); groupStatus2.setConnectionStatus(nestedConnectionStatuses); Collection<ProcessGroupStatus> nestedGroupStatuses = new ArrayList<>(); nestedGroupStatuses.add(groupStatus2); groupStatus1.setProcessGroupStatus(nestedGroupStatuses); ProcessGroupStatus groupStatus3 = new ProcessGroupStatus(); groupStatus3.setBytesRead(1L); ConnectionStatus nestedConnectionStatus2 = new ConnectionStatus(); nestedConnectionStatus2.setId("nested2"); nestedConnectionStatus2.setQueuedCount(3); Collection<ConnectionStatus> nestedConnectionStatuses2 = new ArrayList<>(); nestedConnectionStatuses2.add(nestedConnectionStatus2); groupStatus3.setConnectionStatus(nestedConnectionStatuses2); Collection<ProcessGroupStatus> nestedGroupStatuses2 = new ArrayList<>(); nestedGroupStatuses2.add(groupStatus3); Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>(); groupStatuses.add(groupStatus1); groupStatuses.add(groupStatus3); status.setProcessGroupStatus(groupStatuses); }
Example 7
Source File: StandardEventAccess.java From nifi with Apache License 2.0 | 4 votes |
private ProcessorStatus getProcessorStatus(final FlowFileEvent flowFileEvent, final ProcessorNode procNode, final Predicate<Authorizable> isAuthorized) { final boolean isProcessorAuthorized = isAuthorized.evaluate(procNode); final ProcessScheduler processScheduler = flowController.getProcessScheduler(); final ProcessorStatus status = new ProcessorStatus(); status.setId(procNode.getIdentifier()); status.setGroupId(procNode.getProcessGroup().getIdentifier()); status.setName(isProcessorAuthorized ? procNode.getName() : procNode.getIdentifier()); status.setType(isProcessorAuthorized ? procNode.getComponentType() : "Processor"); if (flowFileEvent != null && flowFileEvent != EmptyFlowFileEvent.INSTANCE) { final int processedCount = flowFileEvent.getFlowFilesOut(); final long numProcessedBytes = flowFileEvent.getContentSizeOut(); status.setOutputBytes(numProcessedBytes); status.setOutputCount(processedCount); final int inputCount = flowFileEvent.getFlowFilesIn(); final long inputBytes = flowFileEvent.getContentSizeIn(); status.setInputBytes(inputBytes); status.setInputCount(inputCount); final long readBytes = flowFileEvent.getBytesRead(); status.setBytesRead(readBytes); final long writtenBytes = flowFileEvent.getBytesWritten(); status.setBytesWritten(writtenBytes); status.setProcessingNanos(flowFileEvent.getProcessingNanoseconds()); status.setInvocations(flowFileEvent.getInvocations()); status.setAverageLineageDuration(flowFileEvent.getAverageLineageMillis()); status.setFlowFilesReceived(flowFileEvent.getFlowFilesReceived()); status.setBytesReceived(flowFileEvent.getBytesReceived()); status.setFlowFilesSent(flowFileEvent.getFlowFilesSent()); status.setBytesSent(flowFileEvent.getBytesSent()); status.setFlowFilesRemoved(flowFileEvent.getFlowFilesRemoved()); if (isProcessorAuthorized) { status.setCounters(flowFileEvent.getCounters()); } } // Determine the run status and get any validation error... only validating while STOPPED // is a trade-off we are willing to make, even though processor validity could change due to // environmental conditions (property configured with a file path and the file being externally // removed). This saves on validation costs that would be unnecessary most of the time. if (ScheduledState.DISABLED.equals(procNode.getScheduledState())) { status.setRunStatus(RunStatus.Disabled); } else if (ScheduledState.RUNNING.equals(procNode.getScheduledState())) { status.setRunStatus(RunStatus.Running); } else if (procNode.getValidationStatus() == ValidationStatus.VALIDATING) { status.setRunStatus(RunStatus.Validating); } else if (procNode.getValidationStatus() == ValidationStatus.INVALID) { status.setRunStatus(RunStatus.Invalid); } else { status.setRunStatus(RunStatus.Stopped); } status.setExecutionNode(procNode.getExecutionNode()); status.setTerminatedThreadCount(procNode.getTerminatedThreadCount()); status.setActiveThreadCount(processScheduler.getActiveThreadCount(procNode)); return status; }