public abstract class AbstractQueueConsumer extends Object implements QueueConsumer, co.cask.tephra.TransactionAware
| Modifier and Type | Field and Description |
|---|---|
protected int |
commitCount |
protected byte[] |
stateColumnName |
protected co.cask.tephra.Transaction |
transaction |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractQueueConsumer(CConfiguration cConf,
ConsumerConfig consumerConfig,
QueueName queueName) |
protected |
AbstractQueueConsumer(CConfiguration cConf,
ConsumerConfig consumerConfig,
QueueName queueName,
byte[] startRow) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract boolean |
claimEntry(byte[] rowKey,
byte[] stateContent) |
boolean |
commitTx() |
DequeueResult<byte[]> |
dequeue()
Dequeue an entry from the queue.
|
DequeueResult<byte[]> |
dequeue(int maxBatchSize)
Dequeue multiple entries from the queue.
|
ConsumerConfig |
getConfig()
Returns the configuration of this consumer.
|
QueueName |
getQueueName()
Returns the queue name that this consumer is working on.
|
protected abstract QueueScanner |
getScanner(byte[] startRow,
byte[] stopRow,
int numRows) |
String |
getTransactionAwareName() |
Collection<byte[]> |
getTxChanges() |
boolean |
rollbackTx() |
void |
startTx(co.cask.tephra.Transaction tx) |
protected abstract void |
undoState(Set<byte[]> rowKeys,
byte[] stateColumnName) |
protected void |
updateStartRow(byte[] startRow)
Called when the start row is updated.
|
protected abstract void |
updateState(Set<byte[]> rowKeys,
byte[] stateColumnName,
byte[] stateContent) |
void |
updateTx(co.cask.tephra.Transaction transaction) |
protected final byte[] stateColumnName
protected co.cask.tephra.Transaction transaction
protected int commitCount
protected AbstractQueueConsumer(CConfiguration cConf, ConsumerConfig consumerConfig, QueueName queueName)
protected AbstractQueueConsumer(CConfiguration cConf, ConsumerConfig consumerConfig, QueueName queueName, @Nullable byte[] startRow)
protected abstract boolean claimEntry(byte[] rowKey,
byte[] stateContent)
throws IOException
IOExceptionprotected abstract void updateState(Set<byte[]> rowKeys, byte[] stateColumnName, byte[] stateContent) throws IOException
IOExceptionprotected abstract void undoState(Set<byte[]> rowKeys, byte[] stateColumnName) throws IOException, InterruptedException
IOExceptionInterruptedExceptionprotected abstract QueueScanner getScanner(byte[] startRow, byte[] stopRow, int numRows) throws IOException
IOExceptionpublic QueueName getQueueName()
QueueConsumergetQueueName in interface QueueConsumerpublic ConsumerConfig getConfig()
QueueConsumergetConfig in interface QueueConsumerpublic DequeueResult<byte[]> dequeue() throws IOException
QueueConsumerdequeue in interface QueueConsumerDequeueResult.IOExceptionpublic DequeueResult<byte[]> dequeue(int maxBatchSize) throws IOException
QueueConsumerdequeue in interface QueueConsumermaxBatchSize - Maximum number of entries to queue.DequeueResult.IOExceptionpublic void startTx(co.cask.tephra.Transaction tx)
startTx in interface co.cask.tephra.TransactionAwarepublic void updateTx(co.cask.tephra.Transaction transaction)
updateTx in interface co.cask.tephra.TransactionAwarepublic Collection<byte[]> getTxChanges()
getTxChanges in interface co.cask.tephra.TransactionAwarepublic boolean commitTx()
throws Exception
commitTx in interface co.cask.tephra.TransactionAwareExceptionpublic boolean rollbackTx()
throws Exception
rollbackTx in interface co.cask.tephra.TransactionAwareExceptionprotected void updateStartRow(byte[] startRow)
public String getTransactionAwareName()
getTransactionAwareName in interface co.cask.tephra.TransactionAwareCopyright © 2016 Cask Data, Inc. Licensed under the Apache License, Version 2.0.