SAMZA-1731: Daemonize threads spawned from SamzaEventHubClientManager.
authorShanthoosh Venkataraman <santhoshvenkat1988@gmail.com>
Wed, 30 May 2018 03:13:41 +0000 (20:13 -0700)
committerJagadish <jvenkatraman@linkedin.com>
Wed, 30 May 2018 03:13:41 +0000 (20:13 -0700)
**Problem:**
Existing SamzaEventHubClientManager implementation spawns non-daemon threads when instantiating EventHubClient. These non-daemon threads stalls shutdown of samza processes even when the main thread has exited.

**Fix:**
Daemonize threads that are spawned from SamzaEventHubClientManager.

Author: Shanthoosh Venkataraman <santhoshvenkat1988@gmail.com>

Reviewers: Jagadish <jagadish@apache.org>

Closes #536 from shanthoosh/SAMZA-1731

samza-azure/src/main/java/org/apache/samza/system/eventhub/SamzaEventHubClientManager.java

index 22621f3..ee51584 100644 (file)
@@ -84,7 +84,7 @@ public class SamzaEventHubClientManager implements EventHubClientManager {
           .setSasKeyName(sasKeyName)
           .setSasKey(sasKey);
 
-      ThreadFactoryBuilder threadFactoryBuilder = new ThreadFactoryBuilder().setNameFormat("Samza EventHubClient Thread-%d");
+      ThreadFactoryBuilder threadFactoryBuilder = new ThreadFactoryBuilder().setNameFormat("Samza EventHubClient Thread-%d").setDaemon(true);
       eventHubClientExecutor = Executors.newFixedThreadPool(numClientThreads, threadFactoryBuilder.build());
       eventHubClient = EventHubClient.createSync(connectionStringBuilder.toString(), retryPolicy, eventHubClientExecutor);
     } catch (IOException | EventHubException e) {