pkuwm commented on a change in pull request #799: [MSDS] Add REST endpoint to 
get mapping of all sharding keys by realm
URL: https://github.com/apache/helix/pull/799#discussion_r382968395
 
 

 ##########
 File path: 
helix-rest/src/main/java/org/apache/helix/rest/metadatastore/ZkMetadataStoreDirectory.java
 ##########
 @@ -111,6 +111,16 @@ public ZkMetadataStoreDirectory(Map<String, String> 
routingZkAddressMap)
     return allShardingKeys;
   }
 
+  @Override
+  public Map<String, List<String>> getShardingKeysByRealm(String namespace) {
+    Map<String, List<String>> shardingKeysByRealmMap = 
_realmToShardingKeysMap.get(namespace);
+    if (shardingKeysByRealmMap == null) {
+      throw new NoSuchElementException("Namespace " + namespace + " does not 
exist!");
+    }
+
+    return shardingKeysByRealmMap;
 
 Review comment:
   I realized that we already consider multi-thread issue (reading and 
refreshing) for this map because it is a concurrent map. Your style 
`contains()` and `get()` would potentially have race condition. So only one 
`get()` makes advantage of a concurrent map to avoid race condition.

----------------------------------------------------------------
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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to