linliu-code commented on code in PR #12804:
URL: https://github.com/apache/hudi/pull/12804#discussion_r1962315616


##########
hudi-common/src/main/java/org/apache/hudi/timeline/TimelineServiceClientBase.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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.
+ */
+
+package org.apache.hudi.timeline;
+
+import org.apache.hudi.common.config.HoodieConfig;
+import org.apache.hudi.common.table.view.FileSystemViewStorageConfig;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.RetryHelper;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Base class for a client to trigger HTTP calls (GET or POST)
+ * to the Timeline Server from the executors.
+ */
+public abstract class TimelineServiceClientBase implements Serializable {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(TimelineServiceClientBase.class);
+
+  private RetryHelper<Response, IOException> retryHelper;
+
+  public TimelineServiceClientBase(HoodieConfig config) {
+    if 
(config.getBooleanOrDefault(FileSystemViewStorageConfig.REMOTE_RETRY_ENABLE)) {
+      retryHelper = new RetryHelper<>(
+          
config.getLongOrDefault(FileSystemViewStorageConfig.REMOTE_MAX_RETRY_INTERVAL_MS),
+          
config.getIntOrDefault(FileSystemViewStorageConfig.REMOTE_MAX_RETRY_NUMBERS),
+          
config.getLongOrDefault(FileSystemViewStorageConfig.REMOTE_INITIAL_RETRY_INTERVAL_MS),
+          
config.getStringOrDefault(FileSystemViewStorageConfig.RETRY_EXCEPTIONS),
+          "Sending request to timeline server");
+    }

Review Comment:
   Done.



##########
hudi-common/src/main/java/org/apache/hudi/timeline/TimelineServiceClientBase.java:
##########
@@ -0,0 +1,141 @@
+/*
+ * 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.
+ */
+
+package org.apache.hudi.timeline;
+
+import org.apache.hudi.common.config.HoodieConfig;
+import org.apache.hudi.common.table.view.FileSystemViewStorageConfig;
+import org.apache.hudi.common.util.Option;
+import org.apache.hudi.common.util.RetryHelper;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Base class for a client to trigger HTTP calls (GET or POST)
+ * to the Timeline Server from the executors.
+ */
+public abstract class TimelineServiceClientBase implements Serializable {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(TimelineServiceClientBase.class);
+
+  private RetryHelper<Response, IOException> retryHelper;
+
+  public TimelineServiceClientBase(HoodieConfig config) {
+    if 
(config.getBooleanOrDefault(FileSystemViewStorageConfig.REMOTE_RETRY_ENABLE)) {
+      retryHelper = new RetryHelper<>(
+          
config.getLongOrDefault(FileSystemViewStorageConfig.REMOTE_MAX_RETRY_INTERVAL_MS),
+          
config.getIntOrDefault(FileSystemViewStorageConfig.REMOTE_MAX_RETRY_NUMBERS),
+          
config.getLongOrDefault(FileSystemViewStorageConfig.REMOTE_INITIAL_RETRY_INTERVAL_MS),
+          
config.getStringOrDefault(FileSystemViewStorageConfig.RETRY_EXCEPTIONS),
+          "Sending request to timeline server");
+    }
+  }
+
+  protected abstract Response executeRequest(Request request) throws 
IOException;
+
+  public Response makeRequest(Request request) throws IOException {
+    return  (retryHelper != null) ? retryHelper.start(() -> 
executeRequest(request)) : executeRequest(request);
+  }
+
+  public static class Request {
+    private final TimelineServiceClient.RequestMethod method;
+    private final String path;
+    private final Option<Map<String, String>> queryParameters;
+
+    public Request(TimelineServiceClient.RequestMethod method, String path, 
Option<Map<String, String>> queryParameters) {

Review Comment:
   Done.



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

Reply via email to