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

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

 ##
 File path: 
zookeeper-api/src/main/java/org/apache/helix/zookeeper/api/client/RealmAwareZkClient.java
 ##
 @@ -40,7 +41,24 @@
 import org.apache.zookeeper.data.Stat;
 
 
+/**
+ * The Realm-aware ZkClient interface.
+ * NOTE: "Realm-aware" does not necessarily mean that the RealmAwareZkClient 
instance will be connecting to multiple ZK realms.
+ * On single-realm mode, RealmAwareZkClient will reject requests going out to 
other ZK realms than the one set at initialization.
+ * On multi-realm mode, RealmAwareZkClient will connect to multiple ZK realms 
but will reject EPHEMERAL AccessMode operations.
+ */
 public interface RealmAwareZkClient {
+
+  /**
+   * Specifies which mode to run this RealmAwareZkClient on.
+   *
+   * SINGLE_REALM: CRUD, change subscription, and EPHEMERAL CreateMode are 
supported.
+   * MULTI_REALM: CRUD and change subscription are supported. Operations 
involving EPHEMERAL CreateMode will throw an UnsupportedOperationException.
+   */
+  enum MODE {
+SINGLE_REALM, MULTI_REALM
 
 Review comment:
   updated!


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] narendly commented on a change in pull request #745: Add RealmAwareZkClient and RealmAwareZkClientFactory interfaces

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

 ##
 File path: 
zookeeper-api/src/main/java/org/apache/helix/zookeeper/api/client/RealmAwareZkClient.java
 ##
 @@ -250,21 +268,22 @@ default long waitForEstablishedSession(long timeout, 
TimeUnit timeUnit) {
* This is for backward compatibility and to avoid breaking the original 
implementation of
* {@link org.apache.helix.zookeeper.zkclient.deprecated.IZkStateListener}.
*/
-  class I0ItecIZkStateListenerHelixImpl
-  implements 
org.apache.helix.zookeeper.zkclient.deprecated.IZkStateListener {
+  class I0ItecIZkStateListenerHelixImpl implements 
org.apache.helix.zookeeper.zkclient.deprecated.IZkStateListener {
 
 Review comment:
   Removed


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] narendly commented on a change in pull request #745: Add RealmAwareZkClient and RealmAwareZkClientFactory interfaces

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

 ##
 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) {
+  if (mode == null) {
+throw new ZkClientException("Mode cannot be null!");
+  }
+  _mode = mode;
+  _zkRealmShardingKey = zkRealmShardingKey;
 
 Review comment:
   That's exactly right.


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] narendly commented on a change in pull request #745: Add RealmAwareZkClient and RealmAwareZkClientFactory interfaces

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

 ##
 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:
   I am thinking that we would use this for FederatedZkClient as well since 
FederatedZkClient is an implementation of RealmAwareZkClient. With that said, 
this is necessary because the mode will have to be different.
   
   So mode is not necessarily encoded in the type.


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] narendly commented on a change in pull request #745: Add RealmAwareZkClient and RealmAwareZkClientFactory interfaces

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

 ##
 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:
   Sure, that's a good idea. Let me add it as well.


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] narendly commented on a change in pull request #745: Add RealmAwareZkClient and RealmAwareZkClientFactory interfaces

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

 ##
 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:
   @kaisun2000 
   I tried that but that is going to break backward-compatibility because of 
different return types in the setter methods.
   
   To illustrate:
   `public ZkClientConfig setZkSerializer(PathBasedZkSerializer zkSerializer)` 
is what we have in HelixZkClient. But if this class extended 
RealmAwareZkClientConfig, then it will be returning an instance of 
RealmAwareZkClientConfig, which would break the existing methods in Shared and 
DedicatedZkClientFactories.


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