Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,8 @@ protected static int upgradeOrDowngradeTable(JavaSparkContext jsc, String basePa
HoodieTableMetaClient metaClient =
HoodieTableMetaClient.builder().setConf(jsc.hadoopConfiguration()).setBasePath(config.getBasePath())
.setLoadActiveTimelineOnLoad(false).setConsistencyGuardConfig(config.getConsistencyGuardConfig())
.setLayoutVersion(Option.of(new TimelineLayoutVersion(config.getTimelineLayoutVersion()))).build();
.setLayoutVersion(Option.of(new TimelineLayoutVersion(config.getTimelineLayoutVersion())))
.setFileSystemRetryConfig(config.getFileSystemRetryConfig()).build();
try {
new UpgradeDowngrade(metaClient, config, new HoodieSparkEngineContext(jsc), SparkUpgradeDowngradeHelper.getInstance())
.run(HoodieTableVersion.valueOf(toVersion), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ protected void initWrapperFSMetrics() {
protected HoodieTableMetaClient createMetaClient(boolean loadActiveTimelineOnLoad) {
return HoodieTableMetaClient.builder().setConf(hadoopConf).setBasePath(config.getBasePath())
.setLoadActiveTimelineOnLoad(loadActiveTimelineOnLoad).setConsistencyGuardConfig(config.getConsistencyGuardConfig())
.setLayoutVersion(Option.of(new TimelineLayoutVersion(config.getTimelineLayoutVersion()))).build();
.setLayoutVersion(Option.of(new TimelineLayoutVersion(config.getTimelineLayoutVersion())))
.setFileSystemRetryConfig(config.getFileSystemRetryConfig()).build();
}

public Option<EmbeddedTimelineService> getTimelineServer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.hudi.common.config.HoodieMetadataConfig;
import org.apache.hudi.common.engine.EngineType;
import org.apache.hudi.common.fs.ConsistencyGuardConfig;
import org.apache.hudi.common.fs.FileSystemRetryConfig;
import org.apache.hudi.common.model.HoodieCleaningPolicy;
import org.apache.hudi.common.model.HoodieFailedWritesCleaningPolicy;
import org.apache.hudi.common.model.HoodieFileFormat;
Expand Down Expand Up @@ -434,6 +435,7 @@ public class HoodieWriteConfig extends HoodieConfig {
.withDocumentation("File Id Prefix provider class, that implements `org.apache.hudi.fileid.FileIdPrefixProvider`");

private ConsistencyGuardConfig consistencyGuardConfig;
private FileSystemRetryConfig fileSystemRetryConfig;

// Hoodie Write Client transparently rewrites File System View config when embedded mode is enabled
// We keep track of original config and rewritten config
Expand Down Expand Up @@ -827,6 +829,7 @@ protected HoodieWriteConfig(EngineType engineType, Properties props) {
newProps.putAll(props);
this.engineType = engineType;
this.consistencyGuardConfig = ConsistencyGuardConfig.newBuilder().fromProperties(newProps).build();
this.fileSystemRetryConfig = FileSystemRetryConfig.newBuilder().fromProperties(newProps).build();
this.clientSpecifiedViewStorageConfig = FileSystemViewStorageConfig.newBuilder().fromProperties(newProps).build();
this.viewStorageConfig = clientSpecifiedViewStorageConfig;
this.hoodiePayloadConfig = HoodiePayloadConfig.newBuilder().fromProperties(newProps).build();
Expand Down Expand Up @@ -1651,6 +1654,10 @@ public ConsistencyGuardConfig getConsistencyGuardConfig() {
return consistencyGuardConfig;
}

public FileSystemRetryConfig getFileSystemRetryConfig() {
return fileSystemRetryConfig;
}

public void setConsistencyGuardConfig(ConsistencyGuardConfig consistencyGuardConfig) {
this.consistencyGuardConfig = consistencyGuardConfig;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public static <T extends HoodieRecordPayload> HoodieFlinkTable<T> create(HoodieW
HoodieTableMetaClient metaClient =
HoodieTableMetaClient.builder().setConf(context.getHadoopConf().get()).setBasePath(config.getBasePath())
.setLoadActiveTimelineOnLoad(true).setConsistencyGuardConfig(config.getConsistencyGuardConfig())
.setLayoutVersion(Option.of(new TimelineLayoutVersion(config.getTimelineLayoutVersion()))).build();
.setLayoutVersion(Option.of(new TimelineLayoutVersion(config.getTimelineLayoutVersion())))
.setFileSystemRetryConfig(config.getFileSystemRetryConfig()).build();
return HoodieFlinkTable.create(config, context, metaClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public static <T extends HoodieRecordPayload> HoodieSparkTable<T> create(HoodieW
HoodieTableMetaClient metaClient =
HoodieTableMetaClient.builder().setConf(context.getHadoopConf().get()).setBasePath(config.getBasePath())
.setLoadActiveTimelineOnLoad(true).setConsistencyGuardConfig(config.getConsistencyGuardConfig())
.setLayoutVersion(Option.of(new TimelineLayoutVersion(config.getTimelineLayoutVersion()))).build();
.setLayoutVersion(Option.of(new TimelineLayoutVersion(config.getTimelineLayoutVersion())))
.setFileSystemRetryConfig(config.getFileSystemRetryConfig()).build();
return HoodieSparkTable.create(config, (HoodieSparkEngineContext) context, metaClient, refreshTimeline);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
* 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.fs;

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 java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

/**
* The file system retry relevant config options.
*/
@ConfigClassProperty(name = "FileSystem Guard Configurations",
groupName = ConfigGroups.Names.WRITE_CLIENT,
description = "The filesystem retry related config options, to help deal with runtime exception like list/get/put/delete performance issues.")
public class FileSystemRetryConfig extends HoodieConfig {

public static final ConfigProperty<String> FILESYSTEM_RETRY_ENABLE = ConfigProperty
.key("hoodie.filesystem.operation.retry.enable")
.defaultValue("false")
.sinceVersion("0.11.0")
.withDocumentation("Enabled to handle list/get/delete etc file system performance issue.");

public static final ConfigProperty<Long> INITIAL_RETRY_INTERVAL_MS = ConfigProperty
.key("hoodie.filesystem.operation.retry.initial_interval_ms")
.defaultValue(100L)
.sinceVersion("0.11.0")
.withDocumentation("Amount of time (in ms) to wait, before retry to do operations on storage.");

public static final ConfigProperty<Long> MAX_RETRY_INTERVAL_MS = ConfigProperty
.key("hoodie.filesystem.operation.retry.max_interval_ms")
.defaultValue(2000L)
.sinceVersion("0.11.0")
.withDocumentation("Maximum amount of time (in ms), to wait for next retry.");

public static final ConfigProperty<Integer> MAX_RETRY_NUMBERS = ConfigProperty
.key("hoodie.filesystem.operation.retry.max_numbers")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be we can name this as "hoodie.filesystem.operation.retry.max.count"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max_times seems better ?

.defaultValue(4)
.sinceVersion("0.11.0")
.withDocumentation("Maximum number of retry actions to perform, with exponential backoff.");

private FileSystemRetryConfig() {
super();
}

public long getInitialRetryIntervalMs() {
return getLong(INITIAL_RETRY_INTERVAL_MS);
}

public long getMaxRetryIntervalMs() {
return getLong(MAX_RETRY_INTERVAL_MS);
}

public int getMaxRetryNumbers() {
return getInt(MAX_RETRY_NUMBERS);
}

public boolean isFileSystemActionRetryEnable() {
return Boolean.parseBoolean(getStringOrDefault(FILESYSTEM_RETRY_ENABLE));
}

public static FileSystemRetryConfig.Builder newBuilder() {
return new Builder();
}

/**
* The builder used to build filesystem configurations.
*/
public static class Builder {

private final FileSystemRetryConfig fileSystemRetryConfig = new FileSystemRetryConfig();

public Builder fromFile(File propertiesFile) throws IOException {
try (FileReader reader = new FileReader(propertiesFile)) {
fileSystemRetryConfig.getProps().load(reader);
return this;
}
}

public Builder fromProperties(Properties props) {
this.fileSystemRetryConfig.getProps().putAll(props);
return this;
}

public Builder withMaxRetryNumbers(int numbers) {
fileSystemRetryConfig.setValue(MAX_RETRY_NUMBERS, String.valueOf(numbers));
return this;
}

public Builder withInitialRetryIntervalMs(long intervalMs) {
fileSystemRetryConfig.setValue(INITIAL_RETRY_INTERVAL_MS, String.valueOf(intervalMs));
return this;
}

public Builder withMaxRetryIntervalMs(long intervalMs) {
fileSystemRetryConfig.setValue(MAX_RETRY_INTERVAL_MS, String.valueOf(intervalMs));
return this;
}

public Builder withFileSystemActionRetryEnabled(boolean enabled) {
fileSystemRetryConfig.setValue(FILESYSTEM_RETRY_ENABLE, String.valueOf(enabled));
return this;
}

public FileSystemRetryConfig build() {
fileSystemRetryConfig.setDefaults(FileSystemRetryConfig.class.getName());
return fileSystemRetryConfig;
}
}
}
Loading