public class InternalPartitionImpl extends Object implements InternalPartition
MAX_REPLICA_COUNT
MAX_BACKUP_COUNT
Constructor and Description |
---|
InternalPartitionImpl(int partitionId,
PartitionListener listener,
PartitionReplica localReplica,
PartitionReplica[] replicas) |
Modifier and Type | Method and Description |
---|---|
Address |
getOwnerOrNull()
Returns the address of the owner of this partition.
|
PartitionReplica |
getOwnerReplicaOrNull()
Returns the partition replica of the owner of this partition.
|
int |
getPartitionId()
Returns the partition ID.
|
PartitionReplica |
getReplica(int replicaIndex)
Returns the partition replica assigned to the replica index.
|
Address |
getReplicaAddress(int replicaIndex)
Returns the address of the replica.
|
int |
getReplicaIndex(PartitionReplica replica)
Return the index of partition replica for this partition.
|
boolean |
isLocal()
Checks if the partition is local.
|
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.
|
boolean |
isOwnerOrBackup(PartitionReplica replica) |
void |
resetMigrating()
Resets migrating flag.
|
boolean |
setMigrating()
Sets migrating flag if it's not set already.
|
String |
toString() |
public InternalPartitionImpl(int partitionId, PartitionListener listener, PartitionReplica localReplica, PartitionReplica[] replicas)
public int getPartitionId()
IPartition
The partition ID will be between 0 and partitionCount (exclusive).
getPartitionId
in interface IPartition
public boolean isMigrating()
IPartition
The returned value could be stale when it is returned.
isMigrating
in interface IPartition
true
if there is a migration going on, false
otherwisepublic boolean setMigrating()
public void resetMigrating()
public boolean isLocal()
IPartition
IPartition.getOwnerOrNull()
returns the same address as 'this' address of the
ClusterService.getThisAddress()
. If the address is null
or a different address, false
is returned.isLocal
in interface IPartition
true
if local, false
otherwisepublic Address getOwnerOrNull()
IPartition
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.
getOwnerOrNull
in interface IPartition
public PartitionReplica getOwnerReplicaOrNull()
InternalPartition
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.
getOwnerReplicaOrNull
in interface InternalPartition
public Address getReplicaAddress(int replicaIndex)
IPartition
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.
getReplicaAddress
in interface IPartition
replicaIndex
- the index of the replicapublic PartitionReplica getReplica(int replicaIndex)
InternalPartition
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.
getReplica
in interface InternalPartition
replicaIndex
- the index of the replicapublic boolean isOwnerOrBackup(Address address)
IPartition
isOwnerOrBackup
in interface IPartition
address
- owner addresstrue
if address is owner or backup, false
otherwisepublic int getReplicaIndex(PartitionReplica replica)
InternalPartition
getReplicaIndex
in interface InternalPartition
replica
- partition replicapublic boolean isOwnerOrBackup(PartitionReplica replica)
Copyright © 2021 Hazelcast, Inc.. All Rights Reserved.