public abstract class AbstractOffsetManager extends java.lang.Object implements OffsetManager, org.springframework.beans.factory.DisposableBean
OffsetManager
. Subclasses may customize functionality as necessary.Modifier and Type | Field and Description |
---|---|
protected ConnectionFactory |
connectionFactory |
protected java.lang.String |
consumerId |
protected java.util.Map<Partition,java.lang.Long> |
highestUpdatedOffsets |
protected java.util.Map<Partition,java.lang.Long> |
initialOffsets |
protected org.apache.commons.logging.Log |
log |
protected long |
referenceTimestamp |
Constructor and Description |
---|
AbstractOffsetManager(ConnectionFactory connectionFactory) |
AbstractOffsetManager(ConnectionFactory connectionFactory,
java.util.Map<Partition,java.lang.Long> initialOffsets) |
Modifier and Type | Method and Description |
---|---|
void |
deleteOffset(Partition partition)
Removes the offset for a given
Partition . |
void |
destroy() |
protected abstract java.lang.Long |
doGetOffset(Partition partition) |
protected abstract void |
doRemoveOffset(Partition partition) |
protected abstract void |
doUpdateOffset(Partition partition,
long offset) |
java.lang.String |
getConsumerId() |
long |
getOffset(Partition partition)
Retrieves the offset for a given
Partition |
void |
resetOffsets(java.util.Collection<Partition> partitionsToReset)
Resets offsets for the given
Partition s. |
void |
setConsumerId(java.lang.String consumerId)
The identifier of a consumer of Kafka messages.
|
void |
setReferenceTimestamp(long referenceTimestamp)
A timestamp to be used for resetting initial offsets
|
void |
updateOffset(Partition partition,
long offset)
Updates the offset for a given
Partition |
protected final org.apache.commons.logging.Log log
protected java.lang.String consumerId
protected long referenceTimestamp
protected ConnectionFactory connectionFactory
protected java.util.Map<Partition,java.lang.Long> initialOffsets
protected java.util.Map<Partition,java.lang.Long> highestUpdatedOffsets
public AbstractOffsetManager(ConnectionFactory connectionFactory)
public AbstractOffsetManager(ConnectionFactory connectionFactory, java.util.Map<Partition,java.lang.Long> initialOffsets)
public java.lang.String getConsumerId()
public void setConsumerId(java.lang.String consumerId)
consumerId
- the consumer IDpublic void setReferenceTimestamp(long referenceTimestamp)
referenceTimestamp
- the reset timestamp for initial offsetspublic void destroy() throws java.lang.Exception
destroy
in interface org.springframework.beans.factory.DisposableBean
java.lang.Exception
public final void updateOffset(Partition partition, long offset)
OffsetManager
Partition
updateOffset
in interface OffsetManager
partition
- the partition whose offset is to be updatedoffset
- the new offset valueOffsetManager.updateOffset(Partition, long)
public final long getOffset(Partition partition)
OffsetManager
Partition
getOffset
in interface OffsetManager
partition
- the partition to beOffsetManager.getOffset(Partition)
public void resetOffsets(java.util.Collection<Partition> partitionsToReset)
OffsetManager
Partition
s. To be invoked when the values stored are invalid,
so a client cannot resume from that position. Implementations must decide on the best strategy to follow.resetOffsets
in interface OffsetManager
partitionsToReset
- to resetpublic void deleteOffset(Partition partition)
OffsetManager
Partition
. Useful
for components that need to clean up after themselves.deleteOffset
in interface OffsetManager
partition
- for which to delete the JavaDocprotected abstract void doUpdateOffset(Partition partition, long offset)
protected abstract void doRemoveOffset(Partition partition)
protected abstract java.lang.Long doGetOffset(Partition partition)