Example usage for com.mongodb MongoClientOptions.Builder threadsAllowedToBlockForConnectionMultiplier

List of usage examples for com.mongodb MongoClientOptions.Builder threadsAllowedToBlockForConnectionMultiplier

Introduction

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

Prototype

int threadsAllowedToBlockForConnectionMultiplier

To view the source code for com.mongodb MongoClientOptions.Builder threadsAllowedToBlockForConnectionMultiplier.

Click Source Link

Usage

From source file:com.clavain.muninmxcd.java

License:Apache License

/**
 * @param args the command line arguments
 *///w w  w. j a v  a2  s. c o  m
public static void main(String[] args) {

    if (args.length < 1) {
        System.err.println("Usage: java -jar MuninMXcd.jar <full path to config>");
        System.exit(1);
    }

    try {

        initialArgs = args;
        p = new Properties();
        FileInputStream propInFile = null;
        propInFile = new FileInputStream(args[0]);
        p.loadFromXML(propInFile);
        String logfile = p.getProperty("log.file");
        socketTimeout = Integer.parseInt(p.getProperty("socket.timeout"));

        PatternLayout layout = new PatternLayout("%d{ISO8601} %-5p %m%n");

        ConsoleAppender consoleAppender = new ConsoleAppender(layout);
        logger.addAppender(consoleAppender);
        FileAppender fileAppender = new FileAppender(layout, logfile, false);
        logger.addAppender(fileAppender);

        logger.info("MuninMX Collector Daemon - " + version + " starting up...");
        logger.info("Loading configuration from <" + args[0] + ">");

        String l_strLogLevel = p.getProperty("log.level");
        // ALL | DEBUG | INFO | WARN | ERROR | FATAL | OFF:
        if (l_strLogLevel.equals("ALL")) {
            logger.setLevel(Level.ALL);
        } else if (l_strLogLevel.equals("DEBUG")) {
            logger.setLevel(Level.DEBUG);
        } else if (l_strLogLevel.equals("INFO")) {
            logger.setLevel(Level.INFO);
        } else if (l_strLogLevel.equals("WARN")) {
            logger.setLevel(Level.WARN);
        } else if (l_strLogLevel.equals("ERROR")) {
            logger.setLevel(Level.ERROR);
        } else if (l_strLogLevel.equals("FATAL")) {
            logger.setLevel(Level.FATAL);
        } else {
            logger.setLevel(Level.OFF);
        }

        if (p.getProperty("log.more") != null) {
            if (p.getProperty("log.more").equals("true")) {
                logMore = true;
            }
        }

    } catch (Exception ex) {
        System.err.println("Failed to Init basic logging infastructure: " + ex.getLocalizedMessage());
        System.exit(1);
    }

    try {
        // connect to db
        logger.info("Connecting to TokuMX");
        MongoClientOptions.Builder builder = new MongoClientOptions.Builder();
        builder.connectionsPerHost(400);
        builder.autoConnectRetry(true);
        builder.threadsAllowedToBlockForConnectionMultiplier(10);

        // speed up inserts, we dont care if we miss some if the shit hits the fan
        builder.writeConcern(WriteConcern.NONE);
        m = new MongoClient(new ServerAddress(p.getProperty("mongo.host")), builder.build());

        // connect to mysql
        connectToDatabase(p);

        // PreFilling Nodes, max 100 in concurrent
        logger.info("Loading initial MuninNode details. This can take a few minutes...");
        v_munin_nodes = new CopyOnWriteArrayList<>();
        v_cinterval_plugins = new CopyOnWriteArrayList<>();
        v_sockets = new CopyOnWriteArrayList<>();

        java.sql.Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT * FROM nodes");
        while (rs.next()) {
            MuninNode mn = new MuninNode();
            mn.setHostname(rs.getString("hostname"));
            mn.setNodename(rs.getString("hostname"));
            mn.setNode_id(rs.getInt("id"));
            mn.setPort(rs.getInt("port"));
            mn.setUser_id(rs.getInt("user_id"));
            mn.setQueryInterval(rs.getInt("query_interval"));
            mn.setStr_via(rs.getString("via_host"));
            mn.setAuthpw(rs.getString("authpw"));
            mn.setGroup(rs.getString("groupname"));
            v_munin_nodes.add(mn);
            logger.info("* " + mn.getHostname() + " queued for pluginfetch");
        }

        // launching quartz scheduler
        logger.info("Launching Scheduler");
        SchedulerFactory sf = new StdSchedulerFactory("quartz.properties");
        sched = sf.getScheduler();
        sched.start();

        // launching quartz scheduler for custom interval
        logger.info("Launching Custom Interval Scheduler");
        SchedulerFactory sfc = new StdSchedulerFactory("customquartz.properties");
        sched_custom = sfc.getScheduler();
        sched_custom.start();

        // starting API server
        new Thread(new JettyLauncher()).start();

        int sleepTime = Integer.parseInt(p.getProperty("startup.sleeptime"));
        int startupIterations = Integer.parseInt(p.getProperty("startup.iterations"));
        // scheduling jobs
        int i = 0;
        for (MuninNode it_mn : v_munin_nodes) {
            if (i == startupIterations) {
                Thread.sleep(sleepTime);
                i = 0;
                logger.info("Waiting " + sleepTime + "ms for new scheduling slot");
            }
            scheduleJob(it_mn);
            i++;
        }

        // schedule custom interval jobs
        dbScheduleAllCustomJobs();

        // add all alerts
        dbAddAllAlerts();

        // Service Checks
        logger.info("Launching Service Check Scheduler");
        SchedulerFactory sfsc = new StdSchedulerFactory("checksquartz.properties");
        sched_checks = sfsc.getScheduler();
        sched_checks.start();
        // load service checks from database
        stmt = conn.createStatement();
        rs = stmt.executeQuery("SELECT * FROM service_checks");
        while (rs.next()) {
            Gson gson = new Gson();
            ServiceCheck tc = gson.fromJson(rs.getString("json"), ServiceCheck.class);
            tc.setCid(rs.getInt("id"));
            tc.setUser_id(rs.getInt("user_id"));
            v_serviceChecks.add(tc);
            logger.info("* " + tc.getCheckname() + " Service Check added");
        }
        // queue service checks
        for (ServiceCheck it_sc : v_serviceChecks) {
            scheduleServiceCheck(it_sc);
        }

        // starting MongoExecutor
        new Thread(new MongoExecutor()).start();

        // starting MongoExecutor for Package Tracking and Essential Informations
        new Thread(new MongoEssentialExecutor()).start();

        // starting MongoExecutor for Service Checks
        new Thread(new MongoCheckExecutor()).start();

        // starting newnodewatcher
        new Thread(new NewNodeWatcher()).start();

        // start pushover sending message
        new Thread(new PushOverLimiter()).start();

        // SMS Limiter
        new Thread(new SMSLimiter()).start();

        // TTS Limiter
        new Thread(new TTSLimiter()).start();

        // start DataRetention Worker
        new Thread(new DataRetentionWorker()).start();

        // start Error Notify Inspector
        new Thread(new ErrorNotifyExecutor()).start();

        int curTime;
        int toTime;
        int mb = 1024 * 1024;
        while (true) {
            Thread.sleep(5000);
            System.out.println("Mongo Queue Size: " + mongo_queue.size());
            System.out.println("Mongo Check Queue Size: " + mongo_check_queue.size());
            System.out.println("Mongo Essential Queue Size: " + mongo_essential_queue.size());

            Runtime runtime = Runtime.getRuntime();
            //Print used memory
            System.out.println("Used Memory:" + (runtime.totalMemory() - runtime.freeMemory()) / mb);

            //Print free memory
            System.out.println("Free Memory:" + runtime.freeMemory() / mb);

            //Print total available memory
            System.out.println("Total Memory:" + runtime.totalMemory() / mb);

            //Print Maximum available memory
            System.out.println("Max Memory:" + runtime.maxMemory() / mb);
            System.out.println(" ");

            if (p.getProperty("kill.sockets").equals("true")) {
                System.out.println("Sockets: " + v_sockets.size());
                // check for sockets that we can kill
                curTime = getUnixtime();
                for (SocketCheck sc : v_sockets) {
                    toTime = curTime - 120;
                    if (sc.getSocketCreated() < toTime) {
                        if (!sc.getSocket().isClosed()) {
                            logger.info("timing out socket... from: " + sc.getHostname());
                            sc.closeSocket();
                            v_sockets.remove(sc);
                        } else {
                            v_sockets.remove(sc);
                        }
                    }
                }
            }

        }
    } catch (Exception ex) {
        System.err.println("Something went wrong as fuck: " + ex.getLocalizedMessage());
        logger.fatal("Something went wrong as fuck. exiting: " + ex.getLocalizedMessage());
        ex.printStackTrace();
        System.exit(1);
    }
}

From source file:com.github.nlloyd.hornofmongo.adaptor.Mongo.java

License:Open Source License

private void initMongoConnection() throws UnknownHostException {
    if ((innerMongo == null)) {
        MongoClientOptions.Builder builder = MongoClientOptions.builder();
        if (mongoOptions != null) {
            //Restore previous options
            builder.description(mongoOptions.description);
            builder.connectionsPerHost(mongoOptions.connectionsPerHost);
            builder.threadsAllowedToBlockForConnectionMultiplier(
                    mongoOptions.threadsAllowedToBlockForConnectionMultiplier);
            builder.maxWaitTime(mongoOptions.maxWaitTime);
            builder.connectTimeout(mongoOptions.connectTimeout);
            builder.socketTimeout(mongoOptions.socketTimeout);
            builder.socketKeepAlive(mongoOptions.socketKeepAlive);
        }//ww  w  .j  av a  2  s .  c om
        MongoClientOptions clientOptions = builder.dbEncoderFactory(HornOfMongoBSONEncoder.FACTORY).build();
        this.innerMongo = new com.mongodb.MongoClient(this.hosts, clientOptions);
        if (options != 0)
            this.innerMongo.setOptions(options);
    }
    if (mongoScope.useMongoShellWriteConcern())
        innerMongo.setWriteConcern(WriteConcern.UNACKNOWLEDGED);
}

From source file:com.novemberain.quartz.mongodb.MongoDBJobStore.java

License:Open Source License

private Mongo connectToMongoDB() throws SchedulerConfigException {

    if (mongoUri != null) {
        return connectToMongoDB(mongoUri);
    }//from  w ww  . j  av  a  2 s  .  c om

    MongoClientOptions.Builder optionsBuilder = MongoClientOptions.builder();
    optionsBuilder.writeConcern(WriteConcern.SAFE);

    if (mongoOptionAutoConnectRetry != null)
        optionsBuilder.autoConnectRetry(mongoOptionAutoConnectRetry);
    if (mongoOptionMaxConnectionsPerHost != null)
        optionsBuilder.connectionsPerHost(mongoOptionMaxConnectionsPerHost);
    if (mongoOptionConnectTimeoutMillis != null)
        optionsBuilder.connectTimeout(mongoOptionConnectTimeoutMillis);
    if (mongoOptionSocketTimeoutMillis != null)
        optionsBuilder.socketTimeout(mongoOptionSocketTimeoutMillis);
    if (mongoOptionSocketKeepAlive != null)
        optionsBuilder.socketKeepAlive(mongoOptionSocketKeepAlive);
    if (mongoOptionThreadsAllowedToBlockForConnectionMultiplier != null)
        optionsBuilder.threadsAllowedToBlockForConnectionMultiplier(
                mongoOptionThreadsAllowedToBlockForConnectionMultiplier);

    MongoClientOptions options = optionsBuilder.build();

    try {
        ArrayList<ServerAddress> serverAddresses = new ArrayList<ServerAddress>();
        for (String a : addresses) {
            serverAddresses.add(new ServerAddress(a));
        }
        return new MongoClient(serverAddresses, options);

    } catch (UnknownHostException e) {
        throw new SchedulerConfigException("Could not connect to MongoDB", e);
    } catch (MongoException e) {
        throw new SchedulerConfigException("Could not connect to MongoDB", e);
    }
}

From source file:in.mtap.iincube.mongoser.config.MongoConfig.java

License:Apache License

private com.mongodb.MongoClient getMongo() {
    if (mongo != null)
        return mongo;
    try {//from  w  w w . j av  a 2  s.  c  o m
        List<ServerAddress> serverAddresses = toAddress(servers);
        MongoClientOptions.Builder opts = new MongoClientOptions.Builder();

        if (threadNo < 100) {
            opts.connectionsPerHost(threadNo);
        } else {
            opts.connectionsPerHost(100);
        }
        opts.threadsAllowedToBlockForConnectionMultiplier(10);
        opts.maxWaitTime(10000);
        mongo = new com.mongodb.MongoClient(serverAddresses, opts.build());
        return mongo;
    } catch (UnknownHostException e) {
        throw new IllegalArgumentException("Unknown host : " + servers);
    }
}

From source file:io.gravitee.repository.mongodb.common.MongoFactory.java

License:Apache License

private MongoClientOptions.Builder builder() {
    MongoClientOptions.Builder builder = MongoClientOptions.builder();

    builder.writeConcern(WriteConcern.SAFE);

    Integer connectionsPerHost = readPropertyValue(propertyPrefix + "connectionsPerHost", Integer.class);
    Integer connectTimeout = readPropertyValue(propertyPrefix + "connectTimeout", Integer.class, 500);
    Integer maxWaitTime = readPropertyValue(propertyPrefix + "maxWaitTime", Integer.class);
    Integer socketTimeout = readPropertyValue(propertyPrefix + "socketTimeout", Integer.class, 500);
    Boolean socketKeepAlive = readPropertyValue(propertyPrefix + "socketKeepAlive", Boolean.class);
    Integer maxConnectionLifeTime = readPropertyValue(propertyPrefix + "maxConnectionLifeTime", Integer.class);
    Integer maxConnectionIdleTime = readPropertyValue(propertyPrefix + "maxConnectionIdleTime", Integer.class);

    // We do not want to wait for a server
    Integer serverSelectionTimeout = readPropertyValue(propertyPrefix + "serverSelectionTimeout", Integer.class,
            0);//from   www  . j  av a  2  s. c o m
    Integer minHeartbeatFrequency = readPropertyValue(propertyPrefix + "minHeartbeatFrequency", Integer.class);
    String description = readPropertyValue(propertyPrefix + "description", String.class, "gravitee.io");
    Integer heartbeatConnectTimeout = readPropertyValue(propertyPrefix + "heartbeatConnectTimeout",
            Integer.class, 1000);
    Integer heartbeatFrequency = readPropertyValue(propertyPrefix + "heartbeatFrequency", Integer.class);
    Integer heartbeatSocketTimeout = readPropertyValue(propertyPrefix + "heartbeatSocketTimeout",
            Integer.class);
    Integer localThreshold = readPropertyValue(propertyPrefix + "localThreshold", Integer.class);
    Integer minConnectionsPerHost = readPropertyValue(propertyPrefix + "minConnectionsPerHost", Integer.class);
    Boolean sslEnabled = readPropertyValue(propertyPrefix + "sslEnabled", Boolean.class);
    Integer threadsAllowedToBlockForConnectionMultiplier = readPropertyValue(
            propertyPrefix + "threadsAllowedToBlockForConnectionMultiplier", Integer.class);
    Boolean cursorFinalizerEnabled = readPropertyValue(propertyPrefix + "cursorFinalizerEnabled",
            Boolean.class);

    if (connectionsPerHost != null)
        builder.connectionsPerHost(connectionsPerHost);
    if (maxWaitTime != null)
        builder.maxWaitTime(maxWaitTime);
    if (connectTimeout != null)
        builder.connectTimeout(connectTimeout);
    if (socketTimeout != null)
        builder.socketTimeout(socketTimeout);
    if (socketKeepAlive != null)
        builder.socketKeepAlive(socketKeepAlive);
    if (maxConnectionLifeTime != null)
        builder.maxConnectionLifeTime(maxConnectionLifeTime);
    if (maxConnectionIdleTime != null)
        builder.maxConnectionIdleTime(maxConnectionIdleTime);
    if (minHeartbeatFrequency != null)
        builder.minHeartbeatFrequency(minHeartbeatFrequency);
    if (description != null)
        builder.description(description);
    if (heartbeatConnectTimeout != null)
        builder.heartbeatConnectTimeout(heartbeatConnectTimeout);
    if (heartbeatFrequency != null)
        builder.heartbeatFrequency(heartbeatFrequency);
    if (heartbeatSocketTimeout != null)
        builder.heartbeatSocketTimeout(heartbeatSocketTimeout);
    if (localThreshold != null)
        builder.localThreshold(localThreshold);
    if (minConnectionsPerHost != null)
        builder.minConnectionsPerHost(minConnectionsPerHost);
    if (sslEnabled != null)
        builder.sslEnabled(sslEnabled);
    if (threadsAllowedToBlockForConnectionMultiplier != null)
        builder.threadsAllowedToBlockForConnectionMultiplier(threadsAllowedToBlockForConnectionMultiplier);
    if (cursorFinalizerEnabled != null)
        builder.cursorFinalizerEnabled(cursorFinalizerEnabled);
    if (serverSelectionTimeout != null)
        builder.serverSelectionTimeout(serverSelectionTimeout);

    return builder;
}

From source file:org.craftercms.commons.mongo.MongoClientOptionsFactory.java

License:Open Source License

@Override
protected MongoClientOptions createInstance() throws Exception {
    MongoClientOptions.Builder builder = MongoClientOptions.builder();
    builder.alwaysUseMBeans(this.alwaysUseMBeans);
    builder.connectionsPerHost(this.connectionsPerHost);
    builder.cursorFinalizerEnabled(this.cursorFinalizerEnabled);
    builder.connectTimeout(this.connectTimeout);
    builder.maxWaitTime(this.maxWaitTime);

    switch (this.readPreference) {
    case PRIMARY_READ_PREFERENCE:
        builder.readPreference(ReadPreference.primary());
        break;//from   ww w  .j  a va 2s .co m
    case NEAREST_READ_PREFERENCE:
        builder.readPreference(ReadPreference.nearest());
        break;
    case SECONDARY_READ_PREFERENCE:
        builder.readPreference(ReadPreference.secondary());
        break;
    default:
        builder.readPreference(ReadPreference.primary());
        break;
    }
    builder.writeConcern(WriteConcern.valueOf(this.writeConcern));
    builder.threadsAllowedToBlockForConnectionMultiplier(this.threadsAllowedToBlockForConnectionMultiplier);
    return builder.build();

}

From source file:org.craftercms.studio.impl.repository.mongodb.data.ClientOptionsFactory.java

License:Open Source License

public void init() {
    MongoClientOptions.Builder builder = MongoClientOptions.builder();
    builder.alwaysUseMBeans(this.alwaysUseMBeans);
    builder.autoConnectRetry(this.autoConnectRetry);
    builder.connectionsPerHost(this.connectionsPerHost);
    builder.cursorFinalizerEnabled(this.cursorFinalizerEnabled);
    builder.connectTimeout(this.connectTimeout);
    builder.maxAutoConnectRetryTime(this.maxAutoConnectRetryTime);
    builder.maxWaitTime(this.maxWaitTime);

    switch (this.readPreference) {
    case PRIMARY_READ_PREFERENCE:
        builder.readPreference(ReadPreference.primary());
        break;//  w  ww  .j  a va  2 s  .  c o  m
    case NEAREST_READ_PREFERENCE:
        builder.readPreference(ReadPreference.nearest());
        break;
    case SECONDARY_READ_PREFERENCE:
        builder.readPreference(ReadPreference.secondary());
        break;
    default:
        builder.readPreference(ReadPreference.primary());
        break;
    }
    builder.socketKeepAlive(this.socketKeepAlive);
    builder.writeConcern(WriteConcern.valueOf(this.writeConcern));
    builder.threadsAllowedToBlockForConnectionMultiplier(this.threadsAllowedToBlockForConnectionMultiplier);
    this.clientOptions = builder.build();
}

From source file:org.datanucleus.store.mongodb.ConnectionFactoryImpl.java

License:Open Source License

private MongoClientOptions getMongodbOptions(StoreManager storeManager) {
    Object connectionsPerHost = storeManager.getProperty("datanucleus.mongodb.connectionsPerHost");
    Object threadsAllowedToBlockForConnectionMultiplier = storeManager
            .getProperty("datanucleus.mongodb.threadsAllowedToBlockForConnectionMultiplier");
    MongoClientOptions.Builder mongoOptionsBuilder = MongoClientOptions.builder();
    if (connectionsPerHost != null) {
        mongoOptionsBuilder.connectionsPerHost(Integer.parseInt((String) connectionsPerHost));
    }/*  www  . j  a v a2s  .  co  m*/
    if (threadsAllowedToBlockForConnectionMultiplier != null) {
        mongoOptionsBuilder.threadsAllowedToBlockForConnectionMultiplier(
                Integer.parseInt((String) threadsAllowedToBlockForConnectionMultiplier));
    }
    return mongoOptionsBuilder.build();
}

From source file:org.eclipselabs.emongo.components.MongoClientProviderComponent.java

License:Open Source License

private MongoClientOptions createMongoClientOptions(Map<String, Object> properties) {
    MongoClientOptions.Builder optionsBuilder = new MongoClientOptions.Builder();

    String description = (String) properties.get(PROP_DESCRIPTION);

    if (description != null)
        optionsBuilder.description(description);

    Integer connectionsPerHost = (Integer) properties.get(PROP_CONNECTIONS_PER_HOST);

    if (connectionsPerHost != null)
        optionsBuilder.connectionsPerHost(connectionsPerHost);

    Integer threadsAllowedToBlockForConnectionMultiplier = (Integer) properties
            .get(PROP_THREADS_ALLOWED_TO_BLOCK_FOR_CONNECTION_MULTIPLIER);

    if (threadsAllowedToBlockForConnectionMultiplier != null)
        optionsBuilder
                .threadsAllowedToBlockForConnectionMultiplier(threadsAllowedToBlockForConnectionMultiplier);

    Integer maxWaitTime = (Integer) properties.get(PROP_MAX_WAIT_TIME);

    if (maxWaitTime != null)
        optionsBuilder.maxWaitTime(maxWaitTime);

    Integer connectTimeout = (Integer) properties.get(PROP_CONNECT_TIMEOUT);

    if (connectTimeout != null)
        optionsBuilder.connectTimeout(connectTimeout);

    Integer socketTimeout = (Integer) properties.get(PROP_SOCKET_TIMEOUT);

    if (socketTimeout != null)
        optionsBuilder.socketTimeout(socketTimeout);

    Boolean socketKeepAlive = (Boolean) properties.get(PROP_SOCKET_KEEP_ALIVE);

    if (socketKeepAlive != null)
        optionsBuilder.socketKeepAlive(socketKeepAlive);

    Boolean autoConnectRetry = (Boolean) properties.get(PROP_AUTO_CONNECT_RETRY);

    if (autoConnectRetry != null)
        optionsBuilder.autoConnectRetry(autoConnectRetry);

    Long maxAutoConnectRetryTime = (Long) properties.get(PROP_MAX_AUTO_CONNECT_RETRY_TIME);

    if (maxAutoConnectRetryTime != null)
        optionsBuilder.maxAutoConnectRetryTime(maxAutoConnectRetryTime);

    Boolean continueOnInsertError = (Boolean) properties.get(PROP_CONTINUE_ON_INSERT_ERROR);

    if (continueOnInsertError == null)
        continueOnInsertError = Boolean.FALSE;

    Integer w = (Integer) properties.get(PROP_W);

    if (w == null)
        w = Integer.valueOf(1);//from  w  w  w  .  j a v  a  2  s . c  om

    Integer wtimeout = (Integer) properties.get(PROP_WTIMEOUT);

    if (wtimeout == null)
        wtimeout = Integer.valueOf(0);

    Boolean fsync = (Boolean) properties.get(PROP_FSYNC);

    if (fsync == null)
        fsync = Boolean.FALSE;

    Boolean j = (Boolean) properties.get(PROP_J);

    if (j == null)
        j = Boolean.FALSE;

    WriteConcern writeConcern = new WriteConcern(w, wtimeout, fsync, j, continueOnInsertError);
    optionsBuilder.writeConcern(writeConcern);

    return optionsBuilder.build();
}

From source file:org.jooby.mongodb.Mongodb.java

License:Apache License

private MongoClientOptions.Builder options(final Config config) {
    MongoClientOptions.Builder builder = MongoClientOptions.builder();

    builder.connectionsPerHost(config.getInt("connectionsPerHost"));
    builder.threadsAllowedToBlockForConnectionMultiplier(
            config.getInt("threadsAllowedToBlockForConnectionMultiplier"));
    builder.maxWaitTime((int) config.getDuration("maxWaitTime", TimeUnit.MILLISECONDS));
    builder.connectTimeout((int) config.getDuration("connectTimeout", TimeUnit.MILLISECONDS));
    builder.socketTimeout((int) config.getDuration("socketTimeout", TimeUnit.MILLISECONDS));
    builder.socketKeepAlive(config.getBoolean("socketKeepAlive"));
    builder.cursorFinalizerEnabled(config.getBoolean("cursorFinalizerEnabled"));
    builder.alwaysUseMBeans(config.getBoolean("alwaysUseMBeans"));
    builder.heartbeatFrequency(config.getInt("heartbeatFrequency"));
    builder.minHeartbeatFrequency(config.getInt("minHeartbeatFrequency"));
    builder.heartbeatConnectTimeout((int) config.getDuration("heartbeatConnectTimeout", TimeUnit.MILLISECONDS));
    builder.heartbeatSocketTimeout((int) config.getDuration("heartbeatSocketTimeout", TimeUnit.MILLISECONDS));

    return builder;
}