@Override public HBaseQueueConsumer getQueueConsumer(ConsumerConfig consumerConfig, HTable hTable, QueueName queueName, HBaseConsumerState consumerState, HBaseConsumerStateStore stateStore) { return new HBase96QueueConsumer(consumerConfig, hTable, queueName, consumerState, stateStore); } }
HBase96QueueConsumer(ConsumerConfig consumerConfig, HTable hTable, QueueName queueName, HBaseConsumerState consumerState, HBaseConsumerStateStore stateStore) { super(consumerConfig, hTable, queueName, consumerState, stateStore); this.processedStateFilter = createStateFilter(); }
public void readFields(DataInput in) throws IOException { this.consumerConfig = DequeueScanAttributes.readConsumerConfig(in); this.transaction = DequeueScanAttributes.readTx(in); this.queueNamePrefixLength = in.readInt(); }
@Override public void start(CoprocessorEnvironment env) { if (env instanceof RegionCoprocessorEnvironment) { String tableName = ((RegionCoprocessorEnvironment) env).getRegion().getTableDesc().getNameAsString(); String configTableName = QueueUtils.determineQueueConfigTableName(tableName); appName = HBaseQueueAdmin.getApplicationName(tableName); flowName = HBaseQueueAdmin.getFlowName(tableName); configCache = ConsumerConfigCache.getInstance(env.getConfiguration(), Bytes.toBytes(configTableName)); } }
@Override public RegionScanner preScannerOpen(ObserverContext<RegionCoprocessorEnvironment> e, Scan scan, RegionScanner s) throws IOException { ConsumerConfig consumerConfig = DequeueScanAttributes.getConsumerConfig(scan); Transaction tx = DequeueScanAttributes.getTx(scan); byte[] queueRowPrefix = DequeueScanAttributes.getQueueRowPrefix(scan); if (consumerConfig == null || tx == null || queueRowPrefix == null) { return super.preScannerOpen(e, scan, s); } Filter dequeueFilter = new DequeueFilter(queueRowPrefix, consumerConfig, tx); Filter existing = scan.getFilter(); if (existing != null) { Filter combined = new FilterList(FilterList.Operator.MUST_PASS_ALL, existing, dequeueFilter); scan.setFilter(combined); } else { scan.setFilter(dequeueFilter); } return super.preScannerOpen(e, scan, s); } }
@Override protected Scan createScan(byte[] startRow, byte[] stopRow, int numRows) { // Scan the table for queue entries. Scan scan = new Scan(); // we should roughly divide by number of buckets, but don't want another RPC for the case we are not exactly right int caching = (int) (1.1 * numRows / HBaseQueueAdmin.ROW_KEY_DISTRIBUTION_BUCKETS); scan.setCaching(caching); scan.setStartRow(startRow); scan.setStopRow(stopRow); scan.addColumn(QueueEntryRow.COLUMN_FAMILY, QueueEntryRow.DATA_COLUMN); scan.addColumn(QueueEntryRow.COLUMN_FAMILY, QueueEntryRow.META_COLUMN); scan.addColumn(QueueEntryRow.COLUMN_FAMILY, stateColumnName); scan.setFilter(createFilter()); scan.setMaxVersions(1); return scan; }