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


Java JedisSentinelPool.destroy方法代码示例

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


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

示例1: customClientName

import redis.clients.jedis.JedisSentinelPool; //导入方法依赖的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

示例2: testSentinel

import redis.clients.jedis.JedisSentinelPool; //导入方法依赖的package包/类
@Test
public void testSentinel() {
    JedisSentinelPool sentinelPool = ClientBuilder.redisSentinel(appId)
            .setConnectionTimeout(2000)
            .setSoTimeout(1000)
            .build();
    HostAndPort currentHostMaster = sentinelPool.getCurrentHostMaster();
    logger.info("current master: {}", currentHostMaster.toString());

    Jedis jedis = sentinelPool.getResource();
    for (int i = 0; i < 10; i++) {
        jedis.lpush("mylist", "list-" + i);
    }
    jedis.close();
    sentinelPool.destroy();
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:17,代码来源:RedisSentinelTest.java

示例3: initializeWithNotAvailableSentinelsShouldThrowException

import redis.clients.jedis.JedisSentinelPool; //导入方法依赖的package包/类
@Test(expected = JedisConnectionException.class)
public void initializeWithNotAvailableSentinelsShouldThrowException() {
  Set<String> wrongSentinels = new HashSet<String>();
  wrongSentinels.add(new HostAndPort("localhost", 65432).toString());
  wrongSentinels.add(new HostAndPort("localhost", 65431).toString());

  JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, wrongSentinels);
  pool.destroy();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:10,代码来源:JedisSentinelPoolTest.java

示例4: returnResourceShouldResetState

import redis.clients.jedis.JedisSentinelPool; //导入方法依赖的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

示例5: returnResourceShouldResetState

import redis.clients.jedis.JedisSentinelPool; //导入方法依赖的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");
    jedis.close();

    jedis2 = pool.getResource();

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

    pool.destroy();
  }
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:32,代码来源:JedisSentinelPoolTest.java

示例6: addSentinel

import redis.clients.jedis.JedisSentinelPool; //导入方法依赖的package包/类
@Override
public boolean addSentinel(long appId, String sentinelHost) {
    AppDesc appDesc = appDao.getAppDescById(appId);
    JedisSentinelPool jedisSentinelPool = redisCenter.getJedisSentinelPool(appDesc);
    if (jedisSentinelPool == null) {
        return false;
    }
    List<InstanceInfo> instanceInfos = instanceDao.getInstListByAppId(appId);
    String masterName = null;
    for (Iterator<InstanceInfo> i = instanceInfos.iterator(); i.hasNext(); ) {
        InstanceInfo instanceInfo = i.next();
        if (instanceInfo.getType() != ConstUtils.CACHE_REDIS_SENTINEL) {
            i.remove();
            continue;
        }
        if (masterName == null && StringUtils.isNotBlank(instanceInfo.getCmd())) {
            masterName = instanceInfo.getCmd();
        }
    }
    Jedis jedis = null;
    String masterHost = null;
    Integer masterPort = null;
    try {
        jedis = jedisSentinelPool.getResource();
        masterHost = jedis.getClient().getHost();
        masterPort = jedis.getClient().getPort();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    } finally {
        jedis.close();
        jedisSentinelPool.destroy();
    }
    boolean isRun = runSentinel(appDesc, sentinelHost, masterName, masterHost, masterPort);
    if (!isRun) {
        return false;
    }
    return true;
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:39,代码来源:RedisDeployCenterImpl.java

示例7: test

import redis.clients.jedis.JedisSentinelPool; //导入方法依赖的package包/类
@Test
public void test() {
	GenericObjectPoolConfig config = new GenericObjectPoolConfig();
	config.setMaxTotal(1);
	config.setBlockWhenExhausted(false);
	Set<String> sentinels = new HashSet<String>();
	sentinels.add(new HostAndPort("192.168.0.36", 26379).toString());
	JedisSentinelPool pool = new JedisSentinelPool("mymaster", sentinels,
			config, 10000000);
	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)
			pool.returnResource(jedis2);

		pool.destroy();
	}

}
 
开发者ID:zhangxinhang,项目名称:mds,代码行数:37,代码来源:SentinelTest.java

示例8: main

import redis.clients.jedis.JedisSentinelPool; //导入方法依赖的package包/类
public static void main(String[] args) {
	GenericObjectPoolConfig config = new GenericObjectPoolConfig();
	config.setMaxTotal(1);
	config.setBlockWhenExhausted(false);
	Set<String> sentinels = new HashSet<String>();
	sentinels.add(new HostAndPort("192.168.0.36", 26379).toString());
	JedisSentinelPool pool = new JedisSentinelPool("mymaster", sentinels,
			config, 10000000);
	Jedis jedis = pool.getResource();
	jedis.set("hello", "world");
	System.out.println(jedis.get("hello"));
	pool.destroy();
}
 
开发者ID:zhangxinhang,项目名称:mds,代码行数:14,代码来源:SentinelTest.java

示例9: initializeWithNotMonitoredMasterNameShouldThrowException

import redis.clients.jedis.JedisSentinelPool; //导入方法依赖的package包/类
@Test(expected = JedisException.class)
public void initializeWithNotMonitoredMasterNameShouldThrowException() {
  final String wrongMasterName = "wrongMasterName";
  JedisSentinelPool pool = new JedisSentinelPool(wrongMasterName, sentinels);
  pool.destroy();
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:7,代码来源:JedisSentinelPoolTest.java

示例10: disconnect

import redis.clients.jedis.JedisSentinelPool; //导入方法依赖的package包/类
public void disconnect() {
    for (JedisSentinelPool jedis : getAllShards()) {
        jedis.destroy();
    }
}
 
开发者ID:sunguangran,项目名称:navi,代码行数:6,代码来源:SentinelPoolBinaryShardedJedis.java


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