public static enum ReadPreference.Mode extends Enum<ReadPreference.Mode>
ReadPreference
modes of service.Enum Constant and Description |
---|
NEAREST
Use the nearest (by latency measurement) member of the replica set:
either primary or secondary servers are allowed.
|
PRIMARY_ONLY
Reads should only be attempted from the primary member of the replica
set.
|
PRIMARY_PREFERRED
Read from the primary but in the case of a fault may fallback to a
secondary.
|
SECONDARY_ONLY
Do not attempt to read from the primary.
|
SECONDARY_PREFERRED
Try to first read from a secondary.
|
SERVER
Do not attempt to read from any server other than the one specified.
|
Modifier and Type | Method and Description |
---|---|
String |
getToken()
Returns the token passed to the mongos server when in a shared
environment.
|
boolean |
isSecondaryOk()
Returns true if the mode allows reading from secondaries, false
otherwise.
|
static ReadPreference.Mode |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static ReadPreference.Mode[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final ReadPreference.Mode NEAREST
If tag matching documents are specified then only server matching the specified tag matching documents would be used.
public static final ReadPreference.Mode PRIMARY_ONLY
public static final ReadPreference.Mode PRIMARY_PREFERRED
If tag matching documents are specified and a fallback to a secondary is required then only secondaries matching the specified tag matching documents would be used.
public static final ReadPreference.Mode SECONDARY_ONLY
If tag matching documents are specified then only secondaries matching the specified tag matching documents would be used.
public static final ReadPreference.Mode SECONDARY_PREFERRED
If tag matching documents are specified then only secondaries matching the specified tag matching documents would be used.
public static final ReadPreference.Mode SERVER
MongoIterator
to ensure cursor fetch and
terminate requests use the originating server.public static ReadPreference.Mode[] values()
for (ReadPreference.Mode c : ReadPreference.Mode.values()) System.out.println(c);
public static ReadPreference.Mode valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic String getToken()
public boolean isSecondaryOk()
Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.