Acquires an explicit row lock. Row locks are no longer supported as of HBase 0.96. While they can still be used with earlier HBase versions, attempting to use them with HBase 0.95 and up will cause a UnsupportedOperationException to be thrown. For a description of wh
| 45 | * All strings are assumed to use the platform's default charset. |
| 46 | */ |
| 47 | public final class RowLockRequest extends HBaseRpc |
| 48 | implements HBaseRpc.HasTable, HBaseRpc.HasKey { |
| 49 | |
| 50 | private static final byte[] LOCK_ROW = new byte[] { |
| 51 | 'l', 'o', 'c', 'k', 'R', 'o', 'w' |
| 52 | }; |
| 53 | |
| 54 | /** |
| 55 | * Constructor. |
| 56 | * <strong>These byte arrays will NOT be copied.</strong> |
| 57 | * @param table The table containing the row to lock. |
| 58 | * @param key The key of the row to lock in that table. |
| 59 | */ |
| 60 | public RowLockRequest(final byte[] table, final byte[] key) { |
| 61 | super(table, key); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Constructor. |
| 66 | * @param table The table containing the row to lock. |
| 67 | * @param key The key of the row to lock in that table. |
| 68 | */ |
| 69 | public RowLockRequest(final String table, final String key) { |
| 70 | this(table.getBytes(), key.getBytes()); |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | byte[] method(final byte unused_server_version) { |
| 75 | return LOCK_ROW; |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public byte[] table() { |
| 80 | return table; |
| 81 | } |
| 82 | |
| 83 | @Override |
| 84 | public byte[] key() { |
| 85 | return key; |
| 86 | } |
| 87 | |
| 88 | // ---------------------- // |
| 89 | // Package private stuff. // |
| 90 | // ---------------------- // |
| 91 | |
| 92 | private int predictSerializedSize() { |
| 93 | int size = 0; |
| 94 | size += 4; // int: Number of parameters. |
| 95 | size += 1; // byte: Type of the 1st parameter. |
| 96 | size += 3; // vint: region name length (3 bytes => max length = 32768). |
| 97 | size += region.name().length; // The region name. |
| 98 | size += 1; // byte: Type of the 2nd parameter. |
| 99 | size += 3; // vint: row key length (3 bytes => max length = 32768). |
| 100 | size += key.length; // The row key. |
| 101 | return size; |
| 102 | } |
| 103 | |
| 104 | /** Serializes this request. */ |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…