cxzl25 commented on PR #4917:
URL: https://github.com/apache/hbase/pull/4917#issuecomment-1344045085

   ### Current
   ```java
   Exception in thread "main" java.lang.NoSuchMethodError: 
org.apache.hadoop.hdfs.client.HdfsDataInputStream.getReadStatistics()Lorg/apache/hadoop/hdfs/DFSInputStream$ReadStatistics;
        at 
org.apache.hadoop.hbase.io.FSDataInputStreamWrapper.updateInputStreamStatistics(FSDataInputStreamWrapper.java:249)
        at 
org.apache.hadoop.hbase.io.FSDataInputStreamWrapper.close(FSDataInputStreamWrapper.java:296)
        at 
org.apache.hadoop.hbase.io.hfile.HFileBlock$FSReaderImpl.closeStreams(HFileBlock.java:1825)
        at 
org.apache.hadoop.hbase.io.hfile.HFilePreadReader.close(HFilePreadReader.java:107)
        at 
org.apache.hadoop.hbase.io.hfile.HFileReaderImpl.close(HFileReaderImpl.java:1421)
        at org.test.TestHFile.main(TestHFile.java:39)
   ```
   
   
   
   ### TestHFile
   ```java
   package org.test;
   
   import org.apache.hadoop.conf.Configuration;
   import org.apache.hadoop.fs.FileSystem;
   import org.apache.hadoop.fs.Path;
   import org.apache.hadoop.hbase.KeyValue;
   import org.apache.hadoop.hbase.io.hfile.CacheConfig;
   import org.apache.hadoop.hbase.io.hfile.HFile;
   import org.apache.hadoop.hbase.io.hfile.HFileContext;
   import org.apache.hadoop.hbase.io.hfile.HFileContextBuilder;
   import org.apache.hadoop.hdfs.MiniDFSCluster;
   
   import java.io.IOException;
   
   public class TestHFile {
   
     public static void main(String[] args) throws IOException {
   
       MiniDFSCluster dfsCluster = new MiniDFSCluster.Builder(new 
Configuration()).build();
       FileSystem fs = dfsCluster.getFileSystem();
       Configuration conf = fs.getConf();
   
       Path file = new Path("/tmp/test_hbase_file.hfile");
   
       HFileContext fileContext = new HFileContextBuilder().build();
   
       CacheConfig cacheConfig = new CacheConfig(conf);
       HFile.Writer writer = HFile.getWriterFactory(conf, cacheConfig)
               .withPath(fs, file)
               .withFileContext(fileContext)
               .create();
   
       KeyValue kv = new KeyValue("k1".getBytes(), null, null, "v1".getBytes());
       writer.append(kv);
       writer.close();
   
       HFile.Reader reader = HFile.createReader(fs, file, conf);
       try {
         reader.close();
       } finally {
         dfsCluster.shutdown();
       }
     }
   }
   ```
   ### pom.xml
   ```xml
   <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
     <modelVersion>4.0.0</modelVersion>
   
     <groupId>org.example</groupId>
     <artifactId>hbase_hfile_test</artifactId>
     <version>1.0-SNAPSHOT</version>
     <packaging>jar</packaging>
   
     <name>hbase_hfile_test</name>
   
     <properties>
       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       <hbase.version>2.4.9</hbase.version>
   <!--    <hbase.version>2.5.2-hadoop3</hbase.version>-->
     </properties>
   
     <profiles>
       <profile>
         <id>hadoop-2.10</id>
         <properties>
           <hadoop.version>2.10.0</hadoop.version>
         </properties>
         <dependencies>
           <dependency>
             <groupId>org.apache.hadoop</groupId>
             <artifactId>hadoop-hdfs</artifactId>
             <version>${hadoop.version}</version>
           </dependency>
           <dependency>
             <groupId>org.apache.hadoop</groupId>
             <artifactId>hadoop-hdfs</artifactId>
             <version>${hadoop.version}</version>
             <classifier>tests</classifier>
           </dependency>
           <dependency>
             <groupId>org.apache.hadoop</groupId>
             <artifactId>hadoop-common</artifactId>
             <version>${hadoop.version}</version>
           </dependency>
           <dependency>
             <groupId>org.apache.hadoop</groupId>
             <artifactId>hadoop-common</artifactId>
             <version>${hadoop.version}</version>
             <classifier>tests</classifier>
           </dependency>
         </dependencies>
       </profile>
       <profile>
         <id>hadoop-3.0</id>
         <properties>
           <hadoop.version>3.0.0</hadoop.version>
         </properties>
         <dependencies>
           <dependency>
             <groupId>org.apache.hadoop</groupId>
             <artifactId>hadoop-hdfs</artifactId>
             <version>${hadoop.version}</version>
           </dependency>
           <dependency>
             <groupId>org.apache.hadoop</groupId>
             <artifactId>hadoop-hdfs-client</artifactId>
             <version>${hadoop.version}</version>
           </dependency>
           <dependency>
             <groupId>org.apache.hadoop</groupId>
             <artifactId>hadoop-common</artifactId>
             <version>${hadoop.version}</version>
           </dependency>
           <dependency>
             <groupId>org.apache.hadoop</groupId>
             <artifactId>hadoop-client-minicluster</artifactId>
             <version>${hadoop.version}</version>
             <exclusions>
               <exclusion>
                 <groupId>org.apache.hadoop</groupId>
                 <artifactId>hadoop-client-api</artifactId>
               </exclusion>
             </exclusions>
           </dependency>
         </dependencies>
       </profile>
     </profiles>
   
     <dependencies>
   
       <dependency>
         <groupId>org.apache.hbase</groupId>
         <artifactId>hbase-server</artifactId>
         <version>${hbase.version}</version>
         <exclusions>
           <exclusion>
             <groupId>org.apache.hadoop</groupId>
             <artifactId>hadoop-hdfs</artifactId>
           </exclusion>
           <exclusion>
             <groupId>org.apache.hadoop</groupId>
             <artifactId>hadoop-common</artifactId>
           </exclusion>
         </exclusions>
       </dependency>
   
       <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>4.12</version>
       </dependency>
     </dependencies>
   </project>
   
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to