public final class SplittingFlushStrategy extends java.lang.Object implements FlushStrategy
FlushStrategy
that splits writes into logical write boundaries and manages flush state across those logical
write boundaries. Actual flush logic is delegated to an externally provided (and updatable) FlushStrategy
.Modifier and Type | Class and Description |
---|---|
static interface |
SplittingFlushStrategy.FlushBoundaryProvider
A provider of
SplittingFlushStrategy.FlushBoundaryProvider.FlushBoundary for each written item. |
FlushStrategy.FlushSender, FlushStrategy.WriteEventsListener
Constructor and Description |
---|
SplittingFlushStrategy(FlushStrategy delegate,
SplittingFlushStrategy.FlushBoundaryProvider boundaryProvider)
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
FlushStrategy.WriteEventsListener |
apply(FlushStrategy.FlushSender sender)
Every time a new write that requires custom flushes is initiated, this method is invoked.
|
boolean |
shouldFlushOnUnwritable()
Returns
true if pending writes, if any, MUST be flushed when the connection is not writable. |
Cancellable |
updateFlushStrategy(NettyConnectionContext.FlushStrategyProvider strategyProvider)
Updates the
FlushStrategy that is used for flushing each delineated write boundary. |
void |
updateFlushStrategy(NettyConnectionContext.FlushStrategyProvider strategyProvider,
int boundariesTillCancel)
Updates the
FlushStrategy that is used for flushing each delineated write boundary. |
public SplittingFlushStrategy(FlushStrategy delegate, SplittingFlushStrategy.FlushBoundaryProvider boundaryProvider)
delegate
- FlushStrategy
to use for flushing each delineated write boundary.boundaryProvider
- SplittingFlushStrategy.FlushBoundaryProvider
to provide SplittingFlushStrategy.FlushBoundaryProvider.FlushBoundary
to delineate writes.public FlushStrategy.WriteEventsListener apply(FlushStrategy.FlushSender sender)
FlushStrategy
FlushStrategy.FlushSender
is used to signal
to the connection that writes should now be
flushed.apply
in interface FlushStrategy
sender
- FlushStrategy.FlushSender
to signal flushes to the connection.FlushStrategy.WriteEventsListener
that would listen to write events on the connection for which custom flushes
are required.public boolean shouldFlushOnUnwritable()
FlushStrategy
true
if pending writes, if any, MUST be flushed when the connection is not writable. This method is expected to be idempotent.
shouldFlushOnUnwritable
in interface FlushStrategy
true
if pending writes, if any, MUST be flushed when the connection is not writable.public Cancellable updateFlushStrategy(NettyConnectionContext.FlushStrategyProvider strategyProvider)
FlushStrategy
that is used for flushing each delineated write boundary.strategyProvider
- NettyConnectionContext.FlushStrategyProvider
to provide the FlushStrategy
to use.Cancellable
that will cancel this update.public void updateFlushStrategy(NettyConnectionContext.FlushStrategyProvider strategyProvider, int boundariesTillCancel)
FlushStrategy
that is used for flushing each delineated write boundary. This update will
automatically be cancelled after it has been applied to boundariesTillCancel
delineated write boundaries.strategyProvider
- NettyConnectionContext.FlushStrategyProvider
to provide the FlushStrategy
to use.boundariesTillCancel
- Number of delineated write boundaries to apply this flush on.