|
20 | 20 |
|
21 | 21 | import java.io.FileNotFoundException; |
22 | 22 | import java.io.IOException; |
23 | | -import java.lang.reflect.InvocationTargetException; |
24 | | -import java.lang.reflect.Method; |
25 | 23 | import java.net.URI; |
26 | 24 | import java.net.URISyntaxException; |
27 | 25 | import java.util.List; |
|
30 | 28 | import java.util.concurrent.ConcurrentHashMap; |
31 | 29 | import org.apache.hadoop.conf.Configuration; |
32 | 30 | import org.apache.hadoop.fs.FSDataOutputStream; |
33 | | -import org.apache.hadoop.fs.FSDataOutputStreamBuilder; |
34 | 31 | import org.apache.hadoop.fs.FileStatus; |
35 | 32 | import org.apache.hadoop.fs.FileSystem; |
36 | 33 | import org.apache.hadoop.fs.LocatedFileStatus; |
@@ -766,77 +763,6 @@ public static void checkShortCircuitReadBufferSize(final Configuration conf) { |
766 | 763 | conf.setIfUnset(dfsKey, Integer.toString(hbaseSize)); |
767 | 764 | } |
768 | 765 |
|
769 | | - private static final class DfsBuilderUtility { |
770 | | - private static final Class<?> BUILDER; |
771 | | - private static final Method REPLICATE; |
772 | | - |
773 | | - static { |
774 | | - String builderName = "org.apache.hadoop.hdfs.DistributedFileSystem$HdfsDataOutputStreamBuilder"; |
775 | | - Class<?> builderClass = null; |
776 | | - try { |
777 | | - builderClass = Class.forName(builderName); |
778 | | - } catch (ClassNotFoundException e) { |
779 | | - LOG.debug("{} not available, will not set replicate when creating output stream", builderName); |
780 | | - } |
781 | | - Method replicateMethod = null; |
782 | | - if (builderClass != null) { |
783 | | - try { |
784 | | - replicateMethod = builderClass.getMethod("replicate"); |
785 | | - LOG.debug("Using builder API via reflection for DFS file creation."); |
786 | | - } catch (NoSuchMethodException e) { |
787 | | - LOG.debug("Could not find replicate method on builder; will not set replicate when" + |
788 | | - " creating output stream", e); |
789 | | - } |
790 | | - } |
791 | | - BUILDER = builderClass; |
792 | | - REPLICATE = replicateMethod; |
793 | | - } |
794 | | - |
795 | | - /** |
796 | | - * Attempt to use builder API via reflection to call the replicate method on the given builder. |
797 | | - */ |
798 | | - static void replicate(FSDataOutputStreamBuilder<?, ?> builder) { |
799 | | - if (BUILDER != null && REPLICATE != null && BUILDER.isAssignableFrom(builder.getClass())) { |
800 | | - try { |
801 | | - REPLICATE.invoke(builder); |
802 | | - } catch (IllegalAccessException | InvocationTargetException e) { |
803 | | - // Should have caught this failure during initialization, so log full trace here |
804 | | - LOG.warn("Couldn't use reflection with builder API", e); |
805 | | - } |
806 | | - } |
807 | | - } |
808 | | - } |
809 | | - |
810 | | - /** |
811 | | - * Attempt to use builder API via reflection to create a file with the given parameters and |
812 | | - * replication enabled. |
813 | | - * <p/> |
814 | | - * Will not attempt to enable replication when passed an HFileSystem. |
815 | | - */ |
816 | | - public static FSDataOutputStream createForWal(FileSystem fs, Path path, boolean overwrite) |
817 | | - throws IOException { |
818 | | - FSDataOutputStreamBuilder<?, ?> builder = fs.createFile(path).overwrite(overwrite); |
819 | | - DfsBuilderUtility.replicate(builder); |
820 | | - return builder.build(); |
821 | | - } |
822 | | - |
823 | | - /** |
824 | | - * Attempt to use builder API via reflection to create a file with the given parameters and |
825 | | - * replication enabled. |
826 | | - * <p/> |
827 | | - * Will not attempt to enable replication when passed an HFileSystem. |
828 | | - */ |
829 | | - public static FSDataOutputStream createForWal(FileSystem fs, Path path, boolean overwrite, |
830 | | - int bufferSize, short replication, long blockSize, boolean isRecursive) throws IOException { |
831 | | - FSDataOutputStreamBuilder<?, ?> builder = fs.createFile(path).overwrite(overwrite) |
832 | | - .bufferSize(bufferSize).replication(replication).blockSize(blockSize); |
833 | | - if (isRecursive) { |
834 | | - builder.recursive(); |
835 | | - } |
836 | | - DfsBuilderUtility.replicate(builder); |
837 | | - return builder.build(); |
838 | | - } |
839 | | - |
840 | 766 | /** |
841 | 767 | * Helper exception for those cases where the place where we need to check a stream capability |
842 | 768 | * is not where we have the needed context to explain the impact and mitigation for a lack. |
|
0 commit comments