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


Java JedisClusterTestUtil.waitForClusterReady方法代碼示例

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


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

示例1: testReadonly

import redis.clients.jedis.tests.utils.JedisClusterTestUtil; //導入方法依賴的package包/類
@Test
public void testReadonly() throws Exception {
  node1.clusterMeet(localHost, nodeInfoSlave2.getPort());
  JedisClusterTestUtil.waitForClusterReady(node1, node2, node3, nodeSlave2);

  for (String nodeInfo : node2.clusterNodes().split("\n")) {
    if (nodeInfo.contains("myself")) {
      nodeSlave2.clusterReplicate(nodeInfo.split(" ")[0]);
      break;
    }
  }
  try {
    nodeSlave2.get("test");
    fail();
  } catch (JedisMovedDataException e) {
  }
  nodeSlave2.readonly();
  nodeSlave2.get("test");

  nodeSlave2.clusterReset(Reset.SOFT);
  nodeSlave2.flushDB();
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:23,代碼來源:JedisClusterTest.java

示例2: testReadonly

import redis.clients.jedis.tests.utils.JedisClusterTestUtil; //導入方法依賴的package包/類
@Test
public void testReadonly() throws Exception {
  node1.clusterMeet(localHost, nodeInfoSlave2.getPort());
  JedisClusterTestUtil.waitForClusterReady(node1, node2, node3, nodeSlave2);

  ClusterNodeInformationParser nodeInfoParser = new ClusterNodeInformationParser();
  for (String nodeInfo : node2.clusterNodes().split("\n")) {
    if (nodeInfo.contains("myself")) {
      nodeSlave2.clusterReplicate(nodeInfo.split(" ")[0]);
      break;
    }
  }
  try {
    nodeSlave2.get("test");
    fail();
  } catch (JedisMovedDataException e) {
  }
  nodeSlave2.readonly();
  nodeSlave2.get("test");

  nodeSlave2.clusterReset(Reset.SOFT);
  nodeSlave2.flushDB();
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:24,代碼來源:JedisClusterTest.java

示例3: setUp

import redis.clients.jedis.tests.utils.JedisClusterTestUtil; //導入方法依賴的package包/類
@Before
public void setUp() throws InterruptedException {
  node1 = new Jedis(nodeInfo1.getHost(), nodeInfo1.getPort());
  node1.auth("cluster");
  node1.flushAll();

  node2 = new Jedis(nodeInfo2.getHost(), nodeInfo2.getPort());
  node2.auth("cluster");
  node2.flushAll();

  node3 = new Jedis(nodeInfo3.getHost(), nodeInfo3.getPort());
  node3.auth("cluster");
  node3.flushAll();

  node4 = new Jedis(nodeInfo4.getHost(), nodeInfo4.getPort());
  node4.auth("cluster");
  node4.flushAll();

  nodeSlave2 = new Jedis(nodeInfoSlave2.getHost(), nodeInfoSlave2.getPort());
  nodeSlave2.auth("cluster");
  nodeSlave2.flushAll();
  // ---- configure cluster

  // add nodes to cluster
  node1.clusterMeet(localHost, nodeInfo2.getPort());
  node1.clusterMeet(localHost, nodeInfo3.getPort());

  // split available slots across the three nodes
  int slotsPerNode = JedisCluster.HASHSLOTS / 3;
  int[] node1Slots = new int[slotsPerNode];
  int[] node2Slots = new int[slotsPerNode + 1];
  int[] node3Slots = new int[slotsPerNode];
  for (int i = 0, slot1 = 0, slot2 = 0, slot3 = 0; i < JedisCluster.HASHSLOTS; i++) {
    if (i < slotsPerNode) {
      node1Slots[slot1++] = i;
    } else if (i > slotsPerNode * 2) {
      node3Slots[slot3++] = i;
    } else {
      node2Slots[slot2++] = i;
    }
  }

  node1.clusterAddSlots(node1Slots);
  node2.clusterAddSlots(node2Slots);
  node3.clusterAddSlots(node3Slots);

  JedisClusterTestUtil.waitForClusterReady(node1, node2, node3);
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:49,代碼來源:JedisClusterTest.java

示例4: testRecalculateSlotsWhenMoved

import redis.clients.jedis.tests.utils.JedisClusterTestUtil; //導入方法依賴的package包/類
@Test
public void testRecalculateSlotsWhenMoved() throws InterruptedException {
  Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
  jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
  JedisCluster jc = new JedisCluster(jedisClusterNode, DEFAULT_TIMEOUT, DEFAULT_TIMEOUT, DEFAULT_REDIRECTIONS, "cluster", DEFAULT_CONFIG);
  int slot51 = JedisClusterCRC16.getSlot("51");
  node2.clusterDelSlots(slot51);
  node3.clusterDelSlots(slot51);
  node3.clusterAddSlots(slot51);

  JedisClusterTestUtil.waitForClusterReady(node1, node2, node3);
  jc.set("51", "foo");
  assertEquals("foo", jc.get("51"));
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:15,代碼來源:JedisClusterTest.java

示例5: testRecalculateSlotsWhenMoved

import redis.clients.jedis.tests.utils.JedisClusterTestUtil; //導入方法依賴的package包/類
@Test
public void testRecalculateSlotsWhenMoved() throws InterruptedException {
  Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
  jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
  JedisCluster jc = new JedisCluster(jedisClusterNode);
  int slot51 = JedisClusterCRC16.getSlot("51");
  node2.clusterDelSlots(slot51);
  node3.clusterDelSlots(slot51);
  node3.clusterAddSlots(slot51);

  JedisClusterTestUtil.waitForClusterReady(node1, node2, node3);
  jc.set("51", "foo");
  assertEquals("foo", jc.get("51"));
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:15,代碼來源:JedisClusterTest.java

示例6: setUp

import redis.clients.jedis.tests.utils.JedisClusterTestUtil; //導入方法依賴的package包/類
@Before
public void setUp() throws InterruptedException {
  node1 = new Jedis(nodeInfo1.getHost(), nodeInfo1.getPort());
  node1.connect();
  node1.flushAll();

  node2 = new Jedis(nodeInfo2.getHost(), nodeInfo2.getPort());
  node2.connect();
  node2.flushAll();

  node3 = new Jedis(nodeInfo3.getHost(), nodeInfo3.getPort());
  node3.connect();
  node3.flushAll();

  node4 = new Jedis(nodeInfo4.getHost(), nodeInfo4.getPort());
  node4.connect();
  node4.flushAll();

  nodeSlave2 = new Jedis(nodeInfoSlave2.getHost(), nodeInfoSlave2.getPort());
  nodeSlave2.connect();
  nodeSlave2.flushAll();
  // ---- configure cluster

  // add nodes to cluster
  node1.clusterMeet(localHost, nodeInfo2.getPort());
  node1.clusterMeet(localHost, nodeInfo3.getPort());

  // split available slots across the three nodes
  int slotsPerNode = JedisCluster.HASHSLOTS / 3;
  int[] node1Slots = new int[slotsPerNode];
  int[] node2Slots = new int[slotsPerNode + 1];
  int[] node3Slots = new int[slotsPerNode];
  for (int i = 0, slot1 = 0, slot2 = 0, slot3 = 0; i < JedisCluster.HASHSLOTS; i++) {
    if (i < slotsPerNode) {
      node1Slots[slot1++] = i;
    } else if (i > slotsPerNode * 2) {
      node3Slots[slot3++] = i;
    } else {
      node2Slots[slot2++] = i;
    }
  }

  node1.clusterAddSlots(node1Slots);
  node2.clusterAddSlots(node2Slots);
  node3.clusterAddSlots(node3Slots);

  JedisClusterTestUtil.waitForClusterReady(node1, node2, node3);
}
 
開發者ID:sohutv,項目名稱:cachecloud,代碼行數:49,代碼來源:JedisClusterTest.java


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