{ super.setMaxIdle(6); super.setMaxTotal(40); super.setMinIdle(1); super.setTimeBetweenEvictionRunsMillis(1000L * 60L * 10L); super.setNumTestsPerEvictionRun(10); super.setMinEvictableIdleTimeMillis(1000L * 60L * 5L); }
public synchronized void init() { if (status != 0) { throw new RuntimeException("client has inited"); } else { status = 1; } // 配置基本属性 GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); poolConfig.setTestOnBorrow(true); poolConfig.setJmxEnabled(true); poolConfig.setMaxTotal(maxTotal); poolConfig.setMaxIdle(maxIdle); poolConfig.setMinIdle(minIdle); poolConfig.setTimeBetweenEvictionRunsMillis(1000 * 60 * 5); poolConfig.setNumTestsPerEvictionRun(10); AbandonedConfig abandonedConfig = new AbandonedConfig(); ConnectionPoolFactory factory = new ConnectionPoolFactory(servers, soTimeout, ioMode); pool = new GenericObjectPool<Connection>(factory, poolConfig, abandonedConfig); }