HDFS-15072. HDFS MiniCluster fails to start when run in directory path with a %. (#1775)

This commit is contained in:
Masatake Iwasaki 2020-01-08 11:28:34 +09:00 committed by Akira Ajisaka
parent a7fccc1122
commit a43c177f1d
2 changed files with 16 additions and 2 deletions

View File

@ -203,9 +203,10 @@ protected ThreadPoolExecutor initializeCacheExecutor(File parent) {
DFSConfigKeys.DFS_DATANODE_FSDATASETCACHE_MAX_THREADS_PER_VOLUME_KEY,
DFSConfigKeys.DFS_DATANODE_FSDATASETCACHE_MAX_THREADS_PER_VOLUME_DEFAULT);
String escapedPath = parent.toString().replaceAll("%", "%%");
ThreadFactory workerFactory = new ThreadFactoryBuilder()
.setDaemon(true)
.setNameFormat("FsVolumeImplWorker-" + parent.toString() + "-%d")
.setNameFormat("FsVolumeImplWorker-" + escapedPath + "-%d")
.build();
ThreadPoolExecutor executor = new ThreadPoolExecutor(
1, maxNumThreads,

View File

@ -950,4 +950,17 @@ public void testBlockReadOpWhileMovingBlock() throws IOException {
}
}
}
@Test(timeout=30000)
public void testDataDirWithPercent() throws IOException {
String baseDir = new FileSystemTestHelper().getTestRootDir();
File dataDir = new File(baseDir, "invalidFormatString-%z");
dataDir.mkdirs();
FsVolumeImpl volumeFixed = new FsVolumeImplBuilder()
.setConf(new HdfsConfiguration())
.setDataset(dataset)
.setStorageID("storage-id")
.setStorageDirectory(
new StorageDirectory(StorageLocation.parse(dataDir.getPath())))
.build();
}
}