Fixes how primitives and map keys are mapped to partitions
Change-Id: I68c9acabb400108def6eda394e2d5c8444ea5800
Showing
1 changed file
with
1 additions
and
5 deletions
| ... | @@ -22,8 +22,6 @@ import java.util.Map; | ... | @@ -22,8 +22,6 @@ import java.util.Map; |
| 22 | import java.util.Set; | 22 | import java.util.Set; |
| 23 | import java.util.TreeMap; | 23 | import java.util.TreeMap; |
| 24 | 24 | ||
| 25 | -import org.apache.commons.lang.StringUtils; | ||
| 26 | -import org.onlab.util.Tools; | ||
| 27 | import org.onosproject.cluster.PartitionId; | 25 | import org.onosproject.cluster.PartitionId; |
| 28 | import org.onosproject.store.primitives.DistributedPrimitiveCreator; | 26 | import org.onosproject.store.primitives.DistributedPrimitiveCreator; |
| 29 | import org.onosproject.store.service.AsyncAtomicCounter; | 27 | import org.onosproject.store.service.AsyncAtomicCounter; |
| ... | @@ -48,7 +46,6 @@ import com.google.common.primitives.Bytes; | ... | @@ -48,7 +46,6 @@ import com.google.common.primitives.Bytes; |
| 48 | * distributed primitives to a collection of other {@link DistributedPrimitiveCreator creators}. | 46 | * distributed primitives to a collection of other {@link DistributedPrimitiveCreator creators}. |
| 49 | */ | 47 | */ |
| 50 | public class FederatedDistributedPrimitiveCreator implements DistributedPrimitiveCreator { | 48 | public class FederatedDistributedPrimitiveCreator implements DistributedPrimitiveCreator { |
| 51 | - | ||
| 52 | private final TreeMap<PartitionId, DistributedPrimitiveCreator> members; | 49 | private final TreeMap<PartitionId, DistributedPrimitiveCreator> members; |
| 53 | private final List<PartitionId> sortedMemberPartitionIds; | 50 | private final List<PartitionId> sortedMemberPartitionIds; |
| 54 | 51 | ||
| ... | @@ -129,8 +126,7 @@ public class FederatedDistributedPrimitiveCreator implements DistributedPrimitiv | ... | @@ -129,8 +126,7 @@ public class FederatedDistributedPrimitiveCreator implements DistributedPrimitiv |
| 129 | * @return primitive creator | 126 | * @return primitive creator |
| 130 | */ | 127 | */ |
| 131 | private DistributedPrimitiveCreator getCreator(String name) { | 128 | private DistributedPrimitiveCreator getCreator(String name) { |
| 132 | - long hashCode = HashCode.fromBytes(Tools.getBytesUtf8(StringUtils.leftPad(name, 8))).asLong(); | 129 | + int index = Hashing.consistentHash(name.hashCode(), members.size()); |
| 133 | - int index = Hashing.consistentHash(hashCode, members.size()); | ||
| 134 | return members.get(sortedMemberPartitionIds.get(index)); | 130 | return members.get(sortedMemberPartitionIds.get(index)); |
| 135 | } | 131 | } |
| 136 | } | 132 | } | ... | ... |
-
Please register or login to post a comment