Fixing partition mapping
partition choice was sometimes negative
Change-Id: I97354360bebe6f8981f926f15661005adf7482c0
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionManager.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionManager.java
index 611ed21..6e856bf 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionManager.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionManager.java
@@ -95,9 +95,13 @@
}
private PartitionId getPartitionForKey(Key intentKey) {
- log.debug("Getting partition for {}: {}", intentKey,
- new PartitionId((int) Math.abs(intentKey.hash()) % NUM_PARTITIONS));
- return new PartitionId((int) Math.abs(intentKey.hash()) % NUM_PARTITIONS);
+ int partition = Math.abs((int) intentKey.hash()) % NUM_PARTITIONS;
+ //TODO investigate Guava consistent hash method
+ // ... does it add significant computational complexity? is it worth it?
+ //int partition = consistentHash(intentKey.hash(), NUM_PARTITIONS);
+ PartitionId id = new PartitionId(partition);
+ log.debug("Getting partition for {}: {}", intentKey, id); //FIXME debug
+ return id;
}
@Override