Package com.mongodb

Class TaggableReadPreference


  • @Immutable
    public abstract class TaggableReadPreference
    extends ReadPreference
    Abstract class for all preference which can be combined with tags
    • Method Detail

      • isSlaveOk

        public boolean isSlaveOk()
        Description copied from class: ReadPreference
        True if this read preference allows reading from a secondary member of a replica set.
        Specified by:
        isSlaveOk in class ReadPreference
        Returns:
        if reading from a secondary is ok
      • getTagSetList

        public List<TagSet> getTagSetList()
        Gets the list of tag sets as a list of TagSet instances.
        Returns:
        the list of tag sets
        Since:
        2.13
      • getMaxStaleness

        @Nullable
        public Long getMaxStaleness(TimeUnit timeUnit)
        Gets the maximum acceptable staleness of a secondary in order to be considered for read operations.

        The maximum staleness feature is designed to prevent badly-lagging servers from being selected. The staleness estimate is imprecise and shouldn't be used to try to select "up-to-date" secondaries.

        The driver estimates the staleness of each secondary, based on lastWriteDate values provided in server isMaster responses, and selects only those secondaries whose staleness is less than or equal to maxStaleness.

        Parameters:
        timeUnit - the time unit in which to return the value
        Returns:
        the maximum acceptable staleness in the given time unit, or null if the value is not set
        Since:
        3.4
        Since server release
        3.4
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object