From 74a4754d1c790b8740a4221f276aa571bc5dbfd5 Mon Sep 17 00:00:00 2001 From: Tsuyoshi Ozawa Date: Thu, 5 Mar 2015 16:05:44 +0900 Subject: [PATCH] HADOOP-11648. Set DomainSocketWatcher thread name explicitly. Contributed by Liang Xie. --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../org/apache/hadoop/net/unix/DomainSocketWatcher.java | 8 +++++--- .../apache/hadoop/net/unix/TestDomainSocketWatcher.java | 2 +- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hadoop/hdfs/server/datanode/ShortCircuitRegistry.java | 2 +- .../hadoop/hdfs/shortcircuit/DfsClientShmManager.java | 3 ++- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index d518d9f52d..92af646602 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -647,6 +647,9 @@ Release 2.7.0 - UNRELEASED HADOOP-11658. Externalize io.compression.codecs property. (Kai Zheng via aajisaka) + HADOOP-11648. Set DomainSocketWatcher thread name explicitly. + (Liang Xie via ozawa) + OPTIMIZATIONS HADOOP-11323. WritableComparator#compare keeps reference to byte array. diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocketWatcher.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocketWatcher.java index 8c617dc8c8..03b52e0f8c 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocketWatcher.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/unix/DomainSocketWatcher.java @@ -238,7 +238,8 @@ private static class FdSet { */ private boolean kicked = false; - public DomainSocketWatcher(int interruptCheckPeriodMs) throws IOException { + public DomainSocketWatcher(int interruptCheckPeriodMs, String src) + throws IOException { if (loadingFailureReason != null) { throw new UnsupportedOperationException(loadingFailureReason); } @@ -246,8 +247,9 @@ public DomainSocketWatcher(int interruptCheckPeriodMs) throws IOException { this.interruptCheckPeriodMs = interruptCheckPeriodMs; notificationSockets = DomainSocket.socketpair(); watcherThread.setDaemon(true); - watcherThread.setUncaughtExceptionHandler( - new Thread.UncaughtExceptionHandler() { + watcherThread.setName(src + " DomainSocketWatcher"); + watcherThread + .setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread thread, Throwable t) { LOG.error(thread + " terminating on unexpected exception", t); diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/unix/TestDomainSocketWatcher.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/unix/TestDomainSocketWatcher.java index e85e414135..4b0e2a80b7 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/unix/TestDomainSocketWatcher.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/net/unix/TestDomainSocketWatcher.java @@ -195,7 +195,7 @@ public void run() { private DomainSocketWatcher newDomainSocketWatcher(int interruptCheckPeriodMs) throws Exception { DomainSocketWatcher watcher = new DomainSocketWatcher( - interruptCheckPeriodMs); + interruptCheckPeriodMs, getClass().getSimpleName()); watcher.watcherThread.setUncaughtExceptionHandler( new Thread.UncaughtExceptionHandler() { @Override diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index f9541e042b..59f69fb85d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -712,6 +712,9 @@ Release 2.7.0 - UNRELEASED HDFS-7746. Add a test randomly mixing append, truncate and snapshot operations. (szetszwo) + HADOOP-11648. Set DomainSocketWatcher thread name explicitly. + (Liang Xie via ozawa) + OPTIMIZATIONS HDFS-7454. Reduce memory footprint for AclEntries in NameNode. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ShortCircuitRegistry.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ShortCircuitRegistry.java index 965b40a0c4..32906f4182 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ShortCircuitRegistry.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/ShortCircuitRegistry.java @@ -176,7 +176,7 @@ public ShortCircuitRegistry(Configuration conf) throws IOException { if (dswLoadingFailure != null) { throw new IOException(dswLoadingFailure); } - watcher = new DomainSocketWatcher(interruptCheck); + watcher = new DomainSocketWatcher(interruptCheck, "datanode"); enabled = true; if (LOG.isDebugEnabled()) { LOG.debug("created new ShortCircuitRegistry with interruptCheck=" + diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/shortcircuit/DfsClientShmManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/shortcircuit/DfsClientShmManager.java index 6dbaf84d26..9092bc531f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/shortcircuit/DfsClientShmManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/shortcircuit/DfsClientShmManager.java @@ -412,7 +412,8 @@ final void shutdown(DfsClientShm shm) { private final DomainSocketWatcher domainSocketWatcher; DfsClientShmManager(int interruptCheckPeriodMs) throws IOException { - this.domainSocketWatcher = new DomainSocketWatcher(interruptCheckPeriodMs); + this.domainSocketWatcher = new DomainSocketWatcher(interruptCheckPeriodMs, + "client"); } public Slot allocSlot(DatanodeInfo datanode, DomainPeer peer,