public interface CPSubsystemManagementService
Unlike the dynamic nature of Hazelcast clusters, CP Subsystem requires manual intervention while expanding/shrinking its size, or when a CP member crashes or becomes unreachable. When a CP member becomes unreachable, it is not automatically removed from CP Subsystem because it could be still alive and partitioned away.
Moreover, by default CP Subsystem works in memory without persisting any
state to disk. It means that a crashed CP member will not be able to recover
by reloading its CP identity and state. Therefore, crashed CP members create
a danger for gradually losing majority of CP groups and eventually total
loss of the availability of CP Subsystem. To prevent such situations,
CPSubsystemManagementService offers a set of APIs. In addition, CP
Subsystem Persistence can be enabled to make CP members persist their CP
state to stable storage. Please see
CPSubsystemConfig.setPersistenceEnabled(boolean) for more details
about CP Subsystem Persistence.
CP Subsystem relies on Hazelcast's failure detectors to test reachability of CP members. Before removing a CP member from CP Subsystem, please make sure that it is declared as unreachable by Hazelcast's failure detector and removed from Hazelcast cluster's member list.
CP member additions and removals are internally handled by performing
a single membership change at a time. When multiple CP members are shutting
down concurrently, their shutdown process is executed serially. When a CP
membership change is triggered, the METADATA CP group creates a membership
change plan for CP groups. Then, the scheduled changes are applied to the CP
groups one by one. After all CP group member removals are done, the shutting
down CP member is removed from the active CP members list and its shutdown
process is completed. A shut-down CP member is automatically replaced with
another available CP member in all of its CP groups, including the METADATA
CP group, in order not to decrease or more importantly not to lose
the majority of CP groups. If there is no available CP member to replace
a shutting down CP member in a CP group, that group's size is reduced by 1
and its majority value is recalculated. Please note that this behaviour is
when CP Subsystem Persistence is disabled. When CP Subsystem Persistence is
enabled, shut-down CP members are not automatically removed from the active
CP members list and they are still considered as part of CP groups
and majority calculations, because they can come back by restoring their
local CP state from stable storage. If you know that a shut-down CP member
will not be restarted, you need to remove that member from CP Subsystem via
A new CP member can be added to CP Subsystem to either increase the number of available CP members for new CP groups or to fill the missing slots in existing CP groups. After the initial Hazelcast cluster startup is done, an existing Hazelcast member can be be promoted to the CP member role. This new CP member automatically joins to CP groups that have missing members, and majority values of these CP groups are recalculated.
|Modifier and Type||Method and Description|
Blocks until the CP discovery process is completed, or the given timeout occurs, or the current thread is interrupted, whichever happens first.
Unconditionally destroys the given active CP group without using the Raft algorithm mechanics.
Returns the active CP group with the given name.
Returns all active CP group ids.
Returns the current list of CP members
Returns the local CP member if this Hazelcast member is part of CP Subsystem, returns null otherwise.
Returns whether the CP discovery process is completed or not.
Promotes the local Hazelcast member to the CP role.
Removes the given unreachable CP member from the active CP members list and all CP groups it belongs to.
Wipes and resets the whole CP Subsystem state and initializes it as if the Hazelcast cluster is starting up initially.
This field is initialized when the local Hazelcast member is one of
in the cluster and the CP discovery process is completed.
HazelcastExceptionif CP Subsystem is not enabled.
HazelcastException- if CP Subsystem is not enabled
CompletionStage<CPGroup> getCPGroup(String name)
CompletionStage<Void> forceDestroyCPGroup(String groupName)
CPGroupDestroyedException. However, if a new proxy is created afterwards, then this CP group is re-created from scratch with a new set of CP members.
This method is idempotent. It has no effect if the given CP group is already destroyed.
This method is idempotent. If the local member is already in the active CP members list, i.e., it is already a CP member, then this method has no effect. When the local member is promoted to the CP role, its member UUID is assigned as its CP member UUID.
Once the returned
Future object is completed, the promoted CP
member has been added to CP groups that have missing CP members, i.e.,
whose current size is smaller than
If the local member is currently being removed from
the active CP members list, then the returned
If there is an ongoing membership change in CP Subsystem when this
method is invoked, then the returned
Future object throws
If the CP discovery process has not completed yet when this method is
invoked, then the returned
Future object throws
If the local member is a lite member, the returned
CompletionStage<Void> removeCPMember(UUID cpMemberUuid)
Before removing a CP member from CP Subsystem, please make sure that it is declared as unreachable by Hazelcast's failure detector and removed from Hazelcast's member list. The behavior is undefined when a running CP member is removed from CP Subsystem.
IllegalStateException- When another CP member is currently being removed from CP Subsystem
IllegalArgumentException- if the given CP member is already removed from CP Subsystem
After this method is called, all CP state and data are wiped and CP members start with empty state.
This method can be invoked only from the Hazelcast master member, which is the first member in the Hazelcast cluster member list.
This method must not be called while there are membership changes in the Hazelcast cluster. Before calling this method, please make sure that there is no new member joining and all existing Hazelcast members have seen the same member list.
To be able to use this method, the initial CP member count of CP
Subsystem, which is defined by
CPSubsystemConfig.getCPMemberCount(), must be satisfied. For
CPSubsystemConfig.getCPMemberCount() is 5 and
only 1 CP member is alive, when this method is called, 4 additional AP
Hazelcast members should exist in the cluster, or new Hazelcast members
must be started.
This method also deletes all data written by CP Subsystem Persistence.
This method triggers a new CP discovery process round. However, if the new CP discovery round fails for any reason, Hazelcast members are not terminated, because Hazelcast members are likely to contain data for AP data structures and their termination can cause data loss. Hence, you need to observe the cluster and check if the CP discovery process completes successfully.
Use with caution: This method is NOT idempotent and multiple invocations can break the whole system! After calling this API, you must observe the system to see if the reset process is successfully completed or failed before making another call.
IllegalStateException- When this method is called on a Hazelcast member that is not the Hazelcast cluster master
IllegalStateException- if current member count of the cluster is smaller than
trueif the CP discovery process completed,
boolean awaitUntilDiscoveryCompleted(long timeout, TimeUnit timeUnit) throws InterruptedException
timeout- maximum time to wait
timeUnit- time unit of the timeout
trueif CP discovery completed,
InterruptedException- if interrupted while waiting
Copyright © 2021 Hazelcast, Inc.. All rights reserved.