@Test public void testGetDiskPathsMap() { CacheConfig.setCacheDataDirPrefix(conf, cacheTestDirPrefix); CacheConfig.setCacheDataDirSuffix(conf, "/fcache/"); CacheConfig.setMaxDisks(conf, maxDisks); createCacheDirectoriesForTest(conf); HashMap<Integer, String> diskPathsMap = CacheUtil.getCacheDiskPathsMap(conf); assertEquals(diskPathsMap.get(0), cacheTestDirPrefix + "0", "Sizes don't match!"); }
public static HashMap<Integer, String> getCacheDiskPathsMap(final Configuration conf) { Supplier<HashMap<Integer, String>> diskPathMapSupplier = Suppliers.memoize(new Supplier<HashMap<Integer, String>>() { @Override public HashMap<Integer, String> get() { final HashMap<Integer, String> dirPathMap = new HashMap<>(); final List<String> dirPrefixList = getDirPrefixList(conf); final String dirSuffix = CacheConfig.getCacheDataDirSuffix(conf); final int maxDisks = CacheConfig.getCacheMaxDisks(conf); int numDisks = 0; for (String dirPrefix : dirPrefixList) { for (int i = 0; i < maxDisks; ++i) { final String cacheDirPath = dirPrefix + i + "/" + dirSuffix; if (exists(cacheDirPath)) { dirPathMap.put(numDisks, dirPrefix + i); ++numDisks; } } } if (numDisks == 0) { for (String dirPrefix : dirPrefixList) { final String cacheDirPath = dirPrefix + "/" + dirSuffix; if (exists(cacheDirPath)) { dirPathMap.put(numDisks, dirPrefix); ++numDisks; } } } return dirPathMap; } }); return diskPathMapSupplier.get(); }
CacheUtil { public static HashMap<Integer, String> getCacheDiskPathsMap(final Configuration conf) { Supplier<HashMap<Integer, String>> diskPathMapSupplier = Suppliers.memoize(new Supplier<HashMap<Integer, String>>() { @Override public HashMap<Integer, String> get() { final HashMap<Integer, String> dirPathMap = new HashMap<>(); final List<String> dirPrefixList = getDirPrefixList(conf); final String dirSuffix = CacheConfig.getCacheDataDirSuffix(conf); final int maxDisks = CacheConfig.getCacheMaxDisks(conf); int numDisks = 0; for (String dirPrefix : dirPrefixList) { for (int i = 0; i < maxDisks; ++i) { final String cacheDirPath = dirPrefix + i + "/" + dirSuffix; if (exists(cacheDirPath)) { dirPathMap.put(numDisks, dirPrefix + i); ++numDisks; } } } if (numDisks == 0) { for (String dirPrefix : dirPrefixList) { final String cacheDirPath = dirPrefix + "/" + dirSuffix; if (exists(cacheDirPath)) { dirPathMap.put(numDisks, dirPrefix); ++numDisks; } } } return dirPathMap; } }); return diskPathMapSupplier.get(); } }
CacheUtil { public static HashMap<Integer, String> getCacheDiskPathsMap(final Configuration conf) { Supplier<HashMap<Integer, String>> diskPathMapSupplier = Suppliers.memoize(new Supplier<HashMap<Integer, String>>() { @Override public HashMap<Integer, String> get() { final HashMap<Integer, String> dirPathMap = new HashMap<>(); final List<String> dirPrefixList = getDirPrefixList(conf); final String dirSuffix = CacheConfig.getCacheDataDirSuffix(conf); final int maxDisks = CacheConfig.getCacheMaxDisks(conf); int numDisks = 0; for (String dirPrefix : dirPrefixList) { for (int i = 0; i < maxDisks; ++i) { final String cacheDirPath = dirPrefix + i + "/" + dirSuffix; if (exists(cacheDirPath)) { dirPathMap.put(numDisks, dirPrefix + i); ++numDisks; } } } if (numDisks == 0) { for (String dirPrefix : dirPrefixList) { final String cacheDirPath = dirPrefix + "/" + dirSuffix; if (exists(cacheDirPath)) { dirPathMap.put(numDisks, dirPrefix); ++numDisks; } } } return dirPathMap; } }); return diskPathMapSupplier.get(); } private  CacheUtil(); }
CacheUtil { public static HashMap<Integer, String> getCacheDiskPathsMap(final Configuration conf) { Supplier<HashMap<Integer, String>> diskPathMapSupplier = Suppliers.memoize(new Supplier<HashMap<Integer, String>>() { @Override public HashMap<Integer, String> get() { final HashMap<Integer, String> dirPathMap = new HashMap<>(); final List<String> dirPrefixList = getDirPrefixList(conf); final String dirSuffix = CacheConfig.getCacheDataDirSuffix(conf); final int maxDisks = CacheConfig.getCacheMaxDisks(conf); int numDisks = 0; for (String dirPrefix : dirPrefixList) { for (int i = 0; i < maxDisks; ++i) { final String cacheDirPath = dirPrefix + i + "/" + dirSuffix; if (exists(cacheDirPath)) { dirPathMap.put(numDisks, dirPrefix + i); ++numDisks; } } } if (numDisks == 0) { for (String dirPrefix : dirPrefixList) { final String cacheDirPath = dirPrefix + "/" + dirSuffix; if (exists(cacheDirPath)) { dirPathMap.put(numDisks, dirPrefix); ++numDisks; } } } return dirPathMap; } }); return diskPathMapSupplier.get(); } 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 HashMap<Integer, String> getCacheDiskPathsMap(final Configuration conf) { Supplier<HashMap<Integer, String>> diskPathMapSupplier = Suppliers.memoize(new Supplier<HashMap<Integer, String>>() { @Override public HashMap<Integer, String> get() { final HashMap<Integer, String> dirPathMap = new HashMap<>(); final List<String> dirPrefixList = getDirPrefixList(conf); final String dirSuffix = CacheConfig.getCacheDataDirSuffix(conf); final int maxDisks = CacheConfig.getCacheMaxDisks(conf); int numDisks = 0; for (String dirPrefix : dirPrefixList) { for (int i = 0; i < maxDisks; ++i) { final String cacheDirPath = dirPrefix + i + "/" + dirSuffix; if (exists(cacheDirPath)) { dirPathMap.put(numDisks, dirPrefix + i); ++numDisks; } } } if (numDisks == 0) { for (String dirPrefix : dirPrefixList) { final String cacheDirPath = dirPrefix + "/" + dirSuffix; if (exists(cacheDirPath)) { dirPathMap.put(numDisks, dirPrefix); ++numDisks; } } } return dirPathMap; } }); return diskPathMapSupplier.get(); } 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; }