com.hazelcast.spi.partition

## Interface IPartitionService

- All Superinterfaces:
    CoreService

      public interface IPartitionService
      extends CoreService

  An SPI service for accessing partition related information.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `SERVICE_NAME` The name of the service.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `addLocalPartitionLostListener(PartitionLostListener partitionLostListener)`
    `String` | `addMigrationListener(MigrationListener migrationListener)`
    `String` | `addPartitionLostListener(PartitionLostListener partitionLostListener)`
    `int` | `getMaxAllowedBackupCount()` Returns maximum allowed backup count according to current cluster formation and partition group configuration.
    `List<Integer>` | `getMemberPartitions(Address target)` Returns partition ID list assigned to given target.
    `Map<Address,List<Integer>>` | `getMemberPartitionsMap()` Gets member partition IDs.
    `long` | `getMigrationQueueSize()`
    `IPartition` | `getPartition(int partitionId)` Returns the `IPartition` for a given partition ID.
    `IPartition` | `getPartition(int partitionId, boolean triggerOwnerAssignment)` Returns the `IPartition` for a given partition ID.
    `int` | `getPartitionCount()` Returns the number of partitions.
    `int` | `getPartitionId(Data key)` Returns the partition ID for a `Data` key.
    `int` | `getPartitionId(Object key)` Returns the partition ID for a given object.
    `Address` | `getPartitionOwner(int partitionId)` Gets the owner of the partition if it's set.
    `Address` | `getPartitionOwnerOrWait(int partitionId)` Gets the owner of the partition.
    `IPartition[]` | `getPartitions()` Returns an array of `IPartition` instances.
    `int` | `getPartitionStateVersion()`
    `boolean` | `hasOnGoingMigration()` Checks if there are any cluster-wide migrations.
    `boolean` | `hasOnGoingMigrationLocal()` Checks if there are any local migrations.
    `boolean` | `isMemberStateSafe()` Queries and returns if this member in a safe state or not.
    `boolean` | `isPartitionOwner(int partitionId)` Check if this node is the owner of a partition.
    `boolean` | `removeMigrationListener(String registrationId)`
    `boolean` | `removePartitionLostListener(String registrationId)`

- - ### Field Detail

    - #### SERVICE_NAME

          static final String SERVICE_NAME

      The name of the service.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getPartitionOwner

          Address getPartitionOwner(int partitionId)

      Gets the owner of the partition if it's set.

      If the owner of the partition is not set yet, it will trigger partition assignment.

      Parameters:
        `partitionId` - the partitionId
      Returns:
        owner of partition or `null` if it's not set yet

    - #### getPartitionOwnerOrWait

          Address getPartitionOwnerOrWait(int partitionId)

      Gets the owner of the partition.

      If none is set, it will wait till the owner is set.

      Parameters:
        `partitionId` - the partitionId
      Returns:
        owner of partition
      Throws:
        `InterruptedException`
        `NoDataMemberInClusterException` - if all nodes are lite members and partitions can't be assigned

    - #### getPartition

          IPartition getPartition(int partitionId)

      Returns the `IPartition` for a given partition ID.

      If the owner of the partition is not set yet, it will trigger partition assignment.

      The `IPartition` for a given partition ID will never change, so the result can be cached safely.

      Parameters:
        `partitionId` - the partition ID
      Returns:
        the IPartition

    - #### getPartition

          IPartition getPartition(int partitionId,
                                  boolean triggerOwnerAssignment)

      Returns the `IPartition` for a given partition ID.

      If the owner of the partition is not set yet and `triggerOwnerAssignment` is `true`, it will trigger partition assignment.

      The `IPartition` for a given partition ID will never change, so the result can be cached safely.

      Parameters:
        `partitionId` - the partition ID
        `triggerOwnerAssignment` - flag to trigger the partition assignment
      Returns:
        the IPartition

    - #### getPartitionId

          int getPartitionId(Data key)

      Returns the partition ID for a `Data` key.
      Parameters:
        `key` - the `Data` key
      Returns:
        the partition ID
      Throws:
        `NullPointerException` - if key is `null`

    - #### getPartitionId

          int getPartitionId(Object key)

      Returns the partition ID for a given object.
      Parameters:
        `key` - the object key
      Returns:
        the partition ID

    - #### getPartitionCount

          int getPartitionCount()

      Returns the number of partitions.
      Returns:
        the number of partitions

    - #### getMemberPartitions

          List<Integer> getMemberPartitions(Address target)

      Returns partition ID list assigned to given target.

      If the owner of the partition is not set yet, it will trigger partition assignment.

      Returns:
        partition ID list assigned to given target

    - #### getMemberPartitionsMap

          Map<Address,List<Integer>> getMemberPartitionsMap()

      Gets member partition IDs.

      Blocks until partitions are assigned.

      Returns:
        map of member address to partition IDs

    - #### addMigrationListener

          String addMigrationListener(MigrationListener migrationListener)

    - #### removeMigrationListener

          boolean removeMigrationListener(String registrationId)

    - #### addPartitionLostListener

          String addPartitionLostListener(PartitionLostListener partitionLostListener)

    - #### addLocalPartitionLostListener

          String addLocalPartitionLostListener(PartitionLostListener partitionLostListener)

    - #### removePartitionLostListener

          boolean removePartitionLostListener(String registrationId)

    - #### getMigrationQueueSize

          long getMigrationQueueSize()

    - #### isMemberStateSafe

          boolean isMemberStateSafe()

      Queries and returns if this member in a safe state or not.

      This method just checks for a safe state, it doesn't force this member to be in a safe state.

      Returns:
        `true` if this member in a safe state, otherwise `false`

    - #### getMaxAllowedBackupCount

          int getMaxAllowedBackupCount()

      Returns maximum allowed backup count according to current cluster formation and partition group configuration.

      The returned number will be in the range of [0, `IPartition.MAX_BACKUP_COUNT`].

      Returns:
        max allowed backup count

    - #### getPartitionStateVersion

          int getPartitionStateVersion()

    - #### hasOnGoingMigration

          boolean hasOnGoingMigration()

      Checks if there are any cluster-wide migrations.
      Returns:
        `true` if there are migrations, `false` otherwise.

    - #### hasOnGoingMigrationLocal

          boolean hasOnGoingMigrationLocal()

      Checks if there are any local migrations.
      Returns:
        `true` if there are migrations, `false` otherwise.

    - #### isPartitionOwner

          boolean isPartitionOwner(int partitionId)

      Check if this node is the owner of a partition.
      Parameters:
        `partitionId` - the partition ID
      Returns:
        `true` if the node owns the partition, `false` if the node doesn't own the partition or if the partition hasn't been assigned yet

    - #### getPartitions

          IPartition[] getPartitions()

      Returns an array of `IPartition` instances.

      Note: Creates a new array on each invocation, not recommended to use in high-loaded parts of code.

      Returns:
        array of `IPartition` instances

Copyright © 2018. All rights reserved.