Package redis.clients.jedis

Examples of redis.clients.jedis.HostAndPort


      assertTrue(inMasters);

      List<String> masterHostAndPort = j
        .sentinelGetMasterAddrByName(MASTER_NAME);
      HostAndPort masterFromSentinel = new HostAndPort(
        masterHostAndPort.get(0),
        Integer.parseInt(masterHostAndPort.get(1)));
      assertEquals(master, masterFromSentinel);

      List<Map<String, String>> slaves = j.sentinelSlaves(MASTER_NAME);
View Full Code Here


    sentinelForFailover.getPort());

  try {
      List<String> masterHostAndPort = j
        .sentinelGetMasterAddrByName(FAILOVER_MASTER_NAME);
      HostAndPort currentMaster = new HostAndPort(
        masterHostAndPort.get(0),
        Integer.parseInt(masterHostAndPort.get(1)));

      JedisSentinelTestUtil.waitForNewPromotedMaster(
        FAILOVER_MASTER_NAME, j, j2);

      masterHostAndPort = j
        .sentinelGetMasterAddrByName(FAILOVER_MASTER_NAME);
      HostAndPort newMaster = new HostAndPort(masterHostAndPort.get(0),
        Integer.parseInt(masterHostAndPort.get(1)));

      assertNotEquals(newMaster, currentMaster);
  } finally {
      j.close();
View Full Code Here

      try {
          port = Integer.parseInt(hostAndPort[1]);
      } catch (final NumberFormatException nfe) {
      }

      envHostsAndPorts.add(new HostAndPort(host, port));
        }
    }

    return envHostsAndPorts;
      }
View Full Code Here

    public void testMovedExceptionParameters() {
  try {
      node1.set("foo", "bar");
  } catch (JedisMovedDataException jme) {
      assertEquals(12182, jme.getSlot());
      assertEquals(new HostAndPort("127.0.0.1", 7381),
        jme.getTargetNode());
      return;
  }
  fail();
    }
View Full Code Here

    }

    @Test
    public void testDiscoverNodesAutomatically() {
  Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
  jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
  JedisCluster jc = new JedisCluster(jedisClusterNode);
  assertEquals(3, jc.getClusterNodes().size());
    }
View Full Code Here

    }

    @Test
    public void testCalculateConnectionPerSlot() {
  Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
  jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
  JedisCluster jc = new JedisCluster(jedisClusterNode);
  jc.set("foo", "bar");
  jc.set("test", "test");
  assertEquals("bar", node3.get("foo"));
  assertEquals("test", node2.get("test"));
View Full Code Here

  node2.clusterSetSlotImporting(15363, node3Id);
  try {
      node2.set("e", "e");
  } catch (JedisMovedDataException jme) {
      assertEquals(15363, jme.getSlot());
      assertEquals(new HostAndPort(localHost, nodeInfo3.getPort()),
        jme.getTargetNode());
  }

  try {
      node3.set("e", "e");
  } catch (JedisAskDataException jae) {
      assertEquals(15363, jae.getSlot());
      assertEquals(new HostAndPort(localHost, nodeInfo2.getPort()),
        jae.getTargetNode());
  }

  jc.set("e", "e");

  try {
      node2.get("e");
  } catch (JedisMovedDataException jme) {
      assertEquals(15363, jme.getSlot());
      assertEquals(new HostAndPort(localHost, nodeInfo3.getPort()),
        jme.getTargetNode());
  }
  try {
      node3.get("e");
  } catch (JedisAskDataException jae) {
      assertEquals(15363, jae.getSlot());
      assertEquals(new HostAndPort(localHost, nodeInfo2.getPort()),
        jae.getTargetNode());
  }

  assertEquals("e", jc.get("e"));
View Full Code Here

  node4.clusterSetSlotImporting(15363, node3Id);
  try {
      node4.set("e", "e");
  } catch (JedisMovedDataException jme) {
      assertEquals(15363, jme.getSlot());
      assertEquals(new HostAndPort(localHost, nodeInfo3.getPort()),
        jme.getTargetNode());
  }

  try {
      node3.set("e", "e");
  } catch (JedisAskDataException jae) {
      assertEquals(15363, jae.getSlot());
      assertEquals(new HostAndPort(localHost, nodeInfo4.getPort()),
        jae.getTargetNode());
  }

  jc.set("e", "e");

  try {
      node4.get("e");
  } catch (JedisMovedDataException jme) {
      assertEquals(15363, jme.getSlot());
      assertEquals(new HostAndPort(localHost, nodeInfo3.getPort()),
        jme.getTargetNode());
  }
  try {
      node3.get("e");
  } catch (JedisAskDataException jae) {
      assertEquals(15363, jae.getSlot());
      assertEquals(new HostAndPort(localHost, nodeInfo4.getPort()),
        jae.getTargetNode());
  }

  assertEquals("e", jc.get("e"));
View Full Code Here

    }

    @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);
View Full Code Here

    }

    @Test
    public void testAskResponse() 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");
  node3.clusterSetSlotImporting(slot51,
    JedisClusterTestUtil.getNodeId(node2.clusterNodes()));
  node2.clusterSetSlotMigrating(slot51,
View Full Code Here

TOP

Related Classes of redis.clients.jedis.HostAndPort

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.