org.apache.nifi.controller.status.ProcessGroupStatus Java Examples
The following examples show how to use
org.apache.nifi.controller.status.ProcessGroupStatus.
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: TestDataDogReportingTask.java From nifi with Apache License 2.0 | 6 votes |
private void initProcessorStatuses() { procStatus = new ProcessorStatus(); procStatus.setProcessingNanos(123456789); procStatus.setInputCount(2); procStatus.setOutputCount(4); procStatus.setActiveThreadCount(6); procStatus.setBytesSent(1256); procStatus.setName("sampleProcessor"); Collection<ProcessorStatus> processorStatuses = new ArrayList<>(); processorStatuses.add(procStatus); status.setProcessorStatus(processorStatuses); ProcessGroupStatus groupStatus = new ProcessGroupStatus(); groupStatus.setProcessorStatus(processorStatuses); Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>(); groupStatuses.add(groupStatus); status.setProcessGroupStatus(groupStatuses); }
Example #2
Source File: TestSiteToSiteStatusReportingTask.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testRemoteProcessGroupStatusWithNullValues() throws IOException, InitializationException { final ProcessGroupStatus pgStatus = generateProcessGroupStatus("root", "Awesome", 1, 0); final Map<PropertyDescriptor, String> properties = new HashMap<>(); properties.put(SiteToSiteUtils.BATCH_SIZE, "4"); properties.put(SiteToSiteStatusReportingTask.COMPONENT_NAME_FILTER_REGEX, "Awesome.*"); properties.put(SiteToSiteStatusReportingTask.COMPONENT_TYPE_FILTER_REGEX, "(RemoteProcessGroup)"); properties.put(SiteToSiteStatusReportingTask.ALLOW_NULL_VALUES,"true"); MockSiteToSiteStatusReportingTask task = initTask(properties, pgStatus); task.onTrigger(context); assertEquals(3, task.dataSent.size()); final String msg = new String(task.dataSent.get(0), StandardCharsets.UTF_8); JsonReader jsonReader = Json.createReader(new ByteArrayInputStream(msg.getBytes())); JsonObject firstElement = jsonReader.readArray().getJsonObject(0); JsonValue targetURI = firstElement.get("targetURI"); assertEquals(targetURI, JsonValue.NULL); }
Example #3
Source File: ControllerFacade.java From localization_nifi with Apache License 2.0 | 6 votes |
/** * Gets the status for the specified output port. * * @param portId output port id * @return the status for the specified output port */ public PortStatus getOutputPortStatus(final String portId) { final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId()); final Port port = root.findOutputPort(portId); // ensure the output port was found if (port == null) { throw new ResourceNotFoundException(String.format("Unable to locate output port with id '%s'.", portId)); } final String groupId = port.getProcessGroup().getIdentifier(); final ProcessGroupStatus processGroupStatus = flowController.getGroupStatus(groupId, NiFiUserUtils.getNiFiUser()); if (processGroupStatus == null) { throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId)); } final PortStatus status = processGroupStatus.getOutputPortStatus().stream().filter(portStatus -> portId.equals(portStatus.getId())).findFirst().orElse(null); if (status == null) { throw new ResourceNotFoundException(String.format("Unable to locate output port with id '%s'.", portId)); } return status; }
Example #4
Source File: DataDogReportingTask.java From localization_nifi with Apache License 2.0 | 6 votes |
@Override public void onTrigger(ReportingContext context) { final ProcessGroupStatus status = context.getEventAccess().getControllerStatus(); metricsPrefix = context.getProperty(METRICS_PREFIX).evaluateAttributeExpressions().getValue(); environment = context.getProperty(ENVIRONMENT).evaluateAttributeExpressions().getValue(); statusId = status.getId(); defaultTags = ImmutableMap.of("env", environment, "dataflow_id", statusId); try { updateDataDogTransport(context); } catch (IOException e) { e.printStackTrace(); } updateAllMetricGroups(status); ddMetricRegistryBuilder.getDatadogReporter().report(); }
Example #5
Source File: ControllerFacade.java From localization_nifi with Apache License 2.0 | 6 votes |
/** * Gets the status for the specified input port. * * @param portId input port id * @return the status for the specified input port */ public PortStatus getInputPortStatus(final String portId) { final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId()); final Port port = root.findInputPort(portId); // ensure the input port was found if (port == null) { throw new ResourceNotFoundException(String.format("Unable to locate input port with id '%s'.", portId)); } final String groupId = port.getProcessGroup().getIdentifier(); final ProcessGroupStatus processGroupStatus = flowController.getGroupStatus(groupId, NiFiUserUtils.getNiFiUser()); if (processGroupStatus == null) { throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId)); } final PortStatus status = processGroupStatus.getInputPortStatus().stream().filter(portStatus -> portId.equals(portStatus.getId())).findFirst().orElse(null); if (status == null) { throw new ResourceNotFoundException(String.format("Unable to locate input port with id '%s'.", portId)); } return status; }
Example #6
Source File: ControllerFacade.java From localization_nifi with Apache License 2.0 | 6 votes |
/** * Gets the status for the specified connection. * * @param connectionId connection id * @return the status for the specified connection */ public ConnectionStatus getConnectionStatus(final String connectionId) { final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId()); final Connection connection = root.findConnection(connectionId); // ensure the connection was found if (connection == null) { throw new ResourceNotFoundException(String.format("Unable to locate connection with id '%s'.", connectionId)); } // calculate the process group status final String groupId = connection.getProcessGroup().getIdentifier(); final ProcessGroupStatus processGroupStatus = flowController.getGroupStatus(groupId, NiFiUserUtils.getNiFiUser()); if (processGroupStatus == null) { throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId)); } final ConnectionStatus status = processGroupStatus.getConnectionStatus().stream().filter(connectionStatus -> connectionId.equals(connectionStatus.getId())).findFirst().orElse(null); if (status == null) { throw new ResourceNotFoundException(String.format("Unable to locate connection with id '%s'.", connectionId)); } return status; }
Example #7
Source File: ControllerFacade.java From nifi with Apache License 2.0 | 6 votes |
/** * Gets the status for the specified connection. * * @param connectionId connection id * @return the status for the specified connection */ public ConnectionStatus getConnectionStatus(final String connectionId) { final ProcessGroup root = getRootGroup(); final Connection connection = root.findConnection(connectionId); // ensure the connection was found if (connection == null) { throw new ResourceNotFoundException(String.format("Unable to locate connection with id '%s'.", connectionId)); } // calculate the process group status final String groupId = connection.getProcessGroup().getIdentifier(); final ProcessGroupStatus processGroupStatus = flowController.getEventAccess().getGroupStatus(groupId, NiFiUserUtils.getNiFiUser(), 1); if (processGroupStatus == null) { throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId)); } final ConnectionStatus status = processGroupStatus.getConnectionStatus().stream().filter(connectionStatus -> connectionId.equals(connectionStatus.getId())).findFirst().orElse(null); if (status == null) { throw new ResourceNotFoundException(String.format("Unable to locate connection with id '%s'.", connectionId)); } return status; }
Example #8
Source File: TestSiteToSiteStatusReportingTask.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testSerializedForm() throws IOException, InitializationException { final ProcessGroupStatus pgStatus = generateProcessGroupStatus("root", "Awesome", 1, 0); final Map<PropertyDescriptor, String> properties = new HashMap<>(); properties.put(SiteToSiteUtils.BATCH_SIZE, "4"); properties.put(SiteToSiteStatusReportingTask.COMPONENT_NAME_FILTER_REGEX, "Awesome.*"); properties.put(SiteToSiteStatusReportingTask.COMPONENT_TYPE_FILTER_REGEX, ".*"); MockSiteToSiteStatusReportingTask task = initTask(properties, pgStatus); task.onTrigger(context); assertEquals(16, task.dataSent.size()); final String msg = new String(task.dataSent.get(0), StandardCharsets.UTF_8); JsonReader jsonReader = Json.createReader(new ByteArrayInputStream(msg.getBytes())); JsonObject firstElement = jsonReader.readArray().getJsonObject(0); JsonString componentId = firstElement.getJsonString("componentId"); assertEquals(pgStatus.getId(), componentId.getString()); JsonNumber terminatedThreads = firstElement.getJsonNumber("terminatedThreadCount"); assertEquals(1, terminatedThreads.longValue()); JsonString versionedFlowState = firstElement.getJsonString("versionedFlowState"); assertEquals("UP_TO_DATE", versionedFlowState.getString()); }
Example #9
Source File: ProvenanceEnumerator.java From nifi with Apache License 2.0 | 6 votes |
public ProvenanceEnumerator(final ReportingContext context, final ComponentLog logger, final int[] fields) { this.logger = logger; this.fields = fields; final EventAccess eventAccess = context.getEventAccess(); this.provenanceEventRepository = eventAccess.getProvenanceRepository(); final ProcessGroupStatus procGroupStatus = eventAccess.getControllerStatus(); this.componentMapHolder = ComponentMapHolder.createComponentMap(procGroupStatus); final boolean isClustered = context.isClustered(); nodeIdentifier = context.getClusterNodeIdentifier(); if (nodeIdentifier == null && isClustered) { logger.warn("This instance of NiFi is configured for clustering, but the Cluster Node Identifier is not yet available. " + "The contentPath and previousContentPath fields will be null for all rows in this query"); } try { this.provenanceEvents = provenanceEventRepository.getEvents(0, FETCH_SIZE); } catch (IOException ioe) { logger.error("Error retrieving provenance events, queries will return no rows"); } reset(); }
Example #10
Source File: ProcessorStatusEnumerator.java From nifi with Apache License 2.0 | 6 votes |
private ProcessorStatus getNextProcessorStatus() { if (processorStatusIterator != null && processorStatusIterator.hasNext()) { return processorStatusIterator.next(); } // No more connections in this PG, so move to the next processorStatusIterator = null; Iterator<ProcessGroupStatus> i = iteratorBreadcrumb.peek(); if (i == null) { return null; } if (i.hasNext()) { ProcessGroupStatus nextPG = i.next(); iteratorBreadcrumb.push(nextPG.getProcessGroupStatus().iterator()); processorStatusIterator = nextPG.getProcessorStatus().iterator(); return getNextProcessorStatus(); } else { // No more child PGs, remove it from the breadcrumb trail and try again iteratorBreadcrumb.pop(); return getNextProcessorStatus(); } }
Example #11
Source File: TestSiteToSiteStatusReportingTask.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testProcessorStatusWithNullValues() throws IOException, InitializationException { final ProcessGroupStatus pgStatus = generateProcessGroupStatus("root", "Awesome", 1, 0); final Map<PropertyDescriptor, String> properties = new HashMap<>(); properties.put(SiteToSiteUtils.BATCH_SIZE, "4"); properties.put(SiteToSiteStatusReportingTask.COMPONENT_NAME_FILTER_REGEX, "Awesome.*"); properties.put(SiteToSiteStatusReportingTask.COMPONENT_TYPE_FILTER_REGEX, "(Processor)"); properties.put(SiteToSiteStatusReportingTask.ALLOW_NULL_VALUES,"true"); MockSiteToSiteStatusReportingTask task = initTask(properties, pgStatus); task.onTrigger(context); final String msg = new String(task.dataSent.get(0), StandardCharsets.UTF_8); JsonReader jsonReader = Json.createReader(new ByteArrayInputStream(msg.getBytes())); JsonObject object = jsonReader.readArray().getJsonObject(0); JsonValue type = object.get("processorType"); assertEquals(type, JsonValue.NULL); }
Example #12
Source File: SiteToSiteStatusReportingTask.java From nifi with Apache License 2.0 | 6 votes |
private void serializePortStatus(final String componentType, final JsonArrayBuilder arrayBuilder, final JsonBuilderFactory factory, final PortStatus status, final DateFormat df, final String hostname, final String applicationName, final String platform, final ProcessGroupStatus parent, final Date currentDate, final Boolean allowNullValues) { final JsonObjectBuilder builder = factory.createObjectBuilder(); final String componentName = status.getName(); if (componentMatchesFilters(componentType, componentName)) { addCommonFields(builder, df, hostname, applicationName, platform, parent, currentDate, componentType, componentName, allowNullValues); addField(builder, "componentId", status.getId(), allowNullValues); addField(builder, "activeThreadCount", status.getActiveThreadCount(), allowNullValues); addField(builder, "bytesReceived", status.getBytesReceived(), allowNullValues); addField(builder, "bytesSent", status.getBytesSent(), allowNullValues); addField(builder, "flowFilesReceived", status.getFlowFilesReceived(), allowNullValues); addField(builder, "flowFilesSent", status.getFlowFilesSent(), allowNullValues); addField(builder, "inputBytes", status.getInputBytes(), allowNullValues); addField(builder, "inputCount", status.getInputCount(), allowNullValues); addField(builder, "outputBytes", status.getOutputBytes(), allowNullValues); addField(builder, "outputCount", status.getOutputCount(), allowNullValues); addField(builder, "runStatus", status.getRunStatus() == null ? null : status.getRunStatus().name(), allowNullValues); addField(builder, "transmitting", status.isTransmitting(), allowNullValues); arrayBuilder.add(builder.build()); } }
Example #13
Source File: MetricsReportingTask.java From nifi with Apache License 2.0 | 6 votes |
/** * Report the registered metrics. * * @param context used for getting the most recent {@link ProcessGroupStatus}. */ @Override public void onTrigger(ReportingContext context) { String groupId = context.getProperty(PROCESS_GROUP_ID).evaluateAttributeExpressions().getValue(); ProcessGroupStatus statusToReport = groupId == null ? context.getEventAccess().getControllerStatus() : context.getEventAccess().getGroupStatus(groupId); if (statusToReport != null) { currentStatusReference.set(statusToReport); reporter.report(); } else { getLogger().error("Process group with provided group id could not be found."); } }
Example #14
Source File: TestDataDogReportingTask.java From localization_nifi with Apache License 2.0 | 6 votes |
private void initProcessorStatuses() { procStatus = new ProcessorStatus(); procStatus.setProcessingNanos(123456789); procStatus.setInputCount(2); procStatus.setOutputCount(4); procStatus.setActiveThreadCount(6); procStatus.setBytesSent(1256); procStatus.setName("sampleProcessor"); Collection<ProcessorStatus> processorStatuses = new ArrayList<>(); processorStatuses.add(procStatus); status.setProcessorStatus(processorStatuses); ProcessGroupStatus groupStatus = new ProcessGroupStatus(); groupStatus.setProcessorStatus(processorStatuses); Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>(); groupStatuses.add(groupStatus); status.setProcessGroupStatus(groupStatuses); }
Example #15
Source File: TestSiteToSiteStatusReportingTask.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testConnectionStatusWithNullValues() throws IOException, InitializationException { final ProcessGroupStatus pgStatus = generateProcessGroupStatus("root", "Awesome", 1, 0); final Map<PropertyDescriptor, String> properties = new HashMap<>(); properties.put(SiteToSiteUtils.BATCH_SIZE, "4"); properties.put(SiteToSiteStatusReportingTask.COMPONENT_NAME_FILTER_REGEX, "Awesome.*"); properties.put(SiteToSiteStatusReportingTask.COMPONENT_TYPE_FILTER_REGEX, "(Connection)"); properties.put(SiteToSiteStatusReportingTask.ALLOW_NULL_VALUES,"true"); MockSiteToSiteStatusReportingTask task = initTask(properties, pgStatus); task.onTrigger(context); final String msg = new String(task.dataSent.get(0), StandardCharsets.UTF_8); JsonReader jsonReader = Json.createReader(new ByteArrayInputStream(msg.getBytes())); JsonObject object = jsonReader.readArray().getJsonObject(0); JsonValue destination = object.get("destinationName"); assertEquals(destination, JsonValue.NULL); }
Example #16
Source File: TestAzureLogAnalyticsReportingTask.java From nifi with Apache License 2.0 | 6 votes |
private void initTestGroupStatuses() { testGroupStatus = new ProcessGroupStatus(); testGroupStatus.setId(TEST_GROUP1_ID); testGroupStatus.setFlowFilesReceived(5); testGroupStatus.setBytesReceived(10000); testGroupStatus.setFlowFilesSent(10); testGroupStatus.setBytesSent(20000); testGroupStatus.setQueuedCount(100); testGroupStatus.setQueuedContentSize(1024L); testGroupStatus.setBytesRead(60000L); testGroupStatus.setBytesWritten(80000L); testGroupStatus.setActiveThreadCount(5); testGroupStatus.setName(TEST_GROUP1_ID); testGroupStatus.setFlowFilesTransferred(5); testGroupStatus.setBytesTransferred(10000); testGroupStatus.setOutputContentSize(1000L); testGroupStatus.setInputContentSize(1000L); testGroupStatus.setOutputCount(100); testGroupStatus.setInputCount(1000); }
Example #17
Source File: MetricsService.java From nifi-prometheus-reporter with Apache License 2.0 | 6 votes |
/** * Generates a Map of metrics for a ProcessGroupStatus instance. * * @param status a ProcessGroupStatus to get metrics from * @param appendPgId if true, the process group ID will be appended at the end of the metric name * @return a map of metrics for the given status */ public Map<String, String> getMetrics(ProcessGroupStatus status, boolean appendPgId) { final Map<String, String> metrics = new HashMap<>(); metrics.put(appendPgId(MetricNames.FLOW_FILES_RECEIVED, status, appendPgId), String.valueOf(status.getFlowFilesReceived())); metrics.put(appendPgId(MetricNames.BYTES_RECEIVED, status, appendPgId), String.valueOf(status.getBytesReceived())); metrics.put(appendPgId(MetricNames.FLOW_FILES_SENT, status, appendPgId), String.valueOf(status.getFlowFilesSent())); metrics.put(appendPgId(MetricNames.BYTES_SENT, status, appendPgId), String.valueOf(status.getBytesSent())); metrics.put(appendPgId(MetricNames.FLOW_FILES_QUEUED, status, appendPgId), String.valueOf(status.getQueuedCount())); metrics.put(appendPgId(MetricNames.BYTES_QUEUED, status, appendPgId), String.valueOf(status.getQueuedContentSize())); metrics.put(appendPgId(MetricNames.BYTES_READ, status, appendPgId), String.valueOf(status.getBytesRead())); metrics.put(appendPgId(MetricNames.BYTES_WRITTEN, status, appendPgId), String.valueOf(status.getBytesWritten())); metrics.put(appendPgId(MetricNames.ACTIVE_THREADS, status, appendPgId), String.valueOf(status.getActiveThreadCount())); final long durationNanos = calculateProcessingNanos(status); metrics.put(appendPgId(MetricNames.TOTAL_TASK_DURATION_NANOS, status, appendPgId), String.valueOf(durationNanos)); final long durationSeconds = TimeUnit.SECONDS.convert(durationNanos, TimeUnit.NANOSECONDS); metrics.put(appendPgId(MetricNames.TOTAL_TASK_DURATION_SECONDS, status, appendPgId), String.valueOf(durationSeconds)); return metrics; }
Example #18
Source File: MetricsService.java From nifi with Apache License 2.0 | 6 votes |
private Map<String,Long> getLongMetrics(ProcessGroupStatus status, boolean appendPgId) { final Map<String,Long> metrics = new HashMap<>(); metrics.put(appendPgId(MetricNames.BYTES_RECEIVED, status, appendPgId), status.getBytesReceived()); metrics.put(appendPgId(MetricNames.BYTES_SENT, status, appendPgId), status.getBytesSent()); metrics.put(appendPgId(MetricNames.BYTES_QUEUED, status, appendPgId), status.getQueuedContentSize()); metrics.put(appendPgId(MetricNames.BYTES_READ, status, appendPgId), status.getBytesRead()); metrics.put(appendPgId(MetricNames.BYTES_WRITTEN, status, appendPgId), status.getBytesWritten()); final long durationNanos = calculateProcessingNanos(status); metrics.put(appendPgId(MetricNames.TOTAL_TASK_DURATION_NANOS, status, appendPgId), durationNanos); final long durationSeconds = TimeUnit.SECONDS.convert(durationNanos, TimeUnit.NANOSECONDS); metrics.put(appendPgId(MetricNames.TOTAL_TASK_DURATION_SECONDS, status, appendPgId), durationSeconds); return metrics; }
Example #19
Source File: PrometheusMetricsFactory.java From nifi-prometheus-reporter with Apache License 2.0 | 6 votes |
public static CollectorRegistry createNifiMetrics(ProcessGroupStatus status, String applicationId) { String processGroupName = status.getName(); AMOUNT_FLOWFILES_TOTAL.labels("sent", applicationId, processGroupName).set(status.getFlowFilesSent()); AMOUNT_FLOWFILES_TOTAL.labels("transferred", applicationId, processGroupName).set(status.getFlowFilesTransferred()); AMOUNT_FLOWFILES_TOTAL.labels("received", applicationId, processGroupName).set(status.getFlowFilesReceived()); AMOUNT_BYTES_TOTAL.labels("sent", applicationId, processGroupName).set(status.getBytesSent()); AMOUNT_BYTES_TOTAL.labels("read", applicationId, processGroupName).set(status.getBytesRead()); AMOUNT_BYTES_TOTAL.labels("written", applicationId, processGroupName).set(status.getBytesWritten()); AMOUNT_BYTES_TOTAL.labels("received", applicationId, processGroupName).set(status.getBytesReceived()); AMOUNT_BYTES_TOTAL.labels("transferred", applicationId, processGroupName).set(status.getBytesTransferred()); SIZE_CONTENT_TOTAL.labels("output", applicationId, processGroupName).set(status.getOutputContentSize()); SIZE_CONTENT_TOTAL.labels("input", applicationId, processGroupName).set(status.getInputContentSize()); SIZE_CONTENT_TOTAL.labels("queued", applicationId, processGroupName).set(status.getQueuedContentSize()); AMOUNT_ITEMS.labels("output", applicationId, processGroupName).set(status.getOutputCount()); AMOUNT_ITEMS.labels("input", applicationId, processGroupName).set(status.getInputCount()); AMOUNT_ITEMS.labels("queued", applicationId, processGroupName).set(status.getQueuedCount()); AMOUNT_THREADS_TOTAL.labels("nano", applicationId, processGroupName).set(status.getActiveThreadCount()); return NIFI_METRICS_REGISTRY; }
Example #20
Source File: TestSiteToSiteStatusReportingTask.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testComponentNameFilter_nested() throws IOException, InitializationException { final ProcessGroupStatus pgStatus = generateProcessGroupStatus("root", "Awesome", 2, 0); final Map<PropertyDescriptor, String> properties = new HashMap<>(); properties.put(SiteToSiteUtils.BATCH_SIZE, "4"); properties.put(SiteToSiteStatusReportingTask.COMPONENT_NAME_FILTER_REGEX, "Awesome.*processor.*"); properties.put(SiteToSiteStatusReportingTask.COMPONENT_TYPE_FILTER_REGEX, ".*"); MockSiteToSiteStatusReportingTask task = initTask(properties, pgStatus); task.onTrigger(context); assertEquals(10, task.dataSent.size()); // 3 + (3 * 3) + (3 * 3 * 3) = 39, or 10 batches of 4 final String msg = new String(task.dataSent.get(0), StandardCharsets.UTF_8); JsonReader jsonReader = Json.createReader(new ByteArrayInputStream(msg.getBytes())); JsonString componentId = jsonReader.readArray().getJsonObject(0).getJsonString("componentId"); assertEquals("root.1.1.processor.1", componentId.getString()); }
Example #21
Source File: ComponentStatusReport.java From localization_nifi with Apache License 2.0 | 5 votes |
public static ComponentStatusReport fromProcessGroupStatus(final ProcessGroupStatus status, final ComponentType... componentTypes) { final Set<ComponentType> componentTypeSet = new HashSet<>(); for (final ComponentType type : componentTypes) { componentTypeSet.add(type); } final ComponentStatusReport report = new ComponentStatusReport(); report.populate(status, componentTypeSet); return report; }
Example #22
Source File: TestMetricsService.java From nifi-prometheus-reporter with Apache License 2.0 | 5 votes |
@Test public void testGetProcessGroupStatusMetricsWithID() { ProcessGroupStatus status = new ProcessGroupStatus(); String id = "1234"; status.setId(id); status.setFlowFilesReceived(5); status.setBytesReceived(10000); status.setFlowFilesSent(10); status.setBytesSent(20000); status.setQueuedCount(100); status.setQueuedContentSize(1024L); status.setBytesRead(60000L); status.setBytesWritten(80000L); status.setActiveThreadCount(5); // create a processor status with processing time ProcessorStatus procStatus = new ProcessorStatus(); procStatus.setProcessingNanos(123456789); Collection<ProcessorStatus> processorStatuses = new ArrayList<>(); processorStatuses.add(procStatus); status.setProcessorStatus(processorStatuses); // create a group status with processing time ProcessGroupStatus groupStatus = new ProcessGroupStatus(); groupStatus.setProcessorStatus(processorStatuses); Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>(); groupStatuses.add(groupStatus); status.setProcessGroupStatus(groupStatuses); final MetricsService service = new MetricsService(); final Map<String, String> metrics = service.getMetrics(status, true); Assert.assertTrue(metrics.containsKey(MetricNames.FLOW_FILES_RECEIVED + MetricNames.METRIC_NAME_SEPARATOR + id)); }
Example #23
Source File: StatusConfigReporterTest.java From nifi-minifi with Apache License 2.0 | 5 votes |
@Before public void setup() { mockFlowController = mock(FlowController.class); rootGroupStatus = mock(ProcessGroupStatus.class); bulletinRepo = mock(BulletinRepository.class); processGroup = mock(ProcessGroup.class); when(mockFlowController.getRootGroupId()).thenReturn("root"); when(mockFlowController.getGroupStatus("root")).thenReturn(rootGroupStatus); when(mockFlowController.getControllerStatus()).thenReturn(rootGroupStatus); when(mockFlowController.getBulletinRepository()).thenReturn(bulletinRepo); when(mockFlowController.getGroup(mockFlowController.getRootGroupId())).thenReturn(processGroup); }
Example #24
Source File: ProcessorStatusEnumerator.java From nifi with Apache License 2.0 | 5 votes |
@Override public boolean moveNext() { currentRow = null; if (iteratorBreadcrumb.isEmpty()) { // Start the breadcrumb trail to follow recursively into process groups looking for connections ProcessGroupStatus rootStatus = context.getEventAccess().getControllerStatus(); iteratorBreadcrumb.push(rootStatus.getProcessGroupStatus().iterator()); processorStatusIterator = rootStatus.getProcessorStatus().iterator(); } final ProcessorStatus connectionStatus = getNextProcessorStatus(); if (connectionStatus == null) { // If we are out of data, close the InputStream. We do this because // Calcite does not necessarily call our close() method. close(); try { onFinish(); } catch (final Exception e) { logger.error("Failed to perform tasks when enumerator was finished", e); } return false; } currentRow = filterColumns(connectionStatus); recordsRead++; return true; }
Example #25
Source File: ConnectionStatusRecursiveIterator.java From nifi with Apache License 2.0 | 5 votes |
@Override public boolean hasNext() { if (iteratorBreadcrumb.isEmpty()) { // Start the breadcrumb trail to follow recursively into process groups looking for connections ProcessGroupStatus rootStatus = context.getEventAccess().getControllerStatus(); iteratorBreadcrumb.push(rootStatus.getProcessGroupStatus().iterator()); connectionStatusIterator = rootStatus.getConnectionStatus().iterator(); } currentRow = getNextConnectionStatus(); return (currentRow != null); }
Example #26
Source File: MetricsService.java From nifi-prometheus-reporter with Apache License 2.0 | 5 votes |
protected long calculateProcessingNanos(final ProcessGroupStatus status) { long nanos = 0L; for (final ProcessorStatus procStats : status.getProcessorStatus()) { nanos += procStats.getProcessingNanos(); } for (final ProcessGroupStatus childGroupStatus : status.getProcessGroupStatus()) { nanos += calculateProcessingNanos(childGroupStatus); } return nanos; }
Example #27
Source File: TestAmbariReportingTask.java From nifi with Apache License 2.0 | 5 votes |
@Before public void setup() { status = new ProcessGroupStatus(); status.setId("1234"); status.setFlowFilesReceived(5); status.setBytesReceived(10000); status.setFlowFilesSent(10); status.setBytesSent(20000); status.setQueuedCount(100); status.setQueuedContentSize(1024L); status.setBytesRead(60000L); status.setBytesWritten(80000L); status.setActiveThreadCount(5); // create a processor status with processing time ProcessorStatus procStatus = new ProcessorStatus(); procStatus.setProcessingNanos(123456789); Collection<ProcessorStatus> processorStatuses = new ArrayList<>(); processorStatuses.add(procStatus); status.setProcessorStatus(processorStatuses); // create a group status with processing time ProcessGroupStatus groupStatus = new ProcessGroupStatus(); groupStatus.setProcessorStatus(processorStatuses); Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>(); groupStatuses.add(groupStatus); status.setProcessGroupStatus(groupStatuses); }
Example #28
Source File: TestSiteToSiteStatusReportingTask.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testProcessorStatus() throws IOException, InitializationException { final ProcessGroupStatus pgStatus = generateProcessGroupStatus("root", "Awesome", 1, 0); final Map<PropertyDescriptor, String> properties = new HashMap<>(); properties.put(SiteToSiteUtils.BATCH_SIZE, "4"); properties.put(SiteToSiteStatusReportingTask.COMPONENT_NAME_FILTER_REGEX, "Awesome.*"); properties.put(SiteToSiteStatusReportingTask.COMPONENT_TYPE_FILTER_REGEX, "(Processor)"); MockSiteToSiteStatusReportingTask task = initTask(properties, pgStatus); task.onTrigger(context); final String msg = new String(task.dataSent.get(0), StandardCharsets.UTF_8); JsonReader jsonReader = Json.createReader(new ByteArrayInputStream(msg.getBytes())); JsonObject object = jsonReader.readArray().getJsonObject(0); JsonString parentName = object.getJsonString("parentName"); assertTrue(parentName.getString().startsWith("Awesome.1-")); JsonString parentPath = object.getJsonString("parentPath"); assertTrue(parentPath.getString().startsWith("NiFi Flow / Awesome.1")); JsonString runStatus = object.getJsonString("runStatus"); assertEquals(RunStatus.Running.name(), runStatus.getString()); JsonNumber inputBytes = object.getJsonNumber("inputBytes"); assertEquals(9, inputBytes.intValue()); JsonObject counterMap = object.getJsonObject("counters"); assertNotNull(counterMap); assertEquals(10, counterMap.getInt("counter1")); assertEquals(5, counterMap.getInt("counter2")); assertNull(object.get("processorType")); }
Example #29
Source File: TestDataDogReportingTask.java From nifi with Apache License 2.0 | 5 votes |
private void initProcessGroupStatus() { status = new ProcessGroupStatus(); status.setId("1234"); status.setFlowFilesReceived(5); status.setBytesReceived(10000); status.setFlowFilesSent(10); status.setBytesSent(20000); status.setQueuedCount(100); status.setQueuedContentSize(1024L); status.setBytesRead(60000L); status.setBytesWritten(80000L); status.setActiveThreadCount(5); status.setInputCount(2); status.setOutputCount(4); }
Example #30
Source File: TestSiteToSiteMetricsReportingTask.java From nifi with Apache License 2.0 | 5 votes |
@Before public void setup() { status = new ProcessGroupStatus(); status.setId("1234"); status.setFlowFilesReceived(5); status.setBytesReceived(10000); status.setFlowFilesSent(10); status.setBytesSent(20000); status.setQueuedCount(100); status.setQueuedContentSize(1024L); status.setBytesRead(null); status.setBytesWritten(80000L); status.setActiveThreadCount(5); // create a processor status with processing time ProcessorStatus procStatus = new ProcessorStatus(); procStatus.setProcessingNanos(123456789); Collection<ProcessorStatus> processorStatuses = new ArrayList<>(); processorStatuses.add(procStatus); status.setProcessorStatus(processorStatuses); // create a group status with processing time ProcessGroupStatus groupStatus = new ProcessGroupStatus(); groupStatus.setProcessorStatus(processorStatuses); Collection<ProcessGroupStatus> groupStatuses = new ArrayList<>(); groupStatuses.add(groupStatus); status.setProcessGroupStatus(groupStatuses); }