R - Type of object that is read from this connection.W - Type of object that is written to this connection.public class PooledConnection<R,W> extends Connection<R,W>
Connection which is pooled and reused.
It is required to call reuse(Subscriber) for reusing this connection.| Modifier and Type | Class and Description |
|---|---|
static interface |
PooledConnection.Owner
A contract for the owner of the
PooledConnection to which any instance of PooledConnection must
be returned after use. |
| Modifier and Type | Field and Description |
|---|---|
static io.netty.util.AttributeKey<java.lang.Long> |
DYNAMIC_CONN_KEEP_ALIVE_TIMEOUT_MS |
CONNECTION_ATTRIBUTE_KEY, markAwarePipelineFLUSH_ON_EACH_BYTES, FLUSH_ON_EACH_FILE_REGION, FLUSH_ON_EACH_STRING, FLUSH_ONLY_ON_READ_COMPLETE| Modifier and Type | Method and Description |
|---|---|
<RR,WW> Connection<RR,WW> |
addChannelHandlerAfter(io.netty.util.concurrent.EventExecutorGroup group,
java.lang.String baseName,
java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
<RR,WW> Connection<RR,WW> |
addChannelHandlerAfter(java.lang.String baseName,
java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
<RR,WW> Connection<RR,WW> |
addChannelHandlerBefore(io.netty.util.concurrent.EventExecutorGroup group,
java.lang.String baseName,
java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
<RR,WW> Connection<RR,WW> |
addChannelHandlerBefore(java.lang.String baseName,
java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
<RR,WW> Connection<RR,WW> |
addChannelHandlerFirst(io.netty.util.concurrent.EventExecutorGroup group,
java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
<RR,WW> Connection<RR,WW> |
addChannelHandlerFirst(java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
<RR,WW> Connection<RR,WW> |
addChannelHandlerLast(io.netty.util.concurrent.EventExecutorGroup group,
java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
<RR,WW> Connection<RR,WW> |
addChannelHandlerLast(java.lang.String name,
io.netty.channel.ChannelHandler handler)
Adds a
ChannelHandler to ChannelPipeline for this connection. |
rx.Observable<java.lang.Void> |
close()
Flushes any pending writes and closes the connection.
|
rx.Observable<java.lang.Void> |
close(boolean flush)
Closes this channel after flushing all pending writes.
|
rx.Observable<java.lang.Void> |
closeListener()
Returns an
Observable that completes when this connection is closed. |
void |
closeNow()
Closes the connection immediately.
|
static <R,W> PooledConnection<R,W> |
create(PooledConnection.Owner owner,
long maxIdleTimeMillis,
Connection<R,W> unpooledDelegate) |
void |
flush()
Flushes any pending writes on this connection by calling
Channel.flush(). |
io.netty.channel.ChannelPipeline |
getChannelPipeline()
Returns the
ChannelPipeline for this connection. |
boolean |
isReused()
Returns
true if this connection is reused at least once. |
boolean |
isUsable()
Returns whether this connection is safe to be used at this moment.
|
<RR,WW> Connection<RR,WW> |
pipelineConfigurator(rx.functions.Action1<io.netty.channel.ChannelPipeline> pipelineConfigurator)
Configures the
ChannelPipeline for this channel, using the passed pipelineConfigurator. |
void |
reuse(rx.Subscriber<? super PooledConnection<R,W>> connectionSubscriber)
This method must be called for reusing the connection i.e.
|
<RR> Connection<RR,W> |
transformRead(rx.Observable.Transformer<R,RR> transformer)
Transforms this connection's input stream using the passed
transformer to create a new
Connection instance. |
<WW> Connection<R,WW> |
transformWrite(AllocatingTransformer<WW,W> transformer)
Transforms this connection to enable writing a different object type.
|
rx.Observable<java.lang.Void> |
write(rx.Observable<W> msgs)
On subscription of the returned
Observable, writes the passed message stream on the underneath channel. |
rx.Observable<java.lang.Void> |
write(rx.Observable<W> msgs,
rx.functions.Func1<W,java.lang.Boolean> flushSelector)
On subscription of the returned
Observable, writes the passed message stream on the underneath channel
and flushes the channel, everytime, flushSelector returns true . |
rx.Observable<java.lang.Void> |
writeAndFlushOnEach(rx.Observable<W> msgs)
On subscription of the returned
Observable, writes the passed message stream on the underneath channel
and flushes the channel, on every write. |
rx.Observable<java.lang.Void> |
writeBytes(rx.Observable<byte[]> msgs)
On subscription of the returned
Observable, writes the passed message stream on the underneath channel. |
rx.Observable<java.lang.Void> |
writeBytes(rx.Observable<byte[]> msgs,
rx.functions.Func1<byte[],java.lang.Boolean> flushSelector)
On subscription of the returned
Observable, writes the passed message stream on the underneath channel
and flushes the channel, everytime, flushSelector returns true . |
rx.Observable<java.lang.Void> |
writeBytesAndFlushOnEach(rx.Observable<byte[]> msgs)
On subscription of the returned
Observable, writes the passed message stream on the underneath channel
and flushes the channel, on every write. |
rx.Observable<java.lang.Void> |
writeFileRegion(rx.Observable<io.netty.channel.FileRegion> msgs)
On subscription of the returned
Observable, writes the passed message stream on the underneath channel. |
rx.Observable<java.lang.Void> |
writeFileRegion(rx.Observable<io.netty.channel.FileRegion> msgs,
rx.functions.Func1<io.netty.channel.FileRegion,java.lang.Boolean> flushSelector)
On subscription of the returned
Observable, writes the passed message stream on the underneath channel
and flushes the channel, everytime, flushSelector returns true . |
rx.Observable<java.lang.Void> |
writeFileRegionAndFlushOnEach(rx.Observable<io.netty.channel.FileRegion> msgs)
On subscription of the returned
Observable, writes the passed message stream on the underneath channel
and flushes the channel, on every write. |
rx.Observable<java.lang.Void> |
writeString(rx.Observable<java.lang.String> msgs)
On subscription of the returned
Observable, writes the passed message stream on the underneath channel. |
rx.Observable<java.lang.Void> |
writeString(rx.Observable<java.lang.String> msgs,
rx.functions.Func1<java.lang.String,java.lang.Boolean> flushSelector)
On subscription of the returned
Observable, writes the passed message stream on the underneath channel
and flushes the channel, everytime, flushSelector returns true . |
rx.Observable<java.lang.Void> |
writeStringAndFlushOnEach(rx.Observable<java.lang.String> msgs)
On subscription of the returned
Observable, writes the passed message stream on the underneath channel
and flushes the channel, on every write. |
connectCloseToChannelClose, getInput, getResettableChannelPipeline, ignoreInput, unsafeNettyChannelpublic static final io.netty.util.AttributeKey<java.lang.Long> DYNAMIC_CONN_KEEP_ALIVE_TIMEOUT_MS
public rx.Observable<java.lang.Void> write(rx.Observable<W> msgs)
ChannelOperationsObservable, writes the passed message stream on the underneath channel.
Observablemsgs - Stream of messages to write.Observable representing the result of this write. Every subscription to this Observable
will replay the write on the channel.public rx.Observable<java.lang.Void> write(rx.Observable<W> msgs, rx.functions.Func1<W,java.lang.Boolean> flushSelector)
ChannelOperationsObservable, writes the passed message stream on the underneath channel
and flushes the channel, everytime, flushSelector returns true . Any writes issued before
subscribing, will also be flushed. However, the returned Observable will not capture the result of those
writes, i.e. if the other writes, fail and this write does not, the returned Observable will not fail.msgs - Message stream to write.flushSelector - A Func1 which is invoked for every item emitted from msgs. Channel is
flushed, iff this function returns, true.Observable representing the result of this write. Every
subscription to this Observable will write the passed messages and flush all pending writes, when the
flushSelector returns truepublic rx.Observable<java.lang.Void> writeAndFlushOnEach(rx.Observable<W> msgs)
ChannelOperationsObservable, writes the passed message stream on the underneath channel
and flushes the channel, on every write. Any writes issued before subscribing, will also be flushed. However, the
returned Observable will not capture the result of those writes, i.e. if the other writes, fail and this
write does not, the returned Observable will not fail.msgs - Message stream to write.Observable representing the result of this write. Every
subscription to this Observable will write the passed messages and flush all pending writes, on every
write.public rx.Observable<java.lang.Void> writeString(rx.Observable<java.lang.String> msgs)
ChannelOperationsObservable, writes the passed message stream on the underneath channel.
Observablemsgs - Stream of messages to write.Observable representing the result of this write. Every subscription to this Observable
will replay the write on the channel.public rx.Observable<java.lang.Void> writeString(rx.Observable<java.lang.String> msgs,
rx.functions.Func1<java.lang.String,java.lang.Boolean> flushSelector)
ChannelOperationsObservable, writes the passed message stream on the underneath channel
and flushes the channel, everytime, flushSelector returns true . Any writes issued before
subscribing, will also be flushed. However, the returned Observable will not capture the result of those
writes, i.e. if the other writes, fail and this write does not, the returned Observable will not fail.msgs - Message stream to write.flushSelector - A Func1 which is invoked for every item emitted from msgs. Channel is
flushed, iff this function returns, true.Observable representing the result of this write. Every
subscription to this Observable will write the passed messages and flush all pending writes, when the
flushSelector returns truepublic rx.Observable<java.lang.Void> writeStringAndFlushOnEach(rx.Observable<java.lang.String> msgs)
ChannelOperationsObservable, writes the passed message stream on the underneath channel
and flushes the channel, on every write. Any writes issued before subscribing, will also be flushed. However, the
returned Observable will not capture the result of those writes, i.e. if the other writes, fail and this
write does not, the returned Observable will not fail.msgs - Message stream to write.Observable representing the result of this write. Every
subscription to this Observable will write the passed messages and flush all pending writes, on every
write.public rx.Observable<java.lang.Void> writeBytes(rx.Observable<byte[]> msgs)
ChannelOperationsObservable, writes the passed message stream on the underneath channel.
Observablemsgs - Stream of messages to write.Observable representing the result of this write. Every subscription to this Observable
will replay the write on the channel.public rx.Observable<java.lang.Void> writeBytes(rx.Observable<byte[]> msgs,
rx.functions.Func1<byte[],java.lang.Boolean> flushSelector)
ChannelOperationsObservable, writes the passed message stream on the underneath channel
and flushes the channel, everytime, flushSelector returns true . Any writes issued before
subscribing, will also be flushed. However, the returned Observable will not capture the result of those
writes, i.e. if the other writes, fail and this write does not, the returned Observable will not fail.msgs - Message stream to write.flushSelector - A Func1 which is invoked for every item emitted from msgs. Channel is
flushed, iff this function returns, true.Observable representing the result of this write. Every
subscription to this Observable will write the passed messages and flush all pending writes, when the
flushSelector returns truepublic rx.Observable<java.lang.Void> writeBytesAndFlushOnEach(rx.Observable<byte[]> msgs)
ChannelOperationsObservable, writes the passed message stream on the underneath channel
and flushes the channel, on every write. Any writes issued before subscribing, will also be flushed. However, the
returned Observable will not capture the result of those writes, i.e. if the other writes, fail and this
write does not, the returned Observable will not fail.msgs - Message stream to write.Observable representing the result of this write. Every
subscription to this Observable will write the passed messages and flush all pending writes, on every
write.public rx.Observable<java.lang.Void> writeFileRegion(rx.Observable<io.netty.channel.FileRegion> msgs)
ChannelOperationsObservable, writes the passed message stream on the underneath channel.
Observablemsgs - Stream of messages to write.Observable representing the result of this write. Every subscription to this Observable
will replay the write on the channel.public rx.Observable<java.lang.Void> writeFileRegion(rx.Observable<io.netty.channel.FileRegion> msgs,
rx.functions.Func1<io.netty.channel.FileRegion,java.lang.Boolean> flushSelector)
ChannelOperationsObservable, writes the passed message stream on the underneath channel
and flushes the channel, everytime, flushSelector returns true . Any writes issued before
subscribing, will also be flushed. However, the returned Observable will not capture the result of those
writes, i.e. if the other writes, fail and this write does not, the returned Observable will not fail.msgs - Message stream to write.flushSelector - A Func1 which is invoked for every item emitted from msgs. Channel is
flushed, iff this function returns, true.Observable representing the result of this write. Every
subscription to this Observable will write the passed messages and flush all pending writes, when the
flushSelector returns truepublic rx.Observable<java.lang.Void> writeFileRegionAndFlushOnEach(rx.Observable<io.netty.channel.FileRegion> msgs)
ChannelOperationsObservable, writes the passed message stream on the underneath channel
and flushes the channel, on every write. Any writes issued before subscribing, will also be flushed. However, the
returned Observable will not capture the result of those writes, i.e. if the other writes, fail and this
write does not, the returned Observable will not fail.msgs - Message stream to write.Observable representing the result of this write. Every
subscription to this Observable will write the passed messages and flush all pending writes, on every
write.public void flush()
ChannelOperationsChannel.flush(). This can be used for
implementing any custom flusing strategies that otherwise can not be implemented by methods like
ChannelOperations.write(Observable, Func1).public rx.Observable<java.lang.Void> close()
ChannelOperationsclose(true)Observable representing the result of close.public rx.Observable<java.lang.Void> close(boolean flush)
ChannelOperationsObservable representing the result of close and flush.public void closeNow()
ChannelOperationsChannelOperations.close() and subscribing to the returned
Observablepublic rx.Observable<java.lang.Void> closeListener()
ChannelOperationsObservable that completes when this connection is closed.Observable that completes when this connection is closed.public <RR,WW> Connection<RR,WW> addChannelHandlerAfter(java.lang.String baseName, java.lang.String name, io.netty.channel.ChannelHandler handler)
ConnectionChannelHandler to ChannelPipeline for this connection. The specified
handler is added after an existing handler with the passed baseName in the pipeline as specified by
ChannelPipeline.addAfter(String, String, ChannelHandler)
For better flexibility of pipeline modification, the method Connection.pipelineConfigurator(Action1) will be
more convenient.addChannelHandlerAfter in class Connection<R,W>baseName - the name of the existing handlername - Name of the handler.handler - Handler instance to add.this.public <RR,WW> Connection<RR,WW> addChannelHandlerAfter(io.netty.util.concurrent.EventExecutorGroup group, java.lang.String baseName, java.lang.String name, io.netty.channel.ChannelHandler handler)
ConnectionChannelHandler to ChannelPipeline for this connection. The specified
handler is added after an existing handler with the passed baseName in the pipeline as specified by
ChannelPipeline.addAfter(EventExecutorGroup, String, String, ChannelHandler)
For better flexibility of pipeline modification, the method Connection.pipelineConfigurator(Action1) will be
more convenient.addChannelHandlerAfter in class Connection<R,W>group - the EventExecutorGroup which will be used to execute the ChannelHandler methodsbaseName - the name of the existing handlername - the name of the handler to appendhandler - Handler instance to add.this.public <RR,WW> Connection<RR,WW> addChannelHandlerBefore(java.lang.String baseName, java.lang.String name, io.netty.channel.ChannelHandler handler)
ConnectionChannelHandler to ChannelPipeline for this connection. The specified
handler is added before an existing handler with the passed baseName in the pipeline as specified by
ChannelPipeline.addBefore(String, String, ChannelHandler)
For better flexibility of pipeline modification, the method Connection.pipelineConfigurator(Action1) will be
more convenient.addChannelHandlerBefore in class Connection<R,W>baseName - the name of the existing handlername - Name of the handler.handler - Handler instance to add.this.public <RR,WW> Connection<RR,WW> addChannelHandlerBefore(io.netty.util.concurrent.EventExecutorGroup group, java.lang.String baseName, java.lang.String name, io.netty.channel.ChannelHandler handler)
ConnectionChannelHandler to ChannelPipeline for this connection. The specified
handler is added before an existing handler with the passed baseName in the pipeline as specified by
ChannelPipeline.addBefore(EventExecutorGroup, String, String, ChannelHandler)
For better flexibility of pipeline modification, the method Connection.pipelineConfigurator(Action1) will be
more convenient.addChannelHandlerBefore in class Connection<R,W>group - the EventExecutorGroup which will be used to execute the ChannelHandler
methodsbaseName - the name of the existing handlername - the name of the handler to appendhandler - Handler instance to add.this.public <RR,WW> Connection<RR,WW> addChannelHandlerFirst(io.netty.util.concurrent.EventExecutorGroup group, java.lang.String name, io.netty.channel.ChannelHandler handler)
ConnectionChannelHandler to ChannelPipeline for this connection. The specified handler is added at
the first position of the pipeline as specified by
ChannelPipeline.addFirst(EventExecutorGroup, String, ChannelHandler)
For better flexibility of pipeline modification, the method Connection.pipelineConfigurator(Action1) will be
more convenient.addChannelHandlerFirst in class Connection<R,W>group - the EventExecutorGroup which will be used to execute the ChannelHandler methodsname - the name of the handler to appendhandler - Handler instance to add.this.public <RR,WW> Connection<RR,WW> addChannelHandlerFirst(java.lang.String name, io.netty.channel.ChannelHandler handler)
ConnectionChannelHandler to ChannelPipeline for this connection. The specified handler is added at
the first position of the pipeline as specified by ChannelPipeline.addFirst(String, ChannelHandler)
For better flexibility of pipeline modification, the method Connection.pipelineConfigurator(Action1) will be
more convenient.addChannelHandlerFirst in class Connection<R,W>name - Name of the handler.handler - Handler instance to add.this.public <RR,WW> Connection<RR,WW> addChannelHandlerLast(io.netty.util.concurrent.EventExecutorGroup group, java.lang.String name, io.netty.channel.ChannelHandler handler)
ConnectionChannelHandler to ChannelPipeline for this connection. The specified handler is added at
the last position of the pipeline as specified by
ChannelPipeline.addLast(EventExecutorGroup, String, ChannelHandler)
For better flexibility of pipeline modification, the method Connection.pipelineConfigurator(Action1) will be
more convenient.addChannelHandlerLast in class Connection<R,W>group - the EventExecutorGroup which will be used to execute the ChannelHandler methodsname - the name of the handler to appendhandler - Handler instance to add.this.public <RR,WW> Connection<RR,WW> addChannelHandlerLast(java.lang.String name, io.netty.channel.ChannelHandler handler)
ConnectionChannelHandler to ChannelPipeline for this connection. The specified handler is added at
the last position of the pipeline as specified by ChannelPipeline.addLast(String, ChannelHandler)
For better flexibility of pipeline modification, the method Connection.pipelineConfigurator(Action1) will be
more convenient.addChannelHandlerLast in class Connection<R,W>name - Name of the handler.handler - Handler instance to add.this.public <RR,WW> Connection<RR,WW> pipelineConfigurator(rx.functions.Action1<io.netty.channel.ChannelPipeline> pipelineConfigurator)
ConnectionChannelPipeline for this channel, using the passed pipelineConfigurator.pipelineConfigurator in class Connection<R,W>pipelineConfigurator - Action to configure ChannelPipeline.this.public <RR> Connection<RR,W> transformRead(rx.Observable.Transformer<R,RR> transformer)
Connectiontransformer to create a new
Connection instance.transformRead in class Connection<R,W>RR - New type of the input stream.transformer - Transformer to transform the input stream.public <WW> Connection<R,WW> transformWrite(AllocatingTransformer<WW,W> transformer)
ConnectiontransformWrite in interface ChannelOperations<W>transformWrite in class Connection<R,W>WW - New object types to be written to the connection.transformer - Transformer to transform objects written to the channel.public boolean isUsable()
Channel.isActive() and it has not passed the maximum idle time in the pool.true if the connection is usable.public void reuse(rx.Subscriber<? super PooledConnection<R,W>> connectionSubscriber)
connectionSubscriber - Subscriber for the pooled connection for reuse.public static <R,W> PooledConnection<R,W> create(PooledConnection.Owner owner, long maxIdleTimeMillis, Connection<R,W> unpooledDelegate)
public boolean isReused()
true if this connection is reused at least once.true if this connection is reused at least once.public io.netty.channel.ChannelPipeline getChannelPipeline()
ConnectionChannelPipeline for this connection.getChannelPipeline in class Connection<R,W>ChannelPipeline for this connection.