diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/FixedFileTrailer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/FixedFileTrailer.java index 67350366c50..f6ae2918d7b 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/FixedFileTrailer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/FixedFileTrailer.java @@ -570,10 +570,17 @@ public class FixedFileTrailer { comparatorClassName = KeyValue.META_COMPARATOR.getClass().getName(); } else if (comparatorClassName.equals(KeyValue.RAW_COMPARATOR.getLegacyKeyComparatorName())) { comparatorClassName = KeyValue.RAW_COMPARATOR.getClass().getName(); + } else if (comparatorClassName.equals("org.apache.hadoop.hbase.CellComparator")) { + // 2.0 based comparators found in class name. Convert it to corresponding Comparators in 1.x + // branch. Refer to HBASE-16189 + comparatorClassName = KeyValue.COMPARATOR.getClass().getName(); + } else if ((comparatorClassName + .equals("org.apache.hadoop.hbase.CellComparator$MetaCellComparator"))) { + // Refer to HBASE-16189. Fallback to 1.x comparators + comparatorClassName = KeyValue.META_COMPARATOR.getClass().getName(); } // if the name wasn't one of the legacy names, maybe its a legit new kind of comparator. - return (Class) Class.forName(comparatorClassName); } catch (ClassNotFoundException ex) { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/CompoundBloomFilter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/CompoundBloomFilter.java index beda805ed1a..23f1c1af3dd 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/CompoundBloomFilter.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/CompoundBloomFilter.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.nio.ByteBuffer; import org.apache.hadoop.hbase.classification.InterfaceAudience; +import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue.KVComparator; import org.apache.hadoop.hbase.io.hfile.BlockType; import org.apache.hadoop.hbase.io.hfile.FixedFileTrailer; @@ -70,8 +71,15 @@ public class CompoundBloomFilter extends CompoundBloomFilterBase totalKeyCount = meta.readLong(); totalMaxKeys = meta.readLong(); numChunks = meta.readInt(); - comparator = FixedFileTrailer.createComparator( - Bytes.toString(Bytes.readByteArray(meta))); + byte[] comparatorClassName = Bytes.readByteArray(meta); + if (comparatorClassName.length != 0) { + comparator = FixedFileTrailer.createComparator(Bytes.toString(comparatorClassName)); + } else { + // Fallback. In 2.0 we will not write the RAW_COMPARATOR name. So when reading back such meta + // data. Refer to HBASE-16189 + // we set the comparator to RAW_COMPARATOR + comparator = KeyValue.RAW_COMPARATOR; + } hash = Hash.getInstance(hashType); if (hash == null) {