ReadPreference getCommandReadPreference ( final DBObject command , @ Nullable final ReadPreference requestedPreference ) { String comString = command . keySet ( ) . iterator ( ) . next ( ) . toLowerCase ( ) ; boolean primaryRequired = ! OBEDIENT_COMMANDS . contains ( comString ) ; if ( primaryRequired ) { return ReadPreference . primary ( ) ; } else if ( requestedPreference == null ) { return ReadPreference . primary ( ) ; } else { return requestedPreference ; } }
Determines the read preference that should be used for the given command .