當前位置: 首頁>>代碼示例>>Java>>正文


Java GenericObjectPoolConfig.setMaxTotal方法代碼示例

本文整理匯總了Java中org.apache.commons.pool2.impl.GenericObjectPoolConfig.setMaxTotal方法的典型用法代碼示例。如果您正苦於以下問題:Java GenericObjectPoolConfig.setMaxTotal方法的具體用法?Java GenericObjectPoolConfig.setMaxTotal怎麽用?Java GenericObjectPoolConfig.setMaxTotal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.pool2.impl.GenericObjectPoolConfig的用法示例。


在下文中一共展示了GenericObjectPoolConfig.setMaxTotal方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkResourceIsCloseable

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //導入方法依賴的package包/類
@Test
public void checkResourceIsCloseable() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);
  JedisPool pool = new JedisPool(config, hnp.getHost(), hnp.getPort(), 2000, "foobared");

  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,代碼行數:22,代碼來源:JedisPoolTest.java

示例2: 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

示例3: 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

示例4: checkResourceIsCloseable

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //導入方法依賴的package包/類
@Test
public void checkResourceIsCloseable() throws URISyntaxException {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);

  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  shards.add(new JedisShardInfo(new URI("redis://:[email protected]:6380")));
  shards.add(new JedisShardInfo(new URI("redis://:[email protected]:6379")));

  ShardedJedisPool pool = new ShardedJedisPool(config, shards);

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

  ShardedJedis jedis2 = pool.getResource();
  try {
    assertEquals(jedis, jedis2);
  } finally {
    jedis2.close();
  }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:27,代碼來源:ShardedJedisPoolTest.java

示例5: ProtostuffSerializePool

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //導入方法依賴的package包/類
public ProtostuffSerializePool(final int maxTotal, final int minIdle, final long maxWaitMillis, final long minEvictableIdleTimeMillis) {
    protostuffpool = new GenericObjectPool<>(new ProtostuffSerializeFactory());

    GenericObjectPoolConfig config = new GenericObjectPoolConfig();

    config.setMaxTotal(maxTotal);
    config.setMinIdle(minIdle);
    config.setMaxWaitMillis(maxWaitMillis);
    config.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);

    protostuffpool.setConfig(config);
}
 
開發者ID:yu199195,項目名稱:happylifeplat-transaction,代碼行數:13,代碼來源:ProtostuffSerializePool.java

示例6: HessianSerializePool

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //導入方法依賴的package包/類
public HessianSerializePool(final int maxTotal, final int minIdle, final long maxWaitMillis, final long minEvictableIdleTimeMillis) {
    hessianPool = new GenericObjectPool<>(new HessianSerializeFactory());

    GenericObjectPoolConfig config = new GenericObjectPoolConfig();

    config.setMaxTotal(maxTotal);
    config.setMinIdle(minIdle);
    config.setMaxWaitMillis(maxWaitMillis);
    config.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);

    hessianPool.setConfig(config);
}
 
開發者ID:yu199195,項目名稱:happylifeplat-transaction,代碼行數:13,代碼來源:HessianSerializePool.java

示例7: 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);
  JedisPool pool = new JedisPool(config, hnp.getHost(), hnp.getPort());
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
  jedis.set("foo", "0");

  Jedis newJedis = pool.getResource();
  newJedis.auth("foobared");
  newJedis.incr("foo");
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:15,代碼來源:JedisPoolTest.java

示例8: returnResourceShouldResetState

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //導入方法依賴的package包/類
@Test
public void returnResourceShouldResetState() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);
  JedisPool pool = new JedisPool(config, hnp.getHost(), hnp.getPort(), 2000, "foobared");

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

  Jedis jedis2 = pool.getResource();
  try {
    assertTrue(jedis == jedis2);
    assertEquals("jedis", jedis2.get("hello"));
  } finally {
    jedis2.close();
  }

  pool.destroy();
  assertTrue(pool.isClosed());
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:28,代碼來源:JedisPoolTest.java

示例9: returnResourceShouldResetState

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //導入方法依賴的package包/類
@Test
public void returnResourceShouldResetState() {
  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();
  Jedis jedis2 = null;

  try {
    jedis.set("hello", "jedis");
    Transaction t = jedis.multi();
    t.set("hello", "world");
    pool.returnResource(jedis);

    jedis2 = pool.getResource();

    assertTrue(jedis == jedis2);
    assertEquals("jedis", jedis2.get("hello"));
  } catch (JedisConnectionException e) {
    if (jedis2 != null) {
      pool.returnBrokenResource(jedis2);
      jedis2 = null;
    }
  } finally {
    if (jedis2 != null) jedis2.close();

    pool.destroy();
  }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:33,代碼來源:JedisSentinelPoolTest.java

示例10: testIfPoolConfigAppliesToClusterPools

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //導入方法依賴的package包/類
@Test(expected = JedisException.class)
public void testIfPoolConfigAppliesToClusterPools() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(0);
  config.setMaxWaitMillis(DEFAULT_TIMEOUT);
  Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
  jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
  JedisCluster jc = new JedisCluster(jedisClusterNode, DEFAULT_TIMEOUT, DEFAULT_TIMEOUT, DEFAULT_REDIRECTIONS, "cluster", config);
  jc.set("52", "poolTestValue");
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:11,代碼來源:JedisClusterTest.java

示例11: 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

示例12: shouldNotShareInstances

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //導入方法依賴的package包/類
@Test
public void shouldNotShareInstances() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(2);

  ShardedJedisPool pool = new ShardedJedisPool(config, shards);

  ShardedJedis j1 = pool.getResource();
  ShardedJedis j2 = pool.getResource();

  assertNotSame(j1.getShard("foo"), j2.getShard("foo"));
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:13,代碼來源:ShardedJedisPoolTest.java

示例13: returnResourceShouldResetState

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //導入方法依賴的package包/類
@Test
public void returnResourceShouldResetState() throws URISyntaxException {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);

  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  shards.add(new JedisShardInfo(new URI("redis://:[email protected]:6380")));
  shards.add(new JedisShardInfo(new URI("redis://:[email protected]:6379")));

  ShardedJedisPool pool = new ShardedJedisPool(config, shards);

  ShardedJedis jedis = pool.getResource();
  jedis.set("pipelined", String.valueOf(0));
  jedis.set("pipelined2", String.valueOf(0));

  ShardedJedisPipeline pipeline = jedis.pipelined();

  pipeline.incr("pipelined");
  pipeline.incr("pipelined2");

  jedis.resetState();

  pipeline = jedis.pipelined();
  pipeline.incr("pipelined");
  pipeline.incr("pipelined2");
  List<Object> results = pipeline.syncAndReturnAll();

  assertEquals(2, results.size());
  pool.returnResource(jedis);
  pool.destroy();
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:33,代碼來源:ShardedJedisPoolTest.java

示例14: doTest

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //導入方法依賴的package包/類
private static void doTest() throws Exception {
    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    poolConfig.setMinIdle(0);
    poolConfig.setMaxIdle(5);
    poolConfig.setMaxTotal(5);
    final JedisPool pool = new JedisPool(poolConfig, "127.0.0.1", 6379, 2000, "weimob123", 8);

    List<Thread> tds = new ArrayList<Thread>();
    final Integer temp = 0;
    final AtomicInteger ind = new AtomicInteger();
    for (int i = 0; i < 50; i++) {
        Thread hj = new Thread(new Runnable() {
            public void run() {
                for (int i; (i = ind.getAndIncrement()) < TOTAL_OPERATIONS; ) {
                    Jedis j = pool.getResource();
                    final String key = "foo" + i;
                    // redisUtil.setRedisData(key, key);
                    j.set(key.getBytes(), ConvertUtil.serialize(temp));
                    j.close();
                }
            }
        });
        tds.add(hj);
        hj.start();
    }

    for (Thread t : tds)
        t.join();
    pool.close();
    pool.destroy();
}
 
開發者ID:TwoDragonLake,項目名稱:tdl-seckill,代碼行數:32,代碼來源:JedisTest.java

示例15: getGenericPoolConfig

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //導入方法依賴的package包/類
public GenericObjectPoolConfig getGenericPoolConfig() {
    GenericObjectPoolConfig genericObjectPoolConfig = new GenericObjectPoolConfig();
    genericObjectPoolConfig.setLifo(this.lifo);
    genericObjectPoolConfig.setMinIdle(this.minIdle);
    genericObjectPoolConfig.setMaxIdle(this.maxIdle);
    genericObjectPoolConfig.setMaxTotal(this.maxTotal);
    genericObjectPoolConfig.setNumTestsPerEvictionRun(this.numtestsPerEviction);
    genericObjectPoolConfig.setBlockWhenExhausted(this.blockedWhenExhausted);
    genericObjectPoolConfig.setTimeBetweenEvictionRunsMillis(this.timeBetweenEvictionRun);
    genericObjectPoolConfig.setTestOnBorrow(this.testOnBorrow);
    genericObjectPoolConfig.setTestOnCreate(this.testOnCreate);
    genericObjectPoolConfig.setTestOnReturn(this.testOnReturn);
    return genericObjectPoolConfig;
}
 
開發者ID:carryxyh,項目名稱:FKC,代碼行數:15,代碼來源:KryoPoolConfig.java


注:本文中的org.apache.commons.pool2.impl.GenericObjectPoolConfig.setMaxTotal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。