Java Code Examples for redis.clients.jedis.JedisPoolConfig#setJmxEnabled()

The following examples show how to use redis.clients.jedis.JedisPoolConfig#setJmxEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JedisConfig.java    From Mars-Java with MIT License 7 votes vote down vote up
public JedisPoolConfig getJedisPoolConfig() {
    jedisPoolConfig = new JedisPoolConfig();
    jedisPoolConfig.setMaxTotal(2048);
    jedisPoolConfig.setMaxIdle(200);
    jedisPoolConfig.setMinIdle(2);
    jedisPoolConfig.setNumTestsPerEvictionRun(2048);
    jedisPoolConfig.setTimeBetweenEvictionRunsMillis(30000);
    jedisPoolConfig.setMinEvictableIdleTimeMillis(-1);
    jedisPoolConfig.setSoftMinEvictableIdleTimeMillis(10000);
    jedisPoolConfig.setMaxWaitMillis(10000);
    jedisPoolConfig.setTestOnBorrow(true);
    jedisPoolConfig.setTestWhileIdle(true);
    jedisPoolConfig.setTestOnReturn(true);
    jedisPoolConfig.setJmxEnabled(true);
    jedisPoolConfig.setBlockWhenExhausted(true);
    return jedisPoolConfig;
}
 
Example 2
Source File: RedisConfig.java    From demo-project with MIT License 6 votes vote down vote up
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
    logger.info("jedisConnectionFactory:初始化了");
    JedisPoolConfig config = new JedisPoolConfig();
    config.setMaxIdle(maxIdle);
    config.setMinIdle(minIdle);
    config.setMaxWaitMillis(maxWaitMillis);
    config.setMaxTotal(maxActive);
    //链接耗尽时是否阻塞,默认true
    config.setBlockWhenExhausted(true);
    //是否启用pool的jmx管理功能,默认true
    config.setJmxEnabled(true);
    JedisConnectionFactory factory = new JedisConnectionFactory();
    factory.setPoolConfig(config);
    factory.setHostName(host);
    factory.setPort(port);
    factory.setPassword(password);
    factory.setDatabase(database);
    factory.setTimeout(timeout);
    return factory;
}
 
Example 3
Source File: RedisAutoConfig.java    From fw-spring-cloud with Apache License 2.0 5 votes vote down vote up
@Bean
public JedisPool redisPoolFactory()  throws Exception{
    log.info("JedisPool注入成功!!");
    log.info("redis地址:" + host + ":" + port);
    JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    jedisPoolConfig.setMaxIdle(maxIdle);
    jedisPoolConfig.setMaxWaitMillis(maxWaitMillis);
    // 连接耗尽时是否阻塞, false报异常,ture阻塞直到超时, 默认true
    jedisPoolConfig.setBlockWhenExhausted(blockWhenExhausted);
    // 是否启用pool的jmx管理功能, 默认true
    jedisPoolConfig.setJmxEnabled(true);
    JedisPool jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout, password);
    return jedisPool;
}
 
Example 4
Source File: RedisMgr.java    From Summer with Apache License 2.0 5 votes vote down vote up
public void loadConfig(InputStream in) throws Exception {
	Properties pro = new Properties();
	pro.load(in);
	redisConfig = new RedisConfig();
	redisConfig.setUrl(pro.getProperty("url"));
	redisConfig.setPort(Integer.parseInt(pro.getProperty("port")));
	redisConfig.setTimeout(Integer.parseInt(pro.getProperty("timeout")));
	redisConfig.setPassword(pro.getProperty("password"));
	redisConfig.setBlockWhenExhausted(Boolean.parseBoolean(pro.getProperty("blockWhenExhausted")));
	redisConfig.setEvictionPolicyClassName(pro.getProperty("evictionPolicyClassName"));
	redisConfig.setJmxEnabled(Boolean.parseBoolean(pro.getProperty("jmxEnabled")));
	redisConfig.setMaxIdle(Integer.parseInt(pro.getProperty("maxIdle")));
	redisConfig.setMaxTotal(Integer.parseInt(pro.getProperty("maxTotal")));
	redisConfig.setMaxWaitMillis(Long.parseLong(pro.getProperty("maxWaitMillis")));
	redisConfig.setTestOnBorrow(Boolean.parseBoolean(pro.getProperty("testOnBorrow")));
	in.close();
	pro.clear();
	JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
	jedisPoolConfig.setBlockWhenExhausted(redisConfig.isBlockWhenExhausted());
	jedisPoolConfig.setEvictionPolicyClassName(redisConfig.getEvictionPolicyClassName());
	jedisPoolConfig.setJmxEnabled(redisConfig.isJmxEnabled());
	jedisPoolConfig.setMaxIdle(redisConfig.getMaxIdle());
	jedisPoolConfig.setMaxTotal(redisConfig.getMaxTotal());
	jedisPoolConfig.setMaxWaitMillis(redisConfig.getMaxWaitMillis());
       jedisPoolConfig.setTestOnBorrow(redisConfig.isTestOnBorrow());
       jedisPool = new JedisPool(jedisPoolConfig, redisConfig.getUrl(), redisConfig.getPort(), redisConfig.getTimeout(), redisConfig.getPassword()); 
}