From 6add372bc142304ef25e0bafb49709654a995f08 Mon Sep 17 00:00:00 2001 From: Mike Moser Date: Wed, 4 Nov 2015 12:14:46 -0500 Subject: [PATCH] NIFI-1085 WebClusterManager fair locking and HeartbeatMonitoringTimerTask scheduling --- .../apache/nifi/cluster/manager/impl/WebClusterManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java index 8d246c1e53..c22e1ec478 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java @@ -330,7 +330,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C private final OptimisticLockingManager optimisticLockingManager; private final StringEncryptor encryptor; private final Queue pendingHeartbeats = new ConcurrentLinkedQueue<>(); - private final ReentrantReadWriteLock resourceRWLock = new ReentrantReadWriteLock(); + private final ReentrantReadWriteLock resourceRWLock = new ReentrantReadWriteLock(true); private final ClusterManagerLock readLock = new ClusterManagerLock(resourceRWLock.readLock(), "Read"); private final ClusterManagerLock writeLock = new ClusterManagerLock(resourceRWLock.writeLock(), "Write"); @@ -480,7 +480,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C try { // setup heartbeat monitoring heartbeatMonitor = new Timer("Heartbeat Monitor", /* is daemon */ true); - heartbeatMonitor.scheduleAtFixedRate(new HeartbeatMonitoringTimerTask(), 0, getHeartbeatMonitoringIntervalSeconds() * 1000); + heartbeatMonitor.schedule(new HeartbeatMonitoringTimerTask(), 0, getHeartbeatMonitoringIntervalSeconds() * 1000); heartbeatProcessor = new Timer("Process Pending Heartbeats", true); final int processPendingHeartbeatDelay = 1000 * Math.max(1, getClusterProtocolHeartbeatSeconds() / 2);