Brian O'Connor

Fixing partition mapping

partition choice was sometimes negative

Change-Id: I97354360bebe6f8981f926f15661005adf7482c0
...@@ -95,9 +95,13 @@ public class PartitionManager implements PartitionService { ...@@ -95,9 +95,13 @@ public class PartitionManager implements PartitionService {
95 } 95 }
96 96
97 private PartitionId getPartitionForKey(Key intentKey) { 97 private PartitionId getPartitionForKey(Key intentKey) {
98 - log.debug("Getting partition for {}: {}", intentKey, 98 + int partition = Math.abs((int) intentKey.hash()) % NUM_PARTITIONS;
99 - new PartitionId((int) Math.abs(intentKey.hash()) % NUM_PARTITIONS)); 99 + //TODO investigate Guava consistent hash method
100 - return new PartitionId((int) Math.abs(intentKey.hash()) % NUM_PARTITIONS); 100 + // ... does it add significant computational complexity? is it worth it?
101 + //int partition = consistentHash(intentKey.hash(), NUM_PARTITIONS);
102 + PartitionId id = new PartitionId(partition);
103 + log.debug("Getting partition for {}: {}", intentKey, id); //FIXME debug
104 + return id;
101 } 105 }
102 106
103 @Override 107 @Override
......