Finished implementation of GossipIntentStore based on new API and semantics.
Change-Id: I1a71d075e5d34ab7b9f7c2533d389235d6da1d9a
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 eb831c5..a709a13 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
@@ -26,6 +26,7 @@
import org.onosproject.cluster.LeadershipEvent;
import org.onosproject.cluster.LeadershipEventListener;
import org.onosproject.cluster.LeadershipService;
+import org.onosproject.net.intent.Key;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,8 +34,6 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import static com.google.common.base.Preconditions.checkNotNull;
-
/**
* Manages the assignment of intent keyspace partitions to instances.
*/
@@ -75,14 +74,15 @@
leadershipService.removeListener(leaderListener);
}
- private PartitionId getPartitionForKey(String intentKey) {
- return new PartitionId(intentKey.hashCode() % NUM_PARTITIONS);
+ private PartitionId getPartitionForKey(Key intentKey) {
+ log.debug("Getting partition for {}: {}", intentKey,
+ new PartitionId(Math.abs(intentKey.hash()) % NUM_PARTITIONS));
+ return new PartitionId(Math.abs(intentKey.hash()) % NUM_PARTITIONS);
}
@Override
- public boolean isMine(String intentKey) {
- return checkNotNull(
- myPartitions.contains(getPartitionForKey(intentKey)));
+ public boolean isMine(Key intentKey) {
+ return myPartitions.contains(getPartitionForKey(intentKey));
}
private final class InternalLeadershipListener implements LeadershipEventListener {
@@ -115,7 +115,6 @@
myPartitions.remove(new PartitionId(partitionId));
}
}
-
}
}
}