@@ -84,10 +84,16 @@ public class HadoopCatalogOperations extends ManagedSchemaOperations
84
84
implements CatalogOperations , FilesetCatalog {
85
85
private static final String SCHEMA_DOES_NOT_EXIST_MSG = "Schema %s does not exist" ;
86
86
private static final String FILESET_DOES_NOT_EXIST_MSG = "Fileset %s does not exist" ;
87
+ private static final ExecutorService FILE_SYSTEM_EXECUTOR =
88
+ Executors .newFixedThreadPool (
89
+ Math .max (2 , Runtime .getRuntime ().availableProcessors () / 2 ),
90
+ r -> {
91
+ Thread thread = new Thread (r , "FileSystem-Get-Thread" );
92
+ thread .setDaemon (true );
93
+ return thread ;
94
+ });
87
95
private static final String SLASH = "/" ;
88
96
private static final Logger LOG = LoggerFactory .getLogger (HadoopCatalogOperations .class );
89
- private static final int TERMINATION_AWAIT_TIMEOUT_SECONDS = 5 ;
90
-
91
97
private final EntityStore store ;
92
98
93
99
private HasPropertyMetadata propertiesMetadata ;
@@ -769,19 +775,11 @@ FileSystem getFileSystem(Path path, Map<String, String> config) throws IOExcepti
769
775
.getOrDefault (
770
776
config , HadoopCatalogPropertiesMetadata .FILESYSTEM_CONNECTION_TIMEOUT_SECONDS );
771
777
772
- ExecutorService executor =
773
- Executors .newSingleThreadExecutor (
774
- r -> {
775
- Thread thread = new Thread (r , "FileSystem-Get-Thread" );
776
- thread .setDaemon (true );
777
- return thread ;
778
- });
779
-
780
778
Future <FileSystem > future = null ;
781
779
782
780
try {
783
781
future =
784
- executor .submit (
782
+ FILE_SYSTEM_EXECUTOR .submit (
785
783
() -> {
786
784
try {
787
785
return provider .getFileSystem (path , config );
@@ -832,19 +830,7 @@ FileSystem getFileSystem(Path path, Map<String, String> config) throws IOExcepti
832
830
if (future != null && !future .isDone ()) {
833
831
future .cancel (true );
834
832
}
835
-
836
- executor .shutdown ();
837
- try {
838
- if (!executor .awaitTermination (TERMINATION_AWAIT_TIMEOUT_SECONDS , TimeUnit .SECONDS )) {
839
- executor .shutdownNow ();
840
- if (!executor .awaitTermination (TERMINATION_AWAIT_TIMEOUT_SECONDS , TimeUnit .SECONDS )) {
841
- LOG .error ("ExecutorService did not terminate" );
842
- }
843
- }
844
- } catch (InterruptedException ie ) {
845
- executor .shutdownNow ();
846
- Thread .currentThread ().interrupt ();
847
- }
833
+ LOG .debug ("FileSystem getting task completed" );
848
834
}
849
835
}
850
836
}
0 commit comments