From 3d1603b59b1a3aeb50d8a2f166a08bb13bf18ed1 Mon Sep 17 00:00:00 2001 From: Dario Guzik Date: Wed, 2 Mar 2011 17:53:27 -0300 Subject: [PATCH] Generate shard nodes by shard position. Shards are now host/port independent --- src/main/java/redis/clients/util/Sharded.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/redis/clients/util/Sharded.java b/src/main/java/redis/clients/util/Sharded.java index 0f7849e..e24bc93 100644 --- a/src/main/java/redis/clients/util/Sharded.java +++ b/src/main/java/redis/clients/util/Sharded.java @@ -56,7 +56,7 @@ public class Sharded> { for (int i = 0; i != shards.size(); ++i) { final S shardInfo = shards.get(i); for (int n = 0; n < 160 * shardInfo.getWeight(); n++) { - nodes.put(this.algo.hash(shardInfo.toString() + n), shardInfo); + nodes.put(this.algo.hash("SHARD-" + i + "-NODE-" + n), shardInfo); } resources.put(shardInfo, shardInfo.createResource()); } @@ -85,7 +85,7 @@ public class Sharded> { /** * A key tag is a special pattern inside a key that, if preset, is the only * part of the key hashed in order to select the server for this key. - * + * * @see http://code.google.com/p/redis/wiki/FAQ#I * 'm_using_some_form_of_key_hashing_for_partitioning,_but_wh * @param key @@ -107,4 +107,5 @@ public class Sharded> { public Collection getAllShards() { return Collections.unmodifiableCollection(resources.values()); } -} \ No newline at end of file +} +