com.hazelcast.client.proxy

## Class PartitionServiceProxy

- java.lang.Object
- - com.hazelcast.client.proxy.PartitionServiceProxy

- All Implemented Interfaces:
    PartitionService

      public final class PartitionServiceProxy
      extends Object
      implements PartitionService

  Author:
    mdogan 5/16/13

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PartitionServiceProxy(ClientPartitionService partitionService, ClientListenerService listenerService)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `addMigrationListener(MigrationListener migrationListener)` Adds a MigrationListener.
    `String` | `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.
    `String` | `randomPartitionKey()` Generates a random partition key.
    `boolean` | `removeMigrationListener(String registrationId)` Removes a MigrationListener.
    `boolean` | `removePartitionLostListener(String registrationId)` Removes a PartitionLostListener.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PartitionServiceProxy

          public PartitionServiceProxy(ClientPartitionService partitionService,
                                       ClientListenerService listenerService)

  - ### Method Detail

    - #### randomPartitionKey

          public String randomPartitionKey()

      Description copied from interface: `PartitionService`
      Generates a random partition key. This is useful if you want to partition data in the same partition, but you do not care which partition it is going to be.

      The returned value will never be `null`. This method is deprecated since Hazelcast 3.5. If you need a random partition-key, you can use e.g. a random number, random string or UUID for that.

      Specified by:
        `randomPartitionKey` in interface `PartitionService`
      Returns:
        the random partition key

    - #### getPartitions

          public Set<Partition> getPartitions()

      Description copied from interface: `PartitionService`
      Returns a set containing all the `Partition`s in the cluster.
      Specified by:
        `getPartitions` in interface `PartitionService`
      Returns:
        all partitions in the cluster

    - #### getPartition

          public Partition getPartition(Object key)

      Description copied from interface: `PartitionService`
      Returns the partition that the given key belongs to.
      Specified by:
        `getPartition` in interface `PartitionService`
      Parameters:
        `key` - the given key
      Returns:
        the partition that the given key belongs to

    - #### addMigrationListener

          public String addMigrationListener(MigrationListener migrationListener)

      Description copied from interface: `PartitionService`
      Adds a MigrationListener.

      The addMigrationListener returns a register ID. This ID is needed to remove the MigrationListener using the `PartitionService.removeMigrationListener(String)` method.

      There is no check for duplicate registrations, so if you register the listener twice, it will get events twice.

      Specified by:
        `addMigrationListener` in interface `PartitionService`
      Parameters:
        `migrationListener` - the added MigrationListener
      Returns:
        returns the registration ID for the MigrationListener
      See Also:
        `PartitionService.removeMigrationListener(String)`

    - #### removeMigrationListener

          public boolean removeMigrationListener(String registrationId)

      Description copied from interface: `PartitionService`
      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.

      Specified by:
        `removeMigrationListener` in interface `PartitionService`
      Parameters:
        `registrationId` - the registration ID of the listener to remove
      Returns:
        `true` if the listener is removed, `false` otherwise
      See Also:
        `PartitionService.addMigrationListener(MigrationListener)`

    - #### addPartitionLostListener

          public String addPartitionLostListener(PartitionLostListener partitionLostListener)

      Description copied from interface: `PartitionService`
      Adds a PartitionLostListener.

      The addPartitionLostListener returns a registration ID. This ID is needed to remove the PartitionLostListener using the `PartitionService.removePartitionLostListener(String)` 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

      Specified by:
        `addPartitionLostListener` in interface `PartitionService`
      Parameters:
        `partitionLostListener` - the added PartitionLostListener
      Returns:
        returns the registration ID for the PartitionLostListener
      See Also:
        `PartitionService.removePartitionLostListener(String)`

    - #### removePartitionLostListener

          public boolean removePartitionLostListener(String registrationId)

      Description copied from interface: `PartitionService`
      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.

      Specified by:
        `removePartitionLostListener` in interface `PartitionService`
      Parameters:
        `registrationId` - the registration ID of the listener to remove
      Returns:
        `true` if the listener is removed, `false` otherwise
      See Also:
        `PartitionService.addPartitionLostListener(PartitionLostListener)`

    - #### isClusterSafe

          public boolean isClusterSafe()

      Description copied from interface: `PartitionService`
      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.

      Specified by:
        `isClusterSafe` in interface `PartitionService`
      Returns:
        `true` if there are no partitions being migrated and all backups are in sync, `false` otherwise

    - #### isMemberSafe

          public boolean isMemberSafe(Member member)

      Description copied from interface: `PartitionService`
      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.

      Specified by:
        `isMemberSafe` in interface `PartitionService`
      Parameters:
        `member` - the cluster member to query
      Returns:
        `true` if the member is in a safe state, `false` otherwise

    - #### isLocalMemberSafe

          public boolean isLocalMemberSafe()

      Description copied from interface: `PartitionService`
      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.

      Specified by:
        `isLocalMemberSafe` in interface `PartitionService`

    - #### forceLocalMemberToBeSafe

          public boolean forceLocalMemberToBeSafe(long timeout,
                                                  TimeUnit unit)

      Description copied from interface: `PartitionService`
      Force the local member to be safe by checking and syncing partitions owned by the local member with at least one of the backups.
      Specified by:
        `forceLocalMemberToBeSafe` in interface `PartitionService`
      Parameters:
        `timeout` - the time limit for checking/syncing with the backup
        `unit` - the unit of time for timeout

Copyright © 2019. All rights reserved.