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 aa...@apache.org on 2019/09/12 03:42:59 UTC

[hadoop] branch trunk updated: HDFS-14840. Use Java Conccurent Instead of Synchronization in BlockPoolTokenSecretManager. Contributed by David Mollitor.

This is an automated email from the ASF dual-hosted git repository.

aajisaka pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 68612a0  HDFS-14840. Use Java Conccurent Instead of Synchronization in BlockPoolTokenSecretManager. Contributed by David Mollitor.
68612a0 is described below

commit 68612a0410066af745e80d3b6d732a6151a635e3
Author: Akira Ajisaka <aa...@apache.org>
AuthorDate: Thu Sep 12 12:41:57 2019 +0900

    HDFS-14840. Use Java Conccurent Instead of Synchronization in BlockPoolTokenSecretManager. Contributed by David Mollitor.
---
 .../token/block/BlockPoolTokenSecretManager.java        | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/security/token/block/BlockPoolTokenSecretManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/security/token/block/BlockPoolTokenSecretManager.java
index bbd3750..e477eee 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/security/token/block/BlockPoolTokenSecretManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/security/token/block/BlockPoolTokenSecretManager.java
@@ -19,8 +19,8 @@ package org.apache.hadoop.hdfs.security.token.block;
 
 import java.io.IOException;
 import java.util.EnumSet;
-import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
 import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier.AccessMode;
@@ -37,30 +37,29 @@ import org.apache.hadoop.fs.StorageType;
 public class BlockPoolTokenSecretManager extends
     SecretManager<BlockTokenIdentifier> {
   
-  private final Map<String, BlockTokenSecretManager> map = 
-    new HashMap<String, BlockTokenSecretManager>();
+  private final Map<String, BlockTokenSecretManager> map =
+      new ConcurrentHashMap<>();
 
   /**
    * Add a block pool Id and corresponding {@link BlockTokenSecretManager} to map
    * @param bpid block pool Id
    * @param secretMgr {@link BlockTokenSecretManager}
    */
-  public synchronized void addBlockPool(String bpid,
-      BlockTokenSecretManager secretMgr) {
+  public void addBlockPool(String bpid, BlockTokenSecretManager secretMgr) {
     map.put(bpid, secretMgr);
   }
 
   @VisibleForTesting
-  public synchronized BlockTokenSecretManager get(String bpid) {
+  public BlockTokenSecretManager get(String bpid) {
     BlockTokenSecretManager secretMgr = map.get(bpid);
     if (secretMgr == null) {
-      throw new IllegalArgumentException("Block pool " + bpid
-          + " is not found");
+      throw new IllegalArgumentException(
+          "Block pool " + bpid + " is not found");
     }
     return secretMgr;
   }
   
-  public synchronized boolean isBlockPoolRegistered(String bpid) {
+  public boolean isBlockPoolRegistered(String bpid) {
     return map.containsKey(bpid);
   }
 


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