Skip to content

Commit

Permalink
HBASE-15218 On RS crash and replay of WAL, loosing all Tags in Cells …
Browse files Browse the repository at this point in the history
…(Anoop Sam John)
  • Loading branch information
saintstack committed Feb 5, 2016
1 parent 9c83210 commit 779bdf1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.KeyValue;
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.Encryption;
import org.apache.hadoop.hbase.io.crypto.Encryptor;
Expand Down Expand Up @@ -60,7 +60,7 @@ public SecureWALCellCodec(Configuration conf, Decryptor decryptor) {
this.decryptor = decryptor;
}

static class EncryptedKvDecoder extends KeyValueCodec.KeyValueDecoder {
static class EncryptedKvDecoder extends KeyValueCodecWithTags.KeyValueDecoder {

private Decryptor decryptor;
private byte[] iv;
Expand Down Expand Up @@ -142,7 +142,7 @@ protected Cell parseCell() throws IOException {

}

static class EncryptedKvEncoder extends KeyValueCodec.KeyValueEncoder {
static class EncryptedKvEncoder extends KeyValueCodecWithTags.KeyValueEncoder {

private Encryptor encryptor;
private final ThreadLocal<byte[]> iv = new ThreadLocal<byte[]>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.apache.hadoop.hbase.codec.BaseDecoder;
import org.apache.hadoop.hbase.codec.BaseEncoder;
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.StreamUtils;
import org.apache.hadoop.hbase.util.Bytes;
Expand Down Expand Up @@ -344,7 +344,7 @@ public void write(Cell cell) throws IOException {
@Override
public Decoder getDecoder(InputStream is) {
return (compression == null)
? new KeyValueCodec.KeyValueDecoder(is) : new CompressedKvDecoder(is, compression);
? new KeyValueCodecWithTags.KeyValueDecoder(is) : new CompressedKvDecoder(is, compression);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
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.ConnectionFactory;
import org.apache.hadoop.hbase.client.Result;
Expand Down Expand Up @@ -219,4 +220,25 @@ public ListLabelsResponse run() throws Exception {
};
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);
}
}
}

0 comments on commit 779bdf1

Please sign in to comment.