qqu0127 commented on code in PR #2385:
URL: https://github.com/apache/helix/pull/2385#discussion_r1128148351


##########
meta-client/src/main/java/org/apache/helix/metaclient/api/MetaClientReconnectPolicy.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.helix.metaclient.api;

Review Comment:
   nit on package management. Maybe this deserves a separate module as 
`retryPolicy`? And usually we should separate its interface and the 
implementation.



##########
meta-client/src/main/java/org/apache/helix/metaclient/api/ExponentialBackoffReconnectPolicy.java:
##########
@@ -0,0 +1,59 @@
+package org.apache.helix.metaclient.api;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static 
org.apache.helix.metaclient.constants.MetaClientConstants.DEFAULT_INIT_EXP_BACKOFF_RETRY_INTERVAL_MS;
+import static 
org.apache.helix.metaclient.constants.MetaClientConstants.DEFAULT_MAX_EXP_BACKOFF_RETRY_INTERVAL_MS;
+
+/**
+ * Policy to define client re-establish connection behavior when connection to 
underlying metadata
+ * store is expired.
+ * Wait time before each backoff period will increase exponentially until a 
user defined max
+ * backoff interval.
+ */
+public class ExponentialBackoffReconnectPolicy implements 
MetaClientReconnectPolicy {
+
+  private long _maxBackOffInterval;
+  private long _initBackoffInterval;

Review Comment:
   final



##########
meta-client/src/main/java/org/apache/helix/metaclient/api/MetaClientReconnectPolicy.java:
##########
@@ -0,0 +1,38 @@
+package org.apache.helix.metaclient.api;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Policy to define client re-establish connection behavior when connection to 
underlying metadata
+ * store is expired.
+ */

Review Comment:
   Not sure if I understand the purpose here. What behavior does this interface 
abstract? If users want to implement their own policy, how do they do that?



##########
meta-client/src/main/java/org/apache/helix/metaclient/factories/MetaClientConfig.java:
##########
@@ -123,6 +137,27 @@ public B setConnectionInitTimeoutInMillis(long timeout) {
       return self();
     }
 
+    /**
+     * Set timeout in ms for operation retry timeout
+     * @param timeout
+     * @return
+     */
+    public B setOperationRetryTimeoutInMillis(long timeout) {
+      _operationRetryTimeout = timeout;
+      return self();
+    }
+
+    /**
+     * Set reconnect policy when connection is lost or expired. By default is
+     * ExponentialBackoffReconnectPolicy
+     * @param reconnectPolicy an instance of type MetaClientReconnectPolicy
+     * @return
+     */
+    public B setMetaClientReconnectPolicy(MetaClientReconnectPolicy 
reconnectPolicy) {

Review Comment:
   If we want to use default value, can we assign it at declaration time?



##########
meta-client/src/main/java/org/apache/helix/metaclient/factories/MetaClientConfig.java:
##########
@@ -32,10 +34,18 @@ public enum StoreType {
   // Wait for init timeout time until connection is initiated
   private final long _connectionInitTimeoutInMillis;
 
+  // Operation failed because of connection lost will be auto retried if 
connection has recovered
+  // within timeout time.
+  private final long _operationRetryTimeoutInMillis;
+

Review Comment:
   It's a little confusing we have both this one and 
`MetaClientReconnectPolicy`. Can we combine these two?



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