pkuwm commented on a change in pull request #761: Add REST read endpoints to 
helix-rest for metadata store directory
URL: https://github.com/apache/helix/pull/761#discussion_r379219384
 
 

 ##########
 File path: 
helix-rest/src/main/java/org/apache/helix/rest/server/resources/metadatastore/MetadataStoreDirectoryAccessor.java
 ##########
 @@ -66,24 +67,44 @@ private void postConstruct() {
   }
 
   /**
-   * Gets all metadata store realms in a namespace with the endpoint.
+   * Gets all existing namespaces in the routing metadata store at endpoint:
+   * "GET /metadata-store-namespaces"
+   *
+   * @return Json response of all namespaces.
+   */
+  @GET
+  @Path("/metadata-store-namespaces")
+  public Response getAllNamespaces() {
+    Collection<String> namespaces = _metadataStoreDirectory.getAllNamespaces();
+    Map<String, Collection<String>> responseMap =
+        
ImmutableMap.of(MetadataStoreRoutingConstants.METADATA_STORE_NAMESPACES, 
namespaces);
+
+    return JSONRepresentation(responseMap);
+  }
+
+  /**
+   * Gets all metadata store realms in a namespace at path: "GET 
/metadata-store-realms",
+   * or gets a metadata store realm with the sharding key at path:
+   * "GET /metadata-store-realms?sharding-key={sharding-key}"
    *
    * @return Json representation of all realms.
    */
   @GET
   @Path("/metadata-store-realms")
-  public Response getAllMetadataStoreRealms() {
-    Map<String, Collection<String>> responseMap;
+  public Response getAllMetadataStoreRealms(@QueryParam("sharding-key") String 
shardingKey) {
 
 Review comment:
   I've thought about this carefully. As it is necessary, I've defined a POJO 
class `MetadataStoreShardingKey` to represent the object mapping. The response 
will look like:
   ```
   {
        "metadataStoreRealms": ["realm-0", "realm-1"]
   }
   ```
   or  single ream with sharding key:
   ```
   {
        "shardingKey": "/a/b/c",
        "realm": "realm-0"
   }
   ```
   I definitely agree that if the response of object is complex (has more 
fields), we would need POJO classes to represent the responses.
   For the time being, since the most of the responses are quite simple: a 
list, I don't think we want to make it complex .  I've tried to make all json 
responses to have key-value mappings.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@helix.apache.org
For additional commands, e-mail: reviews-h...@helix.apache.org

Reply via email to