hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kaka chen <kaka11.c...@gmail.com>
Subject Confused about the process of handle BADVERSION at setData() method in RecoverableZookeeper.java
Date Fri, 21 Sep 2012 03:32:13 GMT
Hi All:
    Can someone explain the handle BADVERSION at setData() method in
RecoverableZookeeper.java, I am very confused. The meta data is MAGIC(1
BYTE) + LENGTH_FIELD(4 BYTE) + ID + DATA, but the parsing is very strange,
and why to compare id with data? Please help me, thanks!

            case BADVERSION:
            // try to verify whether the previous setData success or not
              Stat stat = new Stat();
              byte[] revData = zk.getData(path, false, stat);
              int idLength = Bytes.toInt(revData, ID_LENGTH_SIZE);
              int dataLength = revData.length-ID_LENGTH_SIZE-idLength;
              int dataOffset = ID_LENGTH_SIZE+idLength;

              if(Bytes.compareTo(revData, ID_LENGTH_SIZE, id.length,
                  revData, dataOffset, dataLength) == 0) {
                // the bad version is caused by previous successful setData
                return stat;
            } catch(KeeperException keeperException){
              // the ZK is not reliable at this moment. just throwing
              throw keeperException;

Kaka Chen

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message