Skip to content

Commit 3b33083

Browse files
authored
add the dst create dir recursive check (#79)
Co-authored-by: alantong(佟明达) <[email protected]>
1 parent 6bf09d6 commit 3b33083

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/main/java/org/apache/hadoop/fs/CosFileSystem.java

-1
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ private boolean useOFSRanger() {
484484
*/
485485
private void checkCustomAuth(Configuration conf) throws IOException {
486486
// todo: need get token first
487-
checkInitialized();
488487
this.rangerCredentialsClient.doCheckCustomAuth(conf);
489488
}
490489

src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java

+4
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,8 @@ public class CosNConfigKeys extends CommonConfigurationKeys {
160160
public static final String COSN_POSIX_BUCKET_USE_OFS_RANGER_ENABLED = "fs.cosn.posix.bucket.use_ofs_ranger.enabled";
161161
public static final boolean DEFAULT_COSN_POSIX_BUCKET_USE_OFS_RANGER_ENABLED = false;
162162

163+
// create() recursive check dst dir which increase the getFileStatus call which increase head and list qps.
164+
// please notice when set to false may lose data, so only change to false when you know what are you doing.
165+
public static final String COSN_CREATE_RECURSIVE_CHECK_DST_DIR_ENABLED = "fs.cosn.create.recursive.check_dst_dir.enabled";
166+
public static final boolean DEFAULT_COSN_CREATE_RECURSIVE_CHECK_DST_DIR_ENABLED = true;
163167
}

src/main/java/org/apache/hadoop/fs/CosNFileSystem.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class CosNFileSystem extends FileSystem {
4343
private boolean isPosixBucket;
4444
private NativeFileSystemStore nativeStore;
4545
private boolean isDefaultNativeStore;
46+
private boolean isCreateRecursiveCheckDstDir;
4647
private Path workingDir;
4748
private String owner = "Unknown";
4849
private String group = "Unknown";
@@ -120,6 +121,11 @@ public void initialize(URI uri, Configuration conf) throws IOException {
120121
CosNConfigKeys.READ_AHEAD_QUEUE_SIZE,
121122
CosNConfigKeys.DEFAULT_READ_AHEAD_QUEUE_SIZE
122123
);
124+
125+
this.isCreateRecursiveCheckDstDir = this.getConf().getBoolean(
126+
CosNConfigKeys.COSN_CREATE_RECURSIVE_CHECK_DST_DIR_ENABLED,
127+
CosNConfigKeys.DEFAULT_COSN_CREATE_RECURSIVE_CHECK_DST_DIR_ENABLED
128+
);
123129
Preconditions.checkArgument(uploadThreadPoolSize > 0,
124130
String.format("The uploadThreadPoolSize[%d] should be positive.", uploadThreadPoolSize));
125131
Preconditions.checkArgument(readAheadPoolSize > 0,
@@ -296,7 +302,9 @@ public FSDataOutputStream create(Path f, FsPermission permission,
296302
throw new FileAlreadyExistsException("Directory already exists: " + f);
297303
}
298304
} catch (FileNotFoundException e) {
299-
validatePath(f);
305+
if (this.isCreateRecursiveCheckDstDir) {
306+
validatePath(f);
307+
}
300308
}
301309

302310
Path absolutePath = makeAbsolute(f);

0 commit comments

Comments
 (0)