Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-5878

Use getVisibleLength public api from HdfsDataInputStream from Hadoop-2.

    XMLWordPrintableJSON

Details

    • Reviewed

    Description

      SequencFileLogReader:

      Currently Hbase using getFileLength api from DFSInputStream class by reflection. DFSInputStream is not exposed as public. So, this may change in future. Now HDFS exposed HdfsDataInputStream as public API.
      We can make use of it, when we are not able to find the getFileLength api from DFSInputStream as a else condition. So, that we will not have any sudden surprise like we are facing today.

      Also, it is just logging one warn message and proceeding if it throws any exception while getting the length. I think we can re-throw the exception because there is no point in continuing with dataloss.

      long adjust = 0;
      
                try {
                  Field fIn = FilterInputStream.class.getDeclaredField("in");
                  fIn.setAccessible(true);
                  Object realIn = fIn.get(this.in);
                  // In hadoop 0.22, DFSInputStream is a standalone class.  Before this,
                  // it was an inner class of DFSClient.
                  if (realIn.getClass().getName().endsWith("DFSInputStream")) {
                    Method getFileLength = realIn.getClass().
                      getDeclaredMethod("getFileLength", new Class<?> []{});
                    getFileLength.setAccessible(true);
                    long realLength = ((Long)getFileLength.
                      invoke(realIn, new Object []{})).longValue();
                    assert(realLength >= this.length);
                    adjust = realLength - this.length;
                  } else {
                    LOG.info("Input stream class: " + realIn.getClass().getName() +
                        ", not adjusting length");
                  }
                } catch(Exception e) {
                  SequenceFileLogReader.LOG.warn(
                    "Error while trying to get accurate file length.  " +
                    "Truncation / data loss may occur if RegionServers die.", e);
                }
      
                return adjust + super.getPos();
      

      Attachments

        1. HBASE-5878.patch
          3 kB
          Ashish Singhi
        2. HBASE-5878-branch-1.0.patch
          1 kB
          Andrew Kyle Purtell
        3. HBASE-5878-v2.patch
          3 kB
          Ashish Singhi
        4. HBASE-5878-v3.patch
          4 kB
          Ashish Singhi
        5. HBASE-5878-v4.patch
          4 kB
          Ashish Singhi
        6. HBASE-5878-v5.patch
          4 kB
          Nick Dimiduk
        7. HBASE-5878-v5.patch
          4 kB
          Ashish Singhi
        8. HBASE-5878-v5-0.98.patch
          3 kB
          Nick Dimiduk
        9. HBASE-5878-v6.patch
          4 kB
          Ashish Singhi
        10. HBASE-5878-v6-0.98.patch
          4 kB
          Ashish Singhi
        11. HBASE-5878-v7-0.98.patch
          4 kB
          Ashish Singhi

        Issue Links

          Activity

            People

              ashish singhi Ashish Singhi
              umamaheswararao Uma Maheswara Rao G
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: