You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2019/11/07 20:03:41 UTC

[GitHub] [helix] i3wangyi commented on a change in pull request #534: Implementation of create/get/set methods with custom serializer support

i3wangyi commented on a change in pull request #534: Implementation of create/get/set methods with custom serializer support
URL: https://github.com/apache/helix/pull/534#discussion_r343848126
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/manager/zk/ZkBaseDataAccessor.java
 ##########
 @@ -92,19 +98,42 @@ public ZkBaseDataAccessor(HelixZkClient zkClient) {
     _zkClient = zkClient;
   }
 
+  private synchronized HelixZkClient getNonZNRecordClient() {
+    if (_nonZNRecordClient == null) {
+      _nonZNRecordClient = new ZkClient.Builder().setConnection(
+          new ZkConnection(_zkClient.getServers(), ZkClient.DEFAULT_SESSION_TIMEOUT))
+          .setZkSerializer(new ZkSerializer() {
+            @Override
+            public byte[] serialize(Object data) throws ZkMarshallingError {
+              if (data instanceof byte[]) {
+                return (byte[]) data;
+              }
+              throw new HelixException("Only support a byte array as an argument!");
+            }
+
+            @Override
+            public Object deserialize(byte[] data) throws ZkMarshallingError {
+              return data;
+            }
+          }).build();
+    }
+
+    return _nonZNRecordClient;
+  }
+
   /**
    * sync create
    */
   @Override
   public boolean create(String path, T record, int options) {
-    AccessResult result = doCreate(path, record, options);
+    AccessResult result = doCreate(path, record, options, true);
     return result._retCode == RetCode.OK;
   }
 
   /**
-   * sync create
+   * sync create. In order to support non-ZnRecord creation, the instance of {@link HelixZkClient} needs to be a parameter
    */
-  public AccessResult doCreate(String path, T record, int options) {
+  public AccessResult doCreate(String path, Object record, int options, boolean isZnRecord) {
 
 Review comment:
   However, it will go back to the previous problem when ZKCachedDataAccesor wants to use `doCreate` method directly and it needs to get the instance of ZKClient.

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


With regards,
Apache Git Services

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