Package io.grpc.grpclb
Class CachedSubchannelPool
java.lang.Object
io.grpc.grpclb.CachedSubchannelPool
- All Implemented Interfaces:
SubchannelPool
A
SubchannelPool
that keeps returned LoadBalancer.Subchannel
s for a given time before it's
shut down by the pool.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
(package private) final class
Nested classes/interfaces inherited from interface io.grpc.grpclb.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 TypeMethodDescriptionvoid
clear()
Shuts down all subchannels in the pool immediately.void
Registers a listener to received Subchannel status updates.void
returnSubchannel
(LoadBalancer.Subchannel subchannel, ConnectivityStateInfo lastKnownState) Puts aLoadBalancer.Subchannel
back to the pool.takeOrCreateSubchannel
(EquivalentAddressGroup eag, Attributes defaultAttributes) Takes aLoadBalancer.Subchannel
from the pool for the giveneag
if there is one available.private void
updateCachedSubchannelState
(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:SubchannelPool
Registers a listener to received Subchannel status updates.- Specified by:
registerListener
in interfaceSubchannelPool
-
takeOrCreateSubchannel
public LoadBalancer.Subchannel takeOrCreateSubchannel(EquivalentAddressGroup eag, Attributes defaultAttributes) Description copied from interface:SubchannelPool
Takes aLoadBalancer.Subchannel
from the pool for the giveneag
if there is one available. Otherwise, creates and returns a newSubchannel
with the giveneag
anddefaultAttributes
.- Specified by:
takeOrCreateSubchannel
in interfaceSubchannelPool
-
updateCachedSubchannelState
private void updateCachedSubchannelState(LoadBalancer.Subchannel subchannel, ConnectivityStateInfo newStateInfo) -
returnSubchannel
public void returnSubchannel(LoadBalancer.Subchannel subchannel, ConnectivityStateInfo lastKnownState) Description copied from interface:SubchannelPool
Puts aLoadBalancer.Subchannel
back to the pool. From this point the Subchannel is owned by the pool, and the caller should stop referencing to this Subchannel.- Specified by:
returnSubchannel
in interfaceSubchannelPool
-
clear
public void clear()Description copied from interface:SubchannelPool
Shuts down all subchannels in the pool immediately.- Specified by:
clear
in interfaceSubchannelPool
-