HBASE-15218 On RS crash and replay of WAL, loosing all Tags in Cells (Anoop Sam John)

This commit is contained in:
stack 2016-02-05 10:08:20 -08:00
parent 9c83210945
commit 779bdf1918
3 changed files with 27 additions and 5 deletions

View File

@ -30,7 +30,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil; import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.codec.KeyValueCodec; import org.apache.hadoop.hbase.codec.KeyValueCodecWithTags;
import org.apache.hadoop.hbase.io.crypto.Decryptor; import org.apache.hadoop.hbase.io.crypto.Decryptor;
import org.apache.hadoop.hbase.io.crypto.Encryption; import org.apache.hadoop.hbase.io.crypto.Encryption;
import org.apache.hadoop.hbase.io.crypto.Encryptor; import org.apache.hadoop.hbase.io.crypto.Encryptor;
@ -60,7 +60,7 @@ public class SecureWALCellCodec extends WALCellCodec {
this.decryptor = decryptor; this.decryptor = decryptor;
} }
static class EncryptedKvDecoder extends KeyValueCodec.KeyValueDecoder { static class EncryptedKvDecoder extends KeyValueCodecWithTags.KeyValueDecoder {
private Decryptor decryptor; private Decryptor decryptor;
private byte[] iv; private byte[] iv;
@ -142,7 +142,7 @@ public class SecureWALCellCodec extends WALCellCodec {
} }
static class EncryptedKvEncoder extends KeyValueCodec.KeyValueEncoder { static class EncryptedKvEncoder extends KeyValueCodecWithTags.KeyValueEncoder {
private Encryptor encryptor; private Encryptor encryptor;
private final ThreadLocal<byte[]> iv = new ThreadLocal<byte[]>() { private final ThreadLocal<byte[]> iv = new ThreadLocal<byte[]>() {

View File

@ -31,7 +31,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.codec.BaseDecoder; import org.apache.hadoop.hbase.codec.BaseDecoder;
import org.apache.hadoop.hbase.codec.BaseEncoder; import org.apache.hadoop.hbase.codec.BaseEncoder;
import org.apache.hadoop.hbase.codec.Codec; import org.apache.hadoop.hbase.codec.Codec;
import org.apache.hadoop.hbase.codec.KeyValueCodec; import org.apache.hadoop.hbase.codec.KeyValueCodecWithTags;
import org.apache.hadoop.hbase.io.util.Dictionary; import org.apache.hadoop.hbase.io.util.Dictionary;
import org.apache.hadoop.hbase.io.util.StreamUtils; import org.apache.hadoop.hbase.io.util.StreamUtils;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
@ -344,7 +344,7 @@ public class WALCellCodec implements Codec {
@Override @Override
public Decoder getDecoder(InputStream is) { public Decoder getDecoder(InputStream is) {
return (compression == null) return (compression == null)
? new KeyValueCodec.KeyValueDecoder(is) : new CompressedKvDecoder(is, compression); ? new KeyValueCodecWithTags.KeyValueDecoder(is) : new CompressedKvDecoder(is, compression);
} }
@Override @Override

View File

@ -32,6 +32,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Result;
@ -219,4 +220,25 @@ public class TestVisibilityLabelsWithDefaultVisLabelService extends TestVisibili
}; };
SUPERUSER.runAs(action); SUPERUSER.runAs(action);
} }
@Test(timeout = 60 * 1000)
public void testVisibilityLabelsOnWALReplay() throws Exception {
final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
try (Table table = createTableAndWriteDataWithLabels(tableName,
"(" + SECRET + "|" + CONFIDENTIAL + ")", PRIVATE);) {
List<RegionServerThread> regionServerThreads = TEST_UTIL.getHBaseCluster()
.getRegionServerThreads();
for (RegionServerThread rsThread : regionServerThreads) {
rsThread.getRegionServer().abort("Aborting ");
}
// Start one new RS
RegionServerThread rs = TEST_UTIL.getHBaseCluster().startRegionServer();
waitForLabelsRegionAvailability(rs.getRegionServer());
Scan s = new Scan();
s.setAuthorizations(new Authorizations(SECRET));
ResultScanner scanner = table.getScanner(s);
Result[] next = scanner.next(3);
assertTrue(next.length == 1);
}
}
} }