HBASE-16189 [Rolling Upgrade] 2.0 hfiles cannot be opened by 1.x servers

(Ram)
This commit is contained in:
Ramkrishna 2016-07-18 10:16:23 +05:30
parent 1e3bce943b
commit cfc22ec1ec
2 changed files with 18 additions and 3 deletions

View File

@ -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<? extends KVComparator>)
Class.forName(comparatorClassName);
} catch (ClassNotFoundException ex) {

View File

@ -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) {