CP Subsystem

class CPSubsystem(context)[source]

Bases: object

CP Subsystem is a component of Hazelcast that builds a strongly consistent layer for a set of distributed data structures.

Its APIs can be used for implementing distributed coordination use cases, such as leader election, distributed locking, synchronization, and metadata management.

Its data structures are CP with respect to the CAP principle, i.e., they always maintain linearizability and prefer consistency over availability during network partitions. Besides network partitions, CP Subsystem withstands server and client failures.

Data structures in CP Subsystem run in CP groups. Each CP group elects its own Raft leader and runs the Raft consensus algorithm independently.

The CP data structures differ from the other Hazelcast data structures in two aspects. First, an internal commit is performed on the METADATA CP group every time you fetch a proxy from this interface. Hence, callers should cache returned proxy objects. Second, if you call destroy() on a CP data structure proxy, that data structure is terminated on the underlying CP group and cannot be reinitialized until the CP group is force-destroyed. For this reason, please make sure that you are completely done with a CP data structure before destroying its proxy.

get_atomic_long(name: str) AtomicLong[source]

Returns the distributed AtomicLong instance with given name.

The instance is created on CP Subsystem.

If no group name is given within the name argument, then the AtomicLong instance will be created on the default CP group. If a group name is given, like .get_atomic_long("myLong@group1"), the given group will be initialized first, if not initialized already, and then the instance will be created on this group.

Parameters:

name – Name of the AtomicLong.

Returns:

The AtomicLong proxy for the given name.

get_atomic_reference(name: str) AtomicReference[source]

Returns the distributed AtomicReference instance with given name.

The instance is created on CP Subsystem.

If no group name is given within the name argument, then the AtomicLong instance will be created on the DEFAULT CP group. If a group name is given, like .get_atomic_reference("myRef@group1"), the given group will be initialized first, if not initialized already, and then the instance will be created on this group.

Parameters:

name – Name of the AtomicReference.

Returns:

The AtomicReference proxy for the given name.

get_count_down_latch(name: str) CountDownLatch[source]

Returns the distributed CountDownLatch instance with given name.

The instance is created on CP Subsystem.

If no group name is given within the name argument, then the CountDownLatch instance will be created on the DEFAULT CP group. If a group name is given, like .get_count_down_latch("myLatch@group1"), the given group will be initialized first, if not initialized already, and then the instance will be created on this group.

Parameters:

name – Name of the CountDownLatch.

Returns:

The CountDownLatch proxy for the given name.

get_lock(name: str) FencedLock[source]

Returns the distributed FencedLock instance with given name.

The instance is created on CP Subsystem.

If no group name is given within the name argument, then the FencedLock instance will be created on the DEFAULT CP group. If a group name is given, like .get_lock("myLock@group1"), the given group will be initialized first, if not initialized already, and then the instance will be created on this group.

Parameters:

name – Name of the FencedLock

Returns:

The FencedLock proxy for the given name.

get_semaphore(name: str) Semaphore[source]

Returns the distributed Semaphore instance with given name.

The instance is created on CP Subsystem.

If no group name is given within the name argument, then the Semaphore instance will be created on the DEFAULT CP group. If a group name is given, like .get_semaphore("mySemaphore@group1"), the given group will be initialized first, if not initialized already, and then the instance will be created on this group.

Parameters:

name – Name of the Semaphore

Returns:

The Semaphore proxy for the given name.