List of usage examples for com.mongodb MongoOptions setSocketKeepAlive
public synchronized void setSocketKeepAlive(final boolean keepAlive)
From source file:jp.co.ctc_g.rack.core.config.RackMongoContextConfig.java
License:Apache License
/** * MongoDI????/*from w ww . j a v a2 s .c o m*/ * @return Mongo */ @Bean public MongoOptions mongoOptions() { MongoOptions options = new MongoOptions(); options.setConnectionsPerHost(connectionsPerHost); options.setThreadsAllowedToBlockForConnectionMultiplier(threadAllowedToBlockForConnectionMultiplier); options.setConnectTimeout(connectTimeout); options.setMaxWaitTime(maxWaitTime); options.setAutoConnectRetry(autoConnectRetry); options.setSocketKeepAlive(socketKeepAlive); options.setSocketTimeout(socketTimeout); options.setFsync(fsync); return options; }
From source file:org.eclipse.birt.data.oda.mongodb.impl.MongoDBDriver.java
License:Open Source License
private static MongoOptions addSupplementalOptions(MongoOptions mongoOptions, Properties connProperties) { if (hasKeepSocketAlive(connProperties)) // need to change setting, as MongoDB default is false {/*from w w w.ja va 2s . com*/ if (mongoOptions == null) mongoOptions = createDefaultClientOptions(); mongoOptions.setSocketKeepAlive(true); } return mongoOptions; }
From source file:org.springframework.data.mongodb.core.MongoOptionsFactoryBean.java
License:Apache License
@Override protected MongoOptions createInstance() throws Exception { if (MongoClientVersion.isMongo3Driver()) { throw new IllegalArgumentException(String.format( "Usage of 'mongo-options' is no longer supported for MongoDB Java driver version 3 and above. Please use 'mongo-client-options' and refer to chapter 'MongoDB 3.0 Support' for details.")); }/*from www. j a va 2s . c om*/ MongoOptions options = new MongoOptions(); options.setConnectionsPerHost(connectionsPerHost); options.setThreadsAllowedToBlockForConnectionMultiplier(threadsAllowedToBlockForConnectionMultiplier); options.setMaxWaitTime(maxWaitTime); options.setConnectTimeout(connectTimeout); options.setSocketTimeout(socketTimeout); options.setSocketKeepAlive(socketKeepAlive); options.setW(writeNumber); options.setWtimeout(writeTimeout); options.setFsync(writeFsync); if (ssl) { options.setSocketFactory(sslSocketFactory != null ? sslSocketFactory : SSLSocketFactory.getDefault()); } ReflectiveMongoOptionsInvoker.setAutoConnectRetry(options, autoConnectRetry); ReflectiveMongoOptionsInvoker.setMaxAutoConnectRetryTime(options, maxAutoConnectRetryTime); ReflectiveMongoOptionsInvoker.setSlaveOk(options, slaveOk); return options; }