[GitHub] [helix] kaisun2000 commented on a change in pull request #745: Add RealmAwareZkClient and RealmAwareZkClientFactory interfaces

2020-02-13 Thread GitBox
kaisun2000 commented on a change in pull request #745: Add RealmAwareZkClient 
and RealmAwareZkClientFactory interfaces
URL: https://github.com/apache/helix/pull/745#discussion_r379131214
 
 

 ##
 File path: 
zookeeper-api/src/main/java/org/apache/helix/zookeeper/api/client/RealmAwareZkClient.java
 ##
 @@ -306,48 +326,63 @@ public int hashCode() {
   }
 
   /**
-   * Configuration for creating a new ZkConnection.
+   * ZkConnection-related configs for creating an instance of 
RealmAwareZkClient.
*/
-  class ZkConnectionConfig {
-// Connection configs
-private final String _zkServers;
-private int _sessionTimeout = HelixZkClient.DEFAULT_SESSION_TIMEOUT;
+  class RealmAwareZkConnectionConfig {
+/**
+ * mode: Which mode the RealmAwareZkClientConfig should be created in
+ */
+private final MODE _mode;
+/**
+ * zkRealmShardingKey: used to deduce which ZK realm this 
RealmAwareZkClientConfig should connect to.
+ * NOTE: this field will be ignored if MODE is MULTI_REALM!
+ */
+private final String _zkRealmShardingKey;
+private int _sessionTimeout = DEFAULT_SESSION_TIMEOUT;
 
-public ZkConnectionConfig(String zkServers) {
-  _zkServers = zkServers;
+public RealmAwareZkConnectionConfig(MODE mode, String zkRealmShardingKey) {
 
 Review comment:
   FederatedZkClient is always multi. The implementation of FederateZkClient 
can assume this without you passing a mode. The problem is that if you pass a 
non-multi, it need to handle it then.


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



[GitHub] [helix] kaisun2000 commented on a change in pull request #745: Add RealmAwareZkClient and RealmAwareZkClientFactory interfaces

2020-02-13 Thread GitBox
kaisun2000 commented on a change in pull request #745: Add RealmAwareZkClient 
and RealmAwareZkClientFactory interfaces
URL: https://github.com/apache/helix/pull/745#discussion_r379087412
 
 

 ##
 File path: 
zookeeper-api/src/main/java/org/apache/helix/zookeeper/api/client/RealmAwareZkClient.java
 ##
 @@ -306,48 +326,63 @@ public int hashCode() {
   }
 
   /**
-   * Configuration for creating a new ZkConnection.
+   * ZkConnection-related configs for creating an instance of 
RealmAwareZkClient.
*/
-  class ZkConnectionConfig {
-// Connection configs
-private final String _zkServers;
-private int _sessionTimeout = HelixZkClient.DEFAULT_SESSION_TIMEOUT;
+  class RealmAwareZkConnectionConfig {
+/**
+ * mode: Which mode the RealmAwareZkClientConfig should be created in
+ */
+private final MODE _mode;
+/**
+ * zkRealmShardingKey: used to deduce which ZK realm this 
RealmAwareZkClientConfig should connect to.
+ * NOTE: this field will be ignored if MODE is MULTI_REALM!
+ */
+private final String _zkRealmShardingKey;
+private int _sessionTimeout = DEFAULT_SESSION_TIMEOUT;
 
-public ZkConnectionConfig(String zkServers) {
-  _zkServers = zkServers;
+public RealmAwareZkConnectionConfig(MODE mode, String zkRealmShardingKey) {
 
 Review comment:
   If we think MODE is already encoded in the Type (class hierarchy), we don't 
need this in the constructor.  Based on looking at the psuedo code I drew, I 
don't fee we really need to pass this in. 


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



[GitHub] [helix] kaisun2000 commented on a change in pull request #745: Add RealmAwareZkClient and RealmAwareZkClientFactory interfaces

2020-02-13 Thread GitBox
kaisun2000 commented on a change in pull request #745: Add RealmAwareZkClient 
and RealmAwareZkClientFactory interfaces
URL: https://github.com/apache/helix/pull/745#discussion_r379057281
 
 

 ##
 File path: 
zookeeper-api/src/main/java/org/apache/helix/zookeeper/api/factory/RealmAwareZkClientFactory.java
 ##
 @@ -19,5 +19,13 @@
  * under the License.
  */
 
+import org.apache.helix.zookeeper.api.client.RealmAwareZkClient;
+
+
+/**
+ * Creates an instance of RealmAwareZkClient.
+ */
 public interface RealmAwareZkClientFactory {
+  RealmAwareZkClient 
buildZkClient(RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig,
 
 Review comment:
   To achieve feature parity of HelixZkClientInterface, shall we add this 
constructor too?
   
   `   public RealmAwareZkClient buildZkClient(
 RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig) {
return buildZkClient(connectConfig, new 
RealmAwareZkClient.RealmAwareZkClientConfig());
  }`


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



[GitHub] [helix] kaisun2000 commented on a change in pull request #745: Add RealmAwareZkClient and RealmAwareZkClientFactory interfaces

2020-02-13 Thread GitBox
kaisun2000 commented on a change in pull request #745: Add RealmAwareZkClient 
and RealmAwareZkClientFactory interfaces
URL: https://github.com/apache/helix/pull/745#discussion_r379055450
 
 

 ##
 File path: 
zookeeper-api/src/main/java/org/apache/helix/zookeeper/api/client/HelixZkClient.java
 ##
 @@ -19,8 +19,178 @@
  * under the License.
  */
 
+import org.apache.helix.zookeeper.zkclient.serialize.BasicZkSerializer;
+import org.apache.helix.zookeeper.zkclient.serialize.PathBasedZkSerializer;
+import org.apache.helix.zookeeper.zkclient.serialize.SerializableSerializer;
+import org.apache.helix.zookeeper.zkclient.serialize.ZkSerializer;
+
+
 /**
+ * Deprecated - please use RealmAwareZkClient instead.
+ *
  * HelixZkClient interface that follows the supported API structure of 
RealmAwareZkClient.
  */
+@Deprecated
 public interface HelixZkClient extends RealmAwareZkClient {
+
+  /**
+   * Deprecated - please use RealmAwareZkClient and 
RealmAwareZkConnectionConfig instead.
+   *
+   * Configuration for creating a new ZkConnection.
+   */
+  @Deprecated
+  class ZkConnectionConfig {
+// Connection configs
+private final String _zkServers;
+private int _sessionTimeout = HelixZkClient.DEFAULT_SESSION_TIMEOUT;
+
+public ZkConnectionConfig(String zkServers) {
+  _zkServers = zkServers;
+}
+
+@Override
+public boolean equals(Object obj) {
+  if (obj == this) {
+return true;
+  }
+  if (!(obj instanceof HelixZkClient.ZkConnectionConfig)) {
+return false;
+  }
+  HelixZkClient.ZkConnectionConfig configObj = 
(HelixZkClient.ZkConnectionConfig) obj;
+  return (_zkServers == null && configObj._zkServers == null || _zkServers 
!= null && _zkServers
+  .equals(configObj._zkServers)) && _sessionTimeout == 
configObj._sessionTimeout;
+}
+
+@Override
+public int hashCode() {
+  return _sessionTimeout * 31 + _zkServers.hashCode();
+}
+
+@Override
+public String toString() {
+  return (_zkServers + "_" + _sessionTimeout).replaceAll("[\\W]", "_");
+}
+
+public HelixZkClient.ZkConnectionConfig setSessionTimeout(Integer 
sessionTimeout) {
+  this._sessionTimeout = sessionTimeout;
+  return this;
+}
+
+public String getZkServers() {
+  return _zkServers;
+}
+
+public int getSessionTimeout() {
+  return _sessionTimeout;
+}
+  }
+
+  /**
+   * Deprecated - please use RealmAwareZkClient and RealmAwareZkClientConfig 
instead.
+   *
+   * Configuration for creating a new HelixZkClient with serializer and 
monitor.
+   */
+  @Deprecated
+  class ZkClientConfig {
 
 Review comment:
   Another choice is to let ZkClientConfig inherit 
RealmAwareZkClient.RealmAwareZkClientConfig as the implementation of this two 
class are implementation are exactly the same. This way, no duplicate code. 
What is your take?


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