From f805d48b198471969f070abc49170082dd826e3b 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. (cherry picked from commit 74a4754d1c790b8740a4221f276aa571bc5dbfd5) --- 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 f4728b21f85..d7b0980c0bd 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -227,6 +227,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 8c617dc8c82..03b52e0f8c4 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 @@ public final class DomainSocketWatcher implements Closeable { */ 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 final class DomainSocketWatcher implements Closeable { 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 e85e4141354..4b0e2a80b7b 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 class TestDomainSocketWatcher { 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 fe1c9701e0b..4491d8ada12 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -407,6 +407,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 965b40a0c45..32906f4182d 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 class ShortCircuitRegistry { 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 6dbaf84d269..9092bc531f1 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 @@ public class DfsClientShmManager implements Closeable { 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,