public class PartitionGroupConfig extends Object
Hazelcast will always place partitions on different partition groups so as to provide redundancy.
There are three partition group schemes defined in PartitionGroupConfig.MemberGroupType
: PER_MEMBER, HOST_AWARE
CUSTOM, ZONE_AWARE, SPI.
In all cases a partition will never be created on the same group. If there are more partitions defined than there are partition groups, then only those partitions, up to the number of partition groups, will be created. For example, if you define 2 backups, then with the primary, that makes 3. If you have only two partition groups only two will be created.
Partitions (primaries and backups) will be distributed randomly but not on the same Member.
This provides good redundancy when Members are on separate hosts but not if multiple instances are being
run from the same host.
<partition-group enabled="true" group-type="PER_MEMBER"/>
This scheme provides good redundancy when multiple instances are being run on the same host.
<partition-group enabled="true" group-type="HOST_AWARE"/>
For example, members in data center 1 have IP addresses in the range 10.10.1.* and for data center 2 they have
the IP address range 10.10.2.*. You would achieve HA by configuring a CUSTOM
partition group as follows:
The interfaces can be configured with wildcards ('*') and also with address ranges e.g. '10-20'. Each member-group
can have an unlimited number of interfaces.
<partition-group enabled="true" group-type="CUSTOM">
<member-group>
<interface>10.10.1.*</interface>
</member-group>
<member-group>
<interface>10.10.2.*</interface>
</member-group>
</partition-group>
You can define as many member-group
s as you want. Hazelcast will always store backups in a different
member-group to the primary partition.
<partition-group enabled="true" group-type="ZONE_AWARE"/>
<partition-group enabled="true" group-type="SPI"/>
<partition-group enabled="true" group-type="CUSTOM">
<member-group>
<interface>10.10.1.1</interface>
<interface>10.10.1.2</interface>
</member-group>
<member-group>
<interface>10.10.1.1</interface>
<interface>10.10.1.3</interface>
</member-group>
</partition-group>
In this example there are 2 groups, but because interface 10.10.1.1 is shared between the 2 groups, this member
may store store primary and backups.Modifier and Type | Class and Description |
---|---|
static class |
PartitionGroupConfig.MemberGroupType
Type of member groups.
|
Constructor and Description |
---|
PartitionGroupConfig() |
Modifier and Type | Method and Description |
---|---|
PartitionGroupConfig |
addMemberGroupConfig(MemberGroupConfig memberGroupConfig)
Adds a
MemberGroupConfig . |
PartitionGroupConfig |
clear()
Removes all the
PartitionGroupConfig.MemberGroupType instances. |
PartitionGroupConfig.MemberGroupType |
getGroupType()
Returns the MemberGroupType configured.
|
Collection<MemberGroupConfig> |
getMemberGroupConfigs()
Returns an unmodifiable collection containing all
MemberGroupConfig elements. |
boolean |
isEnabled()
Checks if this PartitionGroupConfig is enabled.
|
PartitionGroupConfig |
setEnabled(boolean enabled)
Enables or disables this PartitionGroupConfig.
|
PartitionGroupConfig |
setGroupType(PartitionGroupConfig.MemberGroupType memberGroupType)
Sets the MemberGroupType.
|
PartitionGroupConfig |
setMemberGroupConfigs(Collection<MemberGroupConfig> memberGroupConfigs)
Adds a MemberGroupConfig.
|
String |
toString() |
public boolean isEnabled()
true
if this PartitionGroupConfig is enabled, false
otherwisepublic PartitionGroupConfig setEnabled(boolean enabled)
enabled
- true
to enable, false
to disablepublic PartitionGroupConfig.MemberGroupType getGroupType()
null
if no MemberGroupType has been configured.public PartitionGroupConfig setGroupType(PartitionGroupConfig.MemberGroupType memberGroupType)
PartitionGroupConfig.MemberGroupType.HOST_AWARE
group type, Hazelcast makes a group for every host, that prevents
a single host containing primary and backup. See the MemberGroupConfig
for more information.memberGroupType
- the MemberGroupType to setIllegalArgumentException
- if memberGroupType is null
getGroupType()
public PartitionGroupConfig addMemberGroupConfig(MemberGroupConfig memberGroupConfig)
MemberGroupConfig
. Duplicate elements are not filtered.memberGroupConfig
- the MemberGroupConfig to addIllegalArgumentException
- if memberGroupConfig is null
addMemberGroupConfig(MemberGroupConfig)
public Collection<MemberGroupConfig> getMemberGroupConfigs()
MemberGroupConfig
elements.MemberGroupConfig
elementssetMemberGroupConfigs(java.util.Collection)
public PartitionGroupConfig clear()
PartitionGroupConfig.MemberGroupType
instances.setMemberGroupConfigs(java.util.Collection)
public PartitionGroupConfig setMemberGroupConfigs(Collection<MemberGroupConfig> memberGroupConfigs)
PartitionGroupConfig.MemberGroupType.CUSTOM
. See the PartitionGroupConfig
for more information and examples
of how this mechanism works.memberGroupConfigs
- the collection of MemberGroupConfig to addIllegalArgumentException
- if memberGroupConfigs is null
getMemberGroupConfigs()
,
clear()
,
addMemberGroupConfig(MemberGroupConfig)
Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.