/** * 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(); }
minConnectionsPerHost = options.getMinConnectionsPerHost(); maxConnectionsPerHost = options.getConnectionsPerHost(); threadsAllowedToBlockForConnectionMultiplier = options.getThreadsAllowedToBlockForConnectionMultiplier(); serverSelectionTimeout = options.getServerSelectionTimeout(); maxWaitTime = options.getMaxWaitTime();
.minSize(getMinConnectionsPerHost()) .maxSize(getConnectionsPerHost()) .maxWaitQueueSize(getThreadsAllowedToBlockForConnectionMultiplier() * getConnectionsPerHost()) .maxWaitTime(getMaxWaitTime(), MILLISECONDS) .maxConnectionIdleTime(getMaxConnectionIdleTime(), MILLISECONDS)
/** * Getter for the amount of threads that block in relation to the amount of possible connections. * * @return Number representing the multiplier of maximum allowed blocked connections in relation to the maximum * allowed connections */ public int getThreadsAllowedToBlockForConnectionMultiplier() { return (threadsAllowedToBlockForConnectionMultiplier > 0) ? threadsAllowedToBlockForConnectionMultiplier : defaults.getThreadsAllowedToBlockForConnectionMultiplier(); }
/** * Getter for the amount of threads that block in relation to the amount of possible connections. * * @return Number representing the multiplier of maximum allowed blocked connections in relation to the maximum * allowed connections */ public int getThreadsAllowedToBlockForConnectionMultiplier() { return (threadsAllowedToBlockForConnectionMultiplier > 0) ? threadsAllowedToBlockForConnectionMultiplier : defaults.getThreadsAllowedToBlockForConnectionMultiplier(); }
Assert.assertEquals(3, options.getThreadsAllowedToBlockForConnectionMultiplier());
Assert.assertEquals(3, options.getThreadsAllowedToBlockForConnectionMultiplier());
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; } }
/** * 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(); }
minConnectionsPerHost = options.getMinConnectionsPerHost(); maxConnectionsPerHost = options.getConnectionsPerHost(); threadsAllowedToBlockForConnectionMultiplier = options.getThreadsAllowedToBlockForConnectionMultiplier(); serverSelectionTimeout = options.getServerSelectionTimeout(); maxWaitTime = options.getMaxWaitTime();
.minSize(getMinConnectionsPerHost()) .maxSize(getConnectionsPerHost()) .maxWaitQueueSize(getThreadsAllowedToBlockForConnectionMultiplier() * getConnectionsPerHost()) .maxWaitTime(getMaxWaitTime(), MILLISECONDS) .maxConnectionIdleTime(getMaxConnectionIdleTime(), MILLISECONDS)