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


Java JedisShardInfo.setPassword方法代碼示例

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


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

示例1: connectWithShardInfoAndCustomHostnameVerifier

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
/**
 * Tests opening an SSL/TLS connection to redis with a custom hostname
 * verifier.
 */
@Test
public void connectWithShardInfoAndCustomHostnameVerifier() {
  final URI uri = URI.create("rediss://localhost:6390");
  final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
  final SSLParameters sslParameters = new SSLParameters();

  HostnameVerifier hostnameVerifier = new BasicHostnameVerifier();
  JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, hostnameVerifier);
  shardInfo.setPassword("foobared");

  Jedis jedis = new Jedis(shardInfo);
  jedis.get("foo");
  jedis.disconnect();
  jedis.close();
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:20,代碼來源:SSLJedisTest.java

示例2: connectWithShardInfoAndCustomSocketFactory

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
/**
 * Tests opening an SSL/TLS connection to redis with a custom socket factory.
 */
@Test
public void connectWithShardInfoAndCustomSocketFactory() throws Exception {
  final URI uri = URI.create("rediss://localhost:6390");
  final SSLSocketFactory sslSocketFactory = createTrustStoreSslSocketFactory();
  final SSLParameters sslParameters = new SSLParameters();

  HostnameVerifier hostnameVerifier = new BasicHostnameVerifier();
  JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, hostnameVerifier);
  shardInfo.setPassword("foobared");

  Jedis jedis = new Jedis(shardInfo);
  jedis.get("foo");
  jedis.disconnect();
  jedis.close();
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:19,代碼來源:SSLJedisTest.java

示例3: connectWithShardInfoAndCustomHostnameVerifierByIpAddress

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
/**
 * Tests opening an SSL/TLS connection to redis with a custom hostname
 * verifier. This test should fail because "127.0.0.1" does not match the
 * certificate subject common name and there are no subject alternative names
 * in the certificate.
 */
@Test
public void connectWithShardInfoAndCustomHostnameVerifierByIpAddress() {
  final URI uri = URI.create("rediss://127.0.0.1:6390");
  final SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
  final SSLParameters sslParameters = new SSLParameters();

  HostnameVerifier hostnameVerifier = new BasicHostnameVerifier();
  JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, sslParameters, hostnameVerifier);
  shardInfo.setPassword("foobared");

  Jedis jedis = new Jedis(shardInfo);
  try {
    jedis.get("foo");
    Assert.fail("The code did not throw the expected JedisConnectionException.");
  } catch (JedisConnectionException e) {
    Assert.assertEquals("The JedisConnectionException does not contain the expected message.",
        "The connection to '127.0.0.1' failed ssl/tls hostname verification.", e.getMessage());
  }

  try {
    jedis.close();
  } catch (Throwable e1) {
    // Expected.
  }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:32,代碼來源:SSLJedisTest.java

示例4: JU_Puts

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
public JU_Puts()
{
    // ���÷ֲ�ʽ��Ⱥ����
    List<JedisShardInfo> v_JSIs = new ArrayList<JedisShardInfo>();
    
    v_JSIs.add(new JedisShardInfo("192.168.105.105" ,6379));  // ��Ⱥ1�е���������
    // v_JSIs.add(new JedisShardInfo("192.168.105.109" ,6379));  // ��Ⱥ2�е���������
    
    // ��������
    for (JedisShardInfo v_Shard : v_JSIs)
    {
        v_Shard.setPassword("redis");
    }
    
    redis = new Redis(v_JSIs);
    redis.setRunMode(RunMode.$Backup);
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.Redis,代碼行數:18,代碼來源:JU_Puts.java

示例5: setUp

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
  Jedis jedis = new Jedis(redis1.getHost(), redis1.getPort());
  jedis.auth("foobared");
  jedis.flushAll();
  jedis.disconnect();
  jedis = new Jedis(redis2.getHost(), redis2.getPort());
  jedis.auth("foobared");
  jedis.flushAll();
  jedis.disconnect();

  JedisShardInfo shardInfo1 = new JedisShardInfo(redis1.getHost(), redis1.getPort());
  JedisShardInfo shardInfo2 = new JedisShardInfo(redis2.getHost(), redis2.getPort());
  shardInfo1.setPassword("foobared");
  shardInfo2.setPassword("foobared");
  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  shards.add(shardInfo1);
  shards.add(shardInfo2);
  this.jedis = new ShardedJedis(shards);

}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:22,代碼來源:ShardedJedisPipelineTest.java

示例6: testSyncWithNoCommandQueued

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
@Test
public void testSyncWithNoCommandQueued() {
  JedisShardInfo shardInfo1 = new JedisShardInfo(redis1.getHost(), redis1.getPort());
  JedisShardInfo shardInfo2 = new JedisShardInfo(redis2.getHost(), redis2.getPort());
  shardInfo1.setPassword("foobared");
  shardInfo2.setPassword("foobared");
  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  shards.add(shardInfo1);
  shards.add(shardInfo2);

  ShardedJedis jedis2 = new ShardedJedis(shards);

  ShardedJedisPipeline pipeline = jedis2.pipelined();
  pipeline.sync();

  jedis2.close();

  jedis2 = new ShardedJedis(shards);
  pipeline = jedis2.pipelined();
  List<Object> resp = pipeline.syncAndReturnAll();
  assertTrue(resp.isEmpty());

  jedis2.close();
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:25,代碼來源:ShardedJedisPipelineTest.java

示例7: testShardNormal

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
public void testShardNormal() {// 13.619秒
	JedisShardInfo jedis = new JedisShardInfo("120.25.241.144", 6379);
	jedis.setPassword("b840fc02d52404542994");

	List<JedisShardInfo> shards = Arrays.asList(jedis);
	ShardedJedis sharding = new ShardedJedis(shards);

	long start = System.currentTimeMillis();
	for (int i = 0; i < 1000; i++) {
		sharding.set("n" + i, "n" + i);
		System.out.println(i);
	}
	long end = System.currentTimeMillis();
	System.out.println("共花費:" + (end - start) / 1000.0 + "秒");

	sharding.disconnect();
	try {
		Closeables.close(sharding, true);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:xiangxik,項目名稱:java-platform,代碼行數:23,代碼來源:RedisExample.java

示例8: testShardPipelined

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
public void testShardPipelined() {// 0.127秒
	JedisShardInfo jedis = new JedisShardInfo("120.25.241.144", 6379);
	jedis.setPassword("b840fc02d52404542994");

	List<JedisShardInfo> shards = Arrays.asList(jedis);
	ShardedJedis sharding = new ShardedJedis(shards);
	ShardedJedisPipeline pipeline = sharding.pipelined();

	long start = System.currentTimeMillis();
	for (int i = 0; i < 1000; i++) {
		pipeline.set("n" + i, "n" + i);
		System.out.println(i);
	}
	pipeline.syncAndReturnAll();
	long end = System.currentTimeMillis();
	System.out.println("共花費:" + (end - start) / 1000.0 + "秒");

	sharding.disconnect();
	try {
		Closeables.close(sharding, true);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:xiangxik,項目名稱:java-platform,代碼行數:25,代碼來源:RedisExample.java

示例9: main

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
/**
 * @param args
 */
public static void main(String[] args) {
	
	List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
	JedisShardInfo shard = new JedisShardInfo("192.168.1.250", 6379);
	shard.setPassword("redisadmin");
	shards.add( shard );
	ShardRedisPlugin redis = new ShardRedisPlugin(shards);
	redis.start();
	
	ShardCache cache = ShardRedis.userShard();
	cache.set("zcq", "--BruceZCQ---");
	cache.set("zcq1", "--BruceZCQ---");
	
	Map<Object, Object> map = new HashMap<Object, Object>();
	map.put("name", "朱叢啟");
	map.put("addr", "北京市");
	
	cache.hmset("map1", map);
	
	System.out.println(cache.get("zcq1"));
	
	System.out.println(cache.hvals("map1"));
}
 
開發者ID:OpeningO,項目名稱:JFinal-ext2,代碼行數:27,代碼來源:ShardRedisCache.java

示例10: main

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
/**
 * @param args
 */
public static void main(String[] args) {
	List<JedisShardInfo> list = new LinkedList<JedisShardInfo>();
	JedisShardInfo jedisShardInfo1 = new JedisShardInfo(ip1, port);
	jedisShardInfo1.setPassword(JedisConstant.password);
	list.add(jedisShardInfo1);
	JedisShardInfo jedisShardInfo2 = new JedisShardInfo(ip2, port);
	jedisShardInfo2.setPassword(JedisConstant.password);
	list.add(jedisShardInfo2);
	ShardedJedisPool pool = new ShardedJedisPool(config, list);
	for (int i = 0; i < 2000; i++) {
		ShardedJedis jedis = pool.getResource();
		String key = "howsun_" + i;
		//jedis.set(key, UUID.randomUUID().toString());
		System.out.println(key + "\t" + jedis.get(key) + "\t" + jedis.toString());
		pool.returnResource(jedis);
	}
}
 
開發者ID:howsun,項目名稱:howsun-javaee-framework,代碼行數:21,代碼來源:JedisShartClient.java

示例11: newShardedJedisPool

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
/**
 * Create a new {@link ShardedJedisPool}.
 * 
 * @param poolConfig
 *            format {@code host1:port1,host2:port2,...}, default Redis port is used if not
 *            specified
 * @param password
 * @param timeoutMs
 * @return
 */
public static ShardedJedisPool newShardedJedisPool(JedisPoolConfig poolConfig,
        String hostsAndPorts, String password, int timeoutMs) {
    List<JedisShardInfo> shards = new ArrayList<>();
    String[] hapList = hostsAndPorts.split("[,;\\s]+");
    for (String hostAndPort : hapList) {
        String[] tokens = hostAndPort.split(":");
        String host = tokens.length > 0 ? tokens[0] : Protocol.DEFAULT_HOST;
        int port = tokens.length > 1 ? Integer.parseInt(tokens[1]) : Protocol.DEFAULT_PORT;
        JedisShardInfo shardInfo = new JedisShardInfo(host, port, timeoutMs);
        shardInfo.setPassword(password);
        shards.add(shardInfo);
    }
    ShardedJedisPool jedisPool = new ShardedJedisPool(poolConfig, shards);
    return jedisPool;
}
 
開發者ID:DDTH,項目名稱:ddth-commons,代碼行數:26,代碼來源:JedisUtils.java

示例12: setSharedJedisPool

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
public static void setSharedJedisPool() {
        JedisPoolConfig config = new JedisPoolConfig();//Jedis池配置
        // 共享jedis池,用於集群
        List<JedisShardInfo> jedisShardInfos = new ArrayList<>();
        JedisShardInfo node01 = new JedisShardInfo("120.24.238.195", 6379);
//        JedisShardInfo node02 = new JedisShardInfo("120.25.162.32", 6379);
//        JedisShardInfo node03 = new JedisShardInfo("112.74.114.226", 6379);
        node01.setPassword("110110");
        jedisShardInfos.add(node01);
//        jedisShardInfos.add(node02);
//        jedisShardInfos.add(node03);
        pool = new ShardedJedisPool(config, jedisShardInfos);
        isSetup = true;
    }
 
開發者ID:wanghan0501,項目名稱:WiFiProbeAnalysis,代碼行數:15,代碼來源:JedisPoolManager.java

示例13: connectWithShardInfoAndEmptyTrustStore

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
/**
 * Tests opening an SSL/TLS connection to redis with an empty certificate
 * trust store. This test should fail because there is no trust anchor for the
 * redis server certificate.
 * 
 * @throws Exception
 */
@Test
public void connectWithShardInfoAndEmptyTrustStore() throws Exception {

  final URI uri = URI.create("rediss://localhost:6390");
  final SSLSocketFactory sslSocketFactory = createTrustNoOneSslSocketFactory();

  JedisShardInfo shardInfo = new JedisShardInfo(uri, sslSocketFactory, null, null);
  shardInfo.setPassword("foobared");

  Jedis jedis = new Jedis(shardInfo);
  try {
    jedis.get("foo");
    Assert.fail("The code did not throw the expected JedisConnectionException.");
  } catch (JedisConnectionException e) {
    Assert.assertEquals("Unexpected first inner exception.",
        SSLException.class, e.getCause().getClass());
    Assert.assertEquals("Unexpected second inner exception.",
        RuntimeException.class, e.getCause().getCause().getClass());
    Assert.assertEquals("Unexpected third inner exception.",
        InvalidAlgorithmParameterException.class, e.getCause().getCause().getCause().getClass());
  }

  try {
    jedis.close();
  } catch (Throwable e1) {
    // Expected.
  }
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:36,代碼來源:SSLJedisTest.java

示例14: connectWithShardInfo

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
@Test
public void connectWithShardInfo() {
  JedisShardInfo shardInfo = new JedisShardInfo("localhost", Protocol.DEFAULT_PORT);
  shardInfo.setPassword("foobared");
  Jedis jedis = new Jedis(shardInfo);
  jedis.get("foo");
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:8,代碼來源:JedisTest.java

示例15: connectionFactory

import redis.clients.jedis.JedisShardInfo; //導入方法依賴的package包/類
@ConditionalOnMissingBean(JedisConnectionFactory.class)
@Bean
public JedisConnectionFactory connectionFactory(RedisConfig config) {
    if (StringUtils.isEmpty(config.getHost()) || StringUtils.isEmpty(config.getPort())) {
        throw new IllegalStateException("missing required redis configuration properties " +
                "(spring.redis.host or spring.redis.port)");
    }
    JedisShardInfo shardInfo = new JedisShardInfo(config.host, config.port, "redisServer");
    shardInfo.setPassword(config.password);
    return new JedisConnectionFactory(shardInfo);
}
 
開發者ID:Catalysts,項目名稱:cat-boot,代碼行數:12,代碼來源:SpringSessionConfig.java


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