com.hazelcast.config
Class PartitionGroupConfig

java.lang.Object
  extended by com.hazelcast.config.PartitionGroupConfig

public class PartitionGroupConfig
extends Object

With the PartitionGroupConfig you can control how primary and backups are going to be split up. In a multi member cluster, Hazelcast will place the backup partition on the same member as the primary partition to prevent data loss.

But in some cases this is not good enough; imagine that you have a 4 member cluster. And imagine that member1 and member2 run in datacenter-1 and member3/member5 in datacenter-2. If you want high availability, you want to all backups of the primary partitions in datacenter-1 or stored in datacenter-2. And you want the same high availability for the primary partitions in data center2.

With the PartitionGroupConfig this behavior can be controlled. Imagine that members in datacenter-1 have ip address 10.10.1.* and ip addresses of datacenter-2 is 10.10.2.* then you can make the following configuration:

10.10.1.* 10.10.2.*

The interfaces can be configured with wildcards '*' and ranges e.g. '10-20'. Each member-group can have as many interfaces as you want.

You can define as many groups as you want, Hazelcast will prevent that in a multi member cluster, backups are going to be stored in the same group as the primary.

You need to be careful with selecting overlapping groups, e.g. 10.10.1.1 10.10.1.2 10.10.1.1 10.10.1.3 In this example there are 2 groups, but because interface 10.10.1.1 is shared between the 2 groups, there is still a chance that this member is going to store primary and backups.

In the previous example we made use of custom group; we creates the groups manually and we configured the interfaces for these groups. There also is another option that doesn't give you the same fine grained control, but can prevent that on a single machine, running multiple HazelcastInstances, a primary and backup are going to be stored. This can be done using the HOST_AWARE group-type:


Nested Class Summary
static class PartitionGroupConfig.MemberGroupType
           
 
Constructor Summary
PartitionGroupConfig()
           
 
Method Summary
 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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PartitionGroupConfig

public PartitionGroupConfig()
Method Detail

isEnabled

public boolean isEnabled()
Checks if this PartitionGroupConfig is enabled.

Returns:
true if enabled, false otherwise.

setEnabled

public PartitionGroupConfig setEnabled(boolean enabled)
Enables or disables this PartitionGroupConfig.

Parameters:
enabled - true if enabled, false if disabled.
Returns:
the updated PartitionGroupConfig.

getGroupType

public PartitionGroupConfig.MemberGroupType getGroupType()
Returns the MemberGroupType configured. Could be null if no MemberGroupType has been configured.

Returns:
the MemberGroupType.

setGroupType

public PartitionGroupConfig setGroupType(PartitionGroupConfig.MemberGroupType memberGroupType)
Sets the MemberGroupType. A @{link MemberGroupType#CUSTOM} indicates that custom groups are created. With the PartitionGroupConfig.MemberGroupType.HOST_AWARE group type, Hazelcast makes a group for every host, that prevent a single host is going to contain primary and backup. See the MemberGroupConfig for more information.

Parameters:
memberGroupType - the MemberGroupType to set.
Returns:
the updated PartitionGroupConfig
Throws:
IllegalArgumentException - if memberGroupType is null.
See Also:
getGroupType()

addMemberGroupConfig

public PartitionGroupConfig addMemberGroupConfig(MemberGroupConfig memberGroupConfig)
Adds a MemberGroupConfig. Duplicate elements are not filtered.

Parameters:
memberGroupConfig - the MemberGroupConfig to add.
Returns:
the updated PartitionGroupConfig
Throws:
IllegalArgumentException - if memberGroupConfig is null.
See Also:
addMemberGroupConfig(MemberGroupConfig)

getMemberGroupConfigs

public Collection<MemberGroupConfig> getMemberGroupConfigs()
Returns an unmodifiable collection containing all MemberGroupConfig elements.

Returns:
the MemberGroupConfig elements.
See Also:
setMemberGroupConfigs(java.util.Collection)

clear

public PartitionGroupConfig clear()
Removes all the PartitionGroupConfig.MemberGroupType instances.

Returns:
the updated PartitionGroupConfig.
See Also:
setMemberGroupConfigs(java.util.Collection)

setMemberGroupConfigs

public PartitionGroupConfig setMemberGroupConfigs(Collection<MemberGroupConfig> memberGroupConfigs)
Adds a MemberGroupConfig. This MemberGroupConfig only has meaning when the group-type is set the PartitionGroupConfig.MemberGroupType.CUSTOM. See the PartitionGroupConfig for more information and examples of how this mechanism works.

Parameters:
memberGroupConfigs - the collection of MemberGroupConfig to add.
Returns:
the updated PartitionGroupConfig
Throws:
IllegalArgumentException - if memberGroupConfigs is null.
See Also:
getMemberGroupConfigs(), clear(), addMemberGroupConfig(MemberGroupConfig)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2014 Hazelcast, Inc.. All Rights Reserved.