@Internal public class CachedBufferStorage extends AbstractBufferStorage
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.
Modifier and Type | Class and Description |
---|---|
static class |
CachedBufferStorage.CachedBufferOrEventSequence
This class represents a sequence of cached buffers and events, created by the
CachedBufferStorage . |
currentBuffered, LOG, maxBufferedBytes, queuedBuffered, rolledBytes, taskName
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 |
getPendingBytes() |
BufferOrEventSequence |
rollOverReusingResources()
It is never reusing resources and is defaulting to
rollOverWithoutReusingResources() . |
BufferOrEventSequence |
rollOverWithoutReusingResources()
Starts a new sequence of buffers and event without reusing the same resources and
returns the current sequence of buffers for reading.
|
completeBufferedSequence, getMaxBufferedBytes, getRolledBytes, isEmpty, isFull, pollNext, rollOver
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
.boe
- The buffer or event to be added into the blocker.public BufferOrEventSequence rollOverReusingResources()
rollOverWithoutReusingResources()
.rollOverReusingResources
in class AbstractBufferStorage
public BufferOrEventSequence rollOverWithoutReusingResources()
AbstractBufferStorage
rollOverWithoutReusingResources
in class AbstractBufferStorage
public void close() throws IOException
BufferStorage
close
in interface AutoCloseable
close
in interface BufferStorage
close
in class AbstractBufferStorage
IOException
public long getPendingBytes()
Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.