com.hazelcast.config

## Class PartitionGroupConfig

- java.lang.Object
- - com.hazelcast.config.PartitionGroupConfig

-     public class PartitionGroupConfig
      extends Object

  With PartitionGroupConfig, you can control how primary and backup partitions are mapped to physical Members.

  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.

  # PER_MEMBER Partition Groups

  This is the default partition scheme and is used if no other scheme is defined. Each Member is in a group of its own.

  Partitions (primaries and backups) will be distributed randomly but not on the same Member. ``

       <partition-group enabled="true" group-type="PER_MEMBER"/>

  This provides good redundancy when Members are on separate hosts but not if multiple instances are being run from the same host.

  # HOST_AWARE Partition Groups

  In this scheme, a group corresponds to a host, based on its IP address. Partitions will not be written to any other members on the same host.

  This scheme provides good redundancy when multiple instances are being run on the same host. ``

       <partition-group enabled="true" group-type="HOST_AWARE"/>

  # CUSTOM Partition Groups

  In this scheme, IP addresses, or IP address ranges, are allocated to groups. Partitions are not written to the same group. This is very useful for ensuring partitions are written to different racks or even availability zones.

  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: ``

       <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>

  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.

  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"/>

  # Zone Aware Partition Groups

  In this scheme, groups are allocated according to the metadata provided by Discovery SPI Partitions are not written to the same group. This is very useful for ensuring partitions are written to availability zones or different racks without providing the IP addresses to the config ahead. `

       <partition-group enabled="true" group-type="SPI"/>

  `

  # SPI Aware Partition Groups

  In this scheme, groups are allocated according to the implementation provided by Discovery SPI.

  ## Overlapping Groups

  Care should be taken when selecting overlapping groups, e.g. `

       <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.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `PartitionGroupConfig.MemberGroupType` Type of member groups.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PartitionGroupConfig()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `PartitionGroupConfig` | `addMemberGroupConfig(MemberGroupConfig memberGroupConfig)` Adds a `MemberGroupConfig`.
    `PartitionGroupConfig` | `clear()` Removes all the `PartitionGroupConfig.MemberGroupType` instances.
    `boolean` | `equals(Object o)`
    `PartitionGroupConfig.MemberGroupType` | `getGroupType()` Returns the MemberGroupType configured.
    `Collection<MemberGroupConfig>` | `getMemberGroupConfigs()` Returns an unmodifiable collection containing all `MemberGroupConfig` elements.
    `int` | `hashCode()`
    `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, finalize, getClass, 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 this PartitionGroupConfig is enabled, `false` otherwise

    - #### setEnabled

          public PartitionGroupConfig setEnabled(boolean enabled)

      Enables or disables this PartitionGroupConfig.
      Parameters:
        `enabled` - `true` to enable, `false` to disable
      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 prevents a single host containing 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:
        an unmodifiable collection containing all `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 to `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)`

    - #### equals

          public final boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public final int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2020. All rights reserved.