@Internal public class CachedBufferStorage extends Object implements BufferStorage
CachedBufferStorage
takes the buffers and events from a data stream and adds them to
a memory queue. After a number of elements have been cached, the CachedBufferStorage
can "roll over":
It presents the cached elements as a readable sequence, and creates a new memory queue.
This CachedBufferStorage
can be used in credit-based flow control for better barrier
alignment in exactly-once mode.
Constructor and Description |
---|
CachedBufferStorage(int pageSize)
Create a new
CachedBufferStorage with unlimited storage. |
CachedBufferStorage(int pageSize,
long maxBufferedBytes,
String taskName)
Creates a new
CachedBufferStorage , caching the buffers or events in memory queue. |
Modifier and Type | Method and Description |
---|---|
void |
add(BufferOrEvent boe)
Adds a buffer or event to the
BufferStorage . |
void |
close()
Cleans up all the resources in the current sequence.
|
long |
getMaxBufferedBytes() |
long |
getPendingBytes() |
long |
getRolledBytes() |
boolean |
isEmpty() |
boolean |
isFull() |
Optional<BufferOrEvent> |
pollNext() |
void |
rollOver()
Start returning next sequence of stored
BufferOrEvent s. |
public CachedBufferStorage(int pageSize)
CachedBufferStorage
with unlimited storage.pageSize
- The page size used to estimate the cached size.public CachedBufferStorage(int pageSize, long maxBufferedBytes, String taskName)
CachedBufferStorage
, caching the buffers or events in memory queue.pageSize
- The page size used to estimate the cached size.public void add(BufferOrEvent boe)
BufferStorage
BufferStorage
.add
in interface BufferStorage
boe
- The buffer or event to be added into the blocker.public void close()
BufferStorage
close
in interface AutoCloseable
close
in interface BufferStorage
public long getPendingBytes()
getPendingBytes
in interface BufferStorage
public boolean isFull()
isFull
in interface BufferStorage
public void rollOver()
BufferStorage
BufferOrEvent
s.rollOver
in interface BufferStorage
public long getRolledBytes()
getRolledBytes
in interface BufferStorage
public boolean isEmpty()
isEmpty
in interface BufferStorage
BufferStorage
doesn't store and data.public Optional<BufferOrEvent> pollNext()
pollNext
in interface BufferStorage
public long getMaxBufferedBytes()
getMaxBufferedBytes
in interface BufferStorage
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.