pkuwm commented on a change in pull request #844: Implement setRoutingData for
MetadataStoreDirectoryService
URL: https://github.com/apache/helix/pull/844#discussion_r386716899
##########
File path:
helix-rest/src/main/java/org/apache/helix/rest/metadatastore/ZkMetadataStoreDirectory.java
##########
@@ -169,72 +186,102 @@ private void init(String namespace, String zkAddress)
throws InvalidRoutingDataE
@Override
public Map<String, String> getAllMappingUnderPath(String namespace, String
path) {
- if (!_routingDataMap.containsKey(namespace)) {
+ // Check _routingZkAddressMap first to see if namespace is included
+ if (!_routingZkAddressMap.containsKey(namespace)) {
throw new NoSuchElementException(
"Failed to get all mapping under path: Namespace " + namespace + "
is not found!");
}
+ // If namespace is included but not routing data, it means the routing
data is invalid
+ if (!_routingDataMap.containsKey(namespace)) {
+ throw new IllegalStateException("Failed to get all mapping under path:
Namespace " + namespace
+ + " contains invalid routing data!");
+ }
return _routingDataMap.get(namespace).getAllMappingUnderPath(path);
}
@Override
public String getMetadataStoreRealm(String namespace, String shardingKey) {
- if (!_routingDataMap.containsKey(namespace)) {
+ // Check _routingZkAddressMap first to see if namespace is included
+ if (!_routingZkAddressMap.containsKey(namespace)) {
throw new NoSuchElementException(
"Failed to get metadata store realm: Namespace " + namespace + " is
not found!");
}
+ // If namespace is included but not routing data, it means the routing
data is invalid
+ if (!_routingDataMap.containsKey(namespace)) {
+ throw new IllegalStateException("Failed to get metadata store realm:
Namespace " + namespace
+ + " contains invalid routing data!");
+ }
return _routingDataMap.get(namespace).getMetadataStoreRealm(shardingKey);
}
@Override
public boolean addMetadataStoreRealm(String namespace, String realm) {
- if (!_routingDataWriterMap.containsKey(namespace)) {
- // throwing NoSuchElementException instead of IllegalArgumentException
to differentiate the
- // status code in the Accessor level
- throw new NoSuchElementException(
- "Failed to add metadata store realm: Namespace " + namespace + " is
not found!");
+ synchronized (this) {
+ if (!_routingDataWriterMap.containsKey(namespace)) {
Review comment:
Before synchronized
----------------------------------------------------------------
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]