git commit: HBASE-12176 WALCellCodec Encoders support for non-KeyValue Cells (Anoop Sam John)
Repository: hbase Updated Branches: refs/heads/master 8ee55fb33 - e3f995783 HBASE-12176 WALCellCodec Encoders support for non-KeyValue Cells (Anoop Sam John) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e3f99578 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e3f99578 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e3f99578 Branch: refs/heads/master Commit: e3f99578304cb30f1b59c34a4193b9b700f3566a Parents: 8ee55fb Author: Enis Soztutar e...@apache.org Authored: Sat Oct 11 15:32:18 2014 -0700 Committer: Enis Soztutar e...@apache.org Committed: Sat Oct 11 15:32:18 2014 -0700 -- .../regionserver/wal/SecureWALCellCodec.java| 36 +- .../hbase/regionserver/wal/WALCellCodec.java| 39 .../hbase/security/access/AuthResult.java | 9 +++-- 3 files changed, 39 insertions(+), 45 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/e3f99578/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SecureWALCellCodec.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SecureWALCellCodec.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SecureWALCellCodec.java index 504e9cb..46f3b88 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SecureWALCellCodec.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SecureWALCellCodec.java @@ -30,6 +30,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; 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.io.crypto.Decryptor; import org.apache.hadoop.hbase.io.crypto.Encryption; @@ -179,16 +180,11 @@ public class SecureWALCellCodec extends WALCellCodec { @Override public void write(Cell cell) throws IOException { - if (!(cell instanceof KeyValue)) throw new IOException(Cannot write non-KV cells to WAL); if (encryptor == null) { super.write(cell); return; } - KeyValue kv = (KeyValue)cell; - byte[] kvBuffer = kv.getBuffer(); - int offset = kv.getOffset(); - byte[] iv = nextIv(); encryptor.setIv(iv); encryptor.reset(); @@ -205,23 +201,27 @@ public class SecureWALCellCodec extends WALCellCodec { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream cout = encryptor.createEncryptionStream(baos); + int tlen = cell.getTagsLength(); // Write the KeyValue infrastructure as VInts. - StreamUtils.writeRawVInt32(cout, kv.getKeyLength()); - StreamUtils.writeRawVInt32(cout, kv.getValueLength()); + StreamUtils.writeRawVInt32(cout, KeyValueUtil.keyLength(cell)); + StreamUtils.writeRawVInt32(cout, cell.getValueLength()); // To support tags - StreamUtils.writeRawVInt32(cout, kv.getTagsLength()); + StreamUtils.writeRawVInt32(cout, tlen); // Write row, qualifier, and family - StreamUtils.writeRawVInt32(cout, kv.getRowLength()); - cout.write(kvBuffer, kv.getRowOffset(), kv.getRowLength()); - StreamUtils.writeRawVInt32(cout, kv.getFamilyLength()); - cout.write(kvBuffer, kv.getFamilyOffset(), kv.getFamilyLength()); - StreamUtils.writeRawVInt32(cout, kv.getQualifierLength()); - cout.write(kvBuffer, kv.getQualifierOffset(), kv.getQualifierLength()); - // Write the rest - int pos = kv.getTimestampOffset(); - int remainingLength = kv.getLength() + offset - pos; - cout.write(kvBuffer, pos, remainingLength); + StreamUtils.writeRawVInt32(cout, cell.getRowLength()); + cout.write(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()); + StreamUtils.writeRawVInt32(cout, cell.getFamilyLength()); + cout.write(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength()); + StreamUtils.writeRawVInt32(cout, cell.getQualifierLength()); + cout.write(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); + // Write the rest ie. ts, type, value and tags parts + StreamUtils.writeLong(cout, cell.getTimestamp()); + cout.write(cell.getTypeByte()); + cout.write(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); + if (tlen 0) { +cout.write(cell.getTagsArray(), cell.getTagsOffset(), tlen); + } cout.close(); StreamUtils.writeRawVInt32(out, baos.size());
git commit: HBASE-12176 WALCellCodec Encoders support for non-KeyValue Cells (Anoop Sam John)
Repository: hbase Updated Branches: refs/heads/branch-1 6a37c169f - 8938dc963 HBASE-12176 WALCellCodec Encoders support for non-KeyValue Cells (Anoop Sam John) Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8938dc96 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8938dc96 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8938dc96 Branch: refs/heads/branch-1 Commit: 8938dc96306c6ea96c050dd0b8837dbb65985031 Parents: 6a37c16 Author: Enis Soztutar e...@apache.org Authored: Sat Oct 11 15:32:18 2014 -0700 Committer: Enis Soztutar e...@apache.org Committed: Sat Oct 11 15:33:31 2014 -0700 -- .../regionserver/wal/SecureWALCellCodec.java| 36 +- .../hbase/regionserver/wal/WALCellCodec.java| 39 .../hbase/security/access/AuthResult.java | 9 +++-- 3 files changed, 39 insertions(+), 45 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hbase/blob/8938dc96/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SecureWALCellCodec.java -- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SecureWALCellCodec.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SecureWALCellCodec.java index 504e9cb..46f3b88 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SecureWALCellCodec.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SecureWALCellCodec.java @@ -30,6 +30,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; 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.io.crypto.Decryptor; import org.apache.hadoop.hbase.io.crypto.Encryption; @@ -179,16 +180,11 @@ public class SecureWALCellCodec extends WALCellCodec { @Override public void write(Cell cell) throws IOException { - if (!(cell instanceof KeyValue)) throw new IOException(Cannot write non-KV cells to WAL); if (encryptor == null) { super.write(cell); return; } - KeyValue kv = (KeyValue)cell; - byte[] kvBuffer = kv.getBuffer(); - int offset = kv.getOffset(); - byte[] iv = nextIv(); encryptor.setIv(iv); encryptor.reset(); @@ -205,23 +201,27 @@ public class SecureWALCellCodec extends WALCellCodec { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream cout = encryptor.createEncryptionStream(baos); + int tlen = cell.getTagsLength(); // Write the KeyValue infrastructure as VInts. - StreamUtils.writeRawVInt32(cout, kv.getKeyLength()); - StreamUtils.writeRawVInt32(cout, kv.getValueLength()); + StreamUtils.writeRawVInt32(cout, KeyValueUtil.keyLength(cell)); + StreamUtils.writeRawVInt32(cout, cell.getValueLength()); // To support tags - StreamUtils.writeRawVInt32(cout, kv.getTagsLength()); + StreamUtils.writeRawVInt32(cout, tlen); // Write row, qualifier, and family - StreamUtils.writeRawVInt32(cout, kv.getRowLength()); - cout.write(kvBuffer, kv.getRowOffset(), kv.getRowLength()); - StreamUtils.writeRawVInt32(cout, kv.getFamilyLength()); - cout.write(kvBuffer, kv.getFamilyOffset(), kv.getFamilyLength()); - StreamUtils.writeRawVInt32(cout, kv.getQualifierLength()); - cout.write(kvBuffer, kv.getQualifierOffset(), kv.getQualifierLength()); - // Write the rest - int pos = kv.getTimestampOffset(); - int remainingLength = kv.getLength() + offset - pos; - cout.write(kvBuffer, pos, remainingLength); + StreamUtils.writeRawVInt32(cout, cell.getRowLength()); + cout.write(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()); + StreamUtils.writeRawVInt32(cout, cell.getFamilyLength()); + cout.write(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength()); + StreamUtils.writeRawVInt32(cout, cell.getQualifierLength()); + cout.write(cell.getQualifierArray(), cell.getQualifierOffset(), cell.getQualifierLength()); + // Write the rest ie. ts, type, value and tags parts + StreamUtils.writeLong(cout, cell.getTimestamp()); + cout.write(cell.getTypeByte()); + cout.write(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()); + if (tlen 0) { +cout.write(cell.getTagsArray(), cell.getTagsOffset(), tlen); + } cout.close(); StreamUtils.writeRawVInt32(out, baos.size());