Madan Jampani | 0934270 | 2015-02-05 23:32:40 -0800 | [diff] [blame^] | 1 | package org.onosproject.store.consistent.impl; |
| 2 | |
| 3 | import java.util.Map; |
| 4 | |
| 5 | /** |
| 6 | * A simple Partitioner that uses the table name hash to |
| 7 | * pick a partition. |
| 8 | * <p> |
| 9 | * This class uses a md5 hash based hashing scheme for hashing the table name to |
| 10 | * a partition. This partitioner maps all keys for a table to the same database |
| 11 | * partition. |
| 12 | */ |
| 13 | public class SimpleTableHashPartitioner extends DatabasePartitioner { |
| 14 | |
| 15 | public SimpleTableHashPartitioner(Map<String, Database> partitionMap) { |
| 16 | super(partitionMap); |
| 17 | } |
| 18 | |
| 19 | @Override |
| 20 | public Database getPartition(String tableName, String key) { |
| 21 | return sortedPartitions[hash(tableName) % sortedPartitions.length]; |
| 22 | } |
| 23 | } |