Package com.mongodb
Class TaggableReadPreference
java.lang.Object
com.mongodb.ReadPreference
com.mongodb.TaggableReadPreference
Abstract class for all preference which can be combined with tags
-
Method Summary
Modifier and TypeMethodDescriptionprotected List<ServerDescription>chooseForNonReplicaSet(ClusterDescription clusterDescription) Choose for non-replica sets.booleanGets the hedge options.getMaxStaleness(TimeUnit timeUnit) Gets the maximum acceptable staleness of a secondary in order to be considered for read operations.Gets the list of tag sets as a list ofTagSetinstances.inthashCode()booleanTrue if this read preference allows reading from a secondary member of a replica set.booleanDeprecated.Gets a document representing this read preference in the wire protocol.toString()abstract TaggableReadPreferencewithHedgeOptions(ReadPreferenceHedgeOptions hedgeOptions) Create a new ReadPreference instance with hedge options.abstract TaggableReadPreferencewithMaxStalenessMS(Long maxStalenessMS, TimeUnit timeUnit) Create a new ReadPreference instance with the maximum acceptable staleness of a secondary in order to be considered for read operations.abstract TaggableReadPreferencewithTagSet(TagSet tagSet) Create a new ReadPreference instance with a new tag set.abstract TaggableReadPreferencewithTagSetList(List<TagSet> tagSet) Create a new ReadPreference instance with a new tag set list.Methods inherited from class com.mongodb.ReadPreference
choose, chooseForReplicaSet, getName, nearest, nearest, nearest, nearest, nearest, nearest, primary, primaryPreferred, primaryPreferred, primaryPreferred, primaryPreferred, primaryPreferred, primaryPreferred, secondary, secondary, secondary, secondary, secondary, secondary, secondaryPreferred, secondaryPreferred, secondaryPreferred, secondaryPreferred, secondaryPreferred, secondaryPreferred, valueOf, valueOf, valueOf
-
Method Details
-
withTagSet
Description copied from class:ReadPreferenceCreate a new ReadPreference instance with a new tag set.Note: this method is not supported for a primary read preference.
- Specified by:
withTagSetin classReadPreference- Parameters:
tagSet- the new tag set- Returns:
- a new ReadPreference instance with a new tag set
-
withTagSetList
Description copied from class:ReadPreferenceCreate a new ReadPreference instance with a new tag set list.Note: this method is not supported for a primary read preference.
- Specified by:
withTagSetListin classReadPreference- Parameters:
tagSet- the new tag set list- Returns:
- a new ReadPreference instance with a new tag set list
-
withMaxStalenessMS
Description copied from class:ReadPreferenceCreate a new ReadPreference instance with the maximum acceptable staleness of a secondary in order to be considered for read operations.Note: this method is not supported for a primary read preference.
- Specified by:
withMaxStalenessMSin classReadPreference- Parameters:
maxStalenessMS- the max allowable staleness of secondaries. The minimum value is either 90 seconds, or the heartbeat frequency plus 10 seconds, whichever is greatest.timeUnit- the time unit of maxStaleness- Returns:
- a new ReadPreference instance with a new maximum allowable staleness
-
withHedgeOptions
Description copied from class:ReadPreferenceCreate a new ReadPreference instance with hedge options.Note: this method is not supported for a primary read preference.
- Specified by:
withHedgeOptionsin classReadPreference- Parameters:
hedgeOptions- the hedge options- Returns:
- a new ReadPreference instance with hedge options
-
isSlaveOk
Deprecated.Description copied from class:ReadPreferenceTrue if this read preference allows reading from a secondary member of a replica set.- Specified by:
isSlaveOkin classReadPreference- Returns:
- if reading from a secondary is ok
-
isSecondaryOk
public boolean isSecondaryOk()Description copied from class:ReadPreferenceTrue if this read preference allows reading from a secondary member of a replica set.- Specified by:
isSecondaryOkin classReadPreference- Returns:
- if reading from a secondary is ok
-
toDocument
Description copied from class:ReadPreferenceGets a document representing this read preference in the wire protocol.- Specified by:
toDocumentin classReadPreference- Returns:
- the document
-
getTagSetList
Gets the list of tag sets as a list ofTagSetinstances.- Returns:
- the list of tag sets
- Since:
- 2.13
-
getMaxStaleness
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 hello 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
-
getHedgeOptions
Gets the hedge options.- Returns:
- the hedge options
- Since:
- 4.1
- Since server release
- 4.4
-
toString
-
equals
-
hashCode
public int hashCode() -
chooseForNonReplicaSet
Description copied from class:ReadPreferenceChoose for non-replica sets.- Specified by:
chooseForNonReplicaSetin classReadPreference- Parameters:
clusterDescription- the cluster description- Returns:
- the list of matching server descriptions
-