/** * Creates a new {@code MongoOptions} with the given options. This class is deprecated, use {@link com.mongodb.MongoClientOptions}. * * @param options the MongoClientOptions to copy values from into the new MongoOptions. * @deprecated use {@link com.mongodb.MongoClientOptions} */ @SuppressWarnings("deprecation") @Deprecated public MongoOptions(final MongoClientOptions options) { connectionsPerHost = options.getConnectionsPerHost(); threadsAllowedToBlockForConnectionMultiplier = options.getThreadsAllowedToBlockForConnectionMultiplier(); maxWaitTime = options.getMaxWaitTime(); connectTimeout = options.getConnectTimeout(); socketFactory = options.getSocketFactory(); socketTimeout = options.getSocketTimeout(); socketKeepAlive = options.isSocketKeepAlive(); readPreference = options.getReadPreference(); dbDecoderFactory = options.getDbDecoderFactory(); dbEncoderFactory = options.getDbEncoderFactory(); description = options.getDescription(); writeConcern = options.getWriteConcern(); alwaysUseMBeans = options.isAlwaysUseMBeans(); requiredReplicaSetName = options.getRequiredReplicaSetName(); }
compressorList = options.getCompressorList(); minConnectionsPerHost = options.getMinConnectionsPerHost(); maxConnectionsPerHost = options.getConnectionsPerHost(); threadsAllowedToBlockForConnectionMultiplier = options.getThreadsAllowedToBlockForConnectionMultiplier(); serverSelectionTimeout = options.getServerSelectionTimeout();
.maxSize(getConnectionsPerHost()) .maxWaitQueueSize(getThreadsAllowedToBlockForConnectionMultiplier() * getConnectionsPerHost()) .maxWaitTime(getMaxWaitTime(), MILLISECONDS) .maxConnectionIdleTime(getMaxConnectionIdleTime(), MILLISECONDS)
mo = b.build(); if (mo.getConnectionsPerHost() <= 0 && !StringUtils.isEmpty(poolSize))
/** * Getter for connectionsPerHost. * * @return number representing the connections per host */ public int getConnectionsPerHost() { return (connectionsPerHost > 0) ? connectionsPerHost : defaults.getConnectionsPerHost(); }
/** * Getter for connectionsPerHost. * * @return number representing the connections per host */ public int getConnectionsPerHost() { return (connectionsPerHost > 0) ? connectionsPerHost : defaults.getConnectionsPerHost(); }
Assert.assertEquals(7, options.getConnectionsPerHost());
Assert.assertEquals(7, options.getConnectionsPerHost());
public static String toString(MongoClientOptions opts) { return Objects.toStringHelper(opts) .add("connectionsPerHost", opts.getConnectionsPerHost()) .add("connectTimeout", opts.getConnectTimeout()) .add("socketTimeout", opts.getSocketTimeout()) .add("socketKeepAlive", opts.isSocketKeepAlive()) .add("maxWaitTime", opts.getMaxWaitTime()) .add("heartbeatFrequency", opts.getHeartbeatFrequency()) .add("threadsAllowedToBlockForConnectionMultiplier", opts.getThreadsAllowedToBlockForConnectionMultiplier()) .add("readPreference", opts.getReadPreference().getName()) .add("writeConcern", opts.getWriteConcern()) .toString(); }
public static String toString(MongoClientOptions opts) { return Objects.toStringHelper(opts) .add("connectionsPerHost", opts.getConnectionsPerHost()) .add("connectTimeout", opts.getConnectTimeout()) .add("socketTimeout", opts.getSocketTimeout()) .add("socketKeepAlive", opts.isSocketKeepAlive()) .add("maxWaitTime", opts.getMaxWaitTime()) .add("heartbeatFrequency", opts.getHeartbeatFrequency()) .add("threadsAllowedToBlockForConnectionMultiplier", opts.getThreadsAllowedToBlockForConnectionMultiplier()) .add("readPreference", opts.getReadPreference().getName()) .add("writeConcern", opts.getWriteConcern()) .toString(); }
@Override public Map<String, ?> properties(RequestContext ctx) throws Exception { Map properties = new HashMap<>(); properties.put(DESCRIPTION, mongoClientOptions.getDescription()); properties.put(CONNECTIONS_PER_HOST, mongoClientOptions.getConnectionsPerHost()); properties.put(THREADS_ALLOWED_TO_BLOCK_FOR_CONNECTION_MULTIPLIER, mongoClientOptions.getThreadsAllowedToBlockForConnectionMultiplier()); properties.put(MAX_WAIT_TIME, mongoClientOptions.getMaxWaitTime()); properties.put(CONNECT_TIMEOUT, mongoClientOptions.getConnectTimeout()); properties.put(SOCKET_KEEP_ALIVE, mongoClientOptions.isSocketKeepAlive()); properties.put(AUTOCONNECT_RETRY, mongoClientOptions.isAutoConnectRetry()); properties.put(MAX_AUTOCONNECT_RETRY_TIME, mongoClientOptions.getMaxAutoConnectRetryTime()); properties.put(CURSOR_FINALIZER_ENABLED, mongoClientOptions.isCursorFinalizerEnabled()); properties.put(ALWAYS_USE_MBEANS, mongoClientOptions.isAlwaysUseMBeans()); return properties; } }
mo = b.build(); if (mo.getConnectionsPerHost() <= 0 && !StringUtils.isEmpty(poolSize))
/** * Uses the configured parameters to create a MongoOptions instance. * * @return MongoOptions instance based on the configured properties */ public MongoClientOptions createMongoOptions() { MongoClientOptions options = MongoClientOptions.builder() .connectionsPerHost(getConnectionsPerHost()) .connectTimeout(getConnectionTimeout()) .maxWaitTime(getMaxWaitTime()) .threadsAllowedToBlockForConnectionMultiplier(getThreadsAllowedToBlockForConnectionMultiplier()) .socketTimeout(getSocketTimeOut()).build(); if (logger.isDebugEnabled()) { logger.debug("Mongo Options"); logger.debug("Connections per host :{}", options.getConnectionsPerHost()); logger.debug("Connection timeout : {}", options.getConnectTimeout()); logger.debug("Max wait timeout : {}", options.getMaxWaitTime()); logger.debug("Threads allowed to block : {}", options.getThreadsAllowedToBlockForConnectionMultiplier()); logger.debug("Socket timeout : {}", options.getSocketTimeout()); } return options; }
/** * Uses the configured parameters to create a MongoOptions instance. * * @return MongoOptions instance based on the configured properties */ public MongoClientOptions createMongoOptions() { MongoClientOptions options = MongoClientOptions.builder() .connectionsPerHost(getConnectionsPerHost()) .connectTimeout(getConnectionTimeout()) .maxWaitTime(getMaxWaitTime()) .threadsAllowedToBlockForConnectionMultiplier(getThreadsAllowedToBlockForConnectionMultiplier()) .socketTimeout(getSocketTimeOut()).build(); if (logger.isDebugEnabled()) { logger.debug("Mongo Options"); logger.debug("Connections per host :{}", options.getConnectionsPerHost()); logger.debug("Connection timeout : {}", options.getConnectTimeout()); logger.debug("Max wait timeout : {}", options.getMaxWaitTime()); logger.debug("Threads allowed to block : {}", options.getThreadsAllowedToBlockForConnectionMultiplier()); logger.debug("Socket timeout : {}", options.getSocketTimeout()); } return options; }
/** * Creates a new {@code MongoOptions} with the given options. This class is deprecated, use {@link com.mongodb.MongoClientOptions}. * * @param options the MongoClientOptions to copy values from into the new MongoOptions. * @deprecated use {@link com.mongodb.MongoClientOptions} */ @SuppressWarnings("deprecation") @Deprecated public MongoOptions(final MongoClientOptions options) { connectionsPerHost = options.getConnectionsPerHost(); threadsAllowedToBlockForConnectionMultiplier = options.getThreadsAllowedToBlockForConnectionMultiplier(); maxWaitTime = options.getMaxWaitTime(); connectTimeout = options.getConnectTimeout(); socketFactory = options.getSocketFactory(); socketTimeout = options.getSocketTimeout(); socketKeepAlive = options.isSocketKeepAlive(); readPreference = options.getReadPreference(); dbDecoderFactory = options.getDbDecoderFactory(); dbEncoderFactory = options.getDbEncoderFactory(); description = options.getDescription(); writeConcern = options.getWriteConcern(); alwaysUseMBeans = options.isAlwaysUseMBeans(); requiredReplicaSetName = options.getRequiredReplicaSetName(); }
public static void assertConfigProperties(MongoDbFactory connector, String writeConcern, Integer connectionsPerHost, Integer maxWaitTime) { if (connectionsPerHost == null) { connectionsPerHost = 100; // default } if (maxWaitTime == null) { maxWaitTime = 120000; // default } assertNotNull(connector); assertEquals(ReflectionTestUtils.getField(connector, "writeConcern"), writeConcern == null ? null : WriteConcern.valueOf(writeConcern)); MongoClient mongoClient = (MongoClient) ReflectionTestUtils.getField(connector, "mongoClient"); assertEquals(connectionsPerHost.intValue(), mongoClient.getMongoClientOptions().getConnectionsPerHost()); assertEquals(maxWaitTime.intValue(), mongoClient.getMongoClientOptions().getMaxWaitTime()); }
compressorList = options.getCompressorList(); minConnectionsPerHost = options.getMinConnectionsPerHost(); maxConnectionsPerHost = options.getConnectionsPerHost(); threadsAllowedToBlockForConnectionMultiplier = options.getThreadsAllowedToBlockForConnectionMultiplier(); serverSelectionTimeout = options.getServerSelectionTimeout();
.maxSize(getConnectionsPerHost()) .maxWaitQueueSize(getThreadsAllowedToBlockForConnectionMultiplier() * getConnectionsPerHost()) .maxWaitTime(getMaxWaitTime(), MILLISECONDS) .maxConnectionIdleTime(getMaxConnectionIdleTime(), MILLISECONDS)