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


Java JedisShardInfo.getTimeout方法代碼示例

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


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

示例1: checkEachRedisServerRunOk

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
@Test(description = "檢查每一台Redis服務器是否運行正常")
public void checkEachRedisServerRunOk() {
    List<JedisShardInfo> shards = RedisConfigUtils.parseRedisServerList(TestConfigUtils.getRedisServers(),
                                                                        TestConfigUtils.getTimeoutMillis());
    for (JedisShardInfo shardInfo : shards) {
        // try-with-resources, in Java SE 7 and later
        try (JedisPool pool = new JedisPool(new JedisPoolConfig(), shardInfo.getHost(), shardInfo.getPort(),
                                            shardInfo.getTimeout())) {
            // Jedis implements Closeable. Hence, the jedis instance will be auto-closed after the last statement.
            try (Jedis jedis = pool.getResource()) {
                assertEquals(jedis.ping(), "PONG");
            }
        }
    }
}
 
開發者ID:EdwardLee03,項目名稱:jedis-x,代碼行數:16,代碼來源:RedisServiceTest.java

示例2: Redis

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
public Redis(JedisPoolConfig i_PoolConfig ,List<JedisShardInfo> i_JedisShardInfos)
{
    if ( JavaHelp.isNull(i_JedisShardInfos) )
    {
        throw new NullPointerException("HostAndPorts is null.");
    }
    
    shardInfoMap    = new ListMap<String ,JedisShardInfo>(i_JedisShardInfos.size() ,false);
    exceptionShards = new ListMap<String ,JedisShardInfo>(i_JedisShardInfos.size() ,false);
    
    for (JedisShardInfo v_Host : i_JedisShardInfos)
    {
        if ( JavaHelp.isNull(v_Host.getHost()) )
        {
            throw new NullPointerException("IP is null.");
        }
        
        if ( 0 >= v_Host.getPort() || v_Host.getPort() >= 65535 )
        {
            throw new VerifyError("Port is not 0~65535.");
        }
        
        if ( JavaHelp.isNull(v_Host.getName()) )
        {
            String         v_Name  = v_Host.getHost() + ":" + v_Host.getPort();
            JedisShardInfo v_Clone = new JedisShardInfo(v_Host.getHost() ,v_Host.getPort() ,v_Host.getTimeout() ,v_Name);
            v_Clone.setPassword(v_Host.getPassword());
            
            if ( shardInfoMap.containsKey(v_Name) )
            {
                throw new VerifyError("JedisShardInfo name[" + v_Name + "] is same.");
            }
            shardInfoMap.put(v_Name ,v_Clone);
        }
        else
        {
            if ( shardInfoMap.containsKey(v_Host.getName()) )
            {
                throw new VerifyError("JedisShardInfo name[" + v_Host.getName() + "] is same.");
            }
            shardInfoMap.put(v_Host.getName() ,v_Host);
        }
    }
    
    JedisPoolConfig v_PoolConfig = i_PoolConfig;
    if ( v_PoolConfig == null )
    {
        v_PoolConfig = new JedisPoolConfig();
        v_PoolConfig.setMaxTotal(1024);
        v_PoolConfig.setMaxIdle(10);
        v_PoolConfig.setMinIdle(1);
    }
    
    shardedPool = new ShardedJedisPool(v_PoolConfig ,JavaHelp.toList(shardInfoMap));
    
    if ( this.shardInfoMap.size() <= 1 )
    {
        this.runMode = RunMode.$Backup;
    }
    else
    {
        this.runMode = RunMode.$Shard;
    }
    
    this.redisKey    = new RedisKey(this);
    this.redisString = new RedisString(this);
    this.redisSet    = new RedisSet(this);
    this.redisHash   = new RedisHash(this);
    this.redisServer = new RedisServer(this);
    this.isKeyOrder  = true;
    this.rowKeyType  = RowKeyType.$TableName_ID;
    this.xjavaID     = "XID_REDIS_" + StringHelp.getUUID();
    XJava.putObject(this.xjavaID ,this);
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.Redis,代碼行數:75,代碼來源:Redis.java


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