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.MeterRegistrarDisposable.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,
Context currentContext) |
protected CoreSubscriber<reactor.pool.PooledRef<T>> |
createDisposableAcquire(TransportConfig config,
ConnectionObserver connectionObserver,
long pendingAcquireTimeout,
reactor.pool.InstrumentedPool<T> pool,
SocketAddress remoteAddress,
MonoSink<Connection> sink,
Context currentContext) |
protected reactor.pool.InstrumentedPool<T> |
createPool(String id,
TransportConfig config,
PooledConnectionProvider.PoolFactory<T> poolFactory,
SocketAddress remoteAddress,
AddressResolverGroup<?> resolverGroup) |
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, waitbuilder, create, create, create, dispose, newConnectionprotected 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)
ConnectionProviderConnection on subscribe.acquire in interface ConnectionProviderconfig - the transport configurationconnectionObserver - the ConnectionObserverremote - the SocketAddress to connect toresolverGroup - the resolver which will resolve the address of the unresolved named addressMono of Connectionpublic final Mono<Void> disposeLater()
ConnectionProvider
This method has NOOP default implementation.
ConnectionProvider implementations may decide to provide more specific implementation.
disposeLater in interface ConnectionProviderpublic final void disposeWhen(SocketAddress address)
ConnectionProvider
This method has NOOP default implementation.
ConnectionProvider implementations may decide to provide more specific implementation.
disposeWhen in interface ConnectionProvideraddress - the remote addresspublic final boolean isDisposed()
isDisposed in interface Disposablepublic int maxConnections()
ConnectionProvidermaxConnections in interface ConnectionProviderpublic Map<SocketAddress,Integer> maxConnectionsPerHost()
ConnectionProvidermaxConnectionsPerHost in interface ConnectionProviderpublic ConnectionProvider.Builder mutate()
ConnectionProviderConnectionProvider.mutate in interface ConnectionProviderConnectionProviderpublic String name()
ConnectionProviderConnectionProvider name used for metrics.name in interface ConnectionProviderConnectionProvider 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, Context currentContext)
protected CoreSubscriber<reactor.pool.PooledRef<T>> createDisposableAcquire(TransportConfig config, ConnectionObserver connectionObserver, long pendingAcquireTimeout, reactor.pool.InstrumentedPool<T> pool, SocketAddress remoteAddress, MonoSink<Connection> sink, Context currentContext)
protected abstract reactor.pool.InstrumentedPool<T> createPool(TransportConfig config, PooledConnectionProvider.PoolFactory<T> poolFactory, SocketAddress remoteAddress, @Nullable AddressResolverGroup<?> resolverGroup)
protected reactor.pool.InstrumentedPool<T> createPool(String id, TransportConfig config, PooledConnectionProvider.PoolFactory<T> poolFactory, SocketAddress remoteAddress, @Nullable 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)