@Override public void clusterMeet(RedisClusterNode node) { Assert.notNull(node, "Cluster node must not be null for CLUSTER MEET command!"); Assert.hasText(node.getHost(), "Node to meet cluster must have a host!"); Assert.isTrue(node.getPort() > 0, "Node to meet cluster must have a port greater 0!"); RFuture<Void> f = executorService.writeAsync((String)null, StringCodec.INSTANCE, RedisCommands.CLUSTER_MEET, node.getHost(), node.getPort()); syncFuture(f); }
@Override public void clusterMeet(RedisClusterNode node) { Assert.notNull(node, "Cluster node must not be null for CLUSTER MEET command!"); Assert.hasText(node.getHost(), "Node to meet cluster must have a host!"); Assert.isTrue(node.getPort() > 0, "Node to meet cluster must have a port greater 0!"); RFuture<Void> f = executorService.writeAsync((String)null, StringCodec.INSTANCE, RedisCommands.CLUSTER_MEET, node.getHost(), node.getPort()); syncFuture(f); }
@Override public void clusterMeet(RedisClusterNode node) { Assert.notNull(node, "Cluster node must not be null for CLUSTER MEET command!"); Assert.hasText(node.getHost(), "Node to meet cluster must have a host!"); Assert.isTrue(node.getPort() > 0, "Node to meet cluster must have a port greater 0!"); RFuture<Void> f = executorService.writeAsync((String)null, StringCodec.INSTANCE, RedisCommands.CLUSTER_MEET, node.getHost(), node.getPort()); syncFuture(f); }
@Override public Collection<RedisClusterNode> clusterGetSlaves(RedisClusterNode master) { Iterable<RedisClusterNode> res = clusterGetNodes(); RedisClusterNode masterNode = null; for (Iterator<RedisClusterNode> iterator = res.iterator(); iterator.hasNext();) { RedisClusterNode redisClusterNode = iterator.next(); if (master.getHost().equals(redisClusterNode.getHost()) && master.getPort().equals(redisClusterNode.getPort())) { masterNode = redisClusterNode; break; } } if (masterNode == null) { throw new IllegalStateException("Unable to find master node: " + master); } for (Iterator<RedisClusterNode> iterator = res.iterator(); iterator.hasNext();) { RedisClusterNode redisClusterNode = iterator.next(); if (redisClusterNode.getMasterId() == null || !redisClusterNode.getMasterId().equals(masterNode.getId())) { iterator.remove(); } } return (Collection<RedisClusterNode>) res; }
protected MasterSlaveEntry getEntry(RedisClusterNode node) { MasterSlaveEntry entry = executorService.getConnectionManager().getEntry(new InetSocketAddress(node.getHost(), node.getPort())); return entry; }
@Override public Collection<RedisClusterNode> clusterGetSlaves(RedisClusterNode master) { Iterable<RedisClusterNode> res = clusterGetNodes(); RedisClusterNode masterNode = null; for (Iterator<RedisClusterNode> iterator = res.iterator(); iterator.hasNext();) { RedisClusterNode redisClusterNode = iterator.next(); if (master.getHost().equals(redisClusterNode.getHost()) && master.getPort().equals(redisClusterNode.getPort())) { masterNode = redisClusterNode; break; } } if (masterNode == null) { throw new IllegalStateException("Unable to find master node: " + master); } for (Iterator<RedisClusterNode> iterator = res.iterator(); iterator.hasNext();) { RedisClusterNode redisClusterNode = iterator.next(); if (redisClusterNode.getMasterId() == null || !redisClusterNode.getMasterId().equals(masterNode.getId())) { iterator.remove(); } } return (Collection<RedisClusterNode>) res; }
@Override public Collection<RedisClusterNode> clusterGetSlaves(RedisClusterNode master) { Iterable<RedisClusterNode> res = clusterGetNodes(); RedisClusterNode masterNode = null; for (Iterator<RedisClusterNode> iterator = res.iterator(); iterator.hasNext();) { RedisClusterNode redisClusterNode = iterator.next(); if (master.getHost().equals(redisClusterNode.getHost()) && master.getPort().equals(redisClusterNode.getPort())) { masterNode = redisClusterNode; break; } } if (masterNode == null) { throw new IllegalStateException("Unable to find master node: " + master); } for (Iterator<RedisClusterNode> iterator = res.iterator(); iterator.hasNext();) { RedisClusterNode redisClusterNode = iterator.next(); if (redisClusterNode.getMasterId() == null || !redisClusterNode.getMasterId().equals(masterNode.getId())) { iterator.remove(); } } return (Collection<RedisClusterNode>) res; }
@Override public void clusterMeet(RedisClusterNode node) { Assert.notNull(node, "Cluster node must not be null for CLUSTER MEET command!"); Assert.hasText(node.getHost(), "Node to meet cluster must have a host!"); Assert.isTrue(node.getPort() > 0, "Node to meet cluster must have a port greater 0!"); this.clusterCommandExecutor.executeCommandOnAllNodes( (LettuceClusterCommandCallback<String>) client -> client.clusterMeet(node.getHost(), node.getPort())); }
protected MasterSlaveEntry getEntry(RedisClusterNode node) { MasterSlaveEntry entry = executorService.getConnectionManager().getEntry(new InetSocketAddress(node.getHost(), node.getPort())); return entry; }
protected MasterSlaveEntry getEntry(RedisClusterNode node) { MasterSlaveEntry entry = executorService.getConnectionManager().getEntry(new InetSocketAddress(node.getHost(), node.getPort())); return entry; }
@Override public void clusterMeet(RedisClusterNode node) { Assert.notNull(node, "Cluster node must not be null for CLUSTER MEET command!"); Assert.hasText(node.getHost(), "Node to meet cluster must have a host!"); Assert.isTrue(node.getPort() > 0, "Node to meet cluster must have a port greater 0!"); clusterCommandExecutor.executeCommandOnAllNodes( (JedisClusterCommandCallback<String>) client -> client.clusterMeet(node.getHost(), node.getPort())); }
/** * Get the {@link RedisClusterNode} matching matching either {@link RedisClusterNode#getHost() host} and * {@link RedisClusterNode#getPort() port} or {@link RedisClusterNode#getId() nodeId} * * @param node must not be {@literal null} * @return never {@literal null}. * @throws ClusterStateFailureException */ public RedisClusterNode lookup(RedisClusterNode node) { Assert.notNull(node, "RedisClusterNode must not be null!"); if (nodes.contains(node) && StringUtils.hasText(node.getHost()) && StringUtils.hasText(node.getId())) { return node; } if (StringUtils.hasText(node.getHost()) && node.getPort() != null) { return lookup(node.getHost(), node.getPort()); } if (StringUtils.hasText(node.getId())) { return lookup(node.getId()); } throw new ClusterStateFailureException( String.format("Could not find node at %s. Have you provided either host and port or the nodeId?", node)); }
@Override public Long clusterCountKeysInSlot(int slot) { RedisClusterNode node = clusterGetNodeForSlot(slot); MasterSlaveEntry entry = executorService.getConnectionManager().getEntry(new InetSocketAddress(node.getHost(), node.getPort())); RFuture<Long> f = executorService.readAsync(entry, StringCodec.INSTANCE, RedisCommands.CLUSTER_COUNTKEYSINSLOT, slot); return syncFuture(f); }
@Override public Long clusterCountKeysInSlot(int slot) { RedisClusterNode node = clusterGetNodeForSlot(slot); MasterSlaveEntry entry = executorService.getConnectionManager().getEntry(new InetSocketAddress(node.getHost(), node.getPort())); RFuture<Long> f = executorService.readAsync(entry, StringCodec.INSTANCE, RedisCommands.CLUSTER_COUNTKEYSINSLOT, slot); return syncFuture(f); }
/** * Get the {@link RedisClusterNode} matching given {@literal host} and {@literal port}. * * @param host must not be {@literal null}. * @param port * @return never {@literal null}. * @throws ClusterStateFailureException */ public RedisClusterNode lookup(String host, int port) { for (RedisClusterNode node : nodes) { if (host.equals(node.getHost()) && (node.getPort() != null && port == node.getPort())) { return node; } } throw new ClusterStateFailureException( String.format("Could not find node at %s:%s. Is your cluster info up to date?", host, port)); }
@Override public Long clusterCountKeysInSlot(int slot) { RedisClusterNode node = clusterGetNodeForSlot(slot); MasterSlaveEntry entry = executorService.getConnectionManager().getEntry(new InetSocketAddress(node.getHost(), node.getPort())); RFuture<Long> f = executorService.readAsync(entry, StringCodec.INSTANCE, RedisCommands.CLUSTER_COUNTKEYSINSLOT, slot); return syncFuture(f); }
private Jedis getConnectionForSpecificNode(RedisClusterNode node) { RedisClusterNode member = topologyProvider.getTopology().lookup(node); if (member != null && connectionHandler != null) { return connectionHandler.getConnectionFromNode(new HostAndPort(member.getHost(), member.getPort())); } return null; }
@Override @SuppressWarnings("unchecked") public RedisClusterCommands<byte[], byte[]> getResourceForSpecificNode(RedisClusterNode node) { Assert.notNull(node, "Node must not be null!"); if (connection == null) { synchronized (this) { if (connection == null) { this.connection = connectionProvider.getConnection(StatefulRedisClusterConnection.class); } } } try { return connection.getConnection(node.getHost(), node.getPort()).sync(); } catch (RedisException e) { throw new DataAccessResourceFailureException(e.getMessage(), e); } }
@Override public void clusterMeet(RedisClusterNode node) { Assert.notNull(node, "Cluster node must not be null for CLUSTER MEET command!"); Assert.hasText(node.getHost(), "Node to meet cluster must have a host!"); Assert.isTrue(node.getPort() > 0, "Node to meet cluster must have a port greater 0!"); clusterCommandExecutor.executeCommandOnAllNodes( (JedisClusterCommandCallback<String>) client -> client.clusterMeet(node.getHost(), node.getPort())); }
@Override public void clusterMeet(RedisClusterNode node) { Assert.notNull(node, "Cluster node must not be null for CLUSTER MEET command!"); Assert.hasText(node.getHost(), "Node to meet cluster must have a host!"); Assert.isTrue(node.getPort() > 0, "Node to meet cluster must have a port greater 0!"); this.clusterCommandExecutor.executeCommandOnAllNodes( (LettuceClusterCommandCallback<String>) client -> client.clusterMeet(node.getHost(), node.getPort())); }