Last active
June 7, 2016 03:59
-
-
Save jpe42/5037cf03768280ab1d81a88e7929c608 to your computer and use it in GitHub Desktop.
Redis Cluster client side host/port mapping using Jedipus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final Map<Node, Node> nodeMappings = new HashMap<>(3); | |
nodeMappings.put(Node.create("internal1", 7001), Node.create("public1", 7001)); | |
nodeMappings.put(Node.create("internal1", 7002), Node.create("public2", 7002)); | |
nodeMappings.put(Node.create("internal1", 7003), Node.create("public3", 7003)); | |
final Collection<Node> discoveryNodes = Collections.singleton(Node.create("public1", 7001)); | |
// Static mapper, could easily be something dynamic as well. | |
final NodeMapper nodeMapper = | |
node -> nodeMappings.getOrDefault(node, node).updateId(node.getId()); | |
final RedisClusterExecutor rce = RedisClusterExecutor.startBuilding(discoveryNodes) | |
.withNodeMapper(nodeMapper).create(); | |
rce.acceptAllMasters(master -> System.out.format("%s %s%n", master, master.sendCmd(Cmds.PING))); | |
// ... | |
rce.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment