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


##########
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())) {
+      zkFlag = 0;
+    }
+    if (mode.name().equals(EntryMode.EPHEMERAL.name())) {
+      zkFlag = 1;

Review Comment:
   can we just return the mode here? Including a separate int value could be 
confusing. 



##########
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())) {
+      zkFlag = 0;
+    }
+    if (mode.name().equals(EntryMode.EPHEMERAL.name())) {
+      zkFlag = 1;

Review Comment:
   can we just return the mode here? Including an extra int value could be 
confusing. 



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