3.2.5.2. Implementing a ConsistentHashFactory
JBoss Data Grid ships with four ConsistentHashFactory implementations:
DefaultConsistentHashFactory- keeps segments balanced evenly across all the nodes, however the key mapping is not guaranteed to be same across caches,as this depends on the history of each cache.SyncConsistentHashFactory- guarantees that the key mapping is the same for each cache, provided the current membership is the same. This has a drawback in that a node joining the cache can cause the existing nodes to also exchange segments, resulting in either additional state transfer traffic, the distribution of the data becoming less even, or both.TopologyAwareConsistentHashFactory- equivalent ofDefaultConsistentHashFactory, but with server hinting enabled.TopologyAwareSyncConsistentHashFactory- equivalent ofSyncConsistentHashFactory, but with server hinting enabled.
In addition to these, a
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
ConsistentHashFactory can be implemented manually. The custom ConsistentHashFactory must implement the following methods:
Consistent hash instances can be created with the following parameters:
- The
hashFunctionparameter is used on top of the keys' own hashCode() implementation. - The
numOwnersparameter is the ideal number of owners for each key. The created consistent hash can have a greater or fewer number of owners, however each key will have at least one owner. - The
numSegmentsdefines the number of hash-space arguments. The implementation may either round up the number of segments for performance, or it may ignore the parameter altogether. - The
membersparameter provides a list of addresses representing the new cache members.
Currently it is not possible to pass custom parameters to
ConsistentHashFactory implementations.