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


Java GenericObjectPoolConfig.setBlockWhenExhausted方法代码示例

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


在下文中一共展示了GenericObjectPoolConfig.setBlockWhenExhausted方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: DefaultSessionPool

import org.apache.commons.pool2.impl.GenericObjectPoolConfig; //导入方法依赖的package包/类
public DefaultSessionPool(final ConnectionService connect, final X509TrustManager trust, final X509KeyManager key,
                          final VaultRegistry registry, final Cache<Path> cache, final TranscriptListener transcript,
                          final Host bookmark) {
    this.connect = connect;
    this.registry = registry;
    this.cache = cache;
    this.bookmark = bookmark;
    this.transcript = transcript;
    final GenericObjectPoolConfig configuration = new GenericObjectPoolConfig();
    configuration.setJmxEnabled(false);
    configuration.setEvictionPolicyClassName(CustomPoolEvictionPolicy.class.getName());
    configuration.setBlockWhenExhausted(true);
    configuration.setMaxWaitMillis(BORROW_MAX_WAIT_INTERVAL);
    this.pool = new GenericObjectPool<Session>(new PooledSessionFactory(connect, trust, key, cache, bookmark, registry), configuration);
    final AbandonedConfig abandon = new AbandonedConfig();
    abandon.setUseUsageTracking(true);
    this.pool.setAbandonedConfig(abandon);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:19,代码来源:DefaultSessionPool.java

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

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

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

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

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

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