@Test (timeout = 30000) public void testIsFileClosed() throws IOException { HTU.getConfiguration().setInt("hbase.lease.recovery.dfs.timeout", 100000); CancelableProgressable reporter = Mockito.mock(CancelableProgressable.class); Mockito.when(reporter.progress()).thenReturn(true); IsFileClosedDistributedFileSystem dfs = Mockito.mock(IsFileClosedDistributedFileSystem.class); Mockito.when(dfs.recoverLease(FILE)). thenReturn(false).thenReturn(false).thenReturn(true); Mockito.when(dfs.isFileClosed(FILE)).thenReturn(true); assertTrue(this.fsHDFSUtils.recoverDFSFileLease(dfs, FILE, HTU.getConfiguration(), reporter)); Mockito.verify(dfs, Mockito.times(2)).recoverLease(FILE); Mockito.verify(dfs, Mockito.times(1)).isFileClosed(FILE); }
private boolean isFileClosed(final DistributedFileSystem dfs, final Method m, final Path p) { try { return (Boolean) m.invoke(dfs, p); } catch (SecurityException e) { LOG.warn("No access", e); } catch (Exception e) { LOG.warn("Failed invocation for " + p.toString(), e); } return false; }
FSHDFSUtils extends FSUtils { private boolean isFileClosed(final DistributedFileSystem dfs, final Method m, final Path p) { try { return (Boolean) m.invoke(dfs, p); } catch (SecurityException e) { LOG.warn("No access", e); } catch (Exception e) { LOG.warn("Failed invocation for " + p.toString(), e); } return false; } }
FSHDFSUtils extends FSUtils { private boolean isFileClosed(final DistributedFileSystem dfs, final Method m, final Path p) { try { return (Boolean) m.invoke(dfs, p); } catch (SecurityException e) { LOG.warn("No access", e); } catch (Exception e) { LOG.warn("Failed invocation for " + p.toString(), e); } return false; }  }
FSHDFSUtils extends FSUtils { private boolean isFileClosed(final DistributedFileSystem dfs, final Method m, final Path p) { try { return (Boolean) m.invoke(dfs, p); } catch (SecurityException e) { LOG.warn("No access", e); } catch (Exception e) { LOG.warn("Failed invocation for " + p.toString(), e); } return false; }  static boolean isSameHdfs(Configuration conf, FileSystem srcFs, FileSystem desFs); @Override void recoverFileLease(final FileSystem fs, final Path p,
      Configuration conf, CancelableProgressable reporter); }
FSHDFSUtils extends FSUtils { private boolean isFileClosed(final DistributedFileSystem dfs, final Method m, final Path p) { try { return (Boolean) m.invoke(dfs, p); } catch (SecurityException e) { LOG.warn("No access", e); } catch (Exception e) { LOG.warn("Failed invocation for " + p.toString(), e); } return false; }  static boolean isSameHdfs(Configuration conf, FileSystem srcFs, FileSystem desFs); @Override void recoverFileLease(final FileSystem fs, final Path p,
      Configuration conf, CancelableProgressable reporter);  }