|
Infinispan Distribution 5.2.6.Final-redhat-2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.infinispan.distribution.ch.DefaultConsistentHashFactory
public class DefaultConsistentHashFactory
Default implementation of ConsistentHashFactory
.
All methods except union(DefaultConsistentHash, DefaultConsistentHash)
return a consistent hash
with floor(numOwners*numSegments/numNodes) <= segments per owner <= ceil(numOwners*numSegments/numNodes).
Nested Class Summary | |
---|---|
static class |
DefaultConsistentHashFactory.Builder
|
static class |
DefaultConsistentHashFactory.Externalizer
|
Constructor Summary | |
---|---|
DefaultConsistentHashFactory()
|
Method Summary | |
---|---|
protected void |
addBackupOwners(DefaultConsistentHashFactory.Builder builder)
|
protected void |
addPrimaryOwners(DefaultConsistentHashFactory.Builder builder)
|
DefaultConsistentHash |
create(Hash hashFunction,
int numOwners,
int numSegments,
List<Address> members)
Create a new consistent hash instance. |
protected boolean |
doAddBackupOwners(DefaultConsistentHashFactory.Builder builder,
int maxSegments)
|
protected void |
doAddPrimaryOwners(DefaultConsistentHashFactory.Builder builder,
int maxSegments,
int maxOwners)
|
protected boolean |
doRemoveExtraBackupOwners(DefaultConsistentHashFactory.Builder builder,
int maxSegments)
|
protected Address |
findNewBackupOwner(DefaultConsistentHashFactory.Builder builder,
Collection<Address> excludes,
int maxSegments)
|
protected Address |
findNewPrimaryOwner(DefaultConsistentHashFactory.Builder builder,
Collection<Address> candidates,
int maxSegments)
|
DefaultConsistentHash |
rebalance(DefaultConsistentHash baseCH)
Create a new consistent hash instance, based on an existing instance, but "balanced" according to the implementation's rules. |
protected void |
rebalanceBuilder(DefaultConsistentHashFactory.Builder builder)
|
protected void |
removeExtraBackupOwners(DefaultConsistentHashFactory.Builder builder,
int minSegments)
|
protected void |
replaceBackupOwners(DefaultConsistentHashFactory.Builder builder,
int maxSegments)
|
protected void |
swapPrimaryOwnersWithBackups(DefaultConsistentHashFactory.Builder builder,
int maxSegments)
|
DefaultConsistentHash |
union(DefaultConsistentHash dch1,
DefaultConsistentHash dch2)
Merges two consistent hash objects that have the same number of segments, numOwners and hash function. |
DefaultConsistentHash |
updateMembers(DefaultConsistentHash baseCH,
List<Address> actualMembers)
Leavers are removed and segments without owners are assigned new owners. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultConsistentHashFactory()
Method Detail |
---|
public DefaultConsistentHash create(Hash hashFunction, int numOwners, int numSegments, List<Address> members)
ConsistentHashFactory
create
in interface ConsistentHashFactory<DefaultConsistentHash>
hashFunction
- The hash function to use on top of the keys' own hashCode()
implementation.numOwners
- The ideal number of owners for each key. The created consistent hash
can have more or less owners, but each key will have at least one owner.numSegments
- Number of hash-space segments. The implementation may round up the number
of segments for performance, or may ignore the parameter altogether.members
- A list of addresses representing the new cache members.public DefaultConsistentHash updateMembers(DefaultConsistentHash baseCH, List<Address> actualMembers)
updateMembers
in interface ConsistentHashFactory<DefaultConsistentHash>
baseCH
- An existing consistent hash instance, should not be null
actualMembers
- A list of addresses representing the new cache members.
public DefaultConsistentHash rebalance(DefaultConsistentHash baseCH)
ConsistentHashFactory
rebalance(rebalance(ch))
must be equivalent to rebalance(ch)
.
rebalance
in interface ConsistentHashFactory<DefaultConsistentHash>
baseCH
- An existing consistent hash instance, should not be null
ConsistentHash
instance, or baseCH
if the existing instance
does not need any changes.public DefaultConsistentHash union(DefaultConsistentHash dch1, DefaultConsistentHash dch2)
union
in interface ConsistentHashFactory<DefaultConsistentHash>
protected void rebalanceBuilder(DefaultConsistentHashFactory.Builder builder)
protected void addPrimaryOwners(DefaultConsistentHashFactory.Builder builder)
protected void doAddPrimaryOwners(DefaultConsistentHashFactory.Builder builder, int maxSegments, int maxOwners)
protected void swapPrimaryOwnersWithBackups(DefaultConsistentHashFactory.Builder builder, int maxSegments)
protected void addBackupOwners(DefaultConsistentHashFactory.Builder builder)
protected void removeExtraBackupOwners(DefaultConsistentHashFactory.Builder builder, int minSegments)
protected boolean doRemoveExtraBackupOwners(DefaultConsistentHashFactory.Builder builder, int maxSegments)
protected boolean doAddBackupOwners(DefaultConsistentHashFactory.Builder builder, int maxSegments)
protected void replaceBackupOwners(DefaultConsistentHashFactory.Builder builder, int maxSegments)
protected Address findNewBackupOwner(DefaultConsistentHashFactory.Builder builder, Collection<Address> excludes, int maxSegments)
protected Address findNewPrimaryOwner(DefaultConsistentHashFactory.Builder builder, Collection<Address> candidates, int maxSegments)
|
Infinispan Distribution 5.2.6.Final-redhat-2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |