Naming Anonymous Threads in OVSDB 52/85752/6
authorxcheara <chetan.arakere@altencalsoftlabs.com>
Fri, 1 Nov 2019 23:14:55 +0000 (04:44 +0530)
committerChetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Sun, 22 Dec 2019 13:03:07 +0000 (13:03 +0000)
JIRA : OVSDB-454

Description:
There are few Anonymous Threads created in OVSDB. It will be difficult to
identify which component created these threads based on the logs
available.

Changes done to provide proper Name to these Threads when created which
helps to easily identify the component owner of such threads.

Signed-off-by: xcheara <chetan.arakere@altencalsoftlabs.com>
Change-Id: I061abd449f81c7cc2c7c847cb1a0f82d62d7e654
Signed-off-by: xcheara <chetan.arakere@altencalsoftlabs.com>
hwvtepsouthbound/hwvtepsouthbound-impl/src/main/java/org/opendaylight/ovsdb/hwvtepsouthbound/HwvtepConnectionInstance.java

index 6e141e98f1f7bbd871844228c4eb29f2966f8ad5..46e795e12868129e5c61356d98e9688a39c9783d 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.SettableFuture;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -77,7 +78,9 @@ public class HwvtepConnectionInstance {
     private final HwvtepDeviceInfo deviceInfo;
     private final DataBroker dataBroker;
     private final HwvtepConnectionManager hwvtepConnectionManager;
-    private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
+    private static final ScheduledExecutorService SCHEDULED_EXECUTOR_SERVICE = Executors
+        .newSingleThreadScheduledExecutor(new ThreadFactoryBuilder()
+        .setNameFormat("HwvtepReconciliationFT-%d").build());
     @VisibleForTesting
     final SettableFuture<Boolean> reconciliationFt = SettableFuture.create();
     @VisibleForTesting
@@ -121,7 +124,7 @@ public class HwvtepConnectionInstance {
 
             if (firstUpdate) {
                 LOG.info("Scheduling the reconciliation timeout task {}", nodeId);
-                scheduledExecutorService.schedule(() -> reconciliationFt.set(Boolean.TRUE),
+                SCHEDULED_EXECUTOR_SERVICE.schedule(() -> reconciliationFt.set(Boolean.TRUE),
                         HwvtepSouthboundConstants.CONFIG_NODE_UPDATE_MAX_DELAY_MS, TimeUnit.MILLISECONDS);
             }
         }