|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.commandhandling.distributed.ConsistentHash
public class ConsistentHash
Basic implementation of a Consistent Hashing algorithm, using the MD5 algorithm to build the hash values for given keys and node names. It contains some basic operation to add nodes and remove nodes given a set of known remaining members.
Each node contains a Set of supported Commands (as a set of the fully qualified names of payload types). When performing a lookup for a given command, only nodes that support the payload type of the command are eligible.
Nested Class Summary | |
---|---|
static class |
ConsistentHash.Member
Represents a member in a consistently hashed cluster. |
Constructor Summary | |
---|---|
ConsistentHash()
Initializes an empty hash. |
Method Summary | |
---|---|
static ConsistentHash |
emptyRing()
Returns an instance of an empty Ring, which can be used to add members. |
boolean |
equals(Object o)
|
String |
getMember(String item,
String commandType)
Returns the member for the given item , that supports given commandType . |
Set<ConsistentHash.Member> |
getMembers()
Returns the set of members part of this hash ring. |
int |
hashCode()
|
void |
readExternal(ObjectInput in)
|
String |
toString()
|
ConsistentHash |
withAdditionalNode(String nodeName,
int segmentCount,
Set<String> supportedCommandTypes)
Returns a ConsistentHash with the given additional nodeName , which is given
segmentCount segments on the ring. |
ConsistentHash |
withExclusively(Collection<String> nodes)
Returns a ConsistentHash instance where only segments leading to the given nodes are available. |
void |
writeExternal(ObjectOutput out)
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ConsistentHash()
emptyRing()
to
obtain an instance.
Method Detail |
---|
public static ConsistentHash emptyRing()
public ConsistentHash withAdditionalNode(String nodeName, int segmentCount, Set<String> supportedCommandTypes)
nodeName
, which is given
segmentCount
segments on the ring. A registration of a node will completely override any previous
registration known for that node.
nodeName
- The name of the node to add. This will be used to compute the segmentssegmentCount
- The number of segments to add the given nodesupportedCommandTypes
- The fully qualified names of command (payload) types this node supports
public ConsistentHash withExclusively(Collection<String> nodes)
nodes
are available.
Each
lookup will always result in one of the given nodes
.
nodes
- The nodes to keep in the consistent hash
nodes
are availablepublic String getMember(String item, String commandType)
item
, that supports given commandType
. If no such
member is available, this method returns null
.
item
- The item to find a node name forcommandType
- The type of command the member must support
item
, or null
if not foundpublic boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public Set<ConsistentHash.Member> getMembers()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |