@@ -34,8 +34,6 @@ public class CosNFileSystem extends FileSystem {
34
34
35
35
static final String SCHEME = "cosn" ;
36
36
static final String PATH_DELIMITER = Path .SEPARATOR ;
37
- static final int BUCKET_LIST_LIMIT = 999 ;
38
- static final int POSIX_BUCKET_LIST_LIMIT = 5000 ;
39
37
static final Charset METADATA_ENCODING = StandardCharsets .UTF_8 ;
40
38
// The length of name:value pair should be less than or equal to 1024 bytes.
41
39
static final int MAX_XATTR_SIZE = 1024 ;
@@ -357,7 +355,11 @@ public boolean delete(Path f, boolean recursive) throws IOException {
357
355
}
358
356
// how to tell the result
359
357
if (!isPosixBucket ) {
360
- internalRecursiveDelete (key );
358
+ int listMaxLength = this .getConf ().getInt (
359
+ CosNConfigKeys .LISTSTATUS_LIST_MAX_KEYS ,
360
+ CosNConfigKeys .DEFAULT_LISTSTATUS_LIST_MAX_KEYS
361
+ );
362
+ internalRecursiveDelete (key , listMaxLength );
361
363
} else {
362
364
internalAutoRecursiveDelete (key );
363
365
}
@@ -372,14 +374,14 @@ public boolean delete(Path f, boolean recursive) throws IOException {
372
374
return true ;
373
375
}
374
376
375
- private void internalRecursiveDelete (String key ) throws IOException {
377
+ private void internalRecursiveDelete (String key , int listMaxLength ) throws IOException {
376
378
CosNDeleteFileContext deleteFileContext = new CosNDeleteFileContext ();
377
379
int deleteToFinishes = 0 ;
378
380
379
381
String priorLastKey = null ;
380
382
do {
381
383
CosNPartialListing listing =
382
- nativeStore .list (key , this . BUCKET_LIST_LIMIT , priorLastKey , true );
384
+ nativeStore .list (key , listMaxLength , priorLastKey , true );
383
385
for (FileMetadata file : listing .getFiles ()) {
384
386
checkPermission (new Path (file .getKey ()), RangerAccessType .DELETE );
385
387
this .boundedCopyThreadPool .execute (new CosNDeleteFileTask (
@@ -486,12 +488,18 @@ public FileStatus getFileStatus(Path f) throws IOException {
486
488
public FileStatus [] listStatus (Path f ) throws IOException {
487
489
Path absolutePath = makeAbsolute (f );
488
490
String key = pathToKey (absolutePath );
489
- int listMaxLength = CosNFileSystem .BUCKET_LIST_LIMIT ;
491
+
492
+ int listMaxLength = this .getConf ().getInt (
493
+ CosNConfigKeys .LISTSTATUS_LIST_MAX_KEYS ,
494
+ CosNConfigKeys .DEFAULT_LISTSTATUS_LIST_MAX_KEYS
495
+ );
490
496
if (isPosixBucket ) {
491
- listMaxLength = CosNFileSystem .POSIX_BUCKET_LIST_LIMIT ;
497
+ listMaxLength = this .getConf ().getInt (
498
+ CosNConfigKeys .LISTSTATUS_POSIX_BUCKET__LIST_MAX_KEYS ,
499
+ CosNConfigKeys .DEFAULT_LISTSTATUS_POSIX_BUCKET_LIST_MAX_KEYS
500
+ );
492
501
}
493
502
494
-
495
503
if (key .length () > 0 ) {
496
504
FileMetadata meta = nativeStore .retrieveMetadata (key );
497
505
if (meta != null && meta .isFile ()) {
@@ -784,16 +792,21 @@ public boolean rename(Path src, Path dst) throws IOException {
784
792
}
785
793
786
794
if (!isPosixBucket ) {
787
- return internalCopyAndDelete (src , dst , srcFileStatus .isDirectory ());
795
+ int listMaxLength = this .getConf ().getInt (
796
+ CosNConfigKeys .LISTSTATUS_LIST_MAX_KEYS ,
797
+ CosNConfigKeys .DEFAULT_LISTSTATUS_LIST_MAX_KEYS
798
+ );
799
+ return internalCopyAndDelete (src , dst , srcFileStatus .isDirectory (), listMaxLength );
788
800
} else {
789
801
return internalRename (src , dst );
790
802
}
791
803
}
792
804
793
- private boolean internalCopyAndDelete (Path srcPath , Path dstPath , boolean isDir ) throws IOException {
805
+ private boolean internalCopyAndDelete (Path srcPath , Path dstPath ,
806
+ boolean isDir , int listMaxLength ) throws IOException {
794
807
boolean result = false ;
795
808
if (isDir ) {
796
- result = this .copyDirectory (srcPath , dstPath );
809
+ result = this .copyDirectory (srcPath , dstPath , listMaxLength );
797
810
} else {
798
811
result = this .copyFile (srcPath , dstPath );
799
812
}
@@ -822,7 +835,7 @@ private boolean copyFile(Path srcPath, Path dstPath) throws IOException {
822
835
return true ;
823
836
}
824
837
825
- private boolean copyDirectory (Path srcPath , Path dstPath ) throws IOException {
838
+ private boolean copyDirectory (Path srcPath , Path dstPath , int listMaxLength ) throws IOException {
826
839
String srcKey = pathToKey (srcPath );
827
840
if (!srcKey .endsWith (PATH_DELIMITER )) {
828
841
srcKey += PATH_DELIMITER ;
@@ -849,7 +862,7 @@ private boolean copyDirectory(Path srcPath, Path dstPath) throws IOException {
849
862
String priorLastKey = null ;
850
863
do {
851
864
CosNPartialListing objectList = this .nativeStore .list (srcKey ,
852
- this . BUCKET_LIST_LIMIT , priorLastKey , true );
865
+ listMaxLength , priorLastKey , true );
853
866
for (FileMetadata file : objectList .getFiles ()) {
854
867
checkPermission (new Path (file .getKey ()), RangerAccessType .DELETE );
855
868
this .boundedCopyThreadPool .execute (new CosNCopyFileTask (
0 commit comments