stream2000 commented on code in PR #9651:
URL: https://github.com/apache/hudi/pull/9651#discussion_r1325472907
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/embedded/EmbeddedTimelineService.java:
##########
@@ -100,6 +100,10 @@ public void startServer() throws IOException {
* writeConfig.getHoodieClientHeartbeatTolerableMisses());
}
+ if (writeConfig.isTimelineServerBasedInstantStateEnabled()) {
+ timelineServiceConfBuilder.enableCkpMetadataRequests(true);
Review Comment:
done. And should we rename all `ckpMetadata` in timeline server to
`InstantState`? for example in `CkpMetadataHandler` there are a lot of
ckpmetadata keywords.
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/meta/CkpMetadataFactory.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.sink.meta;
+
+import org.apache.hudi.common.table.HoodieTableMetaClient;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.configuration.FlinkOptions;
+import org.apache.hudi.table.HoodieTable;
+
+import org.apache.flink.configuration.Configuration;
+
+/**
+ * A factory to generate {@link CkpMetadata} instance based on whether {@link
HoodieWriteConfig#INSTANT_STATE_TIMELINE_SERVER_BASED} enabled.
+ */
+public class CkpMetadataFactory {
+ public static CkpMetadata get(HoodieTable table, Configuration config) {
Review Comment:
done and use `HoodieTableMetaClient` and `HoodieWriteConfig` as param
instead of constructing hoodie table
##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/sink/meta/TimelineBasedCkpMetadata.java:
##########
@@ -0,0 +1,162 @@
+/*
+ * 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.sink.meta;
+
+import org.apache.hudi.common.table.timeline.dto.CkpMetadataDTO;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.timeline.service.handlers.CkpMetadataHandler;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+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.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Stream;
+
+/**
+ * Timeline server based CkpMetadata, will read ckpMessages from
timeline-server instead of from file system directly.
+ */
+public class TimelineBasedCkpMetadata extends CkpMetadata {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(TimelineBasedCkpMetadata.class);
+
+ private final HoodieWriteConfig writeConfig;
+ private ObjectMapper mapper;
+
+ public TimelineBasedCkpMetadata(FileSystem fs, String basePath, String
uniqueId, HoodieWriteConfig writeConfig) {
+ super(fs, basePath, uniqueId);
+ this.writeConfig = writeConfig;
+ mapper = new ObjectMapper();
+ LOG.info("Timeline server based CkpMetadata enabled");
+ }
+
+ @Override
+ public void startInstant(String instant) {
+ super.startInstant(instant);
+ sendRefreshRequest();
+ }
+
+ @Override
+ public void commitInstant(String instant) {
+ super.commitInstant(instant);
+ sendRefreshRequest();
+ }
+
+ @Override
+ public void abortInstant(String instant) {
+ super.abortInstant(instant);
+ sendRefreshRequest();
+ }
+
+ @Override
+ protected Stream<CkpMessage> readCkpMessages(Path ckpMetaPath) throws
IOException {
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]