Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,14 @@ public DirectoryScanner(FsDatasetSpi<?> dataset, Configuration conf) {
conf.getInt(DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_THREADS_KEY,
DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_THREADS_DEFAULT);

if (threads <= 0) {
LOG.warn("Invalid value configured for "
+ DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_THREADS_KEY
+ " ({}), must be greater than 0. Using default ({}).",
threads, DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_THREADS_DEFAULT);
threads = DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_THREADS_DEFAULT;
}

reportCompileThreadPool =
Executors.newFixedThreadPool(threads, new Daemon.DaemonFactory());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,34 @@ public void setup() {
LazyPersistTestCase.initCacheManipulator();
}

/**
* HDFS-17824: When dfs.datanode.directoryscan.threads is 0 or negative,
* DirectoryScanner should use the default instead of throwing
* IllegalArgumentException from Executors.newFixedThreadPool(threads).
*/
@Test
@Timeout(value = 30)
public void testInvalidDirectoryScanThreadsUsesDefault() throws Exception {
Configuration conf = getConfiguration();
conf.setInt(DFSConfigKeys.DFS_DATANODE_DIRECTORYSCAN_THREADS_KEY, 0);
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
try {
cluster.waitActive();
bpid = cluster.getNamesystem().getBlockPoolId();
fds = DataNodeTestUtils.getFSDataset(cluster.getDataNodes().get(0));
scanner = new DirectoryScanner(fds, conf);
scanner.start();
assertTrue(scanner.getRunStatus());
} finally {
if (scanner != null) {
scanner.shutdown();
}
if (cluster != null) {
cluster.shutdown();
}
}
}

/** create a file with a length of <code>fileLen</code>. */
private List<LocatedBlock> createFile(String fileNamePrefix, long fileLen,
boolean isLazyPersist) throws IOException {
Expand Down
Loading