Github user ijokarumawak commented on a diff in the pull request:
https://github.com/apache/nifi/pull/575#discussion_r70728563
--- Diff:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/MonitorActivity.java
---
@@ -234,4 +361,10 @@ public void process(final OutputStream out) throws
IOException {
}
}
}
+
+ @OnPrimaryNodeStateChange
+ public void onPrimaryNodeChange(final PrimaryNodeState newState) {
+ isPrimaryNode = (newState ==
PrimaryNodeState.ELECTED_PRIMARY_NODE);
--- End diff --
This is a great catch, thank you!
@JPercivall in different PR I'm working on, #563 also needs similar
functionality to know whether it's running on a standalone or clustered NiFi,
and if latter whether it's a primary node.
I'm going to try adding a new `@OnAddedToCluster` lifecycle annotation
taking one argument `isPrimaryNode`. Using it together with
`@OnPrimaryNodeStateChange` Processors, Reporting tasks, and Controller
services will be able to control its behavior well in a clustered environment.
How do you think?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---