org.apache.nifi.reporting.ReportingContext Java Examples
The following examples show how to use
org.apache.nifi.reporting.ReportingContext.
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: DataDogReportingTask.java From 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) { logger.warn("Unable to update data dog transport", e); } updateAllMetricGroups(status); ddMetricRegistryBuilder.getDatadogReporter().report(); }
Example #2
Source File: ScriptedActionHandlerTest.java From nifi with Apache License 2.0 | 6 votes |
private void setupTestRunner() throws Exception { runner = TestRunners.newTestRunner(TestProcessor.class); MockScriptedActionHandler handler = initTask("src/test/resources/groovy/test_propertycontext_action_handler.groovy"); mockScriptedBulletinRepository = new MockScriptedBulletinRepository(); Map<String, String> properties = new HashMap<>(); properties.put(handler.getScriptingComponentHelper().SCRIPT_ENGINE.getName(), "Groovy"); properties.put(ScriptingComponentUtils.SCRIPT_FILE.getName(), "src/test/resources/groovy/test_propertycontext_action_handler.groovy"); runner.addControllerService("MockAlertHandler", handler, properties); runner.enableControllerService(handler); actionHandler = (MockScriptedActionHandler) runner.getProcessContext() .getControllerServiceLookup() .getControllerService("MockAlertHandler"); reportingContext = mock(ReportingContext.class); when(reportingContext.getBulletinRepository()).thenReturn(mockScriptedBulletinRepository); when(reportingContext.createBulletin(anyString(), Mockito.any(Severity.class), anyString())) .thenAnswer(invocation -> BulletinFactory.createBulletin(invocation.getArgument(0), invocation.getArgument(1).toString(), invocation.getArgument(2))); }
Example #3
Source File: ScriptedActionHandlerTest.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testPropertyContextActionHandler() throws InitializationException { actionHandler = initTask("src/test/resources/groovy/test_propertycontext_action_handler.groovy"); mockScriptedBulletinRepository = new MockScriptedBulletinRepository(); reportingContext = mock(ReportingContext.class); when(reportingContext.getBulletinRepository()).thenReturn(mockScriptedBulletinRepository); when(reportingContext.createBulletin(anyString(), Mockito.any(Severity.class), anyString())) .thenAnswer(invocation -> BulletinFactory.createBulletin(invocation.getArgument(0), invocation.getArgument(1).toString(), invocation.getArgument(2))); actionHandler.onEnabled(context); List<Action> actions = Arrays.asList(new Action("LOG", attrs), new Action("ALERT", attrs)); actions.forEach(action -> actionHandler.execute(reportingContext, action, facts)); // Verify instead of a bulletin being added, a fact was added (not the intended operation of ActionHandler, but testable) List<Bulletin> bulletinList = mockScriptedBulletinRepository.bulletinList; assertEquals(2, bulletinList.size()); }
Example #4
Source File: ScriptedActionHandlerTest.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testActionHandlerNotPropertyContextActionHandler() throws InitializationException { actionHandler = initTask("src/test/resources/groovy/test_action_handler.groovy"); mockScriptedBulletinRepository = new MockScriptedBulletinRepository(); reportingContext = mock(ReportingContext.class); when(reportingContext.getBulletinRepository()).thenReturn(mockScriptedBulletinRepository); when(reportingContext.createBulletin(anyString(), Mockito.any(Severity.class), anyString())) .thenAnswer(invocation -> BulletinFactory.createBulletin(invocation.getArgument(0), invocation.getArgument(1).toString(), invocation.getArgument(2))); actionHandler.onEnabled(context); List<Action> actions = Arrays.asList(new Action("LOG", attrs), new Action("ALERT", attrs)); actions.forEach(action -> actionHandler.execute(reportingContext, action, facts)); // Verify instead of a bulletin being added, a fact was added (not the intended operation of ActionHandler, but testable) assertTrue(mockScriptedBulletinRepository.bulletinList.isEmpty()); assertEquals(42, facts.get("testFact")); }
Example #5
Source File: AzureLogAnalyticsProvenanceReportingTask.java From nifi with Apache License 2.0 | 6 votes |
@Override public void onTrigger(ReportingContext context) { final boolean isClustered = context.isClustered(); final String nodeId = context.getClusterNodeIdentifier(); if (nodeId == null && isClustered) { getLogger().debug( "This instance of NiFi is configured for clustering, but the Cluster Node Identifier is not yet available. " + "Will wait for Node Identifier to be established."); return; } try { processProvenanceData(context); } catch (final Exception e) { getLogger().error("Failed to publish metrics to Azure Log Analytics", e); } }
Example #6
Source File: ReportLineageToAtlas.java From nifi with Apache License 2.0 | 6 votes |
private void consumeNiFiProvenanceEvents(ReportingContext context, NiFiFlow nifiFlow) { final EventAccess eventAccess = context.getEventAccess(); final AnalysisContext analysisContext = new StandardAnalysisContext(nifiFlow, namespaceResolvers, // FIXME: This class cast shouldn't be necessary to query lineage. Possible refactor target in next major update. (ProvenanceRepository)eventAccess.getProvenanceRepository()); consumer.consumeEvents(context, (componentMapHolder, events) -> { for (ProvenanceEventRecord event : events) { try { lineageStrategy.processEvent(analysisContext, nifiFlow, event); } catch (Exception e) { // If something went wrong, log it and continue with other records. getLogger().error("Skipping failed analyzing event {} due to {}.", new Object[]{event, e, e}); } } nifiAtlasHook.commitMessages(); }); }
Example #7
Source File: PrometheusReportingTask.java From nifi-prometheus-reporter with Apache License 2.0 | 6 votes |
/** * Searches all ProcessGroups defined in a PropertyValue as a comma-separated list of ProcessorGroup-IDs. * Therefore blanks are trimmed and new-line characters are removed! Processors that can not be found are ignored. * * @return List of all ProcessorGroups that were found. * If no groupIDs are defined or none of them could be found an array containing the root-DataFlow will be returned. */ private ProcessGroupStatus[] searchProcessGroups(final ReportingContext context, PropertyValue value) { if (value.isSet()) { String content = value.evaluateAttributeExpressions().getValue(); ProcessGroupStatus[] groups = Arrays .stream(content.replace("\n", "").split(",")) .map(String::trim) .map(context.getEventAccess()::getGroupStatus) .filter(Objects::nonNull) .toArray(ProcessGroupStatus[]::new); return groups.length > 0 ? groups : new ProcessGroupStatus[]{context.getEventAccess().getControllerStatus()}; } else { return new ProcessGroupStatus[]{context.getEventAccess().getControllerStatus()}; } }
Example #8
Source File: TestAlertHandler.java From nifi with Apache License 2.0 | 6 votes |
@Before public void setup() throws InitializationException { runner = TestRunners.newTestRunner(TestProcessor.class); mockComponentLog = new MockComponentLog(); AlertHandler handler = new MockAlertHandler(mockComponentLog); mockAlertBulletinRepository = new MockAlertBulletinRepository(); runner.addControllerService("MockAlertHandler", handler); runner.enableControllerService(handler); alertHandler = (AlertHandler) runner.getProcessContext() .getControllerServiceLookup() .getControllerService("MockAlertHandler"); reportingContext = Mockito.mock(ReportingContext.class); Mockito.when(reportingContext.getBulletinRepository()).thenReturn(mockAlertBulletinRepository); Mockito.when(reportingContext.createBulletin(anyString(), Mockito.any(Severity.class), anyString())) .thenAnswer(invocation -> BulletinFactory.createBulletin(invocation.getArgument(0), invocation.getArgument(1).toString(), invocation.getArgument(2))); }
Example #9
Source File: TestAlertHandler.java From nifi with Apache License 2.0 | 6 votes |
@Test public void testEmptyBulletinRepository(){ final Map<String, String> attributes = new HashMap<>(); final Map<String, Object> metrics = new HashMap<>(); final String category = "Rules Alert"; final String message = "This should be sent as an alert!"; final String severity = "INFO"; attributes.put("category", category); attributes.put("message", message); attributes.put("severity", severity); metrics.put("jvmHeap", "1000000"); metrics.put("cpu", "90"); final Action action = new Action(); action.setType("ALERT"); action.setAttributes(attributes); ReportingContext fakeContext = Mockito.mock(ReportingContext.class); Mockito.when(reportingContext.getBulletinRepository()).thenReturn(null); alertHandler.execute(fakeContext, action, metrics); final String warnMessage = mockComponentLog.getWarnMessage(); assertTrue(StringUtils.isNotEmpty(warnMessage)); assertEquals(warnMessage,"Bulletin Repository is not available which is unusual. Cannot send a bulletin."); }
Example #10
Source File: MetricsEventReportingTask.java From nifi with Apache License 2.0 | 6 votes |
private void fireRules(ReportingContext context, PropertyContextActionHandler actionHandler, RulesEngineService engine, String query) throws Exception { QueryResult queryResult = metricsQueryService.query(context, query); getLogger().debug("Executing query: {}", new Object[]{ query }); ResultSetRecordSet recordSet = metricsQueryService.getResultSetRecordSet(queryResult); Record record; try { while ((record = recordSet.next()) != null) { final Map<String, Object> facts = new HashMap<>(); for (String fieldName : record.getRawFieldNames()) { facts.put(fieldName, record.getValue(fieldName)); } List<Action> actions = engine.fireRules(facts); if(actions == null || actions.isEmpty()){ getLogger().debug("No actions required for provided facts."); } else { actions.forEach(action -> { actionHandler.execute(context, action,facts); }); } } } finally { metricsQueryService.closeQuietly(recordSet); } }
Example #11
Source File: PrometheusServer.java From nifi with Apache License 2.0 | 6 votes |
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { if (logger.isDebugEnabled()) { logger.debug("PrometheusServer Do get called"); } ServletOutputStream response = resp.getOutputStream(); OutputStreamWriter osw = new OutputStreamWriter(response); for(Function<ReportingContext, CollectorRegistry> mc : metricsCollectors) { CollectorRegistry collectorRegistry = mc.apply(getReportingContext()); TextFormat.write004(osw, collectorRegistry.metricFamilySamples()); } osw.flush(); osw.close(); response.flush(); response.close(); resp.setHeader("Content-Type", TextFormat.CONTENT_TYPE_004); resp.setStatus(HttpURLConnection.HTTP_OK); resp.flushBuffer(); }
Example #12
Source File: TestDataDogReportingTask.java From nifi with Apache License 2.0 | 6 votes |
private void initContexts() { configurationContext = Mockito.mock(ConfigurationContext.class); context = Mockito.mock(ReportingContext.class); Mockito.when(context.getProperty(DataDogReportingTask.ENVIRONMENT)) .thenReturn(new MockPropertyValue(env, null)); Mockito.when(context.getProperty(DataDogReportingTask.METRICS_PREFIX)) .thenReturn(new MockPropertyValue(prefix, null)); Mockito.when(context.getProperty(DataDogReportingTask.API_KEY)) .thenReturn(new MockPropertyValue("agent", null)); Mockito.when(context.getProperty(DataDogReportingTask.DATADOG_TRANSPORT)) .thenReturn(new MockPropertyValue("DataDog Agent", null)); EventAccess eventAccess = Mockito.mock(EventAccess.class); Mockito.when(eventAccess.getControllerStatus()).thenReturn(status); Mockito.when(context.getEventAccess()).thenReturn(eventAccess); logger = Mockito.mock(Logger.class); initContext = Mockito.mock(ReportingInitializationContext.class); Mockito.when(initContext.getIdentifier()).thenReturn(UUID.randomUUID().toString()); //Mockito.when(initContext.getLogger()).thenReturn(logger); metricsMap = new ConcurrentHashMap<>(); metricRegistry = Mockito.mock(MetricRegistry.class); virtualMachineMetrics = JmxJvmMetrics.getInstance(); metricsService = Mockito.mock(MetricsService.class); }
Example #13
Source File: TestDataDogReportingTask.java From localization_nifi with Apache License 2.0 | 6 votes |
private void initContexts() { configurationContext = Mockito.mock(ConfigurationContext.class); context = Mockito.mock(ReportingContext.class); Mockito.when(context.getProperty(DataDogReportingTask.ENVIRONMENT)) .thenReturn(new MockPropertyValue(env, null)); Mockito.when(context.getProperty(DataDogReportingTask.METRICS_PREFIX)) .thenReturn(new MockPropertyValue(prefix, null)); Mockito.when(context.getProperty(DataDogReportingTask.API_KEY)) .thenReturn(new MockPropertyValue("agent", null)); Mockito.when(context.getProperty(DataDogReportingTask.DATADOG_TRANSPORT)) .thenReturn(new MockPropertyValue("DataDog Agent", null)); EventAccess eventAccess = Mockito.mock(EventAccess.class); Mockito.when(eventAccess.getControllerStatus()).thenReturn(status); Mockito.when(context.getEventAccess()).thenReturn(eventAccess); logger = Mockito.mock(Logger.class); initContext = Mockito.mock(ReportingInitializationContext.class); Mockito.when(initContext.getIdentifier()).thenReturn(UUID.randomUUID().toString()); //Mockito.when(initContext.getLogger()).thenReturn(logger); metricsMap = new ConcurrentHashMap<>(); metricRegistry = Mockito.mock(MetricRegistry.class); virtualMachineMetrics = VirtualMachineMetrics.getInstance(); metricsService = Mockito.mock(MetricsService.class); }
Example #14
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 #15
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 #16
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 #17
Source File: DataDogReportingTask.java From nifi with Apache License 2.0 | 5 votes |
private void updateDataDogTransport(ReportingContext context) throws IOException { String dataDogTransport = context.getProperty(DATADOG_TRANSPORT).getValue(); if (dataDogTransport.equalsIgnoreCase(DATADOG_AGENT.getValue())) { ddMetricRegistryBuilder.build("agent"); } else if (dataDogTransport.equalsIgnoreCase(DATADOG_HTTP.getValue()) && context.getProperty(API_KEY).isSet()) { ddMetricRegistryBuilder.build(context.getProperty(API_KEY).getValue()); } }
Example #18
Source File: MetricsEventReportingTask.java From nifi with Apache License 2.0 | 5 votes |
@Override public void onTrigger(ReportingContext context) { try { final String query = context.getProperty(QueryMetricsUtil.QUERY).evaluateAttributeExpressions().getValue(); fireRules(context, actionHandler, rulesEngineService, query); } catch (Exception e) { getLogger().error("Error opening loading rules: {}", new Object[]{e.getMessage()}, e); } }
Example #19
Source File: MetricsSqlQueryService.java From nifi with Apache License 2.0 | 5 votes |
private CachedStatement buildCachedStatement(final String sql, final ReportingContext context) throws Exception { final CalciteConnection connection = createConnection(); final SchemaPlus rootSchema = createRootSchema(connection); final ConnectionStatusTable connectionStatusTable = new ConnectionStatusTable(context, getLogger()); rootSchema.add("CONNECTION_STATUS", connectionStatusTable); if (context.isAnalyticsEnabled()) { final ConnectionStatusPredictionsTable connectionStatusPredictionsTable = new ConnectionStatusPredictionsTable(context, getLogger()); rootSchema.add("CONNECTION_STATUS_PREDICTIONS", connectionStatusPredictionsTable); } else { getLogger().debug("Analytics is not enabled, CONNECTION_STATUS_PREDICTIONS table is not available for querying"); } final ProcessorStatusTable processorStatusTable = new ProcessorStatusTable(context, getLogger()); rootSchema.add("PROCESSOR_STATUS", processorStatusTable); final ProcessGroupStatusTable processGroupStatusTable = new ProcessGroupStatusTable(context, getLogger()); rootSchema.add("PROCESS_GROUP_STATUS", processGroupStatusTable); final JvmMetricsTable jvmMetricsTable = new JvmMetricsTable(context, getLogger()); rootSchema.add("JVM_METRICS", jvmMetricsTable); final BulletinTable bulletinTable = new BulletinTable(context, getLogger()); rootSchema.add("BULLETINS", bulletinTable); final ProvenanceTable provenanceTable = new ProvenanceTable(context, getLogger()); rootSchema.add("PROVENANCE", provenanceTable); rootSchema.setCacheEnabled(false); final PreparedStatement stmt = connection.prepareStatement(sql); return new CachedStatement(stmt, connection); }
Example #20
Source File: MonitorDiskUsage.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public void onTrigger(final ReportingContext context) { final String thresholdValue = context.getProperty(DIR_THRESHOLD).getValue(); final Matcher thresholdMatcher = PERCENT_PATTERN.matcher(thresholdValue.trim()); thresholdMatcher.find(); final String thresholdPercentageVal = thresholdMatcher.group(1); final int contentRepoThreshold = Integer.parseInt(thresholdPercentageVal); final File dir = new File(context.getProperty(DIR_LOCATION).getValue()); final String dirName = context.getProperty(DIR_DISPLAY_NAME).getValue(); checkThreshold(dirName, dir.toPath(), contentRepoThreshold, getLogger()); }
Example #21
Source File: JvmMetricsEnumerator.java From nifi with Apache License 2.0 | 5 votes |
public JvmMetricsEnumerator(final ReportingContext context, final ComponentLog logger, final int[] fields) { this.context = context; this.logger = logger; this.fields = fields; reset(); virtualMachineMetrics = JmxJvmMetrics.getInstance(); }
Example #22
Source File: ReportLineageToAtlas.java From nifi with Apache License 2.0 | 5 votes |
/** * In order to avoid authentication expiration issues (i.e. Kerberos ticket and DelegationToken expiration), * create Atlas client instance at every onTrigger execution. */ protected NiFiAtlasClient createNiFiAtlasClient(ReportingContext context) { List<String> urls = parseAtlasUrls(context.getProperty(ATLAS_URLS)); try { return new NiFiAtlasClient(atlasAuthN.createClient(urls.toArray(new String[]{}))); } catch (final NullPointerException e) { throw new ProcessException(String.format("Failed to initialize Atlas client due to %s." + " Make sure 'atlas-application.properties' is in the directory specified with %s" + " or under root classpath if not specified.", e, ATLAS_CONF_DIR.getDisplayName()), e); } }
Example #23
Source File: TestReportLineageToAtlas.java From nifi with Apache License 2.0 | 5 votes |
private void testSetup( Properties atlasConf, Consumer<Map<PropertyDescriptor, String>> propertiesAdjustment, Runnable onSuccess, Consumer<Exception> exceptionConsumer ) throws Exception { // GIVEN String atlasConfDir = createAtlasConfDir(); Map<PropertyDescriptor, String> properties = initReportingTaskProperties(atlasConfDir); propertiesAdjustment.accept(properties); saveAtlasConf(atlasConfDir, atlasConf); reportingContext = mock(ReportingContext.class); when(reportingContext.getProperties()).thenReturn(properties); when(reportingContext.getProperty(any())).then(invocation -> new MockPropertyValue(properties.get(invocation.getArguments()[0]))); ConfigurationContext configurationContext = new MockConfigurationContext(properties, null); testSubject.initialize(initializationContext); // WHEN try { testSubject.setup(configurationContext); onSuccess.run(); // THEN } catch (Exception e) { exceptionConsumer.accept(e); } }
Example #24
Source File: TestReportLineageToAtlas.java From nifi with Apache License 2.0 | 5 votes |
private void testConnectAndReadTimeout(Map<PropertyDescriptor, String> properties, Integer expectedConnectTimeout, Integer expectedReadTimeout) throws Exception { // GIVEN reportingContext = mock(ReportingContext.class); when(reportingContext.getProperties()).thenReturn(properties); when(reportingContext.getProperty(any())).then(invocation -> new MockPropertyValue(properties.get(invocation.getArguments()[0]))); ConfigurationContext configurationContext = new MockConfigurationContext(properties, null); testSubject.initialize(initializationContext); testSubject.setup(configurationContext); // WHEN NiFiAtlasClient niFiAtlasClient = testSubject.createNiFiAtlasClient(reportingContext); // THEN Field fieldAtlasClient = niFiAtlasClient.getClass().getDeclaredField("atlasClient"); fieldAtlasClient.setAccessible(true); AtlasClientV2 atlasClient = (AtlasClientV2) fieldAtlasClient.get(niFiAtlasClient); Field fieldAtlasClientContext = atlasClient.getClass().getSuperclass().getDeclaredField("atlasClientContext"); fieldAtlasClientContext.setAccessible(true); Object atlasClientContext = fieldAtlasClientContext.get(atlasClient); Method getClient = atlasClientContext.getClass().getMethod("getClient"); getClient.setAccessible(true); Client jerseyClient = (Client) getClient.invoke(atlasClientContext); Map<String, Object> jerseyProperties = jerseyClient.getProperties(); Integer actualConnectTimeout = (Integer) jerseyProperties.get("com.sun.jersey.client.property.connectTimeout"); Integer actualReadTimeout = (Integer) jerseyProperties.get("com.sun.jersey.client.property.readTimeout"); assertEquals(expectedConnectTimeout, actualConnectTimeout); assertEquals(expectedReadTimeout, actualReadTimeout); }
Example #25
Source File: StandardGangliaReporter.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public void onTrigger(final ReportingContext context) { final ProcessGroupStatus rootGroupStatus = context.getEventAccess().getControllerStatus(); this.latestStatus.set(rootGroupStatus); gangliaReporter.run(); getLogger().info("{} Sent metrics to Ganglia", new Object[] {this}); }
Example #26
Source File: StandardGangliaReporter.java From nifi with Apache License 2.0 | 5 votes |
@Override public void onTrigger(final ReportingContext context) { final ProcessGroupStatus rootGroupStatus = context.getEventAccess().getControllerStatus(); this.latestStatus.set(rootGroupStatus); gangliaReporter.run(); getLogger().info("{} Sent metrics to Ganglia", new Object[] {this}); }
Example #27
Source File: MonitorDiskUsage.java From nifi with Apache License 2.0 | 5 votes |
@Override public void onTrigger(final ReportingContext context) { final String thresholdValue = context.getProperty(DIR_THRESHOLD).getValue(); final Matcher thresholdMatcher = PERCENT_PATTERN.matcher(thresholdValue.trim()); thresholdMatcher.find(); final String thresholdPercentageVal = thresholdMatcher.group(1); final int contentRepoThreshold = Integer.parseInt(thresholdPercentageVal); final File dir = new File(context.getProperty(DIR_LOCATION).getValue()); final String dirName = context.getProperty(DIR_DISPLAY_NAME).getValue(); checkThreshold(dirName, dir.toPath(), contentRepoThreshold, getLogger()); }
Example #28
Source File: ControllerStatusReportingTask.java From nifi with Apache License 2.0 | 5 votes |
@Override public void onTrigger(final ReportingContext context) { final ProcessGroupStatus controllerStatus = context.getEventAccess().getControllerStatus(); final boolean showDeltas = context.getProperty(SHOW_DELTAS).asBoolean(); final StringBuilder builder = new StringBuilder(); builder.append("Processor Statuses:\n"); builder.append(processorBorderLine); builder.append("\n"); builder.append(processorHeader); builder.append(processorBorderLine); builder.append("\n"); printProcessorStatus(controllerStatus, builder, showDeltas); builder.append(processorBorderLine); processorLogger.info(builder.toString()); builder.setLength(0); builder.append("Connection Statuses:\n"); builder.append(connectionBorderLine); builder.append("\n"); builder.append(connectionHeader); builder.append(connectionBorderLine); builder.append("\n"); printConnectionStatus(controllerStatus, builder, showDeltas); builder.append(connectionBorderLine); connectionLogger.info(builder.toString()); }
Example #29
Source File: ConnectionStatusPredictionsEnumerator.java From nifi with Apache License 2.0 | 5 votes |
public ConnectionStatusPredictionsEnumerator(final ReportingContext context, final ComponentLog logger, final int[] fields) { this.context = context; this.connectionStatusIterator = new ConnectionStatusRecursiveIterator(context); this.logger = logger; this.fields = fields; reset(); }
Example #30
Source File: ConnectionStatusEnumerator.java From nifi with Apache License 2.0 | 5 votes |
public ConnectionStatusEnumerator(final ReportingContext context, final ComponentLog logger, final int[] fields) { this.context = context; this.connectionStatusIterator = new ConnectionStatusRecursiveIterator(context); this.logger = logger; this.fields = fields; reset(); }