@Test public void testCreateCacheDirectories_oneCacheParentExists() { CacheConfig.setCacheDataDirPrefix(conf, cacheTestDirPrefix); CacheConfig.setCacheDataDirSuffix(conf, "/fcache/"); CacheConfig.setMaxDisks(conf, maxDisks + 1); try { CacheUtil.createCacheDirectories(conf); } catch (FileNotFoundException e) { fail("One of the cache parent directories exists"); } }
public static void createCacheDirectories(Configuration conf) throws FileNotFoundException { final List<String> dirPrefixList = getDirPrefixList(conf); final int maxDisks = CacheConfig.getCacheMaxDisks(conf); boolean parentDirectoryExists = false; for (String dirPrefix : dirPrefixList) { for (int i = 0; i < maxDisks; ++i) { final String cacheParentDir = dirPrefix + i; if (exists(cacheParentDir)) { parentDirectoryExists = true; final String cacheDirPath = cacheParentDir + "/" + CacheConfig.getCacheDataDirSuffix(conf); createCacheDirectory(cacheDirPath, conf); } } } if (!parentDirectoryExists) { for (String dirPrefix : dirPrefixList) { if (exists(dirPrefix)) { parentDirectoryExists = true; final String cacheDirPath = dirPrefix + "/" + CacheConfig.getCacheDataDirSuffix(conf); createCacheDirectory(cacheDirPath, conf); } } } if (!parentDirectoryExists) { throw new FileNotFoundException(String.format("None of the cache parent directories exists")); } }
CacheUtil { public static void createCacheDirectories(Configuration conf) throws FileNotFoundException { final List<String> dirPrefixList = getDirPrefixList(conf); final int maxDisks = CacheConfig.getCacheMaxDisks(conf); boolean parentDirectoryExists = false; for (String dirPrefix : dirPrefixList) { for (int i = 0; i < maxDisks; ++i) { final String cacheParentDir = dirPrefix + i; if (exists(cacheParentDir)) { parentDirectoryExists = true; final String cacheDirPath = cacheParentDir + "/" + CacheConfig.getCacheDataDirSuffix(conf); createCacheDirectory(cacheDirPath, conf); } } } if (!parentDirectoryExists) { for (String dirPrefix : dirPrefixList) { if (exists(dirPrefix)) { parentDirectoryExists = true; final String cacheDirPath = dirPrefix + "/" + CacheConfig.getCacheDataDirSuffix(conf); createCacheDirectory(cacheDirPath, conf); } } } if (!parentDirectoryExists) { throw new FileNotFoundException(String.format("None of the cache parent directories exists")); } } }
CacheUtil { public static void createCacheDirectories(Configuration conf) throws FileNotFoundException { final List<String> dirPrefixList = getDirPrefixList(conf); final int maxDisks = CacheConfig.getCacheMaxDisks(conf); boolean parentDirectoryExists = false; for (String dirPrefix : dirPrefixList) { for (int i = 0; i < maxDisks; ++i) { final String cacheParentDir = dirPrefix + i; if (exists(cacheParentDir)) { parentDirectoryExists = true; final String cacheDirPath = cacheParentDir + "/" + CacheConfig.getCacheDataDirSuffix(conf); createCacheDirectory(cacheDirPath, conf); } } } if (!parentDirectoryExists) { for (String dirPrefix : dirPrefixList) { if (exists(dirPrefix)) { parentDirectoryExists = true; final String cacheDirPath = dirPrefix + "/" + CacheConfig.getCacheDataDirSuffix(conf); createCacheDirectory(cacheDirPath, conf); } } } if (!parentDirectoryExists) { throw new FileNotFoundException(String.format("None of the cache parent directories exists")); } } private  CacheUtil(); }
CacheUtil { public static void createCacheDirectories(Configuration conf) throws FileNotFoundException { final List<String> dirPrefixList = getDirPrefixList(conf); final int maxDisks = CacheConfig.getCacheMaxDisks(conf); boolean parentDirectoryExists = false; for (String dirPrefix : dirPrefixList) { for (int i = 0; i < maxDisks; ++i) { final String cacheParentDir = dirPrefix + i; if (exists(cacheParentDir)) { parentDirectoryExists = true; final String cacheDirPath = cacheParentDir + "/" + CacheConfig.getCacheDataDirSuffix(conf); createCacheDirectory(cacheDirPath, conf); } } } if (!parentDirectoryExists) { for (String dirPrefix : dirPrefixList) { if (exists(dirPrefix)) { parentDirectoryExists = true; final String cacheDirPath = dirPrefix + "/" + CacheConfig.getCacheDataDirSuffix(conf); createCacheDirectory(cacheDirPath, conf); } } } if (!parentDirectoryExists) { throw new FileNotFoundException(String.format("None of the cache parent directories exists")); } } private  CacheUtil(); static void createCacheDirectories(Configuration conf); static int getCacheDiskCount(Configuration conf); static HashMap<Integer, String> getCacheDiskPathsMap(final Configuration conf); static String getDirPath(int dirIndex, Configuration conf); static String getLocalPath(String remotePath, Configuration conf, int generationNumber); static String getMetadataFilePath(String remotePath, Configuration conf, int generationNumber); static boolean isMetadataFile(String filePath, Configuration conf); static boolean skipCache(String path, Configuration conf); static List<String> getDirPrefixList(Configuration conf); static String getName(String remotePath); }
CacheUtil { public static void createCacheDirectories(Configuration conf) throws FileNotFoundException { final List<String> dirPrefixList = getDirPrefixList(conf); final int maxDisks = CacheConfig.getCacheMaxDisks(conf); boolean parentDirectoryExists = false; for (String dirPrefix : dirPrefixList) { for (int i = 0; i < maxDisks; ++i) { final String cacheParentDir = dirPrefix + i; if (exists(cacheParentDir)) { parentDirectoryExists = true; final String cacheDirPath = cacheParentDir + "/" + CacheConfig.getCacheDataDirSuffix(conf); createCacheDirectory(cacheDirPath, conf); } } } if (!parentDirectoryExists) { for (String dirPrefix : dirPrefixList) { if (exists(dirPrefix)) { parentDirectoryExists = true; final String cacheDirPath = dirPrefix + "/" + CacheConfig.getCacheDataDirSuffix(conf); createCacheDirectory(cacheDirPath, conf); } } } if (!parentDirectoryExists) { throw new FileNotFoundException(String.format("None of the cache parent directories exists")); } } private  CacheUtil(); static void createCacheDirectories(Configuration conf); static int getCacheDiskCount(Configuration conf); static HashMap<Integer, String> getCacheDiskPathsMap(final Configuration conf); static String getDirPath(int dirIndex, Configuration conf); static String getLocalPath(String remotePath, Configuration conf, int generationNumber); static String getMetadataFilePath(String remotePath, Configuration conf, int generationNumber); static boolean isMetadataFile(String filePath, Configuration conf); static boolean skipCache(String path, Configuration conf); static List<String> getDirPrefixList(Configuration conf); static String getName(String remotePath); static final int UNKONWN_GENERATION_NUMBER; static final int DUMMY_MODE_GENERATION_NUMBER; }