hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aengin...@apache.org
Subject [35/50] hadoop git commit: HDFS-11558. BPServiceActor thread name is too long. Contributed by Xiaobing Zhou
Date Wed, 12 Apr 2017 23:42:22 GMT
HDFS-11558. BPServiceActor thread name is too long. Contributed by Xiaobing Zhou


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/3a913767
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/3a913767
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/3a913767

Branch: refs/heads/HDFS-7240
Commit: 3a91376707d451777b8269f81bcd48315edd9fc7
Parents: 4d4ad0e
Author: Mingliang Liu <liuml07@apache.org>
Authored: Tue Apr 11 15:28:59 2017 -0700
Committer: Mingliang Liu <liuml07@apache.org>
Committed: Tue Apr 11 15:29:38 2017 -0700

----------------------------------------------------------------------
 .../hdfs/server/datanode/BPOfferService.java    | 19 ++++++++++++---
 .../hdfs/server/datanode/BPServiceActor.java    | 25 +++++++++++---------
 .../hdfs/server/datanode/BlockPoolManager.java  |  8 ++++---
 .../server/datanode/TestBPOfferService.java     |  2 +-
 .../server/datanode/TestBlockPoolManager.java   |  4 +++-
 5 files changed, 39 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/3a913767/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPOfferService.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPOfferService.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPOfferService.java
index 00e6b3e..e0daca7 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPOfferService.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPOfferService.java
@@ -70,7 +70,8 @@ class BPOfferService {
    * handshake.
    */
   volatile DatanodeRegistration bpRegistration;
-  
+
+  private final String nameserviceId;
   private final DataNode dn;
 
   /**
@@ -120,12 +121,16 @@ class BPOfferService {
     mWriteLock.unlock();
   }
 
-  BPOfferService(List<InetSocketAddress> nnAddrs,
-      List<InetSocketAddress> lifelineNnAddrs, DataNode dn) {
+  BPOfferService(
+      final String nameserviceId,
+      List<InetSocketAddress> nnAddrs,
+      List<InetSocketAddress> lifelineNnAddrs,
+      DataNode dn) {
     Preconditions.checkArgument(!nnAddrs.isEmpty(),
         "Must pass at least one NN.");
     Preconditions.checkArgument(nnAddrs.size() == lifelineNnAddrs.size(),
         "Must pass same number of NN addresses and lifeline addresses.");
+    this.nameserviceId = nameserviceId;
     this.dn = dn;
 
     for (int i = 0; i < nnAddrs.size(); ++i) {
@@ -170,6 +175,14 @@ class BPOfferService {
     return false;
   }
 
+  /**
+   * Gets nameservice id to which this {@link BPOfferService} maps to.
+   * @return nameservice id, which can be null.
+   */
+  String getNameserviceId() {
+    return nameserviceId;
+  }
+
   String getBlockPoolId() {
     readLock();
     try {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3a913767/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java
index ddc28b7..21e2a3b 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java
@@ -25,7 +25,6 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.SocketTimeoutException;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -279,7 +278,10 @@ class BPServiceActor implements Runnable {
     // This also initializes our block pool in the DN if we are
     // the first NN connection for this BP.
     bpos.verifyAndSetNamespaceInfo(this, nsInfo);
-    
+
+    /* set thread name again to include NamespaceInfo when it's available. */
+    this.bpThread.setName(formatThreadName("heartbeating", nnAddr));
+
     // Second phase of the handshake with the NN.
     register(nsInfo);
   }
@@ -547,14 +549,15 @@ class BPServiceActor implements Runnable {
       lifelineSender.start();
     }
   }
-  
-  private String formatThreadName(String action, InetSocketAddress addr) {
-    Collection<StorageLocation> dataDirs =
-        DataNode.getStorageLocations(dn.getConf());
-    return "DataNode: [" + dataDirs.toString() + "]  " +
-        action + " to " + addr;
+
+  private String formatThreadName(
+      final String action,
+      final InetSocketAddress addr) {
+    final String prefix = bpos.getBlockPoolId() != null ? bpos.getBlockPoolId()
+        : bpos.getNameserviceId();
+    return prefix + " " + action + " to " + addr;
   }
-  
+
   //This must be called only by blockPoolManager.
   void stop() {
     shouldServiceRun = false;
@@ -1008,8 +1011,8 @@ class BPServiceActor implements Runnable {
     }
 
     public void start() {
-      lifelineThread = new Thread(this, formatThreadName("lifeline",
-          lifelineNnAddr));
+      lifelineThread = new Thread(this,
+          formatThreadName("lifeline", lifelineNnAddr));
       lifelineThread.setDaemon(true);
       lifelineThread.setUncaughtExceptionHandler(
           new Thread.UncaughtExceptionHandler() {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3a913767/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolManager.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolManager.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolManager.java
index e94bbb7..f6a11c2 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockPoolManager.java
@@ -211,7 +211,7 @@ class BlockPoolManager {
             lifelineAddrs.add(nnIdToLifelineAddr != null ?
                 nnIdToLifelineAddr.get(nnId) : null);
           }
-          BPOfferService bpos = createBPOS(addrs, lifelineAddrs);
+          BPOfferService bpos = createBPOS(nsToAdd, addrs, lifelineAddrs);
           bpByNameserviceId.put(nsToAdd, bpos);
           offerServices.add(bpos);
         }
@@ -261,8 +261,10 @@ class BlockPoolManager {
   /**
    * Extracted out for test purposes.
    */
-  protected BPOfferService createBPOS(List<InetSocketAddress> nnAddrs,
+  protected BPOfferService createBPOS(
+      final String nameserviceId,
+      List<InetSocketAddress> nnAddrs,
       List<InetSocketAddress> lifelineNnAddrs) {
-    return new BPOfferService(nnAddrs, lifelineNnAddrs, dn);
+    return new BPOfferService(nameserviceId, nnAddrs, lifelineNnAddrs, dn);
   }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3a913767/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBPOfferService.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBPOfferService.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBPOfferService.java
index b9220e0..aa47eeb 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBPOfferService.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBPOfferService.java
@@ -412,7 +412,7 @@ public class TestBPOfferService {
           Mockito.eq(new InetSocketAddress(port)));
     }
 
-    return new BPOfferService(Lists.newArrayList(nnMap.keySet()),
+    return new BPOfferService("test_ns", Lists.newArrayList(nnMap.keySet()),
         Collections.<InetSocketAddress>nCopies(nnMap.size(), null), mockDn);
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3a913767/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBlockPoolManager.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBlockPoolManager.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBlockPoolManager.java
index 8bf40e3..560b32e 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBlockPoolManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBlockPoolManager.java
@@ -51,7 +51,9 @@ public class TestBlockPoolManager {
     bpm = new BlockPoolManager(mockDN){
 
       @Override
-      protected BPOfferService createBPOS(List<InetSocketAddress> nnAddrs,
+      protected BPOfferService createBPOS(
+          final String nameserviceId,
+          List<InetSocketAddress> nnAddrs,
           List<InetSocketAddress> lifelineNnAddrs) {
         final int idx = mockIdx++;
         doLog("create #" + idx);


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message