This is an automated email from the ASF dual-hosted git repository.

alopresto pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new 996688b  NIFI-7389 Makes Missable heartbeat counts configurable
996688b is described below

commit 996688b4194fbae27b1fca005e9031276487597d
Author: Sushil Kumar <[email protected]>
AuthorDate: Fri Apr 24 14:50:01 2020 -0700

    NIFI-7389 Makes Missable heartbeat counts configurable
    
    This closes #4236.
    
    Signed-off-by: Andy LoPresto <[email protected]>
---
 .../src/main/java/org/apache/nifi/util/NiFiProperties.java        | 2 ++
 nifi-docs/src/main/asciidoc/administration-guide.adoc             | 5 +++--
 .../cluster/coordination/heartbeat/AbstractHeartbeatMonitor.java  | 8 ++++++--
 .../src/test/resources/int-tests/clustered-nifi.properties        | 1 +
 .../src/test/resources/int-tests/default-nifi.properties          | 1 +
 .../nifi-framework-bundle/nifi-framework/nifi-resources/pom.xml   | 1 +
 .../nifi-resources/src/main/resources/conf/nifi.properties        | 1 +
 7 files changed, 15 insertions(+), 4 deletions(-)

diff --git 
a/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
 
b/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
index 6bbc921..f0e8e6b 100644
--- 
a/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
+++ 
b/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
@@ -203,6 +203,7 @@ public abstract class NiFiProperties {
 
     // cluster common properties
     public static final String CLUSTER_PROTOCOL_HEARTBEAT_INTERVAL = 
"nifi.cluster.protocol.heartbeat.interval";
+    public static final String CLUSTER_PROTOCOL_HEARTBEAT_MISSABLE_MAX = 
"nifi.cluster.protocol.heartbeat.missable.max";
     public static final String CLUSTER_PROTOCOL_IS_SECURE = 
"nifi.cluster.protocol.is.secure";
 
     // cluster node properties
@@ -305,6 +306,7 @@ public abstract class NiFiProperties {
 
     // cluster common defaults
     public static final String DEFAULT_CLUSTER_PROTOCOL_HEARTBEAT_INTERVAL = 
"5 sec";
+    public static final int DEFAULT_CLUSTER_PROTOCOL_HEARTBEAT_MISSABLE_MAX = 
8;
     public static final String 
DEFAULT_CLUSTER_PROTOCOL_MULTICAST_SERVICE_BROADCAST_DELAY = "500 ms";
     public static final int 
DEFAULT_CLUSTER_PROTOCOL_MULTICAST_SERVICE_LOCATOR_ATTEMPTS = 3;
     public static final String 
DEFAULT_CLUSTER_PROTOCOL_MULTICAST_SERVICE_LOCATOR_ATTEMPTS_DELAY = "1 sec";
diff --git a/nifi-docs/src/main/asciidoc/administration-guide.adoc 
b/nifi-docs/src/main/asciidoc/administration-guide.adoc
index 874b85f..0b941bc 100644
--- a/nifi-docs/src/main/asciidoc/administration-guide.adoc
+++ b/nifi-docs/src/main/asciidoc/administration-guide.adoc
@@ -1629,8 +1629,8 @@ It just depends on the resources available and how the 
Administrator decides to
 
 *Heartbeats*: The nodes communicate their health and status to the currently 
elected Cluster Coordinator via "heartbeats",
 which let the Coordinator know they are still connected to the cluster and 
working properly. By default, the nodes emit
-heartbeats every 5 seconds, and if the Cluster Coordinator does not receive a 
heartbeat from a node within 40 seconds, it
-disconnects the node due to "lack of heartbeat". The 5-second setting is 
configurable in the _nifi.properties_ file (see
+heartbeats every 5 seconds, and if the Cluster Coordinator does not receive a 
heartbeat from a node within 40 seconds (= 5 seconds * 8), it
+disconnects the node due to "lack of heartbeat". The 5-second and 8 times 
settings are configurable in the _nifi.properties_ file (see
 the <<cluster_common_properties>> section for more information). The reason 
that the Cluster Coordinator
 disconnects the node is because the Coordinator needs to ensure that every 
node in the cluster is in sync, and if a node
 is not heard from regularly, the Coordinator cannot be sure it is still in 
sync with the rest of the cluster. If, after
@@ -3334,6 +3334,7 @@ When setting up a NiFi cluster, these properties should 
be configured the same w
 |====
 |*Property*|*Description*
 |`nifi.cluster.protocol.heartbeat.interval`|The interval at which nodes should 
emit heartbeats to the Cluster Coordinator. The default value is `5 sec`.
+|`nifi.cluster.protocol.heartbeat.missable.max`|Maximum number of heartbeats a 
Cluster Coordinator can miss for a node in the cluster before the Cluster 
Coordinator updates the node status to Disconnected. The default value is `8`.
 |`nifi.cluster.protocol.is.secure`|This indicates whether cluster 
communications are secure. The default value is `false`.
 |====
 
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/heartbeat/AbstractHeartbeatMonitor.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/heartbeat/AbstractHeartbeatMonitor.java
index 53fefb4..55d1e30 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/heartbeat/AbstractHeartbeatMonitor.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/heartbeat/AbstractHeartbeatMonitor.java
@@ -38,6 +38,7 @@ import java.util.concurrent.TimeUnit;
 public abstract class AbstractHeartbeatMonitor implements HeartbeatMonitor {
 
     private final int heartbeatIntervalMillis;
+    private final int missableHeartbeatCount;
     private static final Logger logger = 
LoggerFactory.getLogger(AbstractHeartbeatMonitor.class);
     protected final ClusterCoordinator clusterCoordinator;
     protected final FlowEngine flowEngine = new FlowEngine(1, "Heartbeat 
Monitor", true);
@@ -51,6 +52,9 @@ public abstract class AbstractHeartbeatMonitor implements 
HeartbeatMonitor {
                 NiFiProperties.DEFAULT_CLUSTER_PROTOCOL_HEARTBEAT_INTERVAL);
         this.heartbeatIntervalMillis = (int) 
FormatUtils.getTimeDuration(heartbeatInterval, TimeUnit.MILLISECONDS);
 
+        this.missableHeartbeatCount = 
nifiProperties.getIntegerProperty(NiFiProperties.CLUSTER_PROTOCOL_HEARTBEAT_MISSABLE_MAX,
+                
NiFiProperties.DEFAULT_CLUSTER_PROTOCOL_HEARTBEAT_MISSABLE_MAX);
+
         // Register an event listener so that if any nodes are removed, we 
also remove the heartbeat.
         // Otherwise, we'll have a condition where a node is removed from the 
Cluster Coordinator, but its heartbeat has already been received.
         // As a result, when it is processed, we will ask the node to 
reconnect, adding it back to the cluster.
@@ -158,8 +162,8 @@ public abstract class AbstractHeartbeatMonitor implements 
HeartbeatMonitor {
         procStopWatch.stop();
         logger.info("Finished processing {} heartbeats in {}", 
latestHeartbeats.size(), procStopWatch.getDuration());
 
-        // Disconnect any node that hasn't sent a heartbeat in a long time (8 
times the heartbeat interval)
-        final long maxMillis = heartbeatIntervalMillis * 8;
+        // Disconnect any node that hasn't sent a heartbeat in a long time 
(CLUSTER_PROTOCOL_HEARTBEAT_MISSABLE_MAX times the heartbeat interval)
+        final long maxMillis = heartbeatIntervalMillis * 
missableHeartbeatCount;
         final long currentTimestamp = System.currentTimeMillis();
         final long threshold = currentTimestamp - maxMillis;
 
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/clustered-nifi.properties
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/clustered-nifi.properties
index 809eaf3..db79e20 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/clustered-nifi.properties
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/clustered-nifi.properties
@@ -200,6 +200,7 @@ nifi.security.user.knox.audiences=
 
 # cluster common properties (all nodes must have same values) #
 nifi.cluster.protocol.heartbeat.interval=5 sec
+nifi.cluster.protocol.heartbeat.missable.max=8
 nifi.cluster.protocol.is.secure=false
 
 # cluster node properties (only configure for cluster nodes) #
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/default-nifi.properties
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/default-nifi.properties
index 1bbb49a..38891ec 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/default-nifi.properties
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/resources/int-tests/default-nifi.properties
@@ -200,6 +200,7 @@ nifi.security.user.knox.audiences=
 
 # cluster common properties (all nodes must have same values) #
 nifi.cluster.protocol.heartbeat.interval=5 sec
+nifi.cluster.protocol.heartbeat.missable.max=8
 nifi.cluster.protocol.is.secure=false
 
 # cluster node properties (only configure for cluster nodes) #
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/pom.xml 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/pom.xml
index e21dc40..702ffe8 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/pom.xml
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/pom.xml
@@ -178,6 +178,7 @@
 
         <!-- nifi.properties: cluster common properties (cluster manager and 
nodes must have same values) -->
         <nifi.cluster.protocol.heartbeat.interval>5 
sec</nifi.cluster.protocol.heartbeat.interval>
+        
<nifi.cluster.protocol.heartbeat.missable.max>8</nifi.cluster.protocol.heartbeat.missable.max>
         
<nifi.cluster.protocol.is.secure>false</nifi.cluster.protocol.is.secure>
 
         <!-- nifi.properties: cluster node properties (only configure for 
cluster nodes) -->
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties
index 10273aa..2d55730 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties
@@ -212,6 +212,7 @@ 
nifi.security.user.knox.audiences=${nifi.security.user.knox.audiences}
 
 # cluster common properties (all nodes must have same values) #
 
nifi.cluster.protocol.heartbeat.interval=${nifi.cluster.protocol.heartbeat.interval}
+nifi.cluster.protocol.heartbeat.missable.max=${nifi.cluster.protocol.heartbeat.missable.max}
 nifi.cluster.protocol.is.secure=${nifi.cluster.protocol.is.secure}
 
 # cluster node properties (only configure for cluster nodes) #

Reply via email to