Interface PartitionService

    • Method Detail

      • getPartitions

        java.util.Set<Partition> getPartitions()
        Returns a set containing all the Partitions in the cluster.
        Returns:
        all partitions in the cluster
      • getPartition

        Partition getPartition​(@Nonnull
                               java.lang.Object key)
        Returns the partition that the given key belongs to.
        Parameters:
        key - the given key
        Returns:
        the partition that the given key belongs to
      • addMigrationListener

        java.util.UUID addMigrationListener​(MigrationListener migrationListener)
        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:
        java.lang.NullPointerException - if migrationListener is null
        java.lang.UnsupportedOperationException - if this operation isn't supported. For example on the client side it isn't possible to add a MigrationListener
        See Also:
        removeMigrationListener(UUID)
      • removeMigrationListener

        boolean removeMigrationListener​(java.util.UUID registrationId)
        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:
        java.lang.NullPointerException - if registration ID is null
        java.lang.UnsupportedOperationException - if this operation isn't supported, e.g. on the client side it isn't possible to add/remove a MigrationListener
        See Also:
        addMigrationListener(MigrationListener)
      • addPartitionLostListener

        java.util.UUID addPartitionLostListener​(PartitionLostListener partitionLostListener)
        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:
        java.lang.NullPointerException - if partitionLostListener is null
        See Also:
        removePartitionLostListener(UUID)
      • removePartitionLostListener

        boolean removePartitionLostListener​(java.util.UUID registrationId)
        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:
        java.lang.NullPointerException - if registration ID is null
        See Also:
        addPartitionLostListener(PartitionLostListener)
      • isClusterSafe

        boolean isClusterSafe()
        Checks whether the cluster is in a safe state.

        Safe state means; there are no partitions being migrated and all backups are in sync when this method is called.

        Returns:
        true if there are no partitions being migrated and all backups are in sync, false otherwise
        Since:
        3.3
      • isMemberSafe

        boolean isMemberSafe​(Member member)
        Checks whether the given member is in safe state.

        Safe state means; all backups of partitions currently owned by the member are in sync when this method is called.

        Parameters:
        member - the cluster member to query
        Returns:
        true if the member is in a safe state, false otherwise
        Since:
        3.3
      • isLocalMemberSafe

        boolean isLocalMemberSafe()
        Checks whether local member is in safe state.

        Safe state means; all backups of partitions currently owned by local member are in sync when this method is called.

        Since:
        3.3
      • forceLocalMemberToBeSafe

        boolean forceLocalMemberToBeSafe​(long timeout,
                                         java.util.concurrent.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.
        Parameters:
        timeout - the time limit for checking/syncing with the backup
        unit - the unit of time for timeout
        Since:
        3.3