You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "yihua (via GitHub)" <gi...@apache.org> on 2023/04/01 06:58:49 UTC

[GitHub] [hudi] yihua commented on a diff in pull request #8184: [HUDI-5780] Refactor Deltastreamer source configs to use HoodieConfig/ConfigProperty

yihua commented on code in PR #8184:
URL: https://github.com/apache/hudi/pull/8184#discussion_r1155061104


##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/GcsEventsHoodieIncrSource.java:
##########
@@ -114,19 +111,19 @@ public GcsEventsHoodieIncrSource(TypedProperties props, JavaSparkContext jsc, Sp
 
     this(props, jsc, spark, schemaProvider,
             new FilePathsFetcher(props, getSourceFileFormat(props)),
-            new FileDataFetcher(props, props.getString(DATAFILE_FORMAT, DEFAULT_SOURCE_FILE_FORMAT))
+            new FileDataFetcher(props, props.getString(DATAFILE_FORMAT.key(), SOURCE_FILE_FORMAT.defaultValue()))

Review Comment:
   Set default value for `DATAFILE_FORMAT` and use it here instead?



##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/config/GCSEventsSourceConfig.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.utilities.config;
+
+import org.apache.hudi.common.config.ConfigClassProperty;
+import org.apache.hudi.common.config.ConfigGroups;
+import org.apache.hudi.common.config.ConfigProperty;
+import org.apache.hudi.common.config.HoodieConfig;
+
+import javax.annotation.concurrent.Immutable;
+
+/**
+ * Cloud Source Configs
+ */
+@Immutable
+@ConfigClassProperty(name = "Kafka Source Configs",
+    groupName = ConfigGroups.Names.DELTA_STREAMER,
+    subGroupName = ConfigGroups.SubGroupNames.DELTA_STREAMER_SOURCE,
+    description = "Configurations controlling the behavior of Kafka source in Deltastreamer.")

Review Comment:
   Fix the docs.



##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/SqlSource.java:
##########
@@ -91,6 +92,7 @@ protected Pair<Option<Dataset<Row>>, String> fetchNextBatch(
    */
   private static class Config {
 
-    private static final String SOURCE_SQL = "hoodie.deltastreamer.source.sql.sql.query";
+    @Deprecated

Review Comment:
   This can be removed.



##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/config/HoodieIncrSourceConfig.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.utilities.config;
+
+import org.apache.hudi.common.config.ConfigClassProperty;
+import org.apache.hudi.common.config.ConfigGroups;
+import org.apache.hudi.common.config.ConfigProperty;
+import org.apache.hudi.common.config.HoodieConfig;
+import org.apache.hudi.hive.SlashEncodedDayPartitionValueExtractor;
+import org.apache.hudi.utilities.sources.helpers.IncrSourceHelper;
+
+import javax.annotation.concurrent.Immutable;
+
+import java.util.Arrays;
+
+/**
+ * Hudi Incremental Pulling Source Configs
+ */
+@Immutable
+@ConfigClassProperty(name = "Hudi Incremental Source Configs",
+    groupName = ConfigGroups.Names.DELTA_STREAMER,
+    subGroupName = ConfigGroups.SubGroupNames.DELTA_STREAMER_SOURCE,
+    description = "Configurations controlling the behavior of incremental pulling from a Hudi "
+        + "table as a source in Deltastreamer.")
+public class HoodieIncrSourceConfig extends HoodieConfig {
+
+  public static final ConfigProperty<String> HOODIE_SRC_BASE_PATH = ConfigProperty
+      .key("hoodie.deltastreamer.source.hoodieincr.path")
+      .noDefaultValue()
+      .withDocumentation("Base-path for the source Hoodie table");

Review Comment:
   `Hoodie` -> `Hudi`



##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/config/CloudSourceConfig.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.utilities.config;
+
+import org.apache.hudi.common.config.ConfigClassProperty;
+import org.apache.hudi.common.config.ConfigGroups;
+import org.apache.hudi.common.config.ConfigProperty;
+import org.apache.hudi.common.config.HoodieConfig;
+
+import javax.annotation.concurrent.Immutable;
+
+/**
+ * Cloud Source Configs
+ */
+@Immutable
+@ConfigClassProperty(name = "Cloud Source Configs",
+    groupName = ConfigGroups.Names.DELTA_STREAMER,
+    subGroupName = ConfigGroups.SubGroupNames.DELTA_STREAMER_SOURCE,
+    description = "Configs that are common during ingestion across different cloud stores")
+public class CloudSourceConfig extends HoodieConfig {
+
+  public static final ConfigProperty<Integer> BATCH_SIZE_CONF = ConfigProperty
+      .key("hoodie.deltastreamer.source.cloud.meta.batch.size")
+      /*
+       * Provide a reasonable setting to use for default batch size when fetching File Metadata as part of Cloud Ingestion.
+       * If batch size is too big, two possible issues can happen:
+       * i) Acknowledgement takes too long (given that Hudi needs to commit first).
+       * ii) In the case of Google Cloud Pubsub:
+       *   a) it will keep delivering the same message since it wasn't acked in time.
+       *   b) The size of the request that acks outstanding messages may exceed the limit,
+       *      which is 512KB as per Google's docs. See: https://cloud.google.com/pubsub/quotas#resource_limits
+       */
+      .defaultValue(10)
+      .withDocumentation("Number of metadata messages to pull at a time");
+
+  public static final ConfigProperty<Boolean> ACK_MESSAGES = ConfigProperty
+      .key("hoodie.deltastreamer.source.cloud.meta.ack")
+      .defaultValue(true)
+      .withDocumentation("Whether to acknowledge Metadata messages during Cloud Ingestion or not. This is useful during dev and testing.\n "
+          + "In Prod this should always be true. In case of Cloud Pubsub, not acknowledging means Pubsub will keep redelivering the same messages.");
+
+  public static final ConfigProperty<Boolean> ENABLE_EXISTS_CHECK = ConfigProperty
+      .key("hoodie.deltastreamer.source.cloud.data.check.file.exists")
+      .defaultValue(false)
+      .withDocumentation("If true, checks whether file exists before attempting to pull it");
+
+  public static final ConfigProperty<String> SELECT_RELATIVE_PATH_PREFIX = ConfigProperty
+      .key("hoodie.deltastreamer.source.cloud.data.select.relpath.prefix")
+      .noDefaultValue()
+      .withDocumentation("Only selects objects in the bucket whose relative path matches this prefix");
+
+  public static final ConfigProperty<String> IGNORE_RELATIVE_PATH_PREFIX = ConfigProperty
+      .key("hoodie.deltastreamer.source.cloud.data.ignore.relpath.prefix")
+      .noDefaultValue()
+      .withDocumentation("Ignore objects in the bucket whose relative path matches this prefix");
+
+  public static final ConfigProperty<String> IGNORE_RELATIVE_PATH_SUBSTR = ConfigProperty
+      .key("hoodie.deltastreamer.source.cloud.data.ignore.relpath.substring")
+      .noDefaultValue()
+      .withDocumentation("Ignore objects in the bucket whose relative path contains this substring");
+
+  public static final ConfigProperty<String> SPARK_DATASOURCE_OPTIONS = ConfigProperty
+      .key("hoodie.deltastreamer.source.cloud.data.datasource.options")

Review Comment:
   Same here.  @lokeshj1703 let's track this in a new JIRA ticket.



##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/helpers/KafkaOffsetGen.java:
##########
@@ -282,8 +226,8 @@ public OffsetRange[] getNextOffsetRanges(Option<String> lastCheckpointStr, long
     }
 
     // Come up with final set of OffsetRanges to read (account for new partitions, limit number of events)
-    long maxEventsToReadFromKafka = props.getLong(Config.MAX_EVENTS_FROM_KAFKA_SOURCE_PROP.key(),
-            Config.MAX_EVENTS_FROM_KAFKA_SOURCE_PROP.defaultValue());
+    long maxEventsToReadFromKafka = props.getLong(KafkaSourceConfig.MAX_EVENTS_FROM_KAFKA_SOURCE_PROP.key(),

Review Comment:
   Remove `_PROP` from config variable naming.



##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/JdbcSource.java:
##########
@@ -262,82 +264,89 @@ private String checkpoint(Dataset<Row> rowDataset, boolean isIncremental, Option
    * Inner class with config keys.
    */
   protected static class Config {
-
-    /**
-     * {@value #URL} is the jdbc url for the Hoodie datasource.
-     */
-    private static final String URL = "hoodie.deltastreamer.jdbc.url";
+    @Deprecated

Review Comment:
   Since these are private, we can remove them completely.



##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/config/SqlSourceConfig.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.utilities.config;
+
+import org.apache.hudi.common.config.ConfigClassProperty;
+import org.apache.hudi.common.config.ConfigGroups;
+import org.apache.hudi.common.config.ConfigProperty;
+import org.apache.hudi.common.config.HoodieConfig;
+
+import javax.annotation.concurrent.Immutable;
+
+/**
+ * SQL Source Configs
+ */
+@Immutable
+@ConfigClassProperty(name = "SQL Source Configs",
+    groupName = ConfigGroups.Names.DELTA_STREAMER,
+    subGroupName = ConfigGroups.SubGroupNames.DELTA_STREAMER_SOURCE,
+    description = "Configurations controlling the behavior of SQL source in Deltastreamer.")
+public class SqlSourceConfig extends HoodieConfig {
+
+  public static final ConfigProperty<String> SOURCE_SQL = ConfigProperty
+      .key("hoodie.deltastreamer.source.sql.sql.query")
+      .noDefaultValue()
+      .withDocumentation("");

Review Comment:
   Docs.



##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/config/CloudSourceConfig.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.utilities.config;
+
+import org.apache.hudi.common.config.ConfigClassProperty;
+import org.apache.hudi.common.config.ConfigGroups;
+import org.apache.hudi.common.config.ConfigProperty;
+import org.apache.hudi.common.config.HoodieConfig;
+
+import javax.annotation.concurrent.Immutable;
+
+/**
+ * Cloud Source Configs
+ */
+@Immutable
+@ConfigClassProperty(name = "Cloud Source Configs",
+    groupName = ConfigGroups.Names.DELTA_STREAMER,
+    subGroupName = ConfigGroups.SubGroupNames.DELTA_STREAMER_SOURCE,
+    description = "Configs that are common during ingestion across different cloud stores")
+public class CloudSourceConfig extends HoodieConfig {

Review Comment:
   Let's take this separately.  This refactoring PR does not intend to change any behavior and purely for moving configs to use `ConfigProperty` class.
   
   @lokeshj1703 could you file JIRA to track this?



##########
hudi-utilities/src/main/java/org/apache/hudi/utilities/config/SourceTestConfig.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.utilities.config;
+
+import org.apache.hudi.common.config.ConfigProperty;
+
+/**
+ * Configurations for Test Data Sources.
+ */
+public class SourceTestConfig {

Review Comment:
   This is for tests only.  Let's move the class to test package.



-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org