diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CommonFSUtils.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CommonFSUtils.java index fef8e291b31e..b3cadedbfaa1 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CommonFSUtils.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/CommonFSUtils.java @@ -20,8 +20,6 @@ import java.io.FileNotFoundException; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.net.URI; import java.net.URISyntaxException; import java.util.List; @@ -30,7 +28,6 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataOutputStream; -import org.apache.hadoop.fs.FSDataOutputStreamBuilder; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.LocatedFileStatus; @@ -766,77 +763,6 @@ public static void checkShortCircuitReadBufferSize(final Configuration conf) { conf.setIfUnset(dfsKey, Integer.toString(hbaseSize)); } - private static final class DfsBuilderUtility { - private static final Class> BUILDER; - private static final Method REPLICATE; - - static { - String builderName = "org.apache.hadoop.hdfs.DistributedFileSystem$HdfsDataOutputStreamBuilder"; - Class> builderClass = null; - try { - builderClass = Class.forName(builderName); - } catch (ClassNotFoundException e) { - LOG.debug("{} not available, will not set replicate when creating output stream", builderName); - } - Method replicateMethod = null; - if (builderClass != null) { - try { - replicateMethod = builderClass.getMethod("replicate"); - LOG.debug("Using builder API via reflection for DFS file creation."); - } catch (NoSuchMethodException e) { - LOG.debug("Could not find replicate method on builder; will not set replicate when" + - " creating output stream", e); - } - } - BUILDER = builderClass; - REPLICATE = replicateMethod; - } - - /** - * Attempt to use builder API via reflection to call the replicate method on the given builder. - */ - static void replicate(FSDataOutputStreamBuilder, ?> builder) { - if (BUILDER != null && REPLICATE != null && BUILDER.isAssignableFrom(builder.getClass())) { - try { - REPLICATE.invoke(builder); - } catch (IllegalAccessException | InvocationTargetException e) { - // Should have caught this failure during initialization, so log full trace here - LOG.warn("Couldn't use reflection with builder API", e); - } - } - } - } - - /** - * Attempt to use builder API via reflection to create a file with the given parameters and - * replication enabled. - *
- * Will not attempt to enable replication when passed an HFileSystem. - */ - public static FSDataOutputStream createForWal(FileSystem fs, Path path, boolean overwrite) - throws IOException { - FSDataOutputStreamBuilder, ?> builder = fs.createFile(path).overwrite(overwrite); - DfsBuilderUtility.replicate(builder); - return builder.build(); - } - - /** - * Attempt to use builder API via reflection to create a file with the given parameters and - * replication enabled. - * - * Will not attempt to enable replication when passed an HFileSystem. - */ - public static FSDataOutputStream createForWal(FileSystem fs, Path path, boolean overwrite, - int bufferSize, short replication, long blockSize, boolean isRecursive) throws IOException { - FSDataOutputStreamBuilder, ?> builder = fs.createFile(path).overwrite(overwrite) - .bufferSize(bufferSize).replication(replication).blockSize(blockSize); - if (isRecursive) { - builder.recursive(); - } - DfsBuilderUtility.replicate(builder); - return builder.build(); - } - /** * Helper exception for those cases where the place where we need to check a stream capability * is not where we have the needed context to explain the impact and mitigation for a lack. diff --git a/hbase-procedure/pom.xml b/hbase-procedure/pom.xml index 5cf027096bd5..208682c10689 100644 --- a/hbase-procedure/pom.xml +++ b/hbase-procedure/pom.xml @@ -144,6 +144,10 @@