public interface PartitionService
Partition
s and attach/detach MigrationListener
s to listen to partition
migration events.
The methods on the PartitionService are thread-safe.
Partition
,
MigrationListener
,
PartitionLostListener
Modifier and Type | Method and Description |
---|---|
UUID |
addMigrationListener(MigrationListener migrationListener)
Adds a MigrationListener.
|
UUID |
addPartitionLostListener(PartitionLostListener partitionLostListener)
Adds a PartitionLostListener.
|
boolean |
forceLocalMemberToBeSafe(long timeout,
TimeUnit unit)
Force the local member to be safe by checking and syncing partitions owned by the local member
with at least one of the backups.
|
Partition |
getPartition(Object key)
Returns the partition that the given key belongs to.
|
Set<Partition> |
getPartitions()
Returns a set containing all the
Partition s in the cluster. |
boolean |
isClusterSafe()
Checks whether the cluster is in a safe state.
|
boolean |
isLocalMemberSafe()
Checks whether local member is in safe state.
|
boolean |
isMemberSafe(Member member)
Checks whether the given member is in safe state.
|
boolean |
removeMigrationListener(UUID registrationId)
Removes a MigrationListener.
|
boolean |
removePartitionLostListener(UUID registrationId)
Removes a PartitionLostListener.
|
Set<Partition> getPartitions()
Partition
s in the cluster.Partition getPartition(@Nonnull Object key)
key
- the given keyUUID addMigrationListener(MigrationListener migrationListener)
The addMigrationListener returns a register ID. This ID is needed to remove the MigrationListener using the
removeMigrationListener(UUID)
method.
There is no check for duplicate registrations, so if you register the listener twice, it will get events twice.
migrationListener
- the added MigrationListenerNullPointerException
- if migrationListener is null
UnsupportedOperationException
- if this operation isn't supported. For example on the client side it isn't possible
to add a MigrationListenerremoveMigrationListener(UUID)
boolean removeMigrationListener(UUID registrationId)
If the same MigrationListener is registered multiple times, it needs to be removed multiple times.
This method can safely be called multiple times for the same registration ID; every subsequent call is just ignored.
registrationId
- the registration ID of the listener to removetrue
if the listener is removed, false
otherwiseNullPointerException
- if registration ID is null
UnsupportedOperationException
- if this operation isn't supported, e.g. on the client side it isn't possible
to add/remove a MigrationListeneraddMigrationListener(MigrationListener)
UUID addPartitionLostListener(PartitionLostListener partitionLostListener)
The addPartitionLostListener returns a registration ID. This ID is needed to remove the PartitionLostListener using the
removePartitionLostListener(UUID)
method.
There is no check for duplicate registrations, so if you register the listener twice, it will get events twice. IMPORTANT: Please @see com.hazelcast.partition.PartitionLostListener for weaknesses
partitionLostListener
- the added PartitionLostListenerNullPointerException
- if partitionLostListener is null
removePartitionLostListener(UUID)
boolean removePartitionLostListener(UUID registrationId)
If the same PartitionLostListener is registered multiple times, it needs to be removed multiple times.
This method can safely be called multiple times for the same registration ID; every subsequent call is just ignored.
registrationId
- the registration ID of the listener to removetrue
if the listener is removed, false
otherwiseNullPointerException
- if registration ID is null
addPartitionLostListener(PartitionLostListener)
boolean isClusterSafe()
Safe state means; there are no partitions being migrated and all backups are in sync when this method is called.
true
if there are no partitions being migrated and all backups are in sync, false
otherwiseboolean isMemberSafe(Member member)
Safe state means; all backups of partitions currently owned by the member are in sync when this method is called.
member
- the cluster member to querytrue
if the member is in a safe state, false
otherwiseboolean isLocalMemberSafe()
Safe state means; all backups of partitions currently owned by local member are in sync when this method is called.
boolean forceLocalMemberToBeSafe(long timeout, TimeUnit unit)
timeout
- the time limit for checking/syncing with the backupunit
- the unit of time for timeoutCopyright © 2024 Hazelcast, Inc.. All rights reserved.