summaryrefslogtreecommitdiffstats
path: root/vespaclient-container-plugin
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-09-30 14:18:03 +0200
committerJon Marius Venstad <venstad@gmail.com>2020-09-30 14:18:03 +0200
commit88e20c1dea7d982343d417ae55c04add0ebca99a (patch)
treee770084eae0793b70752ce09585786fc1056ef3f /vespaclient-container-plugin
parent08016b3290700eb06e5c4c899a2d2e78ae746080 (diff)
Use named threads for maintenance
Diffstat (limited to 'vespaclient-container-plugin')
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/DocumentOperationExecutorImpl.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/DocumentOperationExecutorImpl.java b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/DocumentOperationExecutorImpl.java
index 824f6b901d3..135b6a824c8 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/DocumentOperationExecutorImpl.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/DocumentOperationExecutorImpl.java
@@ -2,6 +2,7 @@
package com.yahoo.document.restapi;
import com.yahoo.cloud.config.ClusterListConfig;
+import com.yahoo.concurrent.DaemonThreadFactory;
import com.yahoo.document.Document;
import com.yahoo.document.DocumentId;
import com.yahoo.document.DocumentPut;
@@ -103,11 +104,11 @@ public class DocumentOperationExecutorImpl implements DocumentOperationExecutor
this.asyncSession = access.createAsyncSession(new AsyncParameters());
this.clock = requireNonNull(clock);
this.clusters = Map.copyOf(clusters);
- this.throttled = new DelayQueue(maxThrottled, this::send, resendDelay, clock);
+ this.throttled = new DelayQueue(maxThrottled, this::send, resendDelay, clock, "throttle");
this.timeouts = new DelayQueue(Long.MAX_VALUE, (__, context) -> {
context.error(TIMEOUT, "Timed out after " + defaultTimeout);
return true;
- }, defaultTimeout, clock);
+ }, defaultTimeout, clock, "timeout");
}
private static VisitorParameters asParameters(VisitorOptions options, Map<String, StorageCluster> clusters, Duration visitTimeout) {
@@ -295,7 +296,8 @@ public class DocumentOperationExecutorImpl implements DocumentOperationExecutor
private final Duration delay;
private final long defaultWaitMillis;
- public DelayQueue(long maxSize, BiPredicate<Supplier<Result>, OperationContext> action, Duration delay, Clock clock) {
+ public DelayQueue(long maxSize, BiPredicate<Supplier<Result>, OperationContext> action,
+ Duration delay, Clock clock, String threadName) {
if (maxSize < 0)
throw new IllegalArgumentException("Max size cannot be negative, but was " + maxSize);
if (delay.isNegative())
@@ -305,7 +307,7 @@ public class DocumentOperationExecutorImpl implements DocumentOperationExecutor
this.delay = delay;
this.defaultWaitMillis = Math.min(delay.toMillis(), 100); // Run regularly to evict handled contexts.
this.clock = requireNonNull(clock);
- this.maintainer = new Thread(() -> maintain(action));
+ this.maintainer = new DaemonThreadFactory("document-operation-executor-" + threadName).newThread(() -> maintain(action));
this.maintainer.start();
}