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


Java GenericObjectPoolConfig类代码示例

本文整理汇总了Java中org.apache.commons.pool2.impl.GenericObjectPoolConfig的典型用法代码示例。如果您正苦于以下问题:Java GenericObjectPoolConfig类的具体用法?Java GenericObjectPoolConfig怎么用?Java GenericObjectPoolConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GenericObjectPoolConfig类属于org.apache.commons.pool2.impl包,在下文中一共展示了GenericObjectPoolConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getJedisCluster

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
/**
 * 注意:
 * 这里返回的JedisCluster是单例的,并且可以直接注入到其他类中去使用
 * @return
 */
@Bean
public JedisCluster getJedisCluster() {
    //获取服务器数组(这里要相信自己的输入,所以没有考虑空指针问题)
    String[] serverArray = redisProperties.getClusterNodes().split(",");
    Set<HostAndPort> nodes = new HashSet<>();

    for (String ipPort : serverArray) {
        String[] ipPortPair = ipPort.split(":");
        nodes.add(new HostAndPort(ipPortPair[0].trim(), Integer.valueOf(ipPortPair[1].trim())));
    }

    return new JedisCluster(nodes,10000,
            1000,1,redisProperties.getPassword() ,
            new GenericObjectPoolConfig());
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:21,代码来源:JedisClusterConfig.java

示例2: JaRedisPool

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
public JaRedisPool(final String host) {
    URI uri = URI.create(host);
    if (JedisURIHelper.isValid(uri)) {
        String h = uri.getHost();
        int port = uri.getPort();
        String password = JedisURIHelper.getPassword(uri);
        int database = JedisURIHelper.getDBIndex(uri);
        this.internalPool = new GenericObjectPool<>(new JaRedisFactory(h, port,
                Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, password, database, null),
                new GenericObjectPoolConfig());
    } else {
        this.internalPool = new GenericObjectPool<>(new JaRedisFactory(host,
                Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, null,
                Protocol.DEFAULT_DATABASE, null), new GenericObjectPoolConfig());
    }
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:17,代码来源:JaRedisPool.java

示例3: JedisPool

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
public JedisPool(final String host, final SSLSocketFactory sslSocketFactory, final SSLParameters sslParameters,
		final HostnameVerifier hostnameVerifier) {
	URI uri = URI.create(host);
	if (JedisURIHelper.isValid(uri)) {
		String h = uri.getHost();
		int port = uri.getPort();
		String password = JedisURIHelper.getPassword(uri);
		int database = JedisURIHelper.getDBIndex(uri);
		boolean ssl = uri.getScheme().equals("rediss");
		this.internalPool = new GenericObjectPool<Jedis>(
				new JedisFactory(h, port, Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, password, database,
						null, ssl, sslSocketFactory, sslParameters, hostnameVerifier),
				new GenericObjectPoolConfig());
	} else {
		this.internalPool = new GenericObjectPool<Jedis>(
				new JedisFactory(host, Protocol.DEFAULT_PORT, Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT,
						null, Protocol.DEFAULT_DATABASE, null, false, null, null, null),
				new GenericObjectPoolConfig());
	}
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:21,代码来源:JedisPool.java

示例4: initializeSlotsCache

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
private void initializeSlotsCache(Set<HostAndPort> startNodes, GenericObjectPoolConfig poolConfig, String password,
		String clientName) {
	for (HostAndPort hostAndPort : startNodes) {
		Jedis jedis = new Jedis(hostAndPort.getHost(), hostAndPort.getPort());
		try {
			if (password != null) {
				jedis.auth(password);
			}
			if (clientName != null) {
				jedis.clientSetname(clientName);
			}
			cache.discoverClusterNodesAndSlots(jedis);
			break;
		} catch (JedisConnectionException e) {
			// try next nodes
		} finally {
			if (jedis != null) {
				jedis.close();
			}
		}
	}
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:23,代码来源:JedisClusterConnectionHandler.java

示例5: checkResourceIsCloseable

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
@Test
public void checkResourceIsCloseable() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);
  JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, config, 1000,
      "foobared", 2);

  Jedis jedis = pool.getResource();
  try {
    jedis.set("hello", "jedis");
  } finally {
    jedis.close();
  }

  Jedis jedis2 = pool.getResource();
  try {
    assertEquals(jedis, jedis2);
  } finally {
    jedis2.close();
  }
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:23,代码来源:JedisSentinelPoolTest.java

示例6: customClientName

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
@Test
public void customClientName() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);
  JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, config, 1000,
      "foobared", 0, "my_shiny_client_name");

  Jedis jedis = pool.getResource();

  try {
    assertEquals("my_shiny_client_name", jedis.clientGetname());
  } finally {
    jedis.close();
    pool.destroy();
  }

  assertTrue(pool.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:20,代码来源:JedisSentinelPoolTest.java

示例7: testSimplePool

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
@Test
public void testSimplePool() throws Exception {
    GenericObjectPoolConfig pc = new GenericObjectPoolConfig();
    pc.setMinIdle(2);
    pc.setMaxIdle(10);
    pc.setMaxTotal(10);
    JedisPool pool = new JedisPool(pc, "localhost", 6379);

    testWithPool(pool);
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:11,代码来源:RedisCacheTest.java

示例8: start

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
public static void start(){
//        int size = 1024;
        int size = 1024;
        int max = 32;
        GenericObjectPoolConfig genericObjectPoolConfig = new GenericObjectPoolConfig();
        genericObjectPoolConfig.setMaxTotal(size * max);
        genericObjectPoolConfig.setMaxIdle(size * max);
        genericObjectPoolConfig.setMinIdle(size);
        long time = 1000 * 30;
        genericObjectPoolConfig.setMaxWaitMillis(time);
        genericObjectPoolConfig.setSoftMinEvictableIdleTimeMillis(time);

        updateEventCacheFactory = new UpdateEventCacheFactory(new UpdateEventPoolFactory(), genericObjectPoolConfig);
    }
 
开发者ID:jwpttcg66,项目名称:game-executor,代码行数:15,代码来源:UpdateEventCacheService.java

示例9: JaRedisSentinelPool

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
public JaRedisSentinelPool(String masterName, Set<String> sentinels,
                           final GenericObjectPoolConfig poolConfig, final int connectionTimeout, final int soTimeout,
                           final String password, final int database, final String clientName) {
    this.poolConfig = poolConfig;
    this.connectionTimeout = connectionTimeout;
    this.soTimeout = soTimeout;
    this.password = password;
    this.database = database;
    this.clientName = clientName;

    HostAndPort master = initSentinels(sentinels, masterName);
    initPool(master);
}
 
开发者ID:YanXs,项目名称:nighthawk,代码行数:14,代码来源:JaRedisSentinelPool.java

示例10: createRabbitMqChannelPool

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
static RabbitMqChannelPool createRabbitMqChannelPool(RabbitMqChannelFactory channelFactory) {
    GenericObjectPoolConfig config = new GenericObjectPoolConfig();
    config.setJmxNameBase("storm-rabbitmq:name=");
    config.setJmxNamePrefix("ChannelPool");
    RabbitMqChannelPool channelPool = new RabbitMqChannelPool(channelFactory, config);
    channelPool.setMaxTotal(-1);
    channelPool.setMaxIdle(-1);
    return channelPool;
}
 
开发者ID:anderelate,项目名称:storm-rabbitmq,代码行数:10,代码来源:RabbitMqChannelProvider.java

示例11: TracingJedisCluster

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
public TracingJedisCluster(Set<HostAndPort> jedisClusterNode, int connectionTimeout,
    int soTimeout,
    int maxAttempts, GenericObjectPoolConfig poolConfig, Tracer tracer,
    boolean traceWithActiveSpanOnly) {
  super(jedisClusterNode, connectionTimeout, soTimeout, maxAttempts, poolConfig);
  this.helper = new TracingHelper(tracer, traceWithActiveSpanOnly);
}
 
开发者ID:opentracing-contrib,项目名称:java-redis-client,代码行数:8,代码来源:TracingJedisCluster.java

示例12: checkPoolOverflow

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
@Test(expected = JedisException.class)
public void checkPoolOverflow() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);

  ShardedJedisPool pool = new ShardedJedisPool(config, shards);

  ShardedJedis jedis = pool.getResource();
  jedis.set("foo", "0");

  ShardedJedis newJedis = pool.getResource();
  newJedis.incr("foo");
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:15,代码来源:ShardedJedisPoolTest.java

示例13: checkConnectionWithDefaultPort

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
@Test
public void checkConnectionWithDefaultPort() {
  ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
  ShardedJedis jedis = pool.getResource();
  jedis.set("foo", "bar");
  assertEquals("bar", jedis.get("foo"));
  pool.returnResource(jedis);
  pool.destroy();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:10,代码来源:ShardedJedisPoolTest.java

示例14: checkCloseableConnections

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
@Test
public void checkCloseableConnections() throws Exception {
  ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
  ShardedJedis jedis = pool.getResource();
  jedis.set("foo", "bar");
  assertEquals("bar", jedis.get("foo"));
  pool.returnResource(jedis);
  pool.close();
  assertTrue(pool.isClosed());
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:11,代码来源:ShardedJedisPoolTest.java

示例15: checkFailedJedisServer

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入依赖的package包/类
@Test
public void checkFailedJedisServer() {
  ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
  ShardedJedis jedis = pool.getResource();
  jedis.incr("foo");
  pool.returnResource(jedis);
  pool.destroy();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:9,代码来源:ShardedJedisPoolTest.java


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