public class CPSubsystemConfig extends Object
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());
CPSubsystem
,
CPMember
,
CPSession
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 and Description |
---|
CPSubsystemConfig() |
CPSubsystemConfig(CPSubsystemConfig config) |
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() |
public static final int DEFAULT_SESSION_TTL_SECONDS
sessionTimeToLiveSeconds
public static final int DEFAULT_HEARTBEAT_INTERVAL_SECONDS
sessionHeartbeatIntervalSeconds
public static final int MIN_GROUP_SIZE
cpMemberCount
and groupSize
cannot be smaller than
this value. See cpMemberCount
and groupSize
.public static final int MAX_GROUP_SIZE
groupSize
cannot be larger than this value. See groupSize
.public static final int DEFAULT_MISSING_CP_MEMBER_AUTO_REMOVAL_SECONDS
missingCPMemberAutoRemovalSeconds
public CPSubsystemConfig()
public CPSubsystemConfig(CPSubsystemConfig config)
public int getCPMemberCount()
public CPSubsystemConfig setCPMemberCount(int cpMemberCount)
MIN_GROUP_SIZE
and groupSize
public int getGroupSize()
public CPSubsystemConfig setGroupSize(int groupSize)
MIN_GROUP_SIZE
and MAX_GROUP_SIZE
.public int getSessionTimeToLiveSeconds()
public CPSubsystemConfig setSessionTimeToLiveSeconds(int sessionTimeToLiveSeconds)
public int getSessionHeartbeatIntervalSeconds()
public CPSubsystemConfig setSessionHeartbeatIntervalSeconds(int sessionHeartbeatIntervalSeconds)
public int getMissingCPMemberAutoRemovalSeconds()
public CPSubsystemConfig setMissingCPMemberAutoRemovalSeconds(int missingCPMemberAutoRemovalSeconds)
public boolean isFailOnIndeterminateOperationState()
public CPSubsystemConfig setFailOnIndeterminateOperationState(boolean failOnIndeterminateOperationState)
public RaftAlgorithmConfig getRaftAlgorithmConfig()
public CPSubsystemConfig setRaftAlgorithmConfig(RaftAlgorithmConfig raftAlgorithmConfig)
public Map<String,CPSemaphoreConfig> getSemaphoreConfigs()
ISemaphore
configurationsISemaphore
configurationspublic CPSemaphoreConfig findSemaphoreConfig(String name)
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
name
- name of the CP ISemaphore
ISemaphore
configurationpublic CPSubsystemConfig addSemaphoreConfig(CPSemaphoreConfig cpSemaphoreConfig)
ISemaphore
configuration. Name of the CP
ISemaphore
could optionally contain a CPGroup
name,
like "mySemaphore@group1".cpSemaphoreConfig
- the CP ISemaphore
configurationpublic CPSubsystemConfig setSemaphoreConfigs(Map<String,CPSemaphoreConfig> cpSemaphoreConfigs)
ISemaphore
configurations,
mapped by config name. Names could optionally contain
a CPGroup
name, such as "mySemaphore@group1".cpSemaphoreConfigs
- the CP ISemaphore
config map to setpublic Map<String,FencedLockConfig> getLockConfigs()
FencedLock
configurationsFencedLock
configurationspublic FencedLockConfig findLockConfig(String name)
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
name
- name of the FencedLock
FencedLock
configurationpublic CPSubsystemConfig addLockConfig(FencedLockConfig lockConfig)
FencedLock
configuration. Name of the
FencedLock
could optionally contain a CPGroup
name,
like "myLock@group1".lockConfig
- the FencedLock
configurationpublic CPSubsystemConfig setLockConfigs(Map<String,FencedLockConfig> lockConfigs)
FencedLock
configurations, mapped by config
name. Names could optionally contain a CPGroup
name, such as
"myLock@group1".lockConfigs
- the FencedLock
config map to setCopyright © 2020 Hazelcast, Inc.. All Rights Reserved.