dlmarion commented on code in PR #4561:
URL: https://github.com/apache/accumulo/pull/4561#discussion_r1603212258
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftTransportPool.java:
##########
@@ -76,7 +76,8 @@ private ThriftTransportPool(LongSupplier maxAgeMillis) {
final long minNanos = MILLISECONDS.toNanos(250);
final long maxNanos = MINUTES.toNanos(1);
long lastRun = System.nanoTime();
- while (!connectionPool.shutdown) {
+ // loop often, to detect shutdowns quickly
+ while (!connectionPool.awaitShutdown(250)) {
Review Comment:
`CountDownLatch.getCount` is returning a `volatile int` and the `shutdown`
variable is a `volatile boolean`. There may be a little bit of a performance
penalty for calling `CountDownLatch.getCount` over checking `shutdown`, but I
think that may be offset by reducing the compexity of have to maintain the
state of two objects. I would use `CountDownLatch.getCount` in this case. The
javadoc suggests what it could be used for, it doesn't say not to use it.
##########
core/src/main/java/org/apache/accumulo/core/clientImpl/ThriftTransportPool.java:
##########
@@ -431,6 +433,10 @@ void shutdown() {
}
}
+ boolean awaitShutdown(long timeoutMillis) throws InterruptedException {
Review Comment:
If `shutdownLatch` is reachable from where this is called, then we could
remove this method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]