summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2020-09-04 11:32:32 +0200
committerJon Bratseth <bratseth@gmail.com>2020-09-04 11:32:32 +0200
commitd5c995fdce77adbefe406b16d2c8849c7bcb9e5b (patch)
tree22f743add35a98fae051d88301fd1c6007cc1d91
parentf54266496dc50f43a510eb1714ad2853ebd56005 (diff)
Check whether we should poll every pollInterval
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java
index 7bd0918eb74..7536c44e68e 100644
--- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java
+++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java
@@ -556,17 +556,25 @@ public class IOThread implements Runnable, AutoCloseable {
@Override
public void run() {
- while (stopSignal.getCount() > 0)
+ while (stopSignal.getCount() > 0) {
checkOldConnections();
+ try {
+ Thread.sleep(pollIntervalUS/1000);
+ }
+ catch (InterruptedException e) {
+ }
+ }
}
public void checkOldConnections() {
- List<GatewayConnection> toRemove = new ArrayList<>();
+ List<GatewayConnection> toRemove = null;
for (GatewayConnection connection : connections) {
if (closingTime(connection).isBefore(clock.instant())) {
try {
IOThread.processResponse(connection.poll(), endpoint, clusterId, statusReceivedCounter, resultQueue);
connection.close();
+ if (toRemove == null)
+ toRemove = new ArrayList<>(1);
toRemove.add(connection);
} catch (Exception e) {
// Old connection; best effort
@@ -579,7 +587,8 @@ public class IOThread implements Runnable, AutoCloseable {
}
}
}
- connections.removeAll(toRemove);
+ if (toRemove != null)
+ connections.removeAll(toRemove);
}
private boolean timeToPoll(GatewayConnection connection) {