Package org.apache.cassandra.locator
Class DynamicEndpointSnitch
java.lang.Object
org.apache.cassandra.locator.AbstractEndpointSnitch
org.apache.cassandra.locator.DynamicEndpointSnitch
- All Implemented Interfaces:
DynamicEndpointSnitchMBean,IEndpointSnitch,LatencySubscribers.Subscriber
public class DynamicEndpointSnitch
extends AbstractEndpointSnitch
implements LatencySubscribers.Subscriber, DynamicEndpointSnitchMBean
A dynamic snitch that sorts endpoints by latency with an adapted phi failure detector
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDynamicEndpointSnitch(IEndpointSnitch snitch) DynamicEndpointSnitch(IEndpointSnitch snitch, String instance) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddSeverity(double severity) voidUpdate configuration fromDatabaseDescriptorand estart the update-scheduler and reset-scheduler tasks if the configured rates for these tasks have changed.voidclose()intcompareEndpoints(InetAddressAndPort target, Replica a1, Replica a2) compares two endpoints in relation to the target endpoint, returning as Comparator.compare woulddumpTimings(String hostname) doublegetDatacenter(InetAddressAndPort endpoint) returns a String representing the datacenter the given endpoint belongs togetRack(InetAddressAndPort endpoint) returns a String representing the rack the given endpoint belongs tointdoublestatic doublegetSeverity(InetAddressAndPort endpoint) intvoidcalled after Gossiper instance exists immediately before it starts gossipingbooleanisWorthMergingForRangeQuery(ReplicaCollection<?> merged, ReplicaCollection<?> l1, ReplicaCollection<?> l2) Returns whether for a range query doing a query against merged is likely to be faster than 2 sequential queries, one against l1 followed by one against l2.voidreceiveTiming(InetAddressAndPort host, long latency, TimeUnit unit) voidsetSeverity(double severity) Setting a Severity allows operators to inject preference information into the Dynamic Snitch replica selection.<C extends ReplicaCollection<? extends C>>
CsortedByProximity(InetAddressAndPort address, C unsortedAddresses) Sorts the Collection of node addresses by proximity to the given addressvoidbooleanDetermine if the datacenter or rack values in the current node's snitch conflict with those passed in parameters.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.cassandra.locator.IEndpointSnitch
getDatacenter, getDatacenter, getLocalDatacenter, getLocalRack
-
Field Details
-
subsnitch
-
-
Constructor Details
-
DynamicEndpointSnitch
-
DynamicEndpointSnitch
-
-
Method Details
-
applyConfigChanges
public void applyConfigChanges()Update configuration fromDatabaseDescriptorand estart the update-scheduler and reset-scheduler tasks if the configured rates for these tasks have changed. -
close
public void close() -
gossiperStarting
public void gossiperStarting()Description copied from interface:IEndpointSnitchcalled after Gossiper instance exists immediately before it starts gossiping- Specified by:
gossiperStartingin interfaceIEndpointSnitch- Overrides:
gossiperStartingin classAbstractEndpointSnitch
-
getRack
Description copied from interface:IEndpointSnitchreturns a String representing the rack the given endpoint belongs to- Specified by:
getRackin interfaceIEndpointSnitch
-
getDatacenter
Description copied from interface:IEndpointSnitchreturns a String representing the datacenter the given endpoint belongs to- Specified by:
getDatacenterin interfaceIEndpointSnitch
-
sortedByProximity
public <C extends ReplicaCollection<? extends C>> C sortedByProximity(InetAddressAndPort address, C unsortedAddresses) Description copied from class:AbstractEndpointSnitchSorts the Collection of node addresses by proximity to the given address- Specified by:
sortedByProximityin interfaceIEndpointSnitch- Overrides:
sortedByProximityin classAbstractEndpointSnitch- Parameters:
address- the address to sort by proximity tounsortedAddresses- the nodes to sort- Returns:
- a new sorted List
-
compareEndpoints
Description copied from interface:IEndpointSnitchcompares two endpoints in relation to the target endpoint, returning as Comparator.compare would- Specified by:
compareEndpointsin interfaceIEndpointSnitch- Specified by:
compareEndpointsin classAbstractEndpointSnitch
-
receiveTiming
- Specified by:
receiveTimingin interfaceLatencySubscribers.Subscriber
-
updateScores
public void updateScores() -
getScores
- Specified by:
getScoresin interfaceDynamicEndpointSnitchMBean
-
getScoresWithPort
- Specified by:
getScoresWithPortin interfaceDynamicEndpointSnitchMBean
-
getUpdateInterval
public int getUpdateInterval()- Specified by:
getUpdateIntervalin interfaceDynamicEndpointSnitchMBean
-
getResetInterval
public int getResetInterval()- Specified by:
getResetIntervalin interfaceDynamicEndpointSnitchMBean
-
getBadnessThreshold
public double getBadnessThreshold()- Specified by:
getBadnessThresholdin interfaceDynamicEndpointSnitchMBean
-
getSubsnitchClassName
- Specified by:
getSubsnitchClassNamein interfaceDynamicEndpointSnitchMBean
-
dumpTimings
- Specified by:
dumpTimingsin interfaceDynamicEndpointSnitchMBean- Throws:
UnknownHostException
-
setSeverity
public void setSeverity(double severity) Description copied from interface:DynamicEndpointSnitchMBeanSetting a Severity allows operators to inject preference information into the Dynamic Snitch replica selection. When choosing which replicas to participate in a read request, the DSnitch sorts replicas by response latency, and selects the fastest replicas. Latencies are normalized to a score from 0 to 1, with lower scores being faster. The Severity injected here will be added to the normalized score. Thus, adding a Severity greater than 1 will mean the replica will never be contacted (unless needed for ALL or if it is added later for rapid read protection). Conversely, adding a negative Severity means the replica will *always* be contacted. (The "Severity" term is historical and dates to when this was used to represent how badly background tasks like compaction were affecting a replica's performance. See CASSANDRA-3722 for when this was introduced and CASSANDRA-11738 for why it was removed.)- Specified by:
setSeverityin interfaceDynamicEndpointSnitchMBean
-
addSeverity
public static void addSeverity(double severity) -
getSeverity
-
getSeverity
public double getSeverity()- Specified by:
getSeverityin interfaceDynamicEndpointSnitchMBean- Returns:
- the current manually injected Severity.
-
isWorthMergingForRangeQuery
public boolean isWorthMergingForRangeQuery(ReplicaCollection<?> merged, ReplicaCollection<?> l1, ReplicaCollection<?> l2) Description copied from interface:IEndpointSnitchReturns whether for a range query doing a query against merged is likely to be faster than 2 sequential queries, one against l1 followed by one against l2.- Specified by:
isWorthMergingForRangeQueryin interfaceIEndpointSnitch- Overrides:
isWorthMergingForRangeQueryin classAbstractEndpointSnitch
-
validate
Description copied from interface:IEndpointSnitchDetermine if the datacenter or rack values in the current node's snitch conflict with those passed in parameters.- Specified by:
validatein interfaceIEndpointSnitch
-