Package reactor.netty.resources
Class PooledConnectionProvider<T extends Connection>
java.lang.Object
reactor.netty.resources.PooledConnectionProvider<T>
- Type Parameters:
T- the poolable resource
- All Implemented Interfaces:
Disposable,ConnectionProvider
public abstract class PooledConnectionProvider<T extends Connection>
extends Object
implements ConnectionProvider
Base
ConnectionProvider implementation.- Since:
- 1.0.0
- Author:
- Violeta Georgieva
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classNested classes/interfaces inherited from interface reactor.netty.resources.ConnectionProvider
ConnectionProvider.AllocationStrategy<A extends ConnectionProvider.AllocationStrategy<A>>, ConnectionProvider.Builder, ConnectionProvider.ConnectionMetadata, ConnectionProvider.ConnectionPoolSpec<SPEC extends ConnectionProvider.ConnectionPoolSpec<SPEC>>, ConnectionProvider.HostSpecificSpec, ConnectionProvider.MeterRegistrarNested classes/interfaces inherited from interface reactor.core.Disposable
Disposable.Composite, Disposable.Swap -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringContext key used to propagate the caller event loop in the connection pool subscription.Fields inherited from interface reactor.netty.resources.ConnectionProvider
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 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptionfinal Mono<? extends Connection>acquire(TransportConfig config, ConnectionObserver connectionObserver, @Nullable Supplier<? extends SocketAddress> remote, @Nullable AddressResolverGroup<?> resolverGroup) Return an existing or newConnectionon subscribe.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 CoreSubscriber<reactor.pool.PooledRef<T>>createDisposableAcquire(TransportConfig config, ConnectionObserver connectionObserver, long pendingAcquireTimeout, reactor.pool.InstrumentedPool<T> pool, MonoSink<Connection> sink, Context currentContext) protected reactor.pool.InstrumentedPool<T>createPool(String id, TransportConfig config, PooledConnectionProvider.PoolFactory<T> poolFactory, SocketAddress remoteAddress, @Nullable AddressResolverGroup<?> resolverGroup) protected abstract reactor.pool.InstrumentedPool<T>createPool(TransportConfig config, PooledConnectionProvider.PoolFactory<T> poolFactory, SocketAddress remoteAddress, @Nullable AddressResolverGroup<?> resolverGroup) protected ConnectionPoolMetricsdelegateConnectionPoolMetrics(reactor.pool.InstrumentedPool.PoolMetrics metrics) protected voiddeRegisterDefaultMetrics(String id, SocketAddress remoteAddress) Returns a Mono that triggers the disposal of the ConnectionProvider when subscribed to.final voiddisposeWhen(SocketAddress address) Dispose all connection pools for the specified remote address.final booleanprotected static voidlogPoolState(Channel channel, reactor.pool.InstrumentedPool<? extends Connection> pool, String msg) protected static voidlogPoolState(Channel channel, reactor.pool.InstrumentedPool<? extends Connection> pool, String msg, @Nullable Throwable t) intReturns the maximum number of connections before starting pending.Returns the maximum number of connections per host before starting pending.mutate()Returns a builder to mutate properties of thisConnectionProvider.name()ReturnsConnectionProvidername used for metrics.voidprotected PooledConnectionProvider.PoolFactory<T>poolFactory(SocketAddress remoteAddress) protected voidregisterDefaultMetrics(String id, SocketAddress remoteAddress, reactor.pool.InstrumentedPool.PoolMetrics metrics) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface reactor.netty.resources.ConnectionProvider
dispose
-
Field Details
-
CONTEXT_CALLER_EVENTLOOP
Context key used to propagate the caller event loop in the connection pool subscription.- See Also:
-
-
Constructor Details
-
PooledConnectionProvider
-
-
Method Details
-
acquire
public final Mono<? extends Connection> acquire(TransportConfig config, ConnectionObserver connectionObserver, @Nullable Supplier<? extends SocketAddress> remote, @Nullable AddressResolverGroup<?> resolverGroup) Description copied from interface:ConnectionProviderReturn an existing or newConnectionon subscribe.- Specified by:
acquirein interfaceConnectionProvider- Parameters:
config- the transport configurationconnectionObserver- theConnectionObserverremote- theSocketAddressto connect toresolverGroup- the resolver which will resolve the address of the unresolved named address- Returns:
- an existing or new
MonoofConnection
-
disposeLater
Description copied from interface:ConnectionProviderReturns a Mono that triggers the disposal of the ConnectionProvider when subscribed to.This method has
NOOPdefault implementation.ConnectionProviderimplementations may decide to provide more specific implementation.- Specified by:
disposeLaterin interfaceConnectionProvider- Returns:
- a Mono representing the completion of the ConnectionProvider disposal.
-
disposeWhen
Description copied from interface:ConnectionProviderDispose all connection pools for the specified remote address.This method has
NOOPdefault implementation.ConnectionProviderimplementations may decide to provide more specific implementation.- Specified by:
disposeWhenin interfaceConnectionProvider- Parameters:
address- the remote address
-
isDisposed
public final boolean isDisposed()- Specified by:
isDisposedin interfaceDisposable
-
maxConnections
public int maxConnections()Description copied from interface:ConnectionProviderReturns the maximum number of connections before starting pending.- Specified by:
maxConnectionsin interfaceConnectionProvider- Returns:
- the maximum number of connections before starting pending
-
maxConnectionsPerHost
Description copied from interface:ConnectionProviderReturns the maximum number of connections per host before starting pending.- Specified by:
maxConnectionsPerHostin interfaceConnectionProvider- Returns:
- the maximum number of connections per host before starting pending
-
mutate
Description copied from interface:ConnectionProviderReturns a builder to mutate properties of thisConnectionProvider.- Specified by:
mutatein interfaceConnectionProvider- Returns:
- a builder to mutate properties of this
ConnectionProvider
-
name
Description copied from interface:ConnectionProviderReturnsConnectionProvidername used for metrics.- Specified by:
namein interfaceConnectionProvider- Returns:
ConnectionProvidername used for metrics
-
onDispose
-
createDisposableAcquire
protected abstract CoreSubscriber<reactor.pool.PooledRef<T>> createDisposableAcquire(TransportConfig config, ConnectionObserver connectionObserver, long pendingAcquireTimeout, reactor.pool.InstrumentedPool<T> pool, MonoSink<Connection> sink, Context currentContext) -
createDisposableAcquire
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) -
createPool
protected abstract reactor.pool.InstrumentedPool<T> createPool(TransportConfig config, PooledConnectionProvider.PoolFactory<T> poolFactory, SocketAddress remoteAddress, @Nullable AddressResolverGroup<?> resolverGroup) -
createPool
protected reactor.pool.InstrumentedPool<T> createPool(String id, TransportConfig config, PooledConnectionProvider.PoolFactory<T> poolFactory, SocketAddress remoteAddress, @Nullable AddressResolverGroup<?> resolverGroup) -
poolFactory
-
delegateConnectionPoolMetrics
protected ConnectionPoolMetrics delegateConnectionPoolMetrics(reactor.pool.InstrumentedPool.PoolMetrics metrics) -
registerDefaultMetrics
protected void registerDefaultMetrics(String id, SocketAddress remoteAddress, reactor.pool.InstrumentedPool.PoolMetrics metrics) -
deRegisterDefaultMetrics
-
logPoolState
protected static void logPoolState(Channel channel, reactor.pool.InstrumentedPool<? extends Connection> pool, String msg) -
logPoolState
protected static void logPoolState(Channel channel, reactor.pool.InstrumentedPool<? extends Connection> pool, String msg, @Nullable Throwable t)
-