pkuwm commented on a change in pull request #671: Add ZooKeeperAccessor to 
helix-rest
URL: https://github.com/apache/helix/pull/671#discussion_r366615810
 
 

 ##########
 File path: 
helix-rest/src/main/java/org/apache/helix/rest/server/resources/zookeeper/ZooKeeperAccessor.java
 ##########
 @@ -0,0 +1,181 @@
+package org.apache.helix.rest.server.resources.zookeeper;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.UnsupportedEncodingException;
+import java.util.Base64;
+import java.util.List;
+import java.util.Map;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.helix.AccessOption;
+import org.apache.helix.manager.zk.ZkBaseDataAccessor;
+import org.apache.helix.rest.common.ContextPropertyKeys;
+import org.apache.helix.rest.server.ServerContext;
+import org.apache.helix.rest.server.resources.AbstractResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * ZooKeeperAccessor provides methods for accessing ZooKeeper resources 
(ZNodes).
+ * It provides basic ZooKeeper features supported by ZkClient.
+ */
+@Path("/zookeeper")
+public class ZooKeeperAccessor extends AbstractResource {
+  private static final Logger LOG = 
LoggerFactory.getLogger(ZooKeeperAccessor.class.getName());
+  private ZkBaseDataAccessor<byte[]> _zkBaseDataAccessor;
+
+  public enum ZooKeeperCommand {
+    exists, getBinaryData, getStringData, getChildren
 
 Review comment:
   I get your point and understand we should keep the consistence on the REST 
API. So to balance the code level convention and also API 
convention(`?command=getChildren`), I think we can also lookup the command by 
display name like this:
   ```
   public enum ZooKeeperCommand {
        GET_CHILDREN("getChildren");
   
        private String displayName;
        private ZooKeeperCommand(String displayName) {
                this.displayName = displayName;
        }
        public String getDisplayName() {
                return displayName;
        }
   
        private static final Map<String, ZooKeeperCommand> namesMap = 
Maps.newHashMapWithExpectedSize(ZooKeeperCommand.values().length);
   
        static {
                for (ZooKeeperCommand command : ZooKeeperCommand.values()) {
                        namesMap.put(command.getDisplayName(), command);
                }
        }
        public static ZooKeeperCommand lookupByName(String name) {
                return namesMap.get(name);
        }
   }
   
   So we can follow both conventions. What do you think?
   ```

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