public class WindowingOffsetManager extends java.lang.Object implements OffsetManager, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
OffsetManager that aggregates writes over a time or count window, using an underlying delegate to
do the actual operations. Its purpose is to reduce the performance impact of writing operations
wherever this is desirable.
A time window or a number of writes can be specified, or both.
Defaults to 10 seconds window with Integer.MAX_VALUE buffer.
| Constructor and Description |
|---|
WindowingOffsetManager(OffsetManager offsetManager) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
void |
close() |
void |
deleteOffset(Partition partition)
Removes the offset for a given
Partition. |
void |
destroy() |
void |
flush() |
long |
getOffset(Partition partition)
Retrieves the offset for a given
Partition |
void |
resetOffsets(java.util.Collection<Partition> partition)
Resets offsets for the given
Partitions. |
void |
setCount(int count)
How many writes should be aggregated, before invoking the underlying
OffsetManager. |
void |
setShutdownTimeout(int shutdownTimeout)
|
void |
setTimespan(long timespan)
The timespan for aggregating write operations, before invoking the underlying
OffsetManager. |
void |
updateOffset(Partition partition,
long offset)
Updates the offset for a given
Partition |
public WindowingOffsetManager(OffsetManager offsetManager)
public void setTimespan(long timespan)
OffsetManager.timespan - duration in millisecondspublic void setCount(int count)
OffsetManager. Setting this value
to 1 effectively disables windowing.count - number of writespublic void setShutdownTimeout(int shutdownTimeout)
close() and destroy()
operations will wait for receiving a confirmation that
the underlying writes have been processed.shutdownTimeout - duration in millisecondspublic void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.Exceptionpublic void destroy()
throws java.lang.Exception
destroy in interface org.springframework.beans.factory.DisposableBeanjava.lang.Exceptionpublic void updateOffset(Partition partition, long offset)
OffsetManagerPartitionupdateOffset in interface OffsetManagerpartition - the partition whose offset is to be updatedoffset - the new offset valuepublic long getOffset(Partition partition)
OffsetManagerPartitiongetOffset in interface OffsetManagerpartition - the partition to bepublic void deleteOffset(Partition partition)
OffsetManagerPartition. Useful
for components that need to clean up after themselves.deleteOffset in interface OffsetManagerpartition - for which to delete the JavaDocpublic void resetOffsets(java.util.Collection<Partition> partition)
OffsetManagerPartitions. 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 OffsetManagerpartition - to resetpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic void flush()
throws java.io.IOException
flush in interface java.io.Flushablejava.io.IOException