本文整理汇总了Java中org.apache.commons.pool.impl.GenericObjectPool.Config类的典型用法代码示例。如果您正苦于以下问题:Java Config类的具体用法?Java Config怎么用?Java Config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Config类属于org.apache.commons.pool.impl.GenericObjectPool包,在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: useBundleClasses
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
@Override
protected void useBundleClasses() throws Exception
{
new LdapNetworkConnection().close();
new SaslGssApiRequest();
new Krb5LoginConfiguration();
new AddFuture( new LdapNetworkConnection(), 2 );
new LdapConnectionTemplate( new LdapConnectionPool( new DefaultPoolableLdapConnectionFactory(
new LdapConnectionConfig() ) ) );
FilterBuilder.and( FilterBuilder.not( FilterBuilder.contains( "cn", "a", "b" ) ) ).toString();
// Test for DIRAPI-239
PoolableObjectFactory<LdapConnection> factory = new DefaultPoolableLdapConnectionFactory(
new LdapConnectionConfig() );
Config config = new Config();
LdapConnectionPool ldapConnectionPool = new LdapConnectionPool( factory, config );
ldapConnectionPool.getLdapApiService();
ldapConnectionPool.getTestOnBorrow();
}
示例2: parseShardingConfig
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
/**
*
* 功能描述:解析配置文件
*
* @param shardConfig 参数说明 返回值: 类型 <说明>
*/
@SuppressWarnings("unchecked")
private void parseShardingConfig(ShardConfig shardConfig) {
lstInfo4Jedis = new ArrayList<ShardInfo4Jedis>();
Config config = new Config();
setPoolParameters(poolConfig, config);
shardConfig.setConfig(config);
for (ShardInfo4Jedis shardInfo : shardConfig.getShards()) {
lstInfo4Jedis.add(shardInfo);
for (NodeInfo4Jedis node : shardInfo.getNodes()) {
node.setConfig(shardConfig.getConfig());
}
}
isSharding = lstInfo4Jedis.size() > 1 ? true : false;
}
示例3: JdbcCompiledQuery
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
public JdbcCompiledQuery(JdbcDataContext dc, Query query) {
super(query);
_query = query;
_sql = dc.getQueryRewriter().rewriteQuery(query);
final Config config = new Config();
config.maxActive = getSystemPropertyValue(JdbcDataContext.SYSTEM_PROPERTY_COMPILED_QUERY_POOL_MAX_SIZE, -1);
config.minEvictableIdleTimeMillis = getSystemPropertyValue(
JdbcDataContext.SYSTEM_PROPERTY_COMPILED_QUERY_POOL_MIN_EVICTABLE_IDLE_TIME_MILLIS, 500);
config.timeBetweenEvictionRunsMillis = getSystemPropertyValue(
JdbcDataContext.SYSTEM_PROPERTY_COMPILED_QUERY_POOL_TIME_BETWEEN_EVICTION_RUNS_MILLIS, 1000);
_pool = new GenericObjectPool<JdbcCompiledQueryLease>(new JdbcCompiledQueryLeaseFactory(dc, _sql), config);
_closed = false;
logger.debug("Created compiled JDBC query: {}", _sql);
}
示例4: setPoolParameters
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
/**
* 处理连接池信息
*
* @param poolConfig 参数说明
* @param config 参数说明
*/
private void setPoolParameters(PoolConfig poolConfig, Config config) {
if (!StringUtils.isBlank(poolConfig.getTestOnBorrow())) {
// 获取连接池是否检测可用性
config.testOnBorrow = Boolean.valueOf(poolConfig.getTestOnBorrow());
}
if (!StringUtils.isBlank(poolConfig.getTestOnReturn())) {
// 归还时是否检测可用性
config.testOnReturn = Boolean.valueOf(poolConfig.getTestOnReturn());
}
if (!StringUtils.isBlank(poolConfig.getTestWhileIdle())) {
// 空闲时是否检测可用性
config.testWhileIdle = Boolean.valueOf(poolConfig.getTestWhileIdle());
} else {
config.testWhileIdle = true;
}
if (!StringUtils.isBlank(poolConfig.getWhenExhaustedAction())) {
config.whenExhaustedAction = Byte.valueOf(poolConfig.getWhenExhaustedAction());
}
if (!StringUtils.isBlank(poolConfig.getTimeBetweenEvictionRunsMillis())) {
config.timeBetweenEvictionRunsMillis = Long.valueOf(poolConfig.getTimeBetweenEvictionRunsMillis());
} else {
config.timeBetweenEvictionRunsMillis = 30000L;
}
if (!StringUtils.isBlank(poolConfig.getNumTestsPerEvictionRun())) {
config.numTestsPerEvictionRun = Integer.valueOf(poolConfig.getNumTestsPerEvictionRun());
} else {
config.numTestsPerEvictionRun = -1;
}
if (!StringUtils.isBlank(poolConfig.getMinEvictableIdleTimeMillis())) {
config.minEvictableIdleTimeMillis = Integer.valueOf(poolConfig.getMinEvictableIdleTimeMillis());
} else {
config.minEvictableIdleTimeMillis = 60000L;
}
if (!StringUtils.isBlank(poolConfig.getSoftMinEvictableIdleTimeMillis())) {
config.softMinEvictableIdleTimeMillis = Integer.valueOf(poolConfig.getSoftMinEvictableIdleTimeMillis());
}
}
示例5: NormalizerPool
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
private NormalizerPool(Set<CHECKType> exclusions, boolean errorAsWarning)
{
Config poolcfg = new Config();
poolcfg.maxIdle = 3;
poolcfg.maxActive = 20;
poolcfg.timeBetweenEvictionRunsMillis = 1000 * 3600;
poolcfg.testWhileIdle = true;
// since we do not set maxActive for the moment this does not matter
poolcfg.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK;
poolcfg.maxWait = 40000;
NormalizerFactory fact = new NormalizerFactory(exclusions, errorAsWarning);
pool = new GenericObjectPool(fact, poolcfg);
}
示例6: JedisPool
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
public JedisPool(final String host) {
URI uri = URI.create(host);
if (uri.getScheme() != null && uri.getScheme().equals("redis")) {
String h = uri.getHost();
int port = uri.getPort();
String password = uri.getUserInfo().split(":", 2)[1];
int database = Integer.parseInt(uri.getPath().split("/", 2)[1]);
this.internalPool = new GenericObjectPool(new JedisFactory(h, port,
Protocol.DEFAULT_TIMEOUT, password, database), new Config());
} else {
this.internalPool = new GenericObjectPool(new JedisFactory(host,
Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT, null,
Protocol.DEFAULT_DATABASE), new Config());
}
}
示例7: HBaseConnectionManager
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
public HBaseConnectionManager() {
connectionFactory = new HBaseConnectionFactory();
poolConfiguration = new Config();
poolConfiguration.testOnBorrow = true;
poolConfiguration.testWhileIdle = true;
poolConfiguration.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
poolConfiguration.maxActive = 4;
poolConfiguration.maxIdle = 2;
poolConfiguration.minIdle = 1;
}
示例8: getThreadPoolConfig
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
@Override
public Config getThreadPoolConfig() {
Config config = new Config();
config.maxActive = -1; // No upper limit on the number of threads.
config.minIdle = 5; // Always have 5 threads waiting to go.
config.maxIdle = 10; // Maximum number of idle threads.
config.testOnBorrow = false; // Don't test on borrow to improve performance........
config.testOnReturn = true; // But test on return instead
config.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
return config;
}
示例9: CrawlDB
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
/**
* @param host
* @param port
* @param password
* @param timeout
* @param toCrawlDB
* 待抓取的数据库编号
* @param crawledDB
* 已经抓取的URL的数据库的编号
*/
public CrawlDB(String host, int port, String password, int timeout,
int toCrawlDB, int crawledDB) {
tocrawl = new JedisPool(new Config(), host, port, timeout, password,
toCrawlDB);
crawled = new JedisPool(new Config(), host, port, timeout, password,
crawledDB);
this.toCrawlDB = toCrawlDB;
this.crawledDB = crawledDB;
LOG.info("CrawlDB init");
}
示例10: testMov
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
@Test
public void testMov(){
JedisPool pool0 = new JedisPool(new Config(),"localhost",6377,1000,"940409",0);
JedisPool pool1= new JedisPool(new Config(),"localhost",6377,1000,"940409",1);
Jedis j0 = pool0.getResource();
Jedis j1 = pool1.getResource();
System.out.println(j1.get("1"));
j0.set("1", "haha");
j0.move("1", 1);
System.out.println(j1.get("1"));
}
示例11: setTestParameters
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
/**
* 功能描述:验证连接可用性的参数设置
*
* @param config 参数说明 返回值: 类型 <说明>
* @param whenExhaustedAction 参数说明 返回值: 类型 <说明>
* @param testOnBorrow 参数说明 返回值: 类型 <说明>
* @param testOnReturn 参数说明 返回值: 类型 <说明>
* @param testWhileIdle 参数说明 返回值: 类型 <说明>
* @param timeBetweenEvictionRunsMillis 参数说明 返回值: 类型 <说明>
* @param numTestsPerEvictionRun 参数说明 返回值: 类型 <说明>
* @param minEvictableIdleTimeMillis 参数说明 返回值: 类型 <说明>
* @param softMinEvictableIdleTimeMillis 参数说明 返回值: 类型 <说明>
*/
private void setTestParameters(Config config, String whenExhaustedAction, String testOnBorrow, String testOnReturn,
String testWhileIdle, String timeBetweenEvictionRunsMillis, String numTestsPerEvictionRun,
String minEvictableIdleTimeMillis, String softMinEvictableIdleTimeMillis) {
if (!StringUtils.isBlank(testOnBorrow)) {
// 获取连接池是否检测可用性
config.testOnBorrow = Boolean.valueOf(testOnBorrow);
}
if (!StringUtils.isBlank(testOnReturn)) {
// 归还时是否检测可用性
config.testOnReturn = Boolean.valueOf(testOnReturn);
}
if (!StringUtils.isBlank(testWhileIdle)) {
// 空闲时是否检测可用性
config.testWhileIdle = Boolean.valueOf(testWhileIdle);
} else {
config.testWhileIdle = true;
}
if (!StringUtils.isBlank(whenExhaustedAction)) {
config.whenExhaustedAction = Byte.valueOf(whenExhaustedAction);
}
if (!StringUtils.isBlank(timeBetweenEvictionRunsMillis)) {
config.timeBetweenEvictionRunsMillis = Long.valueOf(timeBetweenEvictionRunsMillis);
} else {
config.timeBetweenEvictionRunsMillis = 30000L;
}
if (!StringUtils.isBlank(numTestsPerEvictionRun)) {
config.numTestsPerEvictionRun = Integer.valueOf(numTestsPerEvictionRun);
} else {
config.numTestsPerEvictionRun = -1;
}
if (!StringUtils.isBlank(minEvictableIdleTimeMillis)) {
config.minEvictableIdleTimeMillis = Integer.valueOf(minEvictableIdleTimeMillis);
} else {
config.minEvictableIdleTimeMillis = 60000L;
}
if (!StringUtils.isBlank(softMinEvictableIdleTimeMillis)) {
config.softMinEvictableIdleTimeMillis = Integer.valueOf(softMinEvictableIdleTimeMillis);
}
}
示例12: SSdbPool
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
public SSdbPool(final Config poolConfig, final String hostPortTimeout) {
this(poolConfig, hostPortTimeout, Protocol.DEFAULT_DATABASE);
}
示例13: test
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
@Test
public void test(){
JedisPool j = new JedisPool(new Config(),"localhost",6377,1000,"940409",0);
System.out.println(j.getResource().get("aa"));
j.getResource().set("java", "haha");
}
示例14: DefaultJedisPool
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
/**
* 构造方法
*
* @param poolConfig 池配置
* @param host 主机地址
* @param port 端口
* @param timeout 超时时间
* @param password 密码
* @param dbIndex 索引
* @param isMaster 是否是master
*/
public DefaultJedisPool(final Config poolConfig, final String host, int port, int timeout, final String password,
int dbIndex, boolean isMaster) {
super(poolConfig, new JedisFactory(host, port, timeout, password, dbIndex));
this.host = host;
this.port = port;
this.dbIndex = dbIndex;
this.isMaster = isMaster;
}
示例15: NodeInfo4Jedis
import org.apache.commons.pool.impl.GenericObjectPool.Config; //导入依赖的package包/类
/**
* 构造方法
*
* @param ip Redis服务器ip
* @param port Redis服务器端口号
* @param password Redis服务器访问密码
* @param dbIndex Redis服务器数据库标识,Redis服务器内部使用,相当于数据库的schema
* @param timeOut 连接超时时间
* @param config 配置信息
*/
public NodeInfo4Jedis(String ip, Integer port, String password, int dbIndex, int timeOut, Config config) {
this.ip = ip;
this.port = port;
this.password = password;
this.dbIndex = dbIndex;
this.timeOut = timeOut;
this.config = config;
}