com.mongodb.connection.ConnectionPoolSettings Java Examples
The following examples show how to use
com.mongodb.connection.ConnectionPoolSettings.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MongoClients.java From quarkus with Apache License 2.0 | 6 votes |
@Override public void apply(ConnectionPoolSettings.Builder builder) { config.maxPoolSize.ifPresent(builder::maxSize); config.minPoolSize.ifPresent(builder::minSize); if (config.maxConnectionIdleTime.isPresent()) { builder.maxConnectionIdleTime(config.maxConnectionIdleTime.get().toMillis(), TimeUnit.MILLISECONDS); } if (config.maxConnectionLifeTime.isPresent()) { builder.maxConnectionLifeTime(config.maxConnectionLifeTime.get().toMillis(), TimeUnit.MILLISECONDS); } if (config.maintenanceFrequency.isPresent()) { builder.maintenanceFrequency(config.maintenanceFrequency.get().toMillis(), TimeUnit.MILLISECONDS); } if (config.maintenanceInitialDelay.isPresent()) { builder.maintenanceInitialDelay(config.maintenanceInitialDelay.get().toMillis(), TimeUnit.MILLISECONDS); } for (ConnectionPoolListener connectionPoolListener : connectionPoolListeners) { builder.addConnectionPoolListener(connectionPoolListener); } }
Example #2
Source File: ConnectionPoolSettingsParser.java From vertx-mongo-client with Apache License 2.0 | 5 votes |
public ConnectionPoolSettingsParser(ConnectionString connectionString, JsonObject config) { ConnectionPoolSettings.Builder settings = ConnectionPoolSettings.builder(); if (connectionString != null) { settings.applyConnectionString(connectionString); } else { Integer maxPoolSize = config.getInteger("maxPoolSize"); if (maxPoolSize != null) { settings.maxSize(maxPoolSize); } Integer minPoolSize = config.getInteger("minPoolSize"); if (minPoolSize != null) { settings.minSize(minPoolSize); } Long maxIdleTimeMS = config.getLong("maxIdleTimeMS"); if (maxIdleTimeMS != null) { settings.maxConnectionIdleTime(maxIdleTimeMS, MILLISECONDS); } Long maxLifeTimeMS = config.getLong("maxLifeTimeMS"); if (maxLifeTimeMS != null) { settings.maxConnectionLifeTime(maxLifeTimeMS, MILLISECONDS); } Long waitQueueTimeoutMS = config.getLong("waitQueueTimeoutMS"); if (waitQueueTimeoutMS != null) { settings.maxWaitTime(waitQueueTimeoutMS, MILLISECONDS); } Long maintenanceInitialDelayMS = config.getLong("maintenanceInitialDelayMS"); if (maintenanceInitialDelayMS != null) { settings.maintenanceInitialDelay(maintenanceInitialDelayMS, MILLISECONDS); } Long maintenanceFrequencyMS = config.getLong("maintenanceFrequencyMS"); if (maintenanceFrequencyMS != null) { settings.maintenanceFrequency(maintenanceFrequencyMS, MILLISECONDS); } } this.settings = settings.build(); }
Example #3
Source File: ConnectionPoolSettingsParserTest.java From vertx-mongo-client with Apache License 2.0 | 5 votes |
@Test public void testConnectionPoolSettings() { int maxPoolSize = 42; int minPoolSize = maxPoolSize / 2; // min needs to be less then max long maxIdleTimeMS = Math.abs(randomLong()); long maxLifeTimeMS = Math.abs(randomLong()); // Do not use long because of rounding. long waitQueueTimeoutMS = Math.abs(randomLong()); long maintenanceInitialDelayMS = Math.abs(randomLong()); long maintenanceFrequencyMS = Math.abs(randomLong()); JsonObject config = new JsonObject(); config.put("maxPoolSize", maxPoolSize); config.put("minPoolSize", minPoolSize); config.put("maxIdleTimeMS", maxIdleTimeMS); config.put("maxLifeTimeMS", maxLifeTimeMS); config.put("waitQueueTimeoutMS", waitQueueTimeoutMS); config.put("maintenanceInitialDelayMS", maintenanceInitialDelayMS); config.put("maintenanceFrequencyMS", maintenanceFrequencyMS); ConnectionPoolSettings settings = new ConnectionPoolSettingsParser(null, config).settings(); assertEquals(maxPoolSize, settings.getMaxSize()); assertEquals(minPoolSize, settings.getMinSize()); assertEquals(maxIdleTimeMS, settings.getMaxConnectionIdleTime(MILLISECONDS)); assertEquals(maxLifeTimeMS, settings.getMaxConnectionLifeTime(MILLISECONDS)); assertEquals(waitQueueTimeoutMS, settings.getMaxWaitTime(MILLISECONDS)); assertEquals(maintenanceInitialDelayMS, settings.getMaintenanceInitialDelay(MILLISECONDS)); assertEquals(maintenanceFrequencyMS, settings.getMaintenanceFrequency(MILLISECONDS)); }
Example #4
Source File: ConnectionPoolSettingsParser.java From vertx-mongo-client with Apache License 2.0 | 4 votes |
public ConnectionPoolSettings settings() { return settings; }