List of usage examples for org.apache.commons.pool2.impl GenericObjectPoolConfig setMaxTotal
public void setMaxTotal(int maxTotal)
From source file:net.sheehantech.cherry.pool.PooledPushClient.java
@Override public void init() throws ConnectionFailedException { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); if (maxTotal != null) config.setMaxTotal(maxTotal); if (maxIdle != null) config.setMaxIdle(maxIdle);//from w w w . j a v a2s .c o m if (minIdle != null) config.setMinIdle(minIdle); config.setTestOnBorrow(true); config.setTestWhileIdle(true); config.setBlockWhenExhausted(true); pool = new GenericObjectPool<PooledPushSocket>(new PooledPushSocketFactory(socketFactory, gateway, port), config); try { pool.preparePool(); } catch (Exception e) { throw (new ConnectionFailedException(e)); } logger.debug("Started new push socket pool with {} sockets", pool.getNumIdle()); }
From source file:com.netflix.spinnaker.orca.config.RedisConfiguration.java
@Deprecated // rz - Kept for backwards compat with old connection configs @Bean/*from w w w. ja va 2s. co m*/ @ConfigurationProperties("redis") public GenericObjectPoolConfig redisPoolConfig() { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(100); config.setMaxIdle(100); config.setMinIdle(25); return config; }
From source file:gobblin.hive.HiveMetastoreClientPool.java
/** * Constructor for {@link HiveMetastoreClientPool}. * @deprecated It is recommended to use the static {@link #get} method instead. Use this constructor only if you * different pool configurations are required. *///from www. j a v a 2s. c o m @Deprecated public HiveMetastoreClientPool(Properties properties, Optional<String> metastoreURI) { this.hiveRegProps = new HiveRegProps(new State(properties)); GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(this.hiveRegProps.getNumThreads()); config.setMaxIdle(this.hiveRegProps.getNumThreads()); this.factory = new HiveMetaStoreClientFactory(metastoreURI); this.pool = new GenericObjectPool<>(this.factory, config); this.hiveConf = this.factory.getHiveConf(); }
From source file:com.zxy.commons.redis.RedisPoolFactory.java
private RedisPoolFactory() { GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); poolConfig.setMaxIdle(RedisPropUtils.getMaxIdle()); poolConfig.setMinIdle(RedisPropUtils.getMinIdle()); poolConfig.setMaxTotal(RedisPropUtils.getMaxTotal()); poolConfig.setMaxWaitMillis(RedisPropUtils.getMaxWaitMillis()); poolConfig.setTimeBetweenEvictionRunsMillis(RedisPropUtils.getTimeBetweenEvictionRunsMillis()); poolConfig.setMinEvictableIdleTimeMillis(RedisPropUtils.getMinEvictableIdleTimeMillis()); poolConfig.setTestWhileIdle(RedisPropUtils.getTestWhileIdle()); poolConfig.setTestOnBorrow(RedisPropUtils.getTestOnBorrow()); Set<String> hosts = RedisPropUtils.getServers(); if (hosts.size() > 1) { throw new IllegalArgumentException("ip port??!"); }//w w w . j a va2 s.com HostAndPort hostAndPort = RedisPropUtils.getServer(); int timeout = RedisPropUtils.getTimeout(); this.jedisPool = new JedisPool(poolConfig, hostAndPort.getHost(), hostAndPort.getPort(), timeout); }
From source file:com.zxy.commons.redis.RedisClusterFactory.java
private RedisClusterFactory() { GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); poolConfig.setMaxIdle(RedisPropUtils.getMaxIdle()); poolConfig.setMinIdle(RedisPropUtils.getMinIdle()); poolConfig.setMaxTotal(RedisPropUtils.getMaxTotal()); poolConfig.setMaxWaitMillis(RedisPropUtils.getMaxWaitMillis()); poolConfig.setTimeBetweenEvictionRunsMillis(RedisPropUtils.getTimeBetweenEvictionRunsMillis()); poolConfig.setMinEvictableIdleTimeMillis(RedisPropUtils.getMinEvictableIdleTimeMillis()); poolConfig.setTestWhileIdle(RedisPropUtils.getTestWhileIdle()); poolConfig.setTestOnBorrow(RedisPropUtils.getTestOnBorrow()); int timeout = RedisPropUtils.getTimeout(); Set<HostAndPort> haps = parseHostAndPort(); int maxRedirections = RedisPropUtils.getMaxRedirections(); if (maxRedirections <= 0) { maxRedirections = 5;// w w w. j av a2s .c om } jedisCluster = new JedisCluster(haps, timeout, maxRedirections, poolConfig); }
From source file:com.streamsets.pipeline.stage.origin.sdcipctokafka.IpcToKafkaServlet.java
@Override public void init() throws ServletException { super.init(); int max = configs.maxConcurrentRequests; int minIdle = Math.max(1, configs.maxConcurrentRequests / 4); int maxIdle = configs.maxConcurrentRequests / 2; GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); poolConfig.setMaxTotal(max); poolConfig.setMinIdle(minIdle);//from ww w. j ava 2 s. co m poolConfig.setMaxIdle(maxIdle); LOG.debug("Creating Kafka producer pool with max '{}' minIdle '{}' maxIdle '{}'", max, minIdle, maxIdle); kafkaProducerPool = new GenericObjectPool<>(new SdcKafkaProducerPooledObjectFactory(configs), poolConfig); }
From source file:com.streamsets.pipeline.stage.origin.ipctokafka.IpcToKafkaServlet.java
@Override public void init() throws ServletException { super.init(); int max = configs.maxConcurrentRequests; int minIdle = Math.max(1, configs.maxConcurrentRequests / 4); int maxIdle = configs.maxConcurrentRequests / 2; GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig(); poolConfig.setMaxTotal(max); poolConfig.setMinIdle(minIdle);//from w w w. j av a 2 s . c o m poolConfig.setMaxIdle(maxIdle); LOG.debug("Creating Kafka producer pool with max '{}' minIdle '{}' maxIdle '{}'", max, minIdle, maxIdle); kafkaProducerPool = new GenericObjectPool<>( new SdcKafkaProducerPooledObjectFactory(kafkaConfigBean.kafkaConfig, DataFormat.SDC_JSON), poolConfig); }
From source file:com.skynetcomputing.database.Database.java
/** * Creates a new database connection pool so that statements and queries can be executed. *//*from w w w .j a v a 2s . c om*/ @SuppressWarnings("unchecked") private Database() { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxIdle(5); config.setMaxTotal(10); // Configurable connectionstring. String connString = MiscUtils.getPropertyOrDefault("dbConnection", URL); String connUser = MiscUtils.getPropertyOrDefault("dbUser", USERNAME); String connPassword = MiscUtils.getPropertyOrDefault("dbPassword", PASSWORD); pool = new GenericObjectPool<>(new BasePooledObjectFactory() { @Override public Object create() throws Exception { return DriverManager.getConnection(connString, connUser, connPassword); } @Override public PooledObject wrap(Object o) { return new PooledSoftReference<>(new SoftReference<>(o)); } }, config); }
From source file:me.carbou.mathieu.tictactoe.di.ServiceBindings.java
@Provides @Singleton/*from ww w.jav a2s .c o m*/ JedisPool jedisPool() { URI connectionURI = URI.create(Env.REDISCLOUD_URL); GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMinIdle(0); config.setMaxIdle(5); config.setMaxTotal(30); String password = connectionURI.getUserInfo().split(":", 2)[1]; return new JedisPool(config, connectionURI.getHost(), connectionURI.getPort(), Protocol.DEFAULT_TIMEOUT, password); }
From source file:gobblin.kafka.schemareg.LiKafkaSchemaRegistry.java
/** * @param props properties should contain property "kafka.schema.registry.url", and optionally * "kafka.schema.registry.max.cache.size" (default = 1000) and * "kafka.schema.registry.cache.expire.after.write.min" (default = 10). *//*from w w w . j ava 2s . co m*/ public LiKafkaSchemaRegistry(Properties props) { Preconditions.checkArgument( props.containsKey(KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_URL), String.format("Property %s not provided.", KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_URL)); this.url = props.getProperty(KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_URL); int objPoolSize = Integer .parseInt(props.getProperty(ConfigurationKeys.KAFKA_SOURCE_WORK_UNITS_CREATION_THREADS, "" + ConfigurationKeys.KAFKA_SOURCE_WORK_UNITS_CREATION_DEFAULT_THREAD_COUNT)); LOG.info("Create HttpClient pool with size " + objPoolSize); GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(objPoolSize); config.setMaxIdle(objPoolSize); this.httpClientPool = new GenericObjectPool<>(new HttpClientFactory(), config); }