Generate shard nodes by shard position. Shards are now host/port independent

This commit is contained in:
Dario Guzik
2011-03-02 17:53:27 -03:00
parent 2785604639
commit 3d1603b59b

View File

@@ -56,7 +56,7 @@ public class Sharded<R, S extends ShardInfo<R>> {
for (int i = 0; i != shards.size(); ++i) { for (int i = 0; i != shards.size(); ++i) {
final S shardInfo = shards.get(i); final S shardInfo = shards.get(i);
for (int n = 0; n < 160 * shardInfo.getWeight(); n++) { 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()); resources.put(shardInfo, shardInfo.createResource());
} }
@@ -108,3 +108,4 @@ public class Sharded<R, S extends ShardInfo<R>> {
return Collections.unmodifiableCollection(resources.values()); return Collections.unmodifiableCollection(resources.values());
} }
} }