rahulrane50 commented on code in PR #2385:
URL: https://github.com/apache/helix/pull/2385#discussion_r1124147748
##########
meta-client/src/main/java/org/apache/helix/metaclient/factories/MetaClientConfig.java:
##########
@@ -123,6 +137,21 @@ public B setConnectionInitTimeoutInMillis(long timeout) {
return self();
}
+ /**
+ * Set timeout in mm for connection initialization timeout
Review Comment:
neat typo : ms
##########
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.
+ */
+
+public interface MetaClientReconnectPolicy {
+
+ enum RetryPolicyName {
+ NO_RETRY,
+ EXP_BACKOFF,
+ LINEAR_BACKOFF
Review Comment:
Curious, are we going to implement this one in future PRs?
##########
meta-client/src/main/java/org/apache/helix/metaclient/factories/MetaClientConfig.java:
##########
@@ -145,6 +174,18 @@ final B self() {
}
protected void validate() {
+ if (_metaClientReconnectPolicy == null) {
+ _metaClientReconnectPolicy = new ExponentialBackoffReconnectPolicy();
Review Comment:
Neat : looks like we have default retry policy as exponential polity. May be
we can comment in this Metaclientretry policy
##########
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;
+
+ @Override
+ public RetryPolicyName getPolicyName() {
+ return RetryPolicyName.EXP_BACKOFF;
+ }
+
+ public ExponentialBackoffReconnectPolicy() {
+ _initBackoffInterval = DEFAULT_INIT_EXP_BACKOFF_RETRY_INTERVAL_MS;
+ _maxBackOffInterval = DEFAULT_MAX_EXP_BACKOFF_RETRY_INTERVAL_MS;
+ }
+
+ public ExponentialBackoffReconnectPolicy(long maxBackOffInterval, long
initBackoffInterval) {
+ _maxBackOffInterval = maxBackOffInterval;
+ _initBackoffInterval = initBackoffInterval;
+
+ }
+
+ long getMaxBackOffInterval() {
Review Comment:
May I ask why we have default scope here for these methods?
--
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]