public final class ShardedHBaseQueueStrategy extends Object implements HBaseQueueStrategy, Closeable
HBaseQueueStrategy with sharded keys.
The row key has structure of:
row_key = <shard> <queue_prefix> <write_pointer> <counter>
shard = <salt> <consumer_group_id> <consumer_instance_id>
salt = First byte of MD5 of <consumer_group_id>, <consumer_instance_id> and <queue_name>
consumer_group_id = 8 bytes long value of the target consumer group or 0 if it is FIFO
consumer_instance_id = 4 bytes int value of target consumer instance id or -1 if FIFO
queue_prefix = <name_hash> <queue_name>
name_hash = First byte of MD5 of <queue_name>
queue_name = flowlet_name + "/" + output_name
write_pointer = 8 bytes long value of the write pointer of the transaction
counter = 4 bytes int value of a monotonic increasing number assigned for each entry written in the same transaction
| Modifier and Type | Field and Description |
|---|---|
static int |
PREFIX_BYTES |
| Constructor and Description |
|---|
ShardedHBaseQueueStrategy(HBaseTableUtil tableUtil,
int distributorBuckets)
Constructs a new instance with the given number of buckets for distributed scan.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
QueueScanner |
createScanner(ConsumerConfig consumerConfig,
org.apache.hadoop.hbase.client.HTable hTable,
org.apache.hadoop.hbase.client.Scan scan,
int numRows)
Creates a
QueueScanner from the given Scan on the HBase table. |
byte[] |
getActualRowKey(ConsumerConfig consumerConfig,
byte[] originalRowKey)
Creates the actual row key used for accessing the HBase table from the given queue entry row key.
|
void |
getRowKeys(Iterable<ConsumerGroupConfig> consumerGroupConfigs,
QueueEntry queueEntry,
byte[] rowKeyPrefix,
long writePointer,
int counter,
Collection<byte[]> rowKeys)
Get all the row keys that the queue entries need to write to.
|
public static final int PREFIX_BYTES
public ShardedHBaseQueueStrategy(HBaseTableUtil tableUtil, int distributorBuckets)
public QueueScanner createScanner(ConsumerConfig consumerConfig, org.apache.hadoop.hbase.client.HTable hTable, org.apache.hadoop.hbase.client.Scan scan, int numRows) throws IOException
HBaseQueueStrategyQueueScanner from the given Scan on the HBase table.createScanner in interface HBaseQueueStrategyhTable - HTable for talking to HBasescan - The scan requestnumRows - Maximum number of rows to scan forQueueScanner that scans over the give tableIOExceptionpublic byte[] getActualRowKey(ConsumerConfig consumerConfig, byte[] originalRowKey)
HBaseQueueStrategygetActualRowKey in interface HBaseQueueStrategypublic void getRowKeys(Iterable<ConsumerGroupConfig> consumerGroupConfigs, QueueEntry queueEntry, byte[] rowKeyPrefix, long writePointer, int counter, Collection<byte[]> rowKeys)
HBaseQueueStrategygetRowKeys in interface HBaseQueueStrategyconsumerGroupConfigs - Consumer groups' configurations for the queuequeueEntry - Entry to enqueuerowKeyPrefix - Prefix for row keyswritePointer - The writer pointer of the current transactioncounter - The counter of the given entry in this transactionrowKeys - Collection for storing all the row keys generated by this entrypublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2016 Cask Data, Inc. Licensed under the Apache License, Version 2.0.