blob: 367e3f27b4c092ea9855e3359b903da29d29401b [file] [log] [blame]
Madan Jampani09342702015-02-05 23:32:40 -08001package org.onosproject.store.consistent.impl;
2
3import 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 */
13public 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}