com.hazelcast.partition
Class PartitionServiceProxy

java.lang.Object
  extended by com.hazelcast.partition.PartitionServiceProxy
All Implemented Interfaces:
PartitionService

public class PartitionServiceProxy
extends Object
implements PartitionService


Nested Class Summary
 class PartitionServiceProxy.PartitionProxy
           
 
Constructor Summary
PartitionServiceProxy(InternalPartitionService partitionService)
           
 
Method Summary
 String addMigrationListener(MigrationListener migrationListener)
          Adds a MigrationListener.
 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.
 PartitionServiceProxy.PartitionProxy getPartition(int partitionId)
           
 PartitionServiceProxy.PartitionProxy getPartition(Object key)
          Returns the partition that the given key belongs to.
 Set<Partition> getPartitions()
          Returns a set containing all the Partitions in the cluster.
 boolean isClusterSafe()
          Checks whether the cluster is in a safe state.
 boolean isLocalMemberSafe()
          Check if the local member is safe to shutdown, meaning check if at least one backup of the partitions owned by the local member are in sync with primary.
 boolean isMemberSafe(Member member)
          Check if the given member is safe to shutdown, meaning check if at least one backup of the partitions owned by the given member are in sync with primary.
 String randomPartitionKey()
          Generates a random partition key.
 boolean removeMigrationListener(String registrationId)
          Removes a MigrationListener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PartitionServiceProxy

public PartitionServiceProxy(InternalPartitionService partitionService)
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.

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 Partitions in the cluster.

Specified by:
getPartitions in interface PartitionService
Returns:
all partitions in the cluster

getPartition

public PartitionServiceProxy.PartitionProxy 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 todo: what about null.

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)

isClusterSafe

public boolean isClusterSafe()
Description copied from interface: PartitionService
Checks whether the cluster is in a safe state. When in a safe state, it is permissible to shut down a server instance.

Specified by:
isClusterSafe in interface PartitionService
Returns:
true if there are no partitions being migrated, and there are sufficient backups for each partition per the configuration; false otherwise.

isMemberSafe

public boolean isMemberSafe(Member member)
Description copied from interface: PartitionService
Check if the given member is safe to shutdown, meaning check if at least one backup of the partitions owned by the given member are in sync with primary.

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
Check if the local member is safe to shutdown, meaning check if at least one backup of the partitions owned by the local member are in sync with primary.

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

getPartition

public PartitionServiceProxy.PartitionProxy getPartition(int partitionId)


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.