Example usage for com.mongodb MongoClientOptions getSocketFactory

List of usage examples for com.mongodb MongoClientOptions getSocketFactory

Introduction

In this page you can find the example usage for com.mongodb MongoClientOptions getSocketFactory.

Prototype

@Deprecated
public SocketFactory getSocketFactory() 

Source Link

Document

The socket factory for creating sockets to the mongo server.

Default is SocketFactory.getDefault()

Usage

From source file:com.bnrc.sdn.properties.MongoProperties.java

License:Apache License

private Builder builder(MongoClientOptions options) {
    Builder builder = MongoClientOptions.builder();
    if (options != null) {
        builder.alwaysUseMBeans(options.isAlwaysUseMBeans());
        builder.connectionsPerHost(options.getConnectionsPerHost());
        builder.connectTimeout(options.getConnectTimeout());
        builder.cursorFinalizerEnabled(options.isCursorFinalizerEnabled());
        builder.dbDecoderFactory(options.getDbDecoderFactory());
        builder.dbEncoderFactory(options.getDbEncoderFactory());
        builder.description(options.getDescription());
        builder.maxWaitTime(options.getMaxWaitTime());
        builder.readPreference(options.getReadPreference());
        builder.socketFactory(options.getSocketFactory());
        builder.socketKeepAlive(options.isSocketKeepAlive());
        builder.socketTimeout(options.getSocketTimeout());
        builder.threadsAllowedToBlockForConnectionMultiplier(
                options.getThreadsAllowedToBlockForConnectionMultiplier());
        builder.writeConcern(options.getWriteConcern());
    }//  w  w w  .jav a  2s . c  om
    return builder;
}

From source file:com.eightkdata.mongowp.client.wrapper.MongoClientWrapper.java

License:Open Source License

private void testAddress(HostAndPort address, MongoClientOptions options)
        throws UnreachableMongoServerException {
    SocketAddress sa = new InetSocketAddress(address.getHostText(), address.getPort());
    try (Socket s = options.getSocketFactory().createSocket()) {
        s.connect(sa, 3000);//from  www . j  a  va 2 s . co  m
    } catch (IOException ex) {
        throw new UnreachableMongoServerException(address, ex);
    }
}