com.hazelcast.config.cp

## Class CPSubsystemConfig

- java.lang.Object
- - com.hazelcast.config.cp.CPSubsystemConfig

-     public class CPSubsystemConfig
      extends Object

  Contains configuration options for the `CPSubsystem`.

  You can check the following code snippet to see how the `CPSubsystem` can be initialized by configuring only the `setCPMemberCount(int)` value. In this code, we set 3 to `setCPMemberCount(int)`, and we don't set any value to `setGroupSize(int)`. Therefore, there will be 3 CP members in the CP subsystem and each CP groups will have 3 CP members as well.

           int cpMemberCount = 3;
           int apMemberCount = 2;
           int memberCount = cpMemberCount + apMemberCount;
           Config config = new Config();
           config.getCPSubsystemConfig().setCPMemberCount(cpMemberCount);
           HazelcastInstance[] instances = new HazelcastInstance[memberCount];
           for (int i = 0; i < memberCount; i++) {
               instances[i] = Hazelcast.newHazelcastInstance(config);
           }

           // update an atomic long via a CP member
           IAtomicLong cpLong = instances[0].getCPSubsystem().getAtomicLong("myLong");
           cpLong.set(10);

           // access to its value via an AP member
           cpLong = instances[cpMemberCount].getCPSubsystem().getAtomicLong("myLong");
           System.out.println(cpLong.get());

  In the following code snippet, we configure `setCPMemberCount(int)` to 5 and `setGroupSize(int)` to 3, therefore there will be 5 CP members and CP groups will be initialized by selecting 3 random CP members among them.

           int cpMemberCount = 5;
           int apMemberCount = 2;
           int groupSize = 3;
           int memberCount = cpMemberCount + apMemberCount;
           Config config = new Config();
           config.getCPSubsystemConfig()
                 .setCPMemberCount(cpMemberCount)
                 .setGroupSize(groupSize);
           HazelcastInstance[] instances = new HazelcastInstance[memberCount];
           for (int i = 0; i < memberCount; i++) {
               instances[i] = Hazelcast.newHazelcastInstance(config);
           }

           // update an atomic long via a CP member
           IAtomicLong cpLong = instances[0].getCPSubsystem().getAtomicLong("myLong");
           cpLong.set(10);

           // access to its value via an AP member
           cpLong = instances[cpMemberCount].getCPSubsystem().getAtomicLong("myLong");
           System.out.println(cpLong.get());

  See Also:
    `CPSubsystem`, `CPMember`, `CPSession`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_HEARTBEAT_INTERVAL_SECONDS` Default value of interval for the periodically-committed CP session heartbeats.
    `static int` | `DEFAULT_MISSING_CP_MEMBER_AUTO_REMOVAL_SECONDS` Default duration to wait before automatically removing a missing CP member from the CP subsystem.
    `static int` | `DEFAULT_SESSION_TTL_SECONDS` Default value for a CP session to be kept alive after the last heartbeat it has received.
    `static int` | `MAX_GROUP_SIZE` Maximum number of CP members for CP groups.
    `static int` | `MIN_GROUP_SIZE` Minimum number of CP members for CP groups.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CPSubsystemConfig()`
    `CPSubsystemConfig(CPSubsystemConfig config)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `CPSubsystemConfig` | `addLockConfig(FencedLockConfig lockConfig)` Adds the `FencedLock` configuration.
    `CPSubsystemConfig` | `addSemaphoreConfig(CPSemaphoreConfig cpSemaphoreConfig)` Adds the CP `ISemaphore` configuration.
    `FencedLockConfig` | `findLockConfig(String name)` Returns the `FencedLock` configuration for the given name.
    `CPSemaphoreConfig` | `findSemaphoreConfig(String name)` Returns the CP `ISemaphore` configuration for the given name.
    `int` | `getCPMemberCount()` Returns the number of CP members that will initialize the CP subsystem.
    `int` | `getGroupSize()` Returns number of CP members that each CP group will consist of Returns 0 if CP member count is 0.
    `Map<String,FencedLockConfig>` | `getLockConfigs()` Returns the map of `FencedLock` configurations
    `int` | `getMissingCPMemberAutoRemovalSeconds()` Returns duration to wait before automatically removing a missing CP member from the CP subsystem
    `RaftAlgorithmConfig` | `getRaftAlgorithmConfig()` Returns configuration options for Hazelcast's Raft consensus algorithm implementation
    `Map<String,CPSemaphoreConfig>` | `getSemaphoreConfigs()` Returns the map of CP `ISemaphore` configurations
    `int` | `getSessionHeartbeatIntervalSeconds()` Returns interval for the periodically-committed CP session heartbeats
    `int` | `getSessionTimeToLiveSeconds()` Returns duration for a CP session to be kept alive after the last heartbeat
    `boolean` | `isFailOnIndeterminateOperationState()` Returns the value to determine if CP API calls will fail when result of a replicated operation becomes indeterminate
    `CPSubsystemConfig` | `setCPMemberCount(int cpMemberCount)` Sets the CP member count.
    `CPSubsystemConfig` | `setFailOnIndeterminateOperationState(boolean failOnIndeterminateOperationState)` Sets the value to determine if CP API calls will fail when result of a replicated operation becomes indeterminate
    `CPSubsystemConfig` | `setGroupSize(int groupSize)` Sets group size.
    `CPSubsystemConfig` | `setLockConfigs(Map<String,FencedLockConfig> lockConfigs)` Sets the map of `FencedLock` configurations, mapped by config name.
    `CPSubsystemConfig` | `setMissingCPMemberAutoRemovalSeconds(int missingCPMemberAutoRemovalSeconds)` Sets duration to wait before automatically removing a missing CP member from the CP subsystem
    `CPSubsystemConfig` | `setRaftAlgorithmConfig(RaftAlgorithmConfig raftAlgorithmConfig)` Sets configuration options for Hazelcast's Raft consensus algorithm implementation
    `CPSubsystemConfig` | `setSemaphoreConfigs(Map<String,CPSemaphoreConfig> cpSemaphoreConfigs)` Sets the map of CP `ISemaphore` configurations, mapped by config name.
    `CPSubsystemConfig` | `setSessionHeartbeatIntervalSeconds(int sessionHeartbeatIntervalSeconds)` Sets interval for the periodically-committed CP session heartbeats
    `CPSubsystemConfig` | `setSessionTimeToLiveSeconds(int sessionTimeToLiveSeconds)` Sets duration for a CP session to be kept alive after the last heartbeat
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_SESSION_TTL_SECONDS

          public static final int DEFAULT_SESSION_TTL_SECONDS

      Default value for a CP session to be kept alive after the last heartbeat it has received. See `sessionTimeToLiveSeconds`

    - #### DEFAULT_HEARTBEAT_INTERVAL_SECONDS

          public static final int DEFAULT_HEARTBEAT_INTERVAL_SECONDS

      Default value of interval for the periodically-committed CP session heartbeats. See `sessionHeartbeatIntervalSeconds`
      See Also:
        Constant Field Values

    - #### MIN_GROUP_SIZE

          public static final int MIN_GROUP_SIZE

      Minimum number of CP members for CP groups. If set, `cpMemberCount` and `groupSize` cannot be smaller than this value. See `cpMemberCount` and `groupSize`.
      See Also:
        Constant Field Values

    - #### MAX_GROUP_SIZE

          public static final int MAX_GROUP_SIZE

      Maximum number of CP members for CP groups. If set, `groupSize` cannot be larger than this value. See `groupSize`.
      See Also:
        Constant Field Values

    - #### DEFAULT_MISSING_CP_MEMBER_AUTO_REMOVAL_SECONDS

          public static final int DEFAULT_MISSING_CP_MEMBER_AUTO_REMOVAL_SECONDS

      Default duration to wait before automatically removing a missing CP member from the CP subsystem. See `missingCPMemberAutoRemovalSeconds`

  - ### Constructor Detail

    - #### CPSubsystemConfig

          public CPSubsystemConfig()

    - #### CPSubsystemConfig

          public CPSubsystemConfig(CPSubsystemConfig config)

  - ### Method Detail

    - #### getCPMemberCount

          public int getCPMemberCount()

      Returns the number of CP members that will initialize the CP subsystem. The CP subsystem is disabled if 0.
      Returns:
        the number of CP members that will initialize the CP subsystem

    - #### setCPMemberCount

          public CPSubsystemConfig setCPMemberCount(int cpMemberCount)

      Sets the CP member count. The CP subsystem is disabled if 0. Cannot be smaller than `MIN_GROUP_SIZE` and `groupSize`
      Returns:
        this config instance

    - #### getGroupSize

          public int getGroupSize()

      Returns number of CP members that each CP group will consist of Returns 0 if CP member count is 0. If group size is not set: - returns CP member count if it is an odd number - returns CP member count - 1 if it is an even number
      Returns:
        number of CP members that each CP group will consist of

    - #### setGroupSize

          public CPSubsystemConfig setGroupSize(int groupSize)

      Sets group size. Must be an odd number between `MIN_GROUP_SIZE` and `MAX_GROUP_SIZE`.
      Returns:
        this config instance

    - #### getSessionTimeToLiveSeconds

          public int getSessionTimeToLiveSeconds()

      Returns duration for a CP session to be kept alive after the last heartbeat
      Returns:
        duration for a CP session to be kept alive after the last heartbeat

    - #### setSessionTimeToLiveSeconds

          public CPSubsystemConfig setSessionTimeToLiveSeconds(int sessionTimeToLiveSeconds)

      Sets duration for a CP session to be kept alive after the last heartbeat
      Returns:
        this config instance

    - #### getSessionHeartbeatIntervalSeconds

          public int getSessionHeartbeatIntervalSeconds()

      Returns interval for the periodically-committed CP session heartbeats
      Returns:
        interval for the periodically-committed CP session heartbeats

    - #### setSessionHeartbeatIntervalSeconds

          public CPSubsystemConfig setSessionHeartbeatIntervalSeconds(int sessionHeartbeatIntervalSeconds)

      Sets interval for the periodically-committed CP session heartbeats
      Returns:
        this config instance

    - #### getMissingCPMemberAutoRemovalSeconds

          public int getMissingCPMemberAutoRemovalSeconds()

      Returns duration to wait before automatically removing a missing CP member from the CP subsystem
      Returns:
        duration to wait before automatically removing a missing CP member from the CP subsystem

    - #### setMissingCPMemberAutoRemovalSeconds

          public CPSubsystemConfig setMissingCPMemberAutoRemovalSeconds(int missingCPMemberAutoRemovalSeconds)

      Sets duration to wait before automatically removing a missing CP member from the CP subsystem
      Returns:
        this config instance

    - #### isFailOnIndeterminateOperationState

          public boolean isFailOnIndeterminateOperationState()

      Returns the value to determine if CP API calls will fail when result of a replicated operation becomes indeterminate
      Returns:
        the value to determine if CP API calls will fail when result of a replicated operation becomes indeterminate

    - #### setFailOnIndeterminateOperationState

          public CPSubsystemConfig setFailOnIndeterminateOperationState(boolean failOnIndeterminateOperationState)

      Sets the value to determine if CP API calls will fail when result of a replicated operation becomes indeterminate
      Returns:
        this config instance

    - #### getRaftAlgorithmConfig

          public RaftAlgorithmConfig getRaftAlgorithmConfig()

      Returns configuration options for Hazelcast's Raft consensus algorithm implementation
      Returns:
        configuration options for Hazelcast's Raft consensus algorithm implementation

    - #### setRaftAlgorithmConfig

          public CPSubsystemConfig setRaftAlgorithmConfig(RaftAlgorithmConfig raftAlgorithmConfig)

      Sets configuration options for Hazelcast's Raft consensus algorithm implementation
      Returns:
        this config instance

    - #### getSemaphoreConfigs

          public Map<String,CPSemaphoreConfig> getSemaphoreConfigs()

      Returns the map of CP `ISemaphore` configurations
      Returns:
        the map of CP `ISemaphore` configurations

    - #### findSemaphoreConfig

          public CPSemaphoreConfig findSemaphoreConfig(String name)

      Returns the CP `ISemaphore` configuration for the given name.

      The name is matched by stripping the `CPGroup` name from the given `name` if present. Returns null if there is no config found by the given `name`

      Parameters:
        `name` - name of the CP `ISemaphore`
      Returns:
        the CP `ISemaphore` configuration

    - #### addSemaphoreConfig

          public CPSubsystemConfig addSemaphoreConfig(CPSemaphoreConfig cpSemaphoreConfig)

      Adds the CP `ISemaphore` configuration. Name of the CP `ISemaphore` could optionally contain a `CPGroup` name, like "mySemaphore@group1".
      Parameters:
        `cpSemaphoreConfig` - the CP `ISemaphore` configuration
      Returns:
        this config instance

    - #### setSemaphoreConfigs

          public CPSubsystemConfig setSemaphoreConfigs(Map<String,CPSemaphoreConfig> cpSemaphoreConfigs)

      Sets the map of CP `ISemaphore` configurations, mapped by config name. Names could optionally contain a `CPGroup` name, such as "mySemaphore@group1".
      Parameters:
        `cpSemaphoreConfigs` - the CP `ISemaphore` config map to set
      Returns:
        this config instance

    - #### getLockConfigs

          public Map<String,FencedLockConfig> getLockConfigs()

      Returns the map of `FencedLock` configurations
      Returns:
        the map of `FencedLock` configurations

    - #### findLockConfig

          public FencedLockConfig findLockConfig(String name)

      Returns the `FencedLock` configuration for the given name.

      The name is matched by stripping the `CPGroup` name from the given `name` if present. Returns null if there is no config found by the given `name`

      Parameters:
        `name` - name of the `FencedLock`
      Returns:
        the `FencedLock` configuration

    - #### addLockConfig

          public CPSubsystemConfig addLockConfig(FencedLockConfig lockConfig)

      Adds the `FencedLock` configuration. Name of the `FencedLock` could optionally contain a `CPGroup` name, like "myLock@group1".
      Parameters:
        `lockConfig` - the `FencedLock` configuration
      Returns:
        this config instance

    - #### setLockConfigs

          public CPSubsystemConfig setLockConfigs(Map<String,FencedLockConfig> lockConfigs)

      Sets the map of `FencedLock` configurations, mapped by config name. Names could optionally contain a `CPGroup` name, such as "myLock@group1".
      Parameters:
        `lockConfigs` - the `FencedLock` config map to set
      Returns:
        this config instance

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2019. All rights reserved.