Interface PartitionService
Partition
s and attach/detach MigrationListener
s to listen to partition
migration events.
The methods on the PartitionService are thread-safe.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionaddMigrationListener
(MigrationListener migrationListener) Adds a MigrationListener.addPartitionLostListener
(PartitionLostListener partitionLostListener) Adds a PartitionLostListener.getPartition
(Object key) Returns the partition that the given key belongs to.Returns a set containing all thePartition
s in the cluster.boolean
removeMigrationListener
(UUID registrationId) Removes a MigrationListener.boolean
removePartitionLostListener
(UUID registrationId) Removes a PartitionLostListener.
-
Method Details
-
getPartitions
Returns a set containing all thePartition
s in the cluster.- Returns:
- all partitions in the cluster
-
getPartition
Returns the partition that the given key belongs to.- Parameters:
key
- the given key- Returns:
- the partition that the given key belongs to
-
addMigrationListener
Adds a 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.
- Parameters:
migrationListener
- the added MigrationListener- Returns:
- returns the registration ID for the MigrationListener
- Throws:
NullPointerException
- if migrationListener isnull
UnsupportedOperationException
- if this operation isn't supported. For example on the client side it isn't possible to add a MigrationListener- See Also:
-
removeMigrationListener
Removes a MigrationListener.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.
- Parameters:
registrationId
- the registration ID of the listener to remove- Returns:
true
if the listener is removed,false
otherwise- Throws:
NullPointerException
- if registration ID isnull
UnsupportedOperationException
- if this operation isn't supported, e.g. on the client side it isn't possible to add/remove a MigrationListener- See Also:
-
addPartitionLostListener
Adds a 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
- Parameters:
partitionLostListener
- the added PartitionLostListener- Returns:
- returns the registration ID for the PartitionLostListener
- Throws:
NullPointerException
- if partitionLostListener isnull
- See Also:
-
removePartitionLostListener
Removes a PartitionLostListener.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.
- Parameters:
registrationId
- the registration ID of the listener to remove- Returns:
true
if the listener is removed,false
otherwise- Throws:
NullPointerException
- if registration ID isnull
- See Also:
-