当前位置: 首页>>代码示例>>Java>>正文


Java JedisPoolConfig.setBlockWhenExhausted方法代码示例

本文整理汇总了Java中redis.clients.jedis.JedisPoolConfig.setBlockWhenExhausted方法的典型用法代码示例。如果您正苦于以下问题:Java JedisPoolConfig.setBlockWhenExhausted方法的具体用法?Java JedisPoolConfig.setBlockWhenExhausted怎么用?Java JedisPoolConfig.setBlockWhenExhausted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis.clients.jedis.JedisPoolConfig的用法示例。


在下文中一共展示了JedisPoolConfig.setBlockWhenExhausted方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: jedisConnConfig

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
private void jedisConnConfig(final JedisConnectionFactory jedisConnectionFactory) {
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    try {
        poolConfig.setMaxTotal(Integer.parseInt(REDIS_MAXTOTAL.getValue()));
        poolConfig.setMaxIdle(Integer.parseInt(REDIS_MAXIDLE.getValue()));
        poolConfig.setBlockWhenExhausted(true);
        if (!"".equals(REDIS_PASSWORD.getValue())) {
            jedisConnectionFactory.setPassword(REDIS_PASSWORD.getValue());
        }
        if (!"".equals(REDIS_DATABASE.getValue())) {
            jedisConnectionFactory.setDatabase(Integer.parseInt(REDIS_DATABASE.getValue()));
        }
        jedisConnectionFactory.setPoolConfig(poolConfig);
        jedisConnectionFactory.setUsePool(true);
        jedisConnectionFactory.setTimeout(Integer.parseInt(REDIS_TIMEOUT.getValue()));
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}
 
开发者ID:globocom,项目名称:groot,代码行数:20,代码来源:RedisConfiguration.java

示例2: createJedisPoolConfig

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
private static JedisPoolConfig createJedisPoolConfig(Builder builder) {
    JedisPoolConfig config = new JedisPoolConfig();
    config.setMaxTotal(builder.maxTotal);
    config.setMaxIdle(builder.maxIdle);
    config.setMinIdle(builder.minIdle);
    config.setLifo(builder.lifo);
    config.setFairness(builder.fairness);
    config.setMaxWaitMillis(builder.maxWaitMillis);
    config.setMinEvictableIdleTimeMillis(builder.minEvictableIdleTimeMillis);
    config.setSoftMinEvictableIdleTimeMillis(builder.softMinEvictableIdleTimeMillis);
    config.setNumTestsPerEvictionRun(builder.numTestsPerEvictionRun);
    config.setTestOnCreate(builder.testOnCreate);
    config.setTestOnBorrow(builder.testOnBorrow);
    config.setTestOnReturn(builder.testOnReturn);
    config.setTestWhileIdle(builder.testWhileIdle);
    config.setTimeBetweenEvictionRunsMillis(builder.timeBetweenEvictionRunsMillis);
    config.setEvictionPolicyClassName(builder.evictionPolicyClassName);
    config.setBlockWhenExhausted(builder.blockWhenExhausted);
    config.setJmxEnabled(builder.jmxEnabled);
    config.setJmxNameBase(builder.jmxNameBase);
    config.setJmxNamePrefix(builder.jmxNamePrefix);
    return config;
}
 
开发者ID:vy,项目名称:log4j2-redis-appender,代码行数:24,代码来源:RedisConnectionPoolConfig.java

示例3: JedisPoolConfigFactory

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
private JedisPoolConfigFactory() {
	config = new JedisPoolConfig();
	//连接耗尽时是否阻塞, false报异常,ture阻塞直到超时, 默认true
   	config.setBlockWhenExhausted(true);
   	//设置的逐出策略类名, 默认DefaultEvictionPolicy(当连接超过最大空闲时间,或连接数超过最大空闲连接数)
   	config.setEvictionPolicyClassName("org.apache.commons.pool2.impl.DefaultEvictionPolicy");
   	//是否启用pool的jmx管理功能, 默认true
   	config.setJmxEnabled(true);
   	//是否启用后进先出, 默认true
   	config.setLifo(true);
   	//最大空闲连接数, 默认8个
   	config.setMaxIdle(Integer.parseInt(Config.getAttribute("maxIdle")));
   	//最大连接数, 默认8个
   	config.setMaxTotal(Integer.parseInt(Config.getAttribute("maxTotal")));
   	//获取连接时的最大等待毫秒数(如果设置为阻塞时BlockWhenExhausted),如果超时就抛异常, 小于零:阻塞不确定的时间,  默认-1
   	config.setMaxWaitMillis(Integer.parseInt(Config.getAttribute("maxWait")));
   	//最小空闲连接数, 默认0
   	config.setMinIdle(Integer.parseInt(Config.getAttribute("minIdle")));
   	//在获取连接的时候检查有效性, 默认false
   	config.setTestOnBorrow(Boolean.parseBoolean(Config.getAttribute("testOnBorrow")));
   	//在空闲时检查有效性, 默认false
   	config.setTestWhileIdle(Boolean.parseBoolean(Config.getAttribute("testOnReturn")));
}
 
开发者ID:rocye,项目名称:wx-idk,代码行数:24,代码来源:JedisPoolConfigFactory.java

示例4: buildPoolConfig

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
private static JedisPoolConfig buildPoolConfig() {
	final JedisPoolConfig poolConfig = new JedisPoolConfig();
	poolConfig.setMaxTotal(128);
	poolConfig.setMaxIdle(128);
	poolConfig.setMinIdle(16);
	poolConfig.setTestOnBorrow(true);
	poolConfig.setTestOnReturn(true);
	poolConfig.setTestWhileIdle(true);
	poolConfig.setMinEvictableIdleTimeMillis(Duration.ofSeconds(60).toMillis());
	poolConfig.setTimeBetweenEvictionRunsMillis(Duration.ofSeconds(30).toMillis());
	poolConfig.setNumTestsPerEvictionRun(3);
	poolConfig.setBlockWhenExhausted(true);

	return poolConfig;
}
 
开发者ID:SystemOfAProg,项目名称:VS2Labor,代码行数:16,代码来源:JedisFactory.java

示例5: setPoolParameters

import redis.clients.jedis.JedisPoolConfig; //导入方法依赖的package包/类
/**
 * 处理连接池信息
 * 
 * @param poolConfig 参数说明
 * @param config 参数说明
 */
private void setPoolParameters(PoolConfig poolConfig, JedisPoolConfig config) {
	
    if (!StringUtils.isBlank(poolConfig.getMaxIdle())) {
    	// 获取最大空闲连接数
        config.setMaxIdle(Integer.valueOf(poolConfig.getMaxIdle()));
    }    
    
    if (!StringUtils.isBlank(poolConfig.getMinIdle())) {
    	// 获取最小空闲连接数
        config.setMinIdle(Integer.valueOf(poolConfig.getMinIdle()));
    }           
    
    if (!StringUtils.isBlank(poolConfig.getMaxTotal())) {
    	// 获取最大连接数
        config.setMaxTotal(Integer.valueOf(poolConfig.getMaxTotal()));
    }  
    
    if (!StringUtils.isBlank(poolConfig.getTestOnBorrow())) {
        // 获取连接池是否检测可用性
        config.setTestOnBorrow(Boolean.valueOf(poolConfig.getTestOnBorrow()));
    }

    if (!StringUtils.isBlank(poolConfig.getTestOnReturn())) {
        // 归还时是否检测可用性
        config.setTestOnReturn(Boolean.valueOf(poolConfig.getTestOnReturn()));
    }
    if (!StringUtils.isBlank(poolConfig.getTestWhileIdle())) {
        // 空闲时是否检测可用性
        config.setTestWhileIdle(Boolean.valueOf(poolConfig.getTestWhileIdle()));
    } else {
    	config.setTestWhileIdle(true);
    }
    if (!StringUtils.isBlank(poolConfig.getBlockWhenExhausted())) {
        config.setBlockWhenExhausted(Boolean.valueOf(poolConfig.getBlockWhenExhausted()));
    }
    if (!StringUtils.isBlank(poolConfig.getTimeBetweenEvictionRunsMillis())) {
        config.setTimeBetweenEvictionRunsMillis(Long.valueOf(poolConfig.getTimeBetweenEvictionRunsMillis()));
    } else {
    	config.setTimeBetweenEvictionRunsMillis(30000L);
    }
    if (!StringUtils.isBlank(poolConfig.getNumTestsPerEvictionRun())) {
        config.setNumTestsPerEvictionRun(Integer.valueOf(poolConfig.getNumTestsPerEvictionRun()));
    } else {
    	config.setNumTestsPerEvictionRun(-1);
    }
    if (!StringUtils.isBlank(poolConfig.getMinEvictableIdleTimeMillis())) {
        config.setMinEvictableIdleTimeMillis(Integer.valueOf(poolConfig.getMinEvictableIdleTimeMillis()));
    } else {
        config.setMinEvictableIdleTimeMillis(60000L);
    }
    if (!StringUtils.isBlank(poolConfig.getSoftMinEvictableIdleTimeMillis())) {
        config.setSoftMinEvictableIdleTimeMillis(Integer.valueOf(poolConfig.getSoftMinEvictableIdleTimeMillis()));
    }
}
 
开发者ID:ningyu1,项目名称:jodis-client,代码行数:61,代码来源:DefaultClientImpl.java


注:本文中的redis.clients.jedis.JedisPoolConfig.setBlockWhenExhausted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。