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


Java ShardedJedis.disconnect方法代码示例

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


在下文中一共展示了ShardedJedis.disconnect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkPoolRepairedWhenJedisIsBroken

import redis.clients.jedis.ShardedJedis; //导入方法依赖的package包/类
@Test
public void checkPoolRepairedWhenJedisIsBroken() {
  ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
  ShardedJedis jedis = pool.getResource();
  jedis.disconnect();
  pool.returnBrokenResource(jedis);

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

示例2: testAvoidLeaksUponDisconnect

import redis.clients.jedis.ShardedJedis; //导入方法依赖的package包/类
/**
 * Test for "Issue - BinaryShardedJedis.disconnect() may occur memory leak". You can find more
 * detailed information at https://github.com/xetorthio/jedis/issues/808
 * @throws InterruptedException
 */
@Test
public void testAvoidLeaksUponDisconnect() throws InterruptedException {
  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(2);
  // 6379
  JedisShardInfo shard1 = new JedisShardInfo(redis1.getHost(), redis1.getPort());
  shard1.setPassword("foobared");
  shards.add(shard1);
  // 6380
  JedisShardInfo shard2 = new JedisShardInfo(redis2.getHost(), redis2.getPort());
  shard2.setPassword("foobared");
  shards.add(shard2);

  @SuppressWarnings("resource")
  ShardedJedis shardedJedis = new ShardedJedis(shards);
  // establish the connection for two redis servers
  shardedJedis.set("a", "bar");
  JedisShardInfo ak = shardedJedis.getShardInfo("a");
  assertEquals(shard2, ak);
  shardedJedis.set("b", "bar1");
  JedisShardInfo bk = shardedJedis.getShardInfo("b");
  assertEquals(shard1, bk);

  // We set a name to the instance so it's easy to find it
  Iterator<Jedis> it = shardedJedis.getAllShards().iterator();
  Jedis deadClient = it.next();
  deadClient.clientSetname("DEAD");

  ClientKillerUtil.killClient(deadClient, "DEAD");

  assertEquals(true, deadClient.isConnected());
  assertEquals(false, deadClient.getClient().getSocket().isClosed());
  assertEquals(false, deadClient.getClient().isBroken()); // normal - not found

  shardedJedis.disconnect();

  assertEquals(false, deadClient.isConnected());
  assertEquals(true, deadClient.getClient().getSocket().isClosed());
  assertEquals(true, deadClient.getClient().isBroken());

  Jedis jedis2 = it.next();
  assertEquals(false, jedis2.isConnected());
  assertEquals(true, jedis2.getClient().getSocket().isClosed());
  assertEquals(false, jedis2.getClient().isBroken());

}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:51,代码来源:ShardedJedisTest.java

示例3: disconnect

import redis.clients.jedis.ShardedJedis; //导入方法依赖的package包/类
public void disconnect() {
    ShardedJedis shardedJedis = shardedJedisPool.getResource();
    shardedJedis.disconnect();
}
 
开发者ID:peng9627,项目名称:hall,代码行数:5,代码来源:RedisClientTemplate.java


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