@Test public void wrongReadPreferenceTest() { Map<String, String> properties = new HashMap<String, String>(); properties.put(READ_PREFERENCE.getOptionName(), "falseReadPreference"); ConnectorClusterConfig wrongConfig = new ConnectorClusterConfig(CLUSTER_NAME, null, properties); MongoClientConfiguration config = new MongoClientConfiguration(wrongConfig); try { config.getMongoClientOptions(); fail("A exception must be thrown when no match any option"); } catch (MongoValidationException e) { } }
public MongoClientOptions getMongoClientOptions() throws MongoValidationException { int localThreashold = getIntegerSetting(LOCAL_THREADSHOLD); int maxConnectionsPerHost = getIntegerSetting(MAX_CONNECTIONS_PER_HOST); int connectTimeout = getIntegerSetting(CONNECTION_TIMEOUT); int maxConnectionIdleTime = getIntegerSetting(MAX_IDLE_TIME); ReadPreference readPreference = getReadPreference(); WriteConcern writeConcern = getWriteConcern(); MongoClientOptions clientOptions = new MongoClientOptions.Builder() .localThreshold(localThreashold) .connectionsPerHost(maxConnectionsPerHost).connectTimeout(connectTimeout) .maxConnectionIdleTime(maxConnectionIdleTime).readPreference(readPreference) .writeConcern(writeConcern).build(); return clientOptions; }
MongoClientConfiguration { public MongoClientOptions getMongoClientOptions() throws MongoValidationException { int localThreashold = getIntegerSetting(LOCAL_THREADSHOLD); int maxConnectionsPerHost = getIntegerSetting(MAX_CONNECTIONS_PER_HOST); int connectTimeout = getIntegerSetting(CONNECTION_TIMEOUT); int maxConnectionIdleTime = getIntegerSetting(MAX_IDLE_TIME); ReadPreference readPreference = getReadPreference(); WriteConcern writeConcern = getWriteConcern(); MongoClientOptions clientOptions = new MongoClientOptions.Builder() .localThreshold(localThreashold) .connectionsPerHost(maxConnectionsPerHost).connectTimeout(connectTimeout) .maxConnectionIdleTime(maxConnectionIdleTime).readPreference(readPreference) .writeConcern(writeConcern).build(); return clientOptions; } }
MongoClientConfiguration { public MongoClientOptions getMongoClientOptions() throws MongoValidationException { int localThreashold = getIntegerSetting(LOCAL_THREADSHOLD); int maxConnectionsPerHost = getIntegerSetting(MAX_CONNECTIONS_PER_HOST); int connectTimeout = getIntegerSetting(CONNECTION_TIMEOUT); int maxConnectionIdleTime = getIntegerSetting(MAX_IDLE_TIME); ReadPreference readPreference = getReadPreference(); WriteConcern writeConcern = getWriteConcern(); MongoClientOptions clientOptions = new MongoClientOptions.Builder() .localThreshold(localThreashold) .connectionsPerHost(maxConnectionsPerHost).connectTimeout(connectTimeout) .maxConnectionIdleTime(maxConnectionIdleTime).readPreference(readPreference) .writeConcern(writeConcern).build(); return clientOptions; } MongoClientConfiguration(ConnectorClusterConfig connectorClusterConfig); }
MongoClientConfiguration { public MongoClientOptions getMongoClientOptions() throws MongoValidationException { int localThreashold = getIntegerSetting(LOCAL_THREADSHOLD); int maxConnectionsPerHost = getIntegerSetting(MAX_CONNECTIONS_PER_HOST); int connectTimeout = getIntegerSetting(CONNECTION_TIMEOUT); int maxConnectionIdleTime = getIntegerSetting(MAX_IDLE_TIME); ReadPreference readPreference = getReadPreference(); WriteConcern writeConcern = getWriteConcern(); MongoClientOptions clientOptions = new MongoClientOptions.Builder() .localThreshold(localThreashold) .connectionsPerHost(maxConnectionsPerHost).connectTimeout(connectTimeout) .maxConnectionIdleTime(maxConnectionIdleTime).readPreference(readPreference) .writeConcern(writeConcern).build(); return clientOptions; } MongoClientConfiguration(ConnectorClusterConfig connectorClusterConfig); MongoClientOptions getMongoClientOptions(); List<ServerAddress> getSeeds(); }
MongoClientConfiguration { public MongoClientOptions getMongoClientOptions() throws MongoValidationException { int localThreashold = getIntegerSetting(LOCAL_THREADSHOLD); int maxConnectionsPerHost = getIntegerSetting(MAX_CONNECTIONS_PER_HOST); int connectTimeout = getIntegerSetting(CONNECTION_TIMEOUT); int maxConnectionIdleTime = getIntegerSetting(MAX_IDLE_TIME); ReadPreference readPreference = getReadPreference(); WriteConcern writeConcern = getWriteConcern(); MongoClientOptions clientOptions = new MongoClientOptions.Builder() .localThreshold(localThreashold) .connectionsPerHost(maxConnectionsPerHost).connectTimeout(connectTimeout) .maxConnectionIdleTime(maxConnectionIdleTime).readPreference(readPreference) .writeConcern(writeConcern).build(); return clientOptions; } MongoClientConfiguration(ConnectorClusterConfig connectorClusterConfig); MongoClientOptions getMongoClientOptions(); List<ServerAddress> getSeeds();  }