Skip to content

Commit 4426ad7

Browse files
committed
Added config for rename resilience
1 parent e8ce29f commit 4426ad7

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AbfsConfiguration.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ public class AbfsConfiguration{
328328
FS_AZURE_ENABLE_ABFS_LIST_ITERATOR, DefaultValue = DEFAULT_ENABLE_ABFS_LIST_ITERATOR)
329329
private boolean enableAbfsListIterator;
330330

331+
@BooleanConfigurationValidatorAnnotation(ConfigurationKey =
332+
FS_AZURE_ABFS_RENAME_RESILIENCE, DefaultValue = DEFAULT_ENABLE_ABFS_RENAME_RESILIENCE)
333+
private boolean renameResilience;
334+
331335
public AbfsConfiguration(final Configuration rawConfig, String accountName)
332336
throws IllegalAccessException, InvalidConfigurationValueException, IOException {
333337
this.rawConfig = ProviderUtils.excludeIncompatibleCredentialProviders(
@@ -1130,4 +1134,11 @@ public void setEnableAbfsListIterator(boolean enableAbfsListIterator) {
11301134
this.enableAbfsListIterator = enableAbfsListIterator;
11311135
}
11321136

1137+
public boolean getRenameResilience() {
1138+
return renameResilience;
1139+
}
1140+
1141+
void setRenameResilience(boolean actualResilience) {
1142+
renameResilience = actualResilience;
1143+
}
11331144
}

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/AzureBlobFileSystem.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,19 @@ public boolean rename(final Path src, final Path dst) throws IOException {
441441
return dstFileStatus.isDirectory() ? false : true;
442442
}
443443

444+
boolean isNamespaceEnabled = abfsStore.getIsNamespaceEnabled(tracingContext);
445+
444446
// Non-HNS account need to check dst status on driver side.
445-
if (!abfsStore.getIsNamespaceEnabled(tracingContext) && dstFileStatus == null) {
447+
if (!isNamespaceEnabled && dstFileStatus == null) {
446448
dstFileStatus = tryGetFileStatus(qualifiedDstPath, tracingContext);
447449
}
448450

451+
// for Non-HNS accounts, rename resiliency cannot be maintained
452+
// as eTags are not preserved in rename
453+
if (!isNamespaceEnabled) {
454+
abfsStore.getAbfsConfiguration().setRenameResilience(false);
455+
}
456+
449457
try {
450458
String sourceFileName = src.getName();
451459
Path adjustedDst = dst;

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/constants/ConfigurationKeys.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ public final class ConfigurationKeys {
233233
/** Key for rate limit capacity, as used by IO operations which try to throttle themselves. */
234234
public static final String FS_AZURE_ABFS_IO_RATE_LIMIT = "fs.azure.io.rate.limit";
235235

236+
/** Add extra resilience to rename failures, at the expense of performance. */
237+
public static final String FS_AZURE_ABFS_RENAME_RESILIENCE = "fs.azure.enable.rename.resilience";
238+
236239
public static String accountProperty(String property, String account) {
237240
return property + "." + account;
238241
}

hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/constants/FileSystemConfigurations.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public final class FileSystemConfigurations {
118118

119119
public static final int STREAM_ID_LEN = 12;
120120
public static final boolean DEFAULT_ENABLE_ABFS_LIST_ITERATOR = true;
121+
public static final boolean DEFAULT_ENABLE_ABFS_RENAME_RESILIENCE = true;
121122

122123
/**
123124
* Limit of queued block upload operations before writes

0 commit comments

Comments
 (0)