Class CachedSubchannelPool
java.lang.Object
io.grpc.grpclb.CachedSubchannelPool
- All Implemented Interfaces:
SubchannelPool
A
SubchannelPool that keeps returned LoadBalancer.Subchannels for a given time before it's
shut down by the pool.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class(package private) final classNested classes/interfaces inherited from interface SubchannelPool
SubchannelPool.PooledSubchannelStateListener -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HashMap<EquivalentAddressGroup, CachedSubchannelPool.CacheEntry> private final LoadBalancer.Helper(package private) static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Shuts down all subchannels in the pool immediately.voidRegisters a listener to received Subchannel status updates.voidreturnSubchannel(LoadBalancer.Subchannel subchannel, ConnectivityStateInfo lastKnownState) Puts aLoadBalancer.Subchannelback to the pool.takeOrCreateSubchannel(EquivalentAddressGroup eag, Attributes defaultAttributes) Takes aLoadBalancer.Subchannelfrom the pool for the giveneagif there is one available.private voidupdateCachedSubchannelState(LoadBalancer.Subchannel subchannel, ConnectivityStateInfo newStateInfo)
-
Field Details
-
cache
-
helper
-
listener
-
SHUTDOWN_TIMEOUT_MS
static final long SHUTDOWN_TIMEOUT_MS- See Also:
-
-
Constructor Details
-
CachedSubchannelPool
-
-
Method Details
-
registerListener
Description copied from interface:SubchannelPoolRegisters a listener to received Subchannel status updates.- Specified by:
registerListenerin interfaceSubchannelPool
-
takeOrCreateSubchannel
public LoadBalancer.Subchannel takeOrCreateSubchannel(EquivalentAddressGroup eag, Attributes defaultAttributes) Description copied from interface:SubchannelPoolTakes aLoadBalancer.Subchannelfrom the pool for the giveneagif there is one available. Otherwise, creates and returns a newSubchannelwith the giveneaganddefaultAttributes.- Specified by:
takeOrCreateSubchannelin interfaceSubchannelPool
-
updateCachedSubchannelState
private void updateCachedSubchannelState(LoadBalancer.Subchannel subchannel, ConnectivityStateInfo newStateInfo) -
returnSubchannel
public void returnSubchannel(LoadBalancer.Subchannel subchannel, ConnectivityStateInfo lastKnownState) Description copied from interface:SubchannelPoolPuts aLoadBalancer.Subchannelback to the pool. From this point the Subchannel is owned by the pool, and the caller should stop referencing to this Subchannel.- Specified by:
returnSubchannelin interfaceSubchannelPool
-
clear
public void clear()Description copied from interface:SubchannelPoolShuts down all subchannels in the pool immediately.- Specified by:
clearin interfaceSubchannelPool
-