Force wait queue handler to wake up every time a request is queue
@@ -255,7 +255,7 @@ abstract class BaseCluster implements Cluster {
}
description = newDescription;
- phase.getAndSet(new CountDownLatch(1)).countDown();
+ updatePhase();
}
protected void fireChangeEvent(final ClusterDescriptionChangedEvent event) {
@@ -267,6 +267,10 @@ abstract class BaseCluster implements Cluster {
return description;
}
+ private synchronized void updatePhase() {
+ phase.getAndSet(new CountDownLatch(1)).countDown();
+ }
+
private long getMaxWaitTimeNanos() {
if (settings.getServerSelectionTimeout(NANOSECONDS) < 0) {
return Long.MAX_VALUE;
@@ -463,6 +467,8 @@ abstract class BaseCluster implements Cluster {
waitQueueHandler = new Thread(new WaitQueueHandler(), "cluster-" + clusterId.getValue());
waitQueueHandler.setDaemon(true);
waitQueueHandler.start();
+ } else {
+ updatePhase();
}
}
}
