Package com.google.cloud.spanner.spi.v1
Class PowerOfTwoReplicaSelector
java.lang.Object
com.google.cloud.spanner.spi.v1.PowerOfTwoReplicaSelector
- All Implemented Interfaces:
ReplicaSelector
@InternalApi
@BetaApi
public class PowerOfTwoReplicaSelector
extends Object
implements ReplicaSelector
Implementation of
ReplicaSelector using the "Power of 2 Random Choices" strategy.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionselect(List<ChannelEndpoint> candidates, Function<ChannelEndpoint, Double> scoreLookup) Selects a replica from the given list of candidates.
-
Constructor Details
-
PowerOfTwoReplicaSelector
public PowerOfTwoReplicaSelector()
-
-
Method Details
-
select
public ChannelEndpoint select(List<ChannelEndpoint> candidates, Function<ChannelEndpoint, Double> scoreLookup) Description copied from interface:ReplicaSelectorSelects a replica from the given list of candidates.- Specified by:
selectin interfaceReplicaSelector- Parameters:
candidates- the list of eligible candidates.scoreLookup- a function to look up the latency score for a candidate.- Returns:
- the selected candidate, or null if the list is empty.
-