T
- the poolable resourcepublic abstract class PooledConnectionProvider<T extends Connection> extends Object implements ConnectionProvider
ConnectionProvider
implementation.Modifier and Type | Class and Description |
---|---|
protected static class |
PooledConnectionProvider.PoolFactory<T extends Connection> |
ConnectionProvider.AllocationStrategy<A extends ConnectionProvider.AllocationStrategy<A>>, ConnectionProvider.Builder, ConnectionProvider.ConnectionMetadata, ConnectionProvider.ConnectionPoolSpec<SPEC extends ConnectionProvider.ConnectionPoolSpec<SPEC>>, ConnectionProvider.HostSpecificSpec, ConnectionProvider.MeterRegistrar
Disposable.Composite, Disposable.Swap
Modifier and Type | Field and Description |
---|---|
protected static String |
CONTEXT_CALLER_EVENTLOOP
Context key used to propagate the caller event loop in the connection pool subscription.
|
DEFAULT_POOL_ACQUIRE_TIMEOUT, DEFAULT_POOL_LEASING_STRATEGY, DEFAULT_POOL_MAX_CONNECTIONS, DEFAULT_POOL_MAX_IDLE_TIME, DEFAULT_POOL_MAX_LIFE_TIME, LEASING_STRATEGY_FIFO, LEASING_STRATEGY_LIFO
Modifier | Constructor and Description |
---|---|
protected |
PooledConnectionProvider(ConnectionProvider.Builder builder) |
Modifier and Type | Method and Description |
---|---|
Mono<? extends Connection> |
acquire(TransportConfig config,
ConnectionObserver connectionObserver,
Supplier<? extends SocketAddress> remote,
AddressResolverGroup<?> resolverGroup)
Return an existing or new
Connection on subscribe. |
protected abstract CoreSubscriber<reactor.pool.PooledRef<T>> |
createDisposableAcquire(TransportConfig config,
ConnectionObserver connectionObserver,
long pendingAcquireTimeout,
reactor.pool.InstrumentedPool<T> pool,
MonoSink<Connection> sink) |
protected abstract reactor.pool.InstrumentedPool<T> |
createPool(TransportConfig config,
PooledConnectionProvider.PoolFactory<T> poolFactory,
SocketAddress remoteAddress,
AddressResolverGroup<?> resolverGroup) |
protected void |
deRegisterDefaultMetrics(String id,
SocketAddress remoteAddress) |
Mono<Void> |
disposeLater()
Returns a Mono that triggers the disposal of the ConnectionProvider when subscribed to.
|
void |
disposeWhen(SocketAddress address)
Dispose all connection pools for the specified remote address.
|
boolean |
isDisposed() |
protected static void |
logPoolState(Channel channel,
reactor.pool.InstrumentedPool<? extends Connection> pool,
String msg) |
protected static void |
logPoolState(Channel channel,
reactor.pool.InstrumentedPool<? extends Connection> pool,
String msg,
Throwable t) |
int |
maxConnections()
Returns the maximum number of connections before starting pending
|
Map<SocketAddress,Integer> |
maxConnectionsPerHost()
Returns the maximum number of connections per host before starting pending
|
ConnectionProvider.Builder |
mutate()
Returns a builder to mutate properties of this
ConnectionProvider |
String |
name()
Returns
ConnectionProvider name used for metrics |
void |
onDispose(Mono<Void> disposeMono) |
protected PooledConnectionProvider.PoolFactory<T> |
poolFactory(SocketAddress remoteAddress) |
protected void |
registerDefaultMetrics(String id,
SocketAddress remoteAddress,
reactor.pool.InstrumentedPool.PoolMetrics metrics) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
builder, create, create, create, dispose, newConnection
protected static final String CONTEXT_CALLER_EVENTLOOP
protected PooledConnectionProvider(ConnectionProvider.Builder builder)
public final Mono<? extends Connection> acquire(TransportConfig config, ConnectionObserver connectionObserver, @Nullable Supplier<? extends SocketAddress> remote, @Nullable AddressResolverGroup<?> resolverGroup)
ConnectionProvider
Connection
on subscribe.acquire
in interface ConnectionProvider
config
- the transport configurationconnectionObserver
- the ConnectionObserver
remote
- the SocketAddress
to connect toresolverGroup
- the resolver which will resolve the address of the unresolved named addressMono
of Connection
public final Mono<Void> disposeLater()
ConnectionProvider
This method has NOOP
default implementation.
ConnectionProvider
implementations may decide to provide more specific implementation.
disposeLater
in interface ConnectionProvider
public final void disposeWhen(SocketAddress address)
ConnectionProvider
This method has NOOP
default implementation.
ConnectionProvider
implementations may decide to provide more specific implementation.
disposeWhen
in interface ConnectionProvider
address
- the remote addresspublic final boolean isDisposed()
isDisposed
in interface Disposable
public int maxConnections()
ConnectionProvider
maxConnections
in interface ConnectionProvider
public Map<SocketAddress,Integer> maxConnectionsPerHost()
ConnectionProvider
maxConnectionsPerHost
in interface ConnectionProvider
public ConnectionProvider.Builder mutate()
ConnectionProvider
ConnectionProvider
mutate
in interface ConnectionProvider
ConnectionProvider
public String name()
ConnectionProvider
ConnectionProvider
name used for metricsname
in interface ConnectionProvider
ConnectionProvider
name used for metricsprotected abstract CoreSubscriber<reactor.pool.PooledRef<T>> createDisposableAcquire(TransportConfig config, ConnectionObserver connectionObserver, long pendingAcquireTimeout, reactor.pool.InstrumentedPool<T> pool, MonoSink<Connection> sink)
protected abstract reactor.pool.InstrumentedPool<T> createPool(TransportConfig config, PooledConnectionProvider.PoolFactory<T> poolFactory, SocketAddress remoteAddress, AddressResolverGroup<?> resolverGroup)
protected PooledConnectionProvider.PoolFactory<T> poolFactory(SocketAddress remoteAddress)
protected void registerDefaultMetrics(String id, SocketAddress remoteAddress, reactor.pool.InstrumentedPool.PoolMetrics metrics)
protected void deRegisterDefaultMetrics(String id, SocketAddress remoteAddress)
protected static void logPoolState(Channel channel, reactor.pool.InstrumentedPool<? extends Connection> pool, String msg)
protected static void logPoolState(Channel channel, reactor.pool.InstrumentedPool<? extends Connection> pool, String msg, @Nullable Throwable t)