Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the dst create dir recursive check #79

Merged
merged 1 commit into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/main/java/org/apache/hadoop/fs/CosFileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ private boolean useOFSRanger() {
*/
private void checkCustomAuth(Configuration conf) throws IOException {
// todo: need get token first
checkInitialized();
this.rangerCredentialsClient.doCheckCustomAuth(conf);
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,8 @@ public class CosNConfigKeys extends CommonConfigurationKeys {
public static final String COSN_POSIX_BUCKET_USE_OFS_RANGER_ENABLED = "fs.cosn.posix.bucket.use_ofs_ranger.enabled";
public static final boolean DEFAULT_COSN_POSIX_BUCKET_USE_OFS_RANGER_ENABLED = false;

// create() recursive check dst dir which increase the getFileStatus call which increase head and list qps.
// please notice when set to false may lose data, so only change to false when you know what are you doing.
public static final String COSN_CREATE_RECURSIVE_CHECK_DST_DIR_ENABLED = "fs.cosn.create.recursive.check_dst_dir.enabled";
public static final boolean DEFAULT_COSN_CREATE_RECURSIVE_CHECK_DST_DIR_ENABLED = true;
}
10 changes: 9 additions & 1 deletion src/main/java/org/apache/hadoop/fs/CosNFileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class CosNFileSystem extends FileSystem {
private boolean isPosixBucket;
private NativeFileSystemStore nativeStore;
private boolean isDefaultNativeStore;
private boolean isCreateRecursiveCheckDstDir;
private Path workingDir;
private String owner = "Unknown";
private String group = "Unknown";
Expand Down Expand Up @@ -120,6 +121,11 @@ public void initialize(URI uri, Configuration conf) throws IOException {
CosNConfigKeys.READ_AHEAD_QUEUE_SIZE,
CosNConfigKeys.DEFAULT_READ_AHEAD_QUEUE_SIZE
);

this.isCreateRecursiveCheckDstDir = this.getConf().getBoolean(
CosNConfigKeys.COSN_CREATE_RECURSIVE_CHECK_DST_DIR_ENABLED,
CosNConfigKeys.DEFAULT_COSN_CREATE_RECURSIVE_CHECK_DST_DIR_ENABLED
);
Preconditions.checkArgument(uploadThreadPoolSize > 0,
String.format("The uploadThreadPoolSize[%d] should be positive.", uploadThreadPoolSize));
Preconditions.checkArgument(readAheadPoolSize > 0,
Expand Down Expand Up @@ -296,7 +302,9 @@ public FSDataOutputStream create(Path f, FsPermission permission,
throw new FileAlreadyExistsException("Directory already exists: " + f);
}
} catch (FileNotFoundException e) {
validatePath(f);
if (this.isCreateRecursiveCheckDstDir) {
validatePath(f);
}
}

Path absolutePath = makeAbsolute(f);
Expand Down