mwkang edited a comment on issue #1193: HBASE-23561 Look up of Region in Master 
by encoded region name is O(n)
URL: https://github.com/apache/hbase/pull/1193#issuecomment-590070993
 
 
   I think the current code may have different values for the two maps.
   What do you think about changing it like below?
   
   ```java
   // ...
   
   private final Object regionsMapLock = new Object();
   
   // ...
   
   RegionStateNode createRegionStateNode(RegionInfo regionInfo) {
     synchronized (regionsMapLock) {
       RegionStateNode node = 
regionsMap.computeIfAbsent(regionInfo.getRegionName(), key -> new 
RegionStateNod(regionInfo, regionInTransition));
       encodedRegionsMap.putIfAbsent(node.getRegionInfo().getEncodedName(), 
node);
       return node;
     }
   }
   ```
   
   Also there is a remove logic, it seems safe to use a synchronized.
   ```java
   public void deleteRegion(final RegionInfo regionInfo) {
     synchronized (regionsMapLock) {
       RegionStateNode removeNode = 
regionsMap.remove(regionInfo.getRegionName());
       encodedRegionsMap.remove(regionInfo.getEncodedName(), removeNode);
     }
   
     // ...
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to