Browse Source

HDFS-8391. NN should consider current EC tasks handling count from DN while assigning new tasks. Contributed by Uma Maheswara Rao G.

Uma Maheswara Rao G 10 years ago
parent
commit
c99c337928

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt

@@ -212,3 +212,6 @@
 
 
     HDFS-8364. Erasure coding: fix some minor bugs in EC CLI
     HDFS-8364. Erasure coding: fix some minor bugs in EC CLI
     (Walter Su via vinayakumarb)
     (Walter Su via vinayakumarb)
+
+    HDFS-8391. NN should consider current EC tasks handling count from DN while 
+    assigning new tasks. (umamahesh)

+ 17 - 2
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java

@@ -1909,6 +1909,21 @@ public class DataNode extends ReconfigurableBase
   int getXmitsInProgress() {
   int getXmitsInProgress() {
     return xmitsInProgress.get();
     return xmitsInProgress.get();
   }
   }
+  
+  /**
+   * Increments the xmitsInProgress count. xmitsInProgress count represents the
+   * number of data replication/reconstruction tasks running currently.
+   */
+  public void incrementXmitsInProgress() {
+    xmitsInProgress.getAndIncrement();
+  }
+
+  /**
+   * Decrements the xmitsInProgress count
+   */
+  public void decrementXmitsInProgress() {
+    xmitsInProgress.getAndDecrement();
+  }
 
 
   private void reportBadBlock(final BPOfferService bpos,
   private void reportBadBlock(final BPOfferService bpos,
       final ExtendedBlock block, final String msg) {
       final ExtendedBlock block, final String msg) {
@@ -2128,7 +2143,7 @@ public class DataNode extends ReconfigurableBase
      */
      */
     @Override
     @Override
     public void run() {
     public void run() {
-      xmitsInProgress.getAndIncrement();
+      incrementXmitsInProgress();
       Socket sock = null;
       Socket sock = null;
       DataOutputStream out = null;
       DataOutputStream out = null;
       DataInputStream in = null;
       DataInputStream in = null;
@@ -2207,7 +2222,7 @@ public class DataNode extends ReconfigurableBase
         // check if there are any disk problem
         // check if there are any disk problem
         checkDiskErrorAsync();
         checkDiskErrorAsync();
       } finally {
       } finally {
-        xmitsInProgress.getAndDecrement();
+        decrementXmitsInProgress();
         IOUtils.closeStream(blockSender);
         IOUtils.closeStream(blockSender);
         IOUtils.closeStream(out);
         IOUtils.closeStream(out);
         IOUtils.closeStream(in);
         IOUtils.closeStream(in);

+ 3 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/ErasureCodingWorker.java

@@ -312,6 +312,7 @@ public final class ErasureCodingWorker {
 
 
     @Override
     @Override
     public void run() {
     public void run() {
+      datanode.incrementXmitsInProgress();
       try {
       try {
         // Store the indices of successfully read source
         // Store the indices of successfully read source
         // This will be updated after doing real read.
         // This will be updated after doing real read.
@@ -397,8 +398,9 @@ public final class ErasureCodingWorker {
         // Currently we don't check the acks for packets, this is similar as
         // Currently we don't check the acks for packets, this is similar as
         // block replication.
         // block replication.
       } catch (Throwable e) {
       } catch (Throwable e) {
-        LOG.warn("Failed to recover striped block: " + blockGroup);
+        LOG.warn("Failed to recover striped block: " + blockGroup, e);
       } finally {
       } finally {
+        datanode.decrementXmitsInProgress();
         // close block readers
         // close block readers
         for (StripedReader stripedReader : stripedReaders) {
         for (StripedReader stripedReader : stripedReaders) {
           closeBlockReader(stripedReader.blockReader);
           closeBlockReader(stripedReader.blockReader);