private static LeaseManager createLeaseManager3() throws NoSuchMethodException {
    Method beginFileLeaseMethod =
      DFSClient.class.getDeclaredMethod("beginFileLease", long.class, DFSOutputStream.class);
    beginFileLeaseMethod.setAccessible(true);
    Method endFileLeaseMethod = DFSClient.class.getDeclaredMethod("endFileLease", long.class);
    endFileLeaseMethod.setAccessible(true);
    return new LeaseManager() {

      @Override
      public void begin(FanOutOneBlockAsyncDFSOutput output) {
        try {
          beginFileLeaseMethod.invoke(output.getClient(), output.getDummyStream().getFileId(),
            output.getDummyStream());
        } catch (IllegalAccessException | InvocationTargetException e) {
          throw new RuntimeException(e);
        }
      }

      @Override
      public void end(FanOutOneBlockAsyncDFSOutput output) {
        try {
          endFileLeaseMethod.invoke(output.getClient(), output.getDummyStream().getFileId());
        } catch (IllegalAccessException | InvocationTargetException e) {
          throw new RuntimeException(e);
        }
      }
    };
  }
Helper class for implementing {@link FanOutOneBlockAsyncDFSOutput}.
hbase-asyncfs/src/main/java/org/apache/hadoop/hbase/io/asyncfs/FanOutOneBlockAsyncDFSOutputHelper.java