boneanxs commented on code in PR #9617: URL: https://github.com/apache/hudi/pull/9617#discussion_r1324464738
########## hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieTimeGeneratorConfig.java: ########## @@ -0,0 +1,113 @@ +/* + * 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.common.table.timeline; + +import org.apache.hudi.common.config.ConfigProperty; +import org.apache.hudi.common.config.HoodieConfig; +import org.apache.hudi.common.config.LockConfiguration; +import org.apache.hudi.common.util.Option; +import org.apache.hudi.common.util.ValidationUtils; + +import java.util.Properties; + +import static org.apache.hudi.common.config.LockConfiguration.LOCK_PREFIX; + +public class HoodieTimeGeneratorConfig extends HoodieConfig { + + private static final String BASE_PATH = "hoodie.base.path"; + + public static final ConfigProperty<String> TRUE_TIME_GENERATOR_IMPL = ConfigProperty + .key("hoodie.true.time.generator.impl") + .defaultValue(WaitBasedTimeGenerator.class.getName()) + .sinceVersion("1.0.0") + .markAdvanced() + .withDocumentation("TrueTime generator class name"); + + public static final ConfigProperty<String> TRUE_TIME_LOCK_PROVIDER = ConfigProperty + .key(LOCK_PREFIX + "provider") + .defaultValue("org.apache.hudi.client.transaction.lock.InProcessLockProvider") + .sinceVersion("1.0.0") + .markAdvanced() + .withDocumentation("Lock provider class name used in TrueTime, user can provide " + + "their own implementation of LockProvider which should be subclass of " + + "org.apache.hudi.common.lock.LockProvider"); + + public static final ConfigProperty<Long> MAX_EXPECTED_CLOCK_SKEW_MS = ConfigProperty + .key("hoodie.true.time.generator.max_expected_clock_skew_ms") + .defaultValue(500L) + .withInferFunction(cfg -> { + if (cfg.getStringOrDefault(TRUE_TIME_LOCK_PROVIDER).equals(TRUE_TIME_LOCK_PROVIDER.defaultValue())) { + return Option.of(1L); + } + return Option.empty(); + }) + .sinceVersion("1.0.0") + .markAdvanced() + .withDocumentation("The max expected clock skew time for WaitBasedTrueTimeGenerator"); + + private HoodieTimeGeneratorConfig() { + super(); + } + + public String getTrueTimeGeneratorImpl() { + return props.getProperty(TRUE_TIME_GENERATOR_IMPL.key(), TRUE_TIME_GENERATOR_IMPL.defaultValue()); + } + + public long getMaxExpectedClockSkewMs() { + return props.getLong(MAX_EXPECTED_CLOCK_SKEW_MS.key(), MAX_EXPECTED_CLOCK_SKEW_MS.defaultValue()); + } + + public String getBasePath() { + return props.getString(BASE_PATH); + } + + public static HoodieTimeGeneratorConfig.Builder newBuilder() { + return new HoodieTimeGeneratorConfig.Builder(); + } + + public static class Builder { + private final HoodieTimeGeneratorConfig timeGeneratorConfig = new HoodieTimeGeneratorConfig(); Review Comment: Since we need to set default in build() method, we need to create `HoodieTimeGeneratorConfig` first, also, this is compatible with other HoodieConfig -- 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]
