stream2000 commented on code in PR #9651:
URL: https://github.com/apache/hudi/pull/9651#discussion_r1328048590
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/StreamWriteOperatorCoordinator.java:
##########
@@ -349,8 +351,8 @@ private static void
initMetadataTable(HoodieFlinkWriteClient<?> writeClient) {
writeClient.initMetadataTable();
}
- private static CkpMetadata initCkpMetadata(HoodieTableMetaClient metaClient,
Configuration conf) throws IOException {
- CkpMetadata ckpMetadata = CkpMetadata.getInstance(metaClient,
conf.getString(FlinkOptions.WRITE_CLIENT_ID));
+ private static CkpMetadata initCkpMetadata(HoodieTableMetaClient metaClient,
HoodieWriteConfig writeConfig, Configuration conf) throws IOException {
+ CkpMetadata ckpMetadata = CkpMetadataFactory.getCkpMetadata(metaClient,
writeConfig, conf);
ckpMetadata.bootstrap();
return ckpMetadata;
Review Comment:
You are right, we can't ensure that the refreshing by the coordinator is
successful. I added a new mechanism that the instant states will be refresh if
client request count reaches a threshold, with this mechanism we can ensure
that the writer won't be blocked infinitely.
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/util/TimelineServerHelper.java:
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.util;
+
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieException;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.client.fluent.Request;
+import org.apache.http.client.fluent.Response;
+import org.apache.http.client.utils.URIBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Helper class for executing timeline server requests.
+ */
+public class TimelineServerHelper {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(TimelineServerHelper.class);
+ private final ObjectMapper mapper;
+ private final String timelineServerHost;
+ private final int timelineServerPort;
+ private final int timeoutSecs;
+
+ public TimelineServerHelper(HoodieWriteConfig writeConfig) {
+ this(writeConfig.getViewStorageConfig().getRemoteViewServerHost(),
+ writeConfig.getViewStorageConfig().getRemoteViewServerPort(),
+
writeConfig.getViewStorageConfig().getRemoteTimelineClientTimeoutSecs());
+ }
+
+ public TimelineServerHelper(String timelineServerHost, int
timelineServerPort, int timeoutSecs) {
+ this.mapper = new ObjectMapper();
+ this.timelineServerHost = timelineServerHost;
+ this.timelineServerPort = timelineServerPort;
+ this.timeoutSecs = timeoutSecs;
+ }
+
+ public <T> T executeRequestToTimelineServerWithRetry(String requestPath,
Map<String, String> queryParameters,
+ TypeReference
reference, RequestMethod method) {
+ int retry = 5;
+ while (--retry >= 0) {
+ long start = System.currentTimeMillis();
+ try {
+ return executeRequestToTimelineServer(requestPath, queryParameters,
reference, method);
+ } catch (IOException e) {
+ LOG.warn("Failed to execute request (" + requestPath + ") to timeline
server", e);
+ } finally {
+ LOG.info("Execute request : (" + requestPath + "), costs: " +
(System.currentTimeMillis() - start) + " ms");
Review Comment:
Yes sure. Reusing the retry config of remote file system view retry to
config the retry count. And removed the noisy log.
--
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]