DFSClientCache { DFSClient getDfsClient(String userName) { DFSClient client = null; try { client = clientCache.get(userName); } catch (ExecutionException e) { LOG.error( "Failed to create DFSClient for user:" + userName + " Cause:" + e); } return client; } DFSClientCache(Configuration config);   DFSClientCache(Configuration config, int clientCache); void invalidateDfsInputStream(String userName, String inodePath); static final int SHUTDOWN_HOOK_PRIORITY; }
@Test public void testEviction() throws IOException { Configuration conf = new Configuration(); conf.set(FileSystem.FS_DEFAULT_NAME_KEY, "hdfs: final int MAX_CACHE_SIZE = 2; DFSClientCache cache = new DFSClientCache(conf, MAX_CACHE_SIZE); DFSClient c1 = cache.getDfsClient("test1"); assertTrue(cache.getDfsClient("test1").toString().contains("ugi=test1")); assertEquals(c1, cache.getDfsClient("test1")); assertFalse(isDfsClientClose(c1)); cache.getDfsClient("test2"); assertTrue(isDfsClientClose(c1)); assertEquals(MAX_CACHE_SIZE - 1, cache.clientCache.size()); }