hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject hadoop git commit: HDFS-7979. Initialize block report IDs with a random number.
Date Thu, 09 Apr 2015 04:45:19 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 eafee9a04 -> 351fac25a


HDFS-7979. Initialize block report IDs with a random number.

(cherry picked from commit b1e059089d6a5b2b7006d7d384c6df81ed268bd9)


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

Branch: refs/heads/branch-2
Commit: 351fac25a994de42ec1b1218513326884a1dde43
Parents: eafee9a
Author: Andrew Wang <andrew.wang@cloudera.com>
Authored: Wed Apr 8 21:43:42 2015 -0700
Committer: Andrew Wang <andrew.wang@cloudera.com>
Committed: Wed Apr 8 21:43:57 2015 -0700

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt         |  2 ++
 .../hadoop/hdfs/server/datanode/BPServiceActor.java | 16 +++++++++-------
 .../hdfs/server/protocol/BlockReportContext.java    |  3 +++
 3 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/351fac25/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index ccec529..5a75f383 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -89,6 +89,8 @@ Release 2.8.0 - UNRELEASED
 
     HDFS-8089. Move o.a.h.hdfs.web.resources.* to the client jars. (wheat9)
 
+    HDFS-7979. Initialize block report IDs with a random number. (wang)
+
   OPTIMIZATIONS
 
     HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than

http://git-wip-us.apache.org/repos/asf/hadoop/blob/351fac25/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 dd6f9ac..ba22225 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
@@ -118,6 +118,7 @@ class BPServiceActor implements Runnable {
   private volatile boolean shouldServiceRun = true;
   private final DataNode dn;
   private final DNConf dnConf;
+  private long prevBlockReportId;
 
   private DatanodeRegistration bpRegistration;
   final LinkedList<BPServiceActorAction> bpThreadQueue 
@@ -128,6 +129,7 @@ class BPServiceActor implements Runnable {
     this.dn = bpos.getDataNode();
     this.nnAddr = nnAddr;
     this.dnConf = dn.getDnConf();
+    prevBlockReportId = DFSUtil.getRandom().nextLong();
   }
 
   boolean isAlive() {
@@ -434,15 +436,15 @@ class BPServiceActor implements Runnable {
     return sendImmediateIBR;
   }
 
-  private long prevBlockReportId = 0;
-
   private long generateUniqueBlockReportId() {
-    long id = System.nanoTime();
-    if (id <= prevBlockReportId) {
-      id = prevBlockReportId + 1;
+    // Initialize the block report ID the first time through.
+    // Note that 0 is used on the NN to indicate "uninitialized", so we should
+    // not send a 0 value ourselves.
+    prevBlockReportId++;
+    while (prevBlockReportId == 0) {
+      prevBlockReportId = DFSUtil.getRandom().nextLong();
     }
-    prevBlockReportId = id;
-    return id;
+    return prevBlockReportId;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hadoop/blob/351fac25/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/protocol/BlockReportContext.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/protocol/BlockReportContext.java
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/protocol/BlockReportContext.java
index a084a81..d0b0282 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/protocol/BlockReportContext.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/protocol/BlockReportContext.java
@@ -18,6 +18,8 @@
 
 package org.apache.hadoop.hdfs.server.protocol;
 
+import org.apache.hadoop.classification.InterfaceAudience;
+
 /**
  * The context of the block report.
  *
@@ -27,6 +29,7 @@ package org.apache.hadoop.hdfs.server.protocol;
  * of RPCs which this block report is split into, and the index into that
  * total for the current RPC.
  */
+@InterfaceAudience.Private
 public class BlockReportContext {
   private final int totalRpcs;
   private final int curRpc;


Mime
View raw message