redis.clients.util.Pool.destroy()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(78)

本文整理了Java中redis.clients.util.Pool.destroy()方法的一些代码示例,展示了Pool.destroy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Pool.destroy()方法的具体详情如下:
包路径:redis.clients.util.Pool
类名称:Pool
方法名:destroy

Pool.destroy介绍

暂无

代码示例

代码示例来源:origin: sohutv/cachecloud

@Override
public void close() {
 destroy();
}

代码示例来源:origin: mpusher/mpush

public void destroy() {
  if (pool != null) {
    try {
      pool.destroy();
    } catch (Exception ex) {
      log.warn("Cannot properly close Jedis pool", ex);
    }
    pool = null;
  }
  if (cluster != null) {
    try {
      cluster.close();
    } catch (Exception ex) {
      log.warn("Cannot properly close Jedis cluster", ex);
    }
    cluster = null;
  }
}

代码示例来源:origin: ff4j/ff4j

/**
 * Clean up connections after tests.
 */
public void destroyPool() {
  if (jedisPool != null) {
    jedisPool.destroy();
  }
}

代码示例来源:origin: lindzh/hasting

@Override
public void stopService() {
  if(redisPool!=null){
    this.redisPool.destroy();
  }
}

代码示例来源:origin: Baqend/Orestes-Bloomfilter

public void destroy() {
    pool.destroy();
  }
}

代码示例来源:origin: suninformation/ymate-platform-v2

@Override
  public void destroy() {
    __pool.destroy();
  }
}

代码示例来源:origin: lindzh/hasting

@Override
public void destroy() {
  redisPool.destroy();
}

代码示例来源:origin: org.tinygroup/org.tinygroup.jedis

private void destroy(Pool<Jedis> pool) {
  try {
    pool.destroy();
  } catch (Exception e) {
    logger.errorMessage("销毁{}的连接池{}时出错", e, masterName,
        pool.toString());
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.jedis

private void destroy(Pool<Jedis> pool) {
  try {
    pool.destroy();
  } catch (Exception e) {
    logger.errorMessage("销毁{}的连接池{}时出错", e, masterName,
        pool.toString());
  }
}

代码示例来源:origin: warmbreeze/sharded-jedis-sentinel-pool

public void destroy() {
  for (MasterListener m : masterListeners) {
    m.shutdown();
  }
  
  super.destroy();
}

代码示例来源:origin: penggle/jedis-ms-sentinel

public void destroy() {
  for (MasterSlaveListener m : masterSlaveListeners) {
    m.shutdown();
  }
  super.destroy();
}

代码示例来源:origin: penggle/jedis-ms-sentinel

public void destroy() {
  for (ShardedMasterSlaveListener m : shardedMasterSlaveListeners) {
    m.shutdown();
  }
  super.destroy();
}

代码示例来源:origin: com.github.mpusher/mpush-cache

public void destroy() {
  if (pool != null) {
    try {
      pool.destroy();
    } catch (Exception ex) {
      log.warn("Cannot properly close Jedis pool", ex);
    }
    pool = null;
  }
  if (cluster != null) {
    try {
      cluster.close();
    } catch (Exception ex) {
      log.warn("Cannot properly close Jedis cluster", ex);
    }
    cluster = null;
  }
}

代码示例来源:origin: org.tinygroup/org.tinygroup.jedis

public void destroy() {
  JedisCheck.stop();
  for (MasterListener m : masterListeners) {
    m.shutdown();
  }
  super.destroy();
}

代码示例来源:origin: org.nuxeo.runtime/nuxeo-runtime-redis

@Override
public void stop(ComponentContext context) throws InterruptedException {
  super.stop(context);
  if (executor == null) {
    return;
  }
  try {
    executor.getPool().destroy();
  } finally {
    executor = null;
  }
}

代码示例来源:origin: org.springframework.data/spring-data-redis

public void destroy() {
  if (getUsePool() && pool != null) {
    try {
      pool.destroy();
    } catch (Exception ex) {
      log.warn("Cannot properly close Jedis pool", ex);
    }
    pool = null;
  }
  if (cluster != null) {
    try {
      cluster.close();
    } catch (Exception ex) {
      log.warn("Cannot properly close Jedis cluster", ex);
    }
    try {
      clusterCommandExecutor.destroy();
    } catch (Exception ex) {
      log.warn("Cannot properly close cluster command executor", ex);
    }
  }
}

代码示例来源:origin: penggle/jedis-ms-sentinel

@Test
public void masterSlaveFailover() throws Exception {
  Pool<ShardedMasterSlaveJedis> pool = this.getJedisPool();
  
  ShardedMasterSlaveJedis shardedMasterSlaveJedis = pool.getResource();
  System.out.println(">>> shardedMasterSlaveJedis = " + shardedMasterSlaveJedis);
  pool.returnResource(shardedMasterSlaveJedis);
  
  System.out.println("--------------------------------------");
  
  shardedMasterSlaveJedis = pool.getResource();
  System.out.println(">>> shardedMasterSlaveJedis = " + shardedMasterSlaveJedis);
  pool.returnResource(shardedMasterSlaveJedis);
  
  Thread.sleep(10L * 10);
  
  shardedMasterSlaveJedis = pool.getResource();
  System.out.println(">>> shardedMasterSlaveJedis = " + shardedMasterSlaveJedis);
  pool.returnResource(shardedMasterSlaveJedis);
  
  System.out.println("--------------------------------------");
  pool.destroy();
}

代码示例来源:origin: penggle/jedis-ms-sentinel

@Test
public void masterSetSlaveGet(){
  Date now = new Date();
  String nowTime = String.format("%tF %tT", now, now);
  Pool<MasterSlaveJedis> pool = this.getJedisPool();
  MasterSlaveJedis masterSlaveJedis = pool.getResource();
  
  System.out.println(">>> masterSlaveJedis = " + masterSlaveJedis.getClient().getHost() + ":" + masterSlaveJedis.getClient().getPort());
  System.out.println(">>> nowTime = " + nowTime);
  
  masterSlaveJedis.set("current_time", nowTime);
  
  LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(200));
  
  System.out.println("--------------------------------------");
  Jedis slaveJedis = masterSlaveJedis.opsForSlave();
  System.out.println(">>> slaveJedis = " + slaveJedis.getClient().getHost() + ":" + slaveJedis.getClient().getPort());
  System.out.println(">>> nowTime = " + slaveJedis.get("current_time"));
  
  //slaveJedis.set("current_time", nowTime + ".000"); // slave节点默认是只读的,如果在只读的slave节点上进行写操作会抛出异常
  pool.returnResource(masterSlaveJedis);
  
  System.out.println("--------------------------------------");
  pool.destroy();
}

代码示例来源:origin: penggle/jedis-ms-sentinel

@Test
public void getRourceAndReturnResource(){
  Pool<MasterSlaveJedis> pool = this.getJedisPool();
  MasterSlaveJedis masterSlaveJedis = pool.getResource();
  System.out.println(">>> masterSlaveJedis = " + masterSlaveJedis);
  pool.returnResource(masterSlaveJedis);
  
  System.out.println("--------------------------------------");
  for(int i = 0; i < 10; i++){
    masterSlaveJedis = pool.getResource();
    Jedis slaveJedis = masterSlaveJedis.opsForSlave(String.valueOf(i));
    System.out.println(">>> slaveJedis = " + slaveJedis.getClient().getHost() + ":" + slaveJedis.getClient().getPort());
    pool.returnResource(masterSlaveJedis);
  }
  System.out.println("--------------------------------------");
  
  System.out.println(">>> pool = " + pool);
  pool.destroy();
  System.out.println(">>> pool = " + pool);
  System.out.println(pool.getResource());// 如果pool已经被销毁,调用pool.getResource()会抛出"Can not get a resource from pool"异常
}

代码示例来源:origin: penggle/jedis-ms-sentinel

@Test
public void masterSlaveFailover() throws Exception {
  Pool<MasterSlaveJedis> pool = this.getJedisPool();
  
  MasterSlaveJedis masterSlaveJedis = pool.getResource();
  System.out.println(">>> masterSlaveJedis = " + masterSlaveJedis.getClient().getHost() + ":" + masterSlaveJedis.getClient().getPort());
  pool.returnResource(masterSlaveJedis);
  
  System.out.println("--------------------------------------");
  
  masterSlaveJedis = pool.getResource();
  System.out.println(">>> masterSlaveJedis = " + masterSlaveJedis.getClient().getHost() + ":" + masterSlaveJedis.getClient().getPort());
  pool.returnResource(masterSlaveJedis);
  
  Thread.sleep(120000L * 10);
  
  masterSlaveJedis = pool.getResource();
  System.out.println(">>> masterSlaveJedis = " + masterSlaveJedis.getClient().getHost() + ":" + masterSlaveJedis.getClient().getPort());
  pool.returnResource(masterSlaveJedis);
  
  System.out.println("--------------------------------------");
  pool.destroy();
}

相关文章