com.hazelcast.partition
Interface InternalPartition


public interface InternalPartition

Represents a Partition. It is comparable to the Partition but it is optimized for internal usage, so it exposes method not meant for regular Hazelcast users.

The InternalPartition provides access to information about a partition, most importantly the addresses of the replica's and this information will be updated. So one can cache the InternalPartition and keep asking for partition information.


Field Summary
static int MAX_BACKUP_COUNT
           
static int MAX_REPLICA_COUNT
           
 
Method Summary
 Address getOwnerOrNull()
          Returns the Address of the owner of this partition.
 int getPartitionId()
          Returns the partition id.
 Address getReplicaAddress(int replicaIndex)
          Returns Address of the replica.
 boolean isMigrating()
          Checks if there currently is a migration going on in this partition.
 boolean isOwnerOrBackup(Address address)
          Checks if given address is owner of primary or backup of this partition.
 

Field Detail

MAX_REPLICA_COUNT

static final int MAX_REPLICA_COUNT
See Also:
Constant Field Values

MAX_BACKUP_COUNT

static final int MAX_BACKUP_COUNT
See Also:
Constant Field Values
Method Detail

getPartitionId

int getPartitionId()
Returns the partition id. The partition id will be between 0 and partitionCount (exclusive).

Returns:
the id of the partition.

getOwnerOrNull

Address getOwnerOrNull()
Returns the Address of the owner of this partition.

If no owner has been set yet, null is returned. So be careful with assuming that a non null value is returned.

The value could be stale when returned.

Returns:
the owner.

isMigrating

boolean isMigrating()
Checks if there currently is a migration going on in this partition.

The returned value could be stale when it is returned.

Returns:
true if there is a migration going on, false otherwise.

getReplicaAddress

Address getReplicaAddress(int replicaIndex)
Returns Address of the replica.

The owner has replica index 0.

The returned value could be null if the owner/replica has not yet been set.

The returned value could be stale when it is returned.

Parameters:
replicaIndex - the index of the replica.
Returns:
the Address of the replica.
Throws:
ArrayIndexOutOfBoundsException - when replica index is out of bounds

isOwnerOrBackup

boolean isOwnerOrBackup(Address address)
Checks if given address is owner of primary or backup of this partition.

Parameters:
address - owner address
Returns:
true if address is owner or backup, false otherwise


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