Class CPSubsystemConfig
You can check the following code snippet to see how CP Subsystem
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 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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default directory name for storing CP data.static final intThe default limit number ofCPMapthat can be created.static final intThe default data load timeout duration for restoring CP data from disk.static final intThe default duration for the periodically-committed CP session heartbeats.static final intThe default duration to wait before automatically removing a missing CP member from CP Subsystem.static final intThe default value for a CP session to be kept alive after the last heartbeat it has received.static final intThe maximum number of CP members that can form a CP group.static final intThe minimum number of CP members that can form a CP group. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCPMapConfig(CPMapConfig cpMapConfig) Adds theCPMapConfigconfiguration.addLockConfig(FencedLockConfig lockConfig) Adds theFencedLockconfiguration.addSemaphoreConfig(SemaphoreConfig semaphoreConfig) Adds the CPISemaphoreconfiguration.booleanfindCPMapConfig(String name) Returns theCPMapConfigconfiguration for the given name.findLockConfig(String name) Returns theFencedLockconfiguration for the given name.findSemaphoreConfig(String name) Returns the CPISemaphoreconfiguration for the given name.Returns the base directory for persisting CP data.Returns the map ofCPMapconfigurationsintGets the limit ofCPMapinstances that are permitted to be created.intReturns the number of CP members that will initialize CP Subsystem.intReturns the CP member priority.intReturns the timeout duration for CP members to restore their data from stable storage.intReturns the number of CP members to form CP groups.Returns the map ofFencedLockconfigurationsintReturns the duration to wait before automatically removing a missing CP member from CP SubsystemReturns configuration options for Hazelcast's Raft consensus algorithm implementationReturns the map of CPISemaphoreconfigurationsintReturns the interval for the periodically-committed CP session heartbeats.intReturns the duration for a CP session to be kept alive after its last session heartbeat.inthashCode()booleanReturns the value to determine if CP Subsystem API calls will fail when result of an API call becomes indeterminate.booleanReturns whether CP Subsystem Persistence enabled on this member.setBaseDir(File baseDir) Sets the base directory for persisting CP data.setCpMapConfigs(Map<String, CPMapConfig> cpMapConfigs) setCPMapConfigs(Map<String, CPMapConfig> cpMapConfigs) Sets the map ofCPMapConfigconfigurations, mapped by config name.setCPMapLimit(int cpMapLimit) Sets the limit of permittedCPMapinstances.setCPMemberCount(int cpMemberCount) Sets the CP member count to initialize CP Subsystem.setCPMemberPriority(int cpMemberPriority) Sets the CP member priority.setDataLoadTimeoutSeconds(int dataLoadTimeoutSeconds) Sets the timeout duration for CP members to restore their data from stable storage.setFailOnIndeterminateOperationState(boolean failOnIndeterminateOperationState) Sets the value to determine if CP Subsystem calls will fail when result of an API call becomes indeterminate.setGroupSize(int groupSize) Sets the number of CP members to form CP groups.setLockConfigs(Map<String, FencedLockConfig> lockConfigs) Sets the map ofFencedLockconfigurations, mapped by config name.setMapLimit(int cpMapLimit) setMissingCPMemberAutoRemovalSeconds(int missingCPMemberAutoRemovalSeconds) Sets the duration to wait before automatically removing a missing CP member from CP Subsystem.setPersistenceEnabled(boolean persistenceEnabled) Sets whether CP Subsystem Persistence is enabled on this member.setRaftAlgorithmConfig(RaftAlgorithmConfig raftAlgorithmConfig) Sets configuration options for Hazelcast's Raft consensus algorithm implementationsetSemaphoreConfigs(Map<String, SemaphoreConfig> semaphoreConfigs) Sets the map of CPISemaphoreconfigurations, mapped by config name.setSessionHeartbeatIntervalSeconds(int sessionHeartbeatIntervalSeconds) Sets the interval for the periodically-committed CP session heartbeats.setSessionTimeToLiveSeconds(int sessionTimeToLiveSeconds) Sets the duration for a CP session to be kept alive after its last session heartbeat.toString()
-
Field Details
-
DEFAULT_SESSION_TTL_SECONDS
public static final int DEFAULT_SESSION_TTL_SECONDSThe default value for a CP session to be kept alive after the last heartbeat it has received. SeesessionTimeToLiveSeconds -
DEFAULT_HEARTBEAT_INTERVAL_SECONDS
public static final int DEFAULT_HEARTBEAT_INTERVAL_SECONDSThe default duration for the periodically-committed CP session heartbeats. SeesessionHeartbeatIntervalSeconds- See Also:
-
MIN_GROUP_SIZE
public static final int MIN_GROUP_SIZEThe minimum number of CP members that can form a CP group. SeegroupSize- See Also:
-
MAX_GROUP_SIZE
public static final int MAX_GROUP_SIZEThe maximum number of CP members that can form a CP group. Theoretically, there is no upper bound on the number of CP members to run the Raft consensus algorithm. However, since the Raft consensus algorithm synchronously replicates operations to the majority of a CP group members, a larger CP group means more replication overhead, and memory consumption as well. The current maximum CP group size limit offers a sufficient degree of fault tolerance for CP Subsystem usages.See
groupSize- See Also:
-
DEFAULT_MISSING_CP_MEMBER_AUTO_REMOVAL_SECONDS
public static final int DEFAULT_MISSING_CP_MEMBER_AUTO_REMOVAL_SECONDSThe default duration to wait before automatically removing a missing CP member from CP Subsystem. SeemissingCPMemberAutoRemovalSeconds -
CP_BASE_DIR_DEFAULT
The default directory name for storing CP data. SeebaseDir- See Also:
-
DEFAULT_DATA_LOAD_TIMEOUT_SECONDS
public static final int DEFAULT_DATA_LOAD_TIMEOUT_SECONDSThe default data load timeout duration for restoring CP data from disk. SeedataLoadTimeoutSeconds- See Also:
-
DEFAULT_CP_MAP_LIMIT
public static final int DEFAULT_CP_MAP_LIMITThe default limit number ofCPMapthat can be created.- See Also:
-
-
Constructor Details
-
CPSubsystemConfig
public CPSubsystemConfig() -
CPSubsystemConfig
-
-
Method Details
-
getCPMemberCount
public int getCPMemberCount()Returns the number of CP members that will initialize CP Subsystem. CP Subsystem is disabled if it is 0.- Returns:
- the number of CP members that will initialize CP Subsystem
-
setCPMemberCount
Sets the CP member count to initialize CP Subsystem. CP Subsystem is disabled if 0. Cannot be smaller thanMIN_GROUP_SIZEandgroupSize- Returns:
- this config instance
-
getGroupSize
public int getGroupSize()Returns the number of CP members to form CP groups. Returns 0 ifcpMemberCountis 0. If group size is not set: - returns the CP member count if it is an odd number, - returns the CP member count - 1 if it is an even number.- Returns:
- the number of CP members to form CP groups
-
setGroupSize
Sets the number of CP members to form CP groups. Must be an odd number betweenMIN_GROUP_SIZEandMAX_GROUP_SIZE.- Returns:
- this config instance
-
getSessionTimeToLiveSeconds
public int getSessionTimeToLiveSeconds()Returns the duration for a CP session to be kept alive after its last session heartbeat.- Returns:
- the duration for a CP session to be kept alive after its last session heartbeat
-
setSessionTimeToLiveSeconds
Sets the duration for a CP session to be kept alive after its last session heartbeat.- Returns:
- this config instance
-
getSessionHeartbeatIntervalSeconds
public int getSessionHeartbeatIntervalSeconds()Returns the interval for the periodically-committed CP session heartbeats.- Returns:
- the interval for the periodically-committed CP session heartbeats
-
setSessionHeartbeatIntervalSeconds
Sets the interval for the periodically-committed CP session heartbeats.- Returns:
- this config instance
-
getMissingCPMemberAutoRemovalSeconds
public int getMissingCPMemberAutoRemovalSeconds()Returns the duration to wait before automatically removing a missing CP member from CP Subsystem- Returns:
- the duration to wait before automatically removing a missing CP member from the CP Subsystem
-
setMissingCPMemberAutoRemovalSeconds
public CPSubsystemConfig setMissingCPMemberAutoRemovalSeconds(int missingCPMemberAutoRemovalSeconds) Sets the duration to wait before automatically removing a missing CP member from CP Subsystem.- Returns:
- this config instance
-
isFailOnIndeterminateOperationState
public boolean isFailOnIndeterminateOperationState()Returns the value to determine if CP Subsystem API calls will fail when result of an API call becomes indeterminate.- Returns:
- the value to determine if CP Subsystem calls will fail when result of an API call becomes indeterminate
-
setFailOnIndeterminateOperationState
public CPSubsystemConfig setFailOnIndeterminateOperationState(boolean failOnIndeterminateOperationState) Sets the value to determine if CP Subsystem calls will fail when result of an API call becomes indeterminate.- Returns:
- this config instance
-
isPersistenceEnabled
public boolean isPersistenceEnabled()Returns whether CP Subsystem Persistence enabled on this member.- Returns:
- true if CP Subsystem Persistence is enabled, false otherwise
-
setPersistenceEnabled
Sets whether CP Subsystem Persistence is enabled on this member.- Returns:
- this config instance
-
getBaseDir
Returns the base directory for persisting CP data. Can be an absolute or relative path to the node startup directory.- Returns:
- returns the base directory for CP data
-
setBaseDir
Sets the base directory for persisting CP data. Can be an absolute or relative path to the node startup directory.- Parameters:
baseDir- base directory- Returns:
- this config instance
-
getDataLoadTimeoutSeconds
public int getDataLoadTimeoutSeconds()Returns the timeout duration for CP members to restore their data from stable storage. A CP member fails its startup if it cannot complete its CP data restore process before this timeout duration.- Returns:
- the timeout duration for CP members to restore their data from stable storage
-
setDataLoadTimeoutSeconds
Sets the timeout duration for CP members to restore their data from stable storage. A CP member fails its startup if it cannot complete its CP data restore process before this timeout duration.- Parameters:
dataLoadTimeoutSeconds- the timeout duration for CP members to restore their data from stable storage- Returns:
- this config instance
-
setCPMemberPriority
Sets the CP member priority. CP groups' leadership will be transferred to members with higher priorities within the CP group.- Parameters:
cpMemberPriority- can be any integer number- Returns:
- this config instance
-
getCPMemberPriority
public int getCPMemberPriority()Returns the CP member priority.- Returns:
- the CP member priority
-
getRaftAlgorithmConfig
Returns configuration options for Hazelcast's Raft consensus algorithm implementation- Returns:
- configuration options for Hazelcast's Raft consensus algorithm implementation
-
setRaftAlgorithmConfig
Sets configuration options for Hazelcast's Raft consensus algorithm implementation- Returns:
- this config instance
-
getSemaphoreConfigs
Returns the map of CPISemaphoreconfigurations- Returns:
- the map of CP
ISemaphoreconfigurations
-
findSemaphoreConfig
Returns the CPISemaphoreconfiguration for the given name.The name is matched by stripping the
CPGroupname from the givennameif present. Returns null if there is no config found by the givenname- Parameters:
name- name of the CPISemaphore- Returns:
- the CP
ISemaphoreconfiguration
-
addSemaphoreConfig
Adds the CPISemaphoreconfiguration. Name of the CPISemaphorecould optionally contain aCPGroupname, like "mySemaphore@group1".- Parameters:
semaphoreConfig- the CPISemaphoreconfiguration- Returns:
- this config instance
-
setSemaphoreConfigs
Sets the map of CPISemaphoreconfigurations, mapped by config name. Names could optionally contain aCPGroupname, such as "mySemaphore@group1".- Parameters:
semaphoreConfigs- the CPISemaphoreconfig map to set- Returns:
- this config instance
-
getLockConfigs
Returns the map ofFencedLockconfigurations- Returns:
- the map of
FencedLockconfigurations
-
findLockConfig
Returns theFencedLockconfiguration for the given name.The name is matched by stripping the
CPGroupname from the givennameif present. Returns null if there is no config found by the givenname- Parameters:
name- name of theFencedLock- Returns:
- the
FencedLockconfiguration
-
addLockConfig
Adds theFencedLockconfiguration. Name of theFencedLockcould optionally contain aCPGroupname, like "myLock@group1".- Parameters:
lockConfig- theFencedLockconfiguration- Returns:
- this config instance
-
setLockConfigs
Sets the map ofFencedLockconfigurations, mapped by config name. Names could optionally contain aCPGroupname, such as "myLock@group1".- Parameters:
lockConfigs- theFencedLockconfig map to set- Returns:
- this config instance
-
setCpMapConfigs
-
getCpMapConfigs
Returns the map ofCPMapconfigurations- Returns:
- the map of
CPMapConfigconfigurations - Since:
- 5.4
-
findCPMapConfig
Returns theCPMapConfigconfiguration for the given name.The name is matched by stripping the
CPGroupname from the givennameif present. Returns null if there is no config found by the givenname- Parameters:
name- name of theCPMapConfig- Returns:
- the
CPMapConfigconfiguration - Since:
- 5.4
-
addCPMapConfig
Adds theCPMapConfigconfiguration. Name of theCPMapConfigcould optionally contain aCPGroupname, like "myMap@group1".- Parameters:
cpMapConfig- theCPMapConfigconfiguration- Returns:
- this config instance
- Since:
- 5.4
-
setCPMapConfigs
Sets the map ofCPMapConfigconfigurations, mapped by config name. Names could optionally contain aCPGroupname, such as "myLock@group1".- Parameters:
cpMapConfigs- theCPMapConfigconfig map to set- Returns:
- this config instance
- Since:
- 5.4
-
setCPMapLimit
Sets the limit of permittedCPMapinstances.This is a soft limit and is used exclusively by Hazelcast Management Center.
- Parameters:
cpMapLimit- limit ofCPMapinstances- Throws:
IllegalArgumentException- ifcpMapLimit < 0
-
getCPMapLimit
public int getCPMapLimit()Gets the limit ofCPMapinstances that are permitted to be created. -
setMapLimit
-
toString
-
equals
-
hashCode
public int hashCode()
-