Example usage for com.mongodb ReadPreference secondaryPreferred

List of usage examples for com.mongodb ReadPreference secondaryPreferred

Introduction

In this page you can find the example usage for com.mongodb ReadPreference secondaryPreferred.

Prototype

public static ReadPreference secondaryPreferred(final long maxStaleness, final TimeUnit timeUnit) 

Source Link

Document

Gets a read preference that forces reads to a secondary that is less stale than the given maximumm if one is available, otherwise to the primary.

Usage

From source file:com.github.maasdi.mongo.NamedReadPreference.java

License:Apache License

public ReadPreference getTaggableReadPreference(DBObject firstTagSet, DBObject... remainingTagSets) {

    switch (this) {
    case PRIMARY_PREFERRED:
        return ReadPreference.primaryPreferred(firstTagSet, remainingTagSets);
    case SECONDARY:
        return ReadPreference.secondary(firstTagSet, remainingTagSets);
    case SECONDARY_PREFERRED:
        return ReadPreference.secondaryPreferred(firstTagSet, remainingTagSets);
    case NEAREST:
        return ReadPreference.nearest(firstTagSet, remainingTagSets);
    default://from  w w w  . java 2s.c  o  m
        return (pref instanceof TaggableReadPreference) ? pref : null;
    }
}