org.tinygroup.dbrouter.util
类 ConsistentHash<T>

java.lang.Object
  继承者 org.tinygroup.dbrouter.util.ConsistentHash<T>

public class ConsistentHash<T>
extends Object


构造方法摘要
ConsistentHash(Collection<T> nodes)
           
ConsistentHash(int numberOfReplicas, Collection<T> nodes)
           
 
方法摘要
 void addShardInfo(T node)
          增加虚拟接点与真实机器节点映射
static String getRandomString(int length)
           
 List<Long> getShard(T node)
           
 T getShardInfo(String key)
          取得真实机器节点
 Long hash(String key)
          MurMurHash算法,是非加密HASH算法,性能很高,碰撞率低
 void removeShardInfo(T node)
          删除真实机器节点
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

ConsistentHash

public ConsistentHash(Collection<T> nodes)

ConsistentHash

public ConsistentHash(int numberOfReplicas,
                      Collection<T> nodes)
参数:
hashFunction - hash 函数接口
numberOfReplicas - 每个机器节点关联的虚拟节点个数
nodes - 真实机器节点
方法详细信息

addShardInfo

public void addShardInfo(T node)
增加虚拟接点与真实机器节点映射

参数:
node -

getShard

public List<Long> getShard(T node)

removeShardInfo

public void removeShardInfo(T node)
删除真实机器节点

参数:
node -

getShardInfo

public T getShardInfo(String key)
取得真实机器节点

参数:
key -
返回:

hash

public Long hash(String key)
MurMurHash算法,是非加密HASH算法,性能很高,碰撞率低


getRandomString

public static String getRandomString(int length)


Copyright © 2006–2015 TinyGroup. All rights reserved.