You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by we...@apache.org on 2021/07/02 09:02:35 UTC

[hbase] branch master updated: HBASE-26057 Remove reflections used to access Hadoop 2 API in FanOutOneBlockAsyncDFSOutputHelper (#3448)

This is an automated email from the ASF dual-hosted git repository.

weichiu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/master by this push:
     new 5ef5e64  HBASE-26057 Remove reflections used to access Hadoop 2 API in FanOutOneBlockAsyncDFSOutputHelper (#3448)
5ef5e64 is described below

commit 5ef5e6401026a00dfb40533c9b4d5c73da0f0114
Author: Wei-Chiu Chuang <we...@apache.org>
AuthorDate: Fri Jul 2 02:01:53 2021 -0700

    HBASE-26057 Remove reflections used to access Hadoop 2 API in FanOutOneBlockAsyncDFSOutputHelper (#3448)
    
    Signed-off-by: Duo Zhang <zh...@apache.org>
    Signed-off-by: Michael Stack <st...@apache.org>
---
 .../FanOutOneBlockAsyncDFSOutputHelper.java        | 47 +---------------------
 1 file changed, 2 insertions(+), 45 deletions(-)

diff --git a/hbase-asyncfs/src/main/java/org/apache/hadoop/hbase/io/asyncfs/FanOutOneBlockAsyncDFSOutputHelper.java b/hbase-asyncfs/src/main/java/org/apache/hadoop/hbase/io/asyncfs/FanOutOneBlockAsyncDFSOutputHelper.java
index 6bed33f..f4a0005 100644
--- a/hbase-asyncfs/src/main/java/org/apache/hadoop/hbase/io/asyncfs/FanOutOneBlockAsyncDFSOutputHelper.java
+++ b/hbase-asyncfs/src/main/java/org/apache/hadoop/hbase/io/asyncfs/FanOutOneBlockAsyncDFSOutputHelper.java
@@ -139,15 +139,6 @@ public final class FanOutOneBlockAsyncDFSOutputHelper {
 
   private static final LeaseManager LEASE_MANAGER;
 
-  // This is used to terminate a recoverFileLease call when FileSystem is already closed.
-  // isClientRunning is not public so we need to use reflection.
-  private interface DFSClientAdaptor {
-
-    boolean isClientRunning(DFSClient client);
-  }
-
-  private static final DFSClientAdaptor DFS_CLIENT_ADAPTOR;
-
   // helper class for creating files.
   private interface FileCreator {
     default HdfsFileStatus create(ClientProtocol instance, String src, FsPermission masked,
@@ -173,22 +164,6 @@ public final class FanOutOneBlockAsyncDFSOutputHelper {
 
   private static final FileCreator FILE_CREATOR;
 
-  private static DFSClientAdaptor createDFSClientAdaptor() throws NoSuchMethodException {
-    Method isClientRunningMethod = DFSClient.class.getDeclaredMethod("isClientRunning");
-    isClientRunningMethod.setAccessible(true);
-    return new DFSClientAdaptor() {
-
-      @Override
-      public boolean isClientRunning(DFSClient client) {
-        try {
-          return (Boolean) isClientRunningMethod.invoke(client);
-        } catch (IllegalAccessException | InvocationTargetException e) {
-          throw new RuntimeException(e);
-        }
-      }
-    };
-  }
-
   private static LeaseManager createLeaseManager() throws NoSuchMethodException {
     Method beginFileLeaseMethod =
         DFSClient.class.getDeclaredMethod("beginFileLease", long.class, DFSOutputStream.class);
@@ -241,18 +216,6 @@ public final class FanOutOneBlockAsyncDFSOutputHelper {
     };
   }
 
-  private static FileCreator createFileCreator2() throws NoSuchMethodException {
-    Method createMethod = ClientProtocol.class.getMethod("create", String.class, FsPermission.class,
-      String.class, EnumSetWritable.class, boolean.class, short.class, long.class,
-      CryptoProtocolVersion[].class);
-
-    return (instance, src, masked, clientName, flag, createParent, replication, blockSize,
-        supportedVersions) -> {
-      return (HdfsFileStatus) createMethod.invoke(instance, src, masked, clientName, flag,
-        createParent, replication, blockSize, supportedVersions);
-    };
-  }
-
   private static FileCreator createFileCreator() throws NoSuchMethodException {
     try {
       return createFileCreator3_3();
@@ -260,12 +223,7 @@ public final class FanOutOneBlockAsyncDFSOutputHelper {
       LOG.debug("ClientProtocol::create wrong number of arguments, should be hadoop 3.2 or below");
     }
 
-    try {
-      return createFileCreator3();
-    } catch (NoSuchMethodException e) {
-      LOG.debug("ClientProtocol::create wrong number of arguments, should be hadoop 2.x");
-    }
-    return createFileCreator2();
+    return createFileCreator3();
   }
 
   // cancel the processing if DFSClient is already closed.
@@ -279,14 +237,13 @@ public final class FanOutOneBlockAsyncDFSOutputHelper {
 
     @Override
     public boolean progress() {
-      return DFS_CLIENT_ADAPTOR.isClientRunning(client);
+      return client.isClientRunning();
     }
   }
 
   static {
     try {
       LEASE_MANAGER = createLeaseManager();
-      DFS_CLIENT_ADAPTOR = createDFSClientAdaptor();
       FILE_CREATOR = createFileCreator();
     } catch (Exception e) {
       String msg = "Couldn't properly initialize access to HDFS internals. Please " +