qqu0127 commented on code in PR #2335:
URL: https://github.com/apache/helix/pull/2335#discussion_r1068780318


##########
meta-client/src/main/java/org/apache/helix/metaclient/impl/zk/ZkMetaClient.java:
##########
@@ -67,14 +67,33 @@ public ZkMetaClient(ZkMetaClientConfig config) {
   }
 
   @Override
-  public void create(String key, T data) {
-    // TODO: This function is implemented only for test. It does not have 
proper error handling
-    _zkClient.create(key, data, ZooDefs.Ids.OPEN_ACL_UNSAFE, 
CreateMode.PERSISTENT);
+  public void create(String key, Object data) {
+    try {
+      create(key, data, EntryMode.PERSISTENT);
+    } catch (Exception e) {
+      throw new MetaClientException(e);
+    }
   }
 
   @Override
-  public void create(String key, T data, EntryMode mode) {
+  public void create(String key, Object data, MetaClientInterface.EntryMode 
mode) {
 
+    try{
+      _zkClient.create(key, data, metaClientModeToZkMode(mode));
+    } catch (ZkException | KeeperException e) {
+      throw new MetaClientException(e);
+    }
+  }
+
+  private CreateMode metaClientModeToZkMode(EntryMode mode) throws 
KeeperException {
+    int zkFlag = -1;
+    if (mode.name().equals(EntryMode.PERSISTENT.name())) {

Review Comment:
   A better way is to compare directly on the Enum level with switch or use 
EnumMap. Comparing string is unstable.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to