當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。