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


##########
meta-client/src/main/java/org/apache/helix/metaclient/factories/MetaClientConfig.java:
##########
@@ -56,56 +69,82 @@ public StoreType getStoreType() {
   //  private RetryProtocol _retryProtocol;
 
 
-  private MetaClientConfig(String connectionAddress, long connectionTimeout, 
boolean enableAuth,
-      StoreType storeType) {
+  protected MetaClientConfig(String connectionAddress, long 
connectionInitTimeoutInMillis,
+      long sessionTimeoutInMillis, boolean enableAuth, StoreType storeType) {
     _connectionAddress = connectionAddress;
-    _connectionTimeout = connectionTimeout;
+    _connectionInitTimeoutInMillis = connectionInitTimeoutInMillis;
+    _sessionTimeoutInMillis = sessionTimeoutInMillis;
     _enableAuth = enableAuth;
     _storeType = storeType;
   }
 
-  public static class Builder {
-    private String _connectionAddress;
-
-    private long _connectionTimeout;
-    private boolean _enableAuth;
-    //private RetryProtocol _retryProtocol;
-    private StoreType _storeType;
+  public static class MetaClientConfigBuilder<B extends 
MetaClientConfigBuilder<B>> {
+    protected String _connectionAddress;
 
+    protected long _connectionInitTimeoutInMillis;
+    protected long _sessionTimeoutInMillis;
+    // protected long _operationRetryTimeout;
+    // protected RetryProtocol _retryProtocol;
+    protected boolean _enableAuth;
+    protected StoreType _storeType;
 
 
     public MetaClientConfig build() {
       validate();
-      return new MetaClientConfig(_connectionAddress, _connectionTimeout, 
_enableAuth, _storeType);
+      return new MetaClientConfig(_connectionAddress, 
_connectionInitTimeoutInMillis,
+          _sessionTimeoutInMillis,
+          _enableAuth, _storeType);
     }
 
-    public Builder() {
+    public MetaClientConfigBuilder() {
       // set default values
       setAuthEnabled(false);
-      setConnectionTimeout(-1);
+      
setConnectionInitTimeoutInMillis(MetaClientConstants.DEFAULT_CONNECTION_INIT_TIMEOUT_MS);
+      
setSessionTimeoutInMillis(MetaClientConstants.DEFAULT_SESSION_TIMEOUT_MS);
     }
 
-    public Builder setConnectionAddress(String connectionAddress) {
+    public B setConnectionAddress(String connectionAddress) {
       _connectionAddress = connectionAddress;
-      return this;
+      return self();
     }
 
-    public Builder setAuthEnabled(Boolean enableAuth) {
+    public B setAuthEnabled(Boolean enableAuth) {
       _enableAuth = enableAuth;
-      return this;
+      return self();
+    }
+
+    /**
+     * Set timeout in mm for connection initialization timeout
+     * @param timeout
+     * @return
+     */
+    public B setConnectionInitTimeoutInMillis(long timeout) {
+      _connectionInitTimeoutInMillis = timeout;
+      return self();
     }
 
-    public Builder setConnectionTimeout(long timeout) {
-      _connectionTimeout = timeout;
-      return this;
+    /**
+     * Set timeout in mm for session timeout. When a client becomes 
partitioned from the metadata
+     * service for more than session timeout, new session will be established.
+     * @param timeout
+     * @return
+     */
+    public B setSessionTimeoutInMillis(long timeout) {
+      _sessionTimeoutInMillis = timeout;
+      return self();
     }
 
-    public Builder setStoreType(StoreType storeType) {
+    public B setStoreType(StoreType storeType) {
       _storeType = storeType;
-      return this;
+      return self();
+    }
+
+    @SuppressWarnings("unchecked")
+    final B self() {
+      return (B) this;
     }
 
-    private void validate() {
+    protected void validate() {

Review Comment:
   Yes we plan to add it later in future.



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