public abstract class ReadPreference
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
private static class |
ReadPreference.PrimaryReadPreference
Preference to read from primary only.
|
static class |
ReadPreference.TaggedReadPreference
Deprecated.
As of release 2.9, replaced by
secondaryPreferred(DBObject, DBObject...) |
| Modifier and Type | Field and Description |
|---|---|
private static ReadPreference |
_NEAREST |
private static ReadPreference |
_PRIMARY |
private static ReadPreference |
_PRIMARY_PREFERRED |
private static ReadPreference |
_SECONDARY |
private static ReadPreference |
_SECONDARY_PREFERRED |
static ReadPreference |
PRIMARY
Deprecated.
As of release 2.9.0, replaced by
ReadPreference.primary() |
static ReadPreference |
SECONDARY
Deprecated.
As of release 2.9.0, replaced by
ReadPreference.secondaryPreferred() |
| Constructor and Description |
|---|
ReadPreference() |
| Modifier and Type | Method and Description |
|---|---|
(package private) abstract java.util.List<ServerDescription> |
choose(ClusterDescription clusterDescription) |
abstract java.lang.String |
getName()
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(DBObject firstTagSet,
DBObject... remainingTagSets)
Deprecated.
use factory methods that take
TagSet instead |
static TaggableReadPreference |
nearest(java.util.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(DBObject firstTagSet,
DBObject... remainingTagSets)
Deprecated.
use factory methods that take
TagSet instead |
static TaggableReadPreference |
primaryPreferred(java.util.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(DBObject firstTagSet,
DBObject... remainingTagSets)
Deprecated.
use factory methods that take
TagSet instead |
static TaggableReadPreference |
secondary(java.util.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(DBObject firstTagSet,
DBObject... remainingTagSets)
Deprecated.
use factory methods that take
TagSet instead |
static TaggableReadPreference |
secondaryPreferred(java.util.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 DBObject |
toDBObject()
Deprecated.
for internal use only
|
private static TagSet |
toTags(DBObject tagsDocument) |
private static java.util.List<TagSet> |
toTagsList(DBObject firstTagSet,
DBObject... remainingTagSets) |
static ReadPreference |
valueOf(java.lang.String name)
Creates a read preference from the given read preference name.
|
static TaggableReadPreference |
valueOf(java.lang.String name,
DBObject firstTagSet,
DBObject... remainingTagSets)
Deprecated.
use method that takes a
List<TagSet> |
static TaggableReadPreference |
valueOf(java.lang.String name,
java.util.List<TagSet> tagSetList)
Creates a taggable read preference from the given read preference name and list of tag sets.
|
static ReadPreference |
withTags(DBObject tags)
Deprecated.
As of release 2.9.0, replaced by
ReadPreference.secondaryPreferred(DBObject firstTagSet, DBObject... remainingTagSets) |
static ReadPreference |
withTags(java.util.Map<java.lang.String,java.lang.String> tags)
Deprecated.
As of release 2.9.0, replaced by
ReadPreference.secondaryPreferred(DBObject firstTagSet, DBObject... remainingTagSets) |
@Deprecated public static final ReadPreference PRIMARY
ReadPreference.primary()ReadPreference.primary().primary()@Deprecated public static final ReadPreference SECONDARY
ReadPreference.secondaryPreferred()ReadPreference.secondaryPreferred. This reference should really have been called
ReadPreference.SECONDARY_PREFERRED, but the naming of it preceded the idea of distinguishing
between secondary and secondary-preferred, so for backwards compatibility, leaving the name as is with
the behavior as it was when it was created.secondary(),
secondaryPreferred()private static final ReadPreference _PRIMARY
private static final ReadPreference _SECONDARY
private static final ReadPreference _SECONDARY_PREFERRED
private static final ReadPreference _PRIMARY_PREFERRED
private static final ReadPreference _NEAREST
public abstract boolean isSlaveOk()
@Deprecated public abstract DBObject toDBObject()
DBObject.DBObject representation of this preferencepublic abstract java.lang.String getName()
abstract java.util.List<ServerDescription> choose(ClusterDescription clusterDescription)
public 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(java.util.List<TagSet> tagSetList)
tagSetList - the list of tag sets to limit the list of secondaries topublic static TaggableReadPreference secondary(java.util.List<TagSet> tagSetList)
tagSetList - the list of tag sets to limit the list of secondaries topublic static TaggableReadPreference secondaryPreferred(java.util.List<TagSet> tagSetList)
tagSetList - the list of tag sets to limit the list of secondaries topublic static TaggableReadPreference nearest(java.util.List<TagSet> tagSetList)
tagSetList - the list of tag sets to limit the list of secondaries to@Deprecated public static TaggableReadPreference primaryPreferred(DBObject firstTagSet, DBObject... remainingTagSets)
TagSet insteadprimaryPreferred(TagSet),
primaryPreferred(java.util.List)@Deprecated public static TaggableReadPreference secondary(DBObject firstTagSet, DBObject... remainingTagSets)
TagSet insteadsecondary(TagSet),
secondary(java.util.List)@Deprecated public static TaggableReadPreference secondaryPreferred(DBObject firstTagSet, DBObject... remainingTagSets)
TagSet insteadsecondaryPreferred(TagSet),
secondaryPreferred(java.util.List)@Deprecated public static TaggableReadPreference nearest(DBObject firstTagSet, DBObject... remainingTagSets)
TagSet insteadnearest(TagSet),
nearest(java.util.List)public static ReadPreference valueOf(java.lang.String name)
name - the name of the read preferencepublic static TaggableReadPreference valueOf(java.lang.String name, java.util.List<TagSet> tagSetList)
name - the name of the read preferencetagSetList - the list of tag sets@Deprecated public static TaggableReadPreference valueOf(java.lang.String name, DBObject firstTagSet, DBObject... remainingTagSets)
List<TagSet>name - the name of the read preferencefirstTagSet - the first set of tagsremainingTagSets - the remaining set of tags@Deprecated public static ReadPreference withTags(java.util.Map<java.lang.String,java.lang.String> tags)
ReadPreference.secondaryPreferred(DBObject firstTagSet, DBObject... remainingTagSets)@Deprecated public static ReadPreference withTags(DBObject tags)
ReadPreference.secondaryPreferred(DBObject firstTagSet, DBObject... remainingTagSets)private static java.util.List<TagSet> toTagsList(DBObject firstTagSet, DBObject... remainingTagSets)