You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ka...@apache.org on 2014/10/22 23:34:15 UTC

git commit: HADOOP-11122. Fix findbugs in ZK DelegationTokenSecretManagers. (Arun Suresh via kasha) (cherry picked from commit 70719e5c62f32836914bea88e1ddd99c0ed009e1)

Repository: hadoop
Updated Branches:
  refs/heads/branch-2 3476b9630 -> b3bb4fdc7


HADOOP-11122. Fix findbugs in ZK DelegationTokenSecretManagers. (Arun Suresh via kasha)
(cherry picked from commit 70719e5c62f32836914bea88e1ddd99c0ed009e1)


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

Branch: refs/heads/branch-2
Commit: b3bb4fdc7cf51cb3a030f889a7ca26bfea434cc4
Parents: 3476b96
Author: Karthik Kambatla <ka...@apache.org>
Authored: Wed Oct 22 14:26:27 2014 -0700
Committer: Karthik Kambatla <ka...@apache.org>
Committed: Wed Oct 22 14:33:56 2014 -0700

----------------------------------------------------------------------
 hadoop-common-project/hadoop-common/CHANGES.txt     |  3 +++
 .../AbstractDelegationTokenSecretManager.java       | 12 +++---------
 .../delegation/ZKDelegationTokenSecretManager.java  | 16 ++++++++++------
 3 files changed, 16 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/b3bb4fdc/hadoop-common-project/hadoop-common/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt
index b0f5038..e1730ca 100644
--- a/hadoop-common-project/hadoop-common/CHANGES.txt
+++ b/hadoop-common-project/hadoop-common/CHANGES.txt
@@ -652,6 +652,9 @@ Release 2.6.0 - UNRELEASED
     HADOOP-11175. Fix several issues of hadoop security configuration in user
     doc. (Yi Liu via cnauroth)
 
+    HADOOP-11122. Fix findbugs in ZK DelegationTokenSecretManagers.
+    (Arun Suresh via kasha)
+
 Release 2.5.1 - 2014-09-05
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b3bb4fdc/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java
index 7b6bf35..ebba6a1 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenSecretManager.java
@@ -163,11 +163,6 @@ extends AbstractDelegationTokenIdentifier>
     return;
   }
 
-  // for ZK based secretManager
-  protected void updateMasterKey(DelegationKey key) throws IOException{
-    return;
-  }
-
   // RM
   protected void removeStoredMasterKey(DelegationKey key) {
     return;
@@ -191,7 +186,7 @@ extends AbstractDelegationTokenIdentifier>
    * For subclasses externalizing the storage, for example Zookeeper
    * based implementations
    */
-  protected int getDelegationTokenSeqNum() {
+  protected synchronized int getDelegationTokenSeqNum() {
     return delegationTokenSequenceNumber;
   }
 
@@ -199,7 +194,7 @@ extends AbstractDelegationTokenIdentifier>
    * For subclasses externalizing the storage, for example Zookeeper
    * based implementations
    */
-  protected int incrementDelegationTokenSeqNum() {
+  protected synchronized int incrementDelegationTokenSeqNum() {
     return ++delegationTokenSequenceNumber;
   }
 
@@ -207,7 +202,7 @@ extends AbstractDelegationTokenIdentifier>
    * For subclasses externalizing the storage, for example Zookeeper
    * based implementations
    */
-  protected void setDelegationTokenSeqNum(int seqNum) {
+  protected synchronized void setDelegationTokenSeqNum(int seqNum) {
     delegationTokenSequenceNumber = seqNum;
   }
 
@@ -234,7 +229,6 @@ extends AbstractDelegationTokenIdentifier>
    */
   protected void updateDelegationKey(DelegationKey key) throws IOException {
     allKeys.put(key.getKeyId(), key);
-    updateMasterKey(key);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hadoop/blob/b3bb4fdc/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/ZKDelegationTokenSecretManager.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/ZKDelegationTokenSecretManager.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/ZKDelegationTokenSecretManager.java
index 23c7144..5f68844 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/ZKDelegationTokenSecretManager.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/ZKDelegationTokenSecretManager.java
@@ -276,7 +276,7 @@ public abstract class ZKDelegationTokenSecretManager<TokenIdent extends Abstract
   }
 
   @Override
-  public void startThreads() throws IOException {
+  public synchronized void startThreads() throws IOException {
     if (!isExternalClient) {
       try {
         zkClient.start();
@@ -402,7 +402,7 @@ public abstract class ZKDelegationTokenSecretManager<TokenIdent extends Abstract
   }
 
   @Override
-  public void stopThreads() {
+  public synchronized void stopThreads() {
     try {
       if (!isExternalClient && (zkClient != null)) {
         zkClient.close();
@@ -434,12 +434,12 @@ public abstract class ZKDelegationTokenSecretManager<TokenIdent extends Abstract
   }
 
   @Override
-  protected int getDelegationTokenSeqNum() {
+  protected synchronized int getDelegationTokenSeqNum() {
     return seqCounter.getCount();
   }
 
   @Override
-  protected int incrementDelegationTokenSeqNum() {
+  protected synchronized int incrementDelegationTokenSeqNum() {
     try {
       while (!seqCounter.trySetCount(seqCounter.getCount() + 1)) {
       }
@@ -450,8 +450,12 @@ public abstract class ZKDelegationTokenSecretManager<TokenIdent extends Abstract
   }
 
   @Override
-  protected void setDelegationTokenSeqNum(int seqNum) {
-    delegationTokenSequenceNumber = seqNum;
+  protected synchronized void setDelegationTokenSeqNum(int seqNum) {
+    try {
+      seqCounter.setCount(seqNum);
+    } catch (Exception e) {
+      throw new RuntimeException("Could not set shared counter !!", e);
+    }
   }
 
   @Override