Skip to content

Commit 6a29976

Browse files
committed
[apache#6562] improvement(catalogs): Optimize the code path in createFileset and optimize path
Set the number of core threads and queue size, and set the idle time.
1 parent dc15896 commit 6a29976

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

catalogs/catalog-hadoop/src/main/java/org/apache/gravitino/catalog/hadoop/HadoopCatalogOperations.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
import java.util.Map;
3333
import java.util.Optional;
3434
import java.util.concurrent.ExecutionException;
35-
import java.util.concurrent.ExecutorService;
36-
import java.util.concurrent.Executors;
3735
import java.util.concurrent.Future;
36+
import java.util.concurrent.LinkedBlockingQueue;
37+
import java.util.concurrent.ThreadPoolExecutor;
3838
import java.util.concurrent.TimeUnit;
3939
import java.util.concurrent.TimeoutException;
4040
import org.apache.commons.lang3.StringUtils;
@@ -84,9 +84,13 @@ public class HadoopCatalogOperations extends ManagedSchemaOperations
8484
implements CatalogOperations, FilesetCatalog {
8585
private static final String SCHEMA_DOES_NOT_EXIST_MSG = "Schema %s does not exist";
8686
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(
87+
private static final ThreadPoolExecutor FILE_SYSTEM_EXECUTOR =
88+
new ThreadPoolExecutor(
89+
2,
8990
Math.max(2, Runtime.getRuntime().availableProcessors() / 2),
91+
60L,
92+
TimeUnit.SECONDS,
93+
new LinkedBlockingQueue<>(100),
9094
r -> {
9195
Thread thread = new Thread(r, "FileSystem-Get-Thread");
9296
thread.setDaemon(true);
@@ -110,6 +114,10 @@ public class HadoopCatalogOperations extends ManagedSchemaOperations
110114

111115
private FileSystemProvider defaultFileSystemProvider;
112116

117+
static {
118+
FILE_SYSTEM_EXECUTOR.allowCoreThreadTimeOut(true);
119+
}
120+
113121
HadoopCatalogOperations(EntityStore store) {
114122
this.store = store;
115123
}

0 commit comments

Comments
 (0)