I
- The type of the object that is read from this connection.O
- The type of objects that are written to this connection.public class PooledConnection<I,O> extends ObservableConnection<I,O>
ObservableConnection
that is used by ConnectionPool
.
The pool using this connection must call setConnectionPool(ConnectionPool)
before using the instance.
Failure to do so will never return this connection to the pool and the close()
will dispose this connection.closeStartTimeMillis
closeIssued, CONNECTION_ALREADY_CLOSED
Modifier | Constructor and Description |
---|---|
protected |
PooledConnection(io.netty.channel.Channel channel,
long maxIdleTimeMillis,
ChannelMetricEventProvider metricEventProvider,
MetricEventsSubject<?> eventsSubject) |
Modifier and Type | Method and Description |
---|---|
protected rx.Observable<java.lang.Void> |
_closeChannel() |
void |
beforeReuse() |
rx.Observable<java.lang.Void> |
close()
Closes this connection.
|
rx.Observable<java.lang.Void> |
closeUnderlyingChannel() |
static <I,O> PooledConnection<I,O> |
create(io.netty.channel.Channel channel,
ChannelMetricEventProvider metricEventProvider,
MetricEventsSubject<?> eventsSubject) |
static <I,O> PooledConnection<I,O> |
create(io.netty.channel.Channel channel,
long maxIdleTimeMillis,
ChannelMetricEventProvider metricEventProvider,
MetricEventsSubject<?> eventsSubject) |
boolean |
isUsable()
Returns whether this connection is safe to be used at this moment.
|
void |
setConnectionPool(ConnectionPool<I,O> pool) |
void |
updateMaxIdleTimeMillis(long maxIdleTimeMillis) |
_close, create, fireNewRxConnectionEvent, getInput, updateInputSubject
cancelPendingWrites, close, flush, getAllocator, getChannel, isCloseIssued, write, write, writeAndFlush, writeAndFlush, writeBytes, writeBytes, writeBytesAndFlush, writeBytesAndFlush, writeFileRegion, writeOnChannel, writeString, writeStringAndFlush
protected PooledConnection(io.netty.channel.Channel channel, long maxIdleTimeMillis, ChannelMetricEventProvider metricEventProvider, MetricEventsSubject<?> eventsSubject)
public void setConnectionPool(ConnectionPool<I,O> pool)
public rx.Observable<java.lang.Void> close()
ObservableConnection
close
in interface ChannelWriter<O>
close
in class ObservableConnection<I,O>
Observable.error(Throwable)
if the
close is already issued (may not be completed)protected rx.Observable<java.lang.Void> _closeChannel()
_closeChannel
in class ObservableConnection<I,O>
public rx.Observable<java.lang.Void> closeUnderlyingChannel()
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 beforeReuse()
public void updateMaxIdleTimeMillis(long maxIdleTimeMillis)
public static <I,O> PooledConnection<I,O> create(io.netty.channel.Channel channel, long maxIdleTimeMillis, ChannelMetricEventProvider metricEventProvider, MetricEventsSubject<?> eventsSubject)
public static <I,O> PooledConnection<I,O> create(io.netty.channel.Channel channel, ChannelMetricEventProvider metricEventProvider, MetricEventsSubject<?> eventsSubject)