Class AbstractReplicationStrategy

    • Field Detail

      • configOptions

        public final java.util.Map<java.lang.String,​java.lang.String> configOptions
      • keyspaceName

        protected final java.lang.String keyspaceName
    • Constructor Detail

      • AbstractReplicationStrategy

        protected AbstractReplicationStrategy​(java.lang.String keyspaceName,
                                              TokenMetadata tokenMetadata,
                                              IEndpointSnitch snitch,
                                              java.util.Map<java.lang.String,​java.lang.String> configOptions)
    • Method Detail

      • getNaturalReplicasForToken

        public EndpointsForToken getNaturalReplicasForToken​(RingPosition<?> searchPosition)
        get the (possibly cached) endpoints that should store the given Token. Note that while the endpoints are conceptually a Set (no duplicates will be included), we return a List to avoid an extra allocation when sorting by proximity later
        Parameters:
        searchPosition - the position the natural endpoints are requested for
        Returns:
        a copy of the natural endpoints for the given token
      • calculateNaturalReplicas

        public abstract EndpointsForRange calculateNaturalReplicas​(Token searchToken,
                                                                   TokenMetadata tokenMetadata)
        Calculate the natural endpoints for the given token. Endpoints are returned in the order they occur in the ring following the searchToken, as defined by the replication strategy. Note that the order of the replicas is _implicitly relied upon_ by the definition of "primary" range in StorageService.getPrimaryRangesForEndpoint(String, InetAddressAndPort) which is in turn relied on by various components like repair and size estimate calculations.
        Parameters:
        tokenMetadata - the token metadata used to find the searchToken, e.g. contains token to endpoint mapping information
        searchToken - the token to find the natural endpoints for
        Returns:
        a copy of the natural endpoints for the given token
        See Also:
        getNaturalReplicasForToken(org.apache.cassandra.dht.RingPosition)
      • getReplicationFactor

        public abstract ReplicationFactor getReplicationFactor()
        calculate the RF based on strategy_options. When overwriting, ensure that this get() is FAST, as this is called often.
        Returns:
        the replication factor
      • hasTransientReplicas

        public boolean hasTransientReplicas()
      • maybeWarnOnOptions

        @Deprecated
        public void maybeWarnOnOptions()
        Deprecated.
      • maybeWarnOnOptions

        public void maybeWarnOnOptions​(ClientState state)
      • recognizedOptions

        public java.util.Collection<java.lang.String> recognizedOptions()
      • prepareReplicationStrategyOptions

        public static void prepareReplicationStrategyOptions​(java.lang.Class<? extends AbstractReplicationStrategy> strategyClass,
                                                             java.util.Map<java.lang.String,​java.lang.String> strategyOptions,
                                                             java.util.Map<java.lang.String,​java.lang.String> previousStrategyOptions)
        Before constructing the ARS we first give it a chance to prepare the options map in any way it would like to. For example datacenter auto-expansion or other templating to make the user interface more usable. Note that this may mutate the passed strategyOptions Map. We do this prior to the construction of the strategyClass itself because at that point the option map is already immutable and comes from ReplicationParams (and should probably stay that way so we don't start having bugs related to ReplicationParams being mutable). Instead ARS classes get a static hook here via the prepareOptions(Map, Map) method to mutate the user input before it becomes an immutable part of the ReplicationParams.
        Parameters:
        strategyClass - The class to call prepareOptions on
        strategyOptions - The proposed strategy options that will be potentially mutated by the prepareOptions method.
        previousStrategyOptions - In the case of an ALTER statement, the previous strategy options of this class. This map cannot be mutated.