@Immutable public abstract class ReadPreference extends Object
Modifier and Type | Method and Description |
---|---|
abstract List<ServerDescription> |
choose(ClusterDescription clusterDescription)
Chooses the servers from the given cluster than match this read preference.
|
abstract String |
getName()
Gets the name of this read preference.
|
abstract boolean |
isSlaveOk()
True if this read preference allows reading from a secondary member of a replica set.
|
static ReadPreference |
nearest()
Gets a read preference that forces reads to a primary or a secondary.
|
static TaggableReadPreference |
nearest(List<TagSet> tagSetList)
Gets a read preference that forces reads to the primary or a secondary with one of the given sets of tags.
|
static TaggableReadPreference |
nearest(TagSet tagSet)
Gets a read preference that forces reads to the primary or a secondary with the given set of tags.
|
static ReadPreference |
primary()
Gets a read preference that forces read to the primary.
|
static ReadPreference |
primaryPreferred()
Gets a read preference that forces reads to the primary if available, otherwise to a secondary.
|
static TaggableReadPreference |
primaryPreferred(List<TagSet> tagSetList)
Gets a read preference that forces reads to the primary if available, otherwise to a secondary with one of the given sets of tags.
|
static TaggableReadPreference |
primaryPreferred(TagSet tagSet)
Gets a read preference that forces reads to the primary if available, otherwise to a secondary with the given set of tags.
|
static ReadPreference |
secondary()
Gets a read preference that forces reads to a secondary.
|
static TaggableReadPreference |
secondary(List<TagSet> tagSetList)
Gets a read preference that forces reads to a secondary with one of the given sets of tags.
|
static TaggableReadPreference |
secondary(TagSet tagSet)
Gets a read preference that forces reads to a secondary with the given set of tags.
|
static ReadPreference |
secondaryPreferred()
Gets a read preference that forces reads to a secondary if one is available, otherwise to the primary.
|
static TaggableReadPreference |
secondaryPreferred(List<TagSet> tagSetList)
Gets a read preference that forces reads to a secondary with one of the given sets of tags.
|
static TaggableReadPreference |
secondaryPreferred(TagSet tagSet)
Gets a read preference that forces reads to a secondary with the given set of tags, or the primary is none are available.
|
abstract BsonDocument |
toDocument()
Gets a document representing this read preference in the wire protocol.
|
static ReadPreference |
valueOf(String name)
Creates a read preference from the given read preference name.
|
static TaggableReadPreference |
valueOf(String name,
List<TagSet> tagSetList)
Creates a taggable read preference from the given read preference name and list of tag sets.
|
public abstract boolean isSlaveOk()
public abstract String getName()
public abstract BsonDocument toDocument()
public abstract List<ServerDescription> choose(ClusterDescription clusterDescription)
clusterDescription
- the cluster descriptionpublic static ReadPreference primary()
public static ReadPreference primaryPreferred()
public static ReadPreference secondary()
public static ReadPreference secondaryPreferred()
public static ReadPreference nearest()
public static TaggableReadPreference primaryPreferred(TagSet tagSet)
tagSet
- the set of tags to limit the list of secondaries to.public static TaggableReadPreference secondary(TagSet tagSet)
tagSet
- the set of tags to limit the list of secondaries topublic static TaggableReadPreference secondaryPreferred(TagSet tagSet)
tagSet
- the set of tags to limit the list of secondaries topublic static TaggableReadPreference nearest(TagSet tagSet)
tagSet
- the set of tags to limit the list of secondaries topublic static TaggableReadPreference primaryPreferred(List<TagSet> tagSetList)
tagSetList
- the list of tag sets to limit the list of secondaries topublic static TaggableReadPreference secondary(List<TagSet> tagSetList)
tagSetList
- the list of tag sets to limit the list of secondaries topublic static TaggableReadPreference secondaryPreferred(List<TagSet> tagSetList)
tagSetList
- the list of tag sets to limit the list of secondaries topublic static TaggableReadPreference nearest(List<TagSet> tagSetList)
tagSetList
- the list of tag sets to limit the list of secondaries topublic static ReadPreference valueOf(String name)
name
- the name of the read preferencepublic static TaggableReadPreference valueOf(String name, List<TagSet> tagSetList)
name
- the name of the read preferencetagSetList
- the list of tag sets