com.hazelcast.partition.impl
public class InternalPartitionServiceImpl extends Object implements InternalPartitionService, ManagedService, EventPublishingService<PartitionEvent,PartitionEventListener<PartitionEvent>>, PartitionAwareService
InternalPartitionService
implementation.DEFAULT_REPLICA_SYNC_DELAY, MIGRATION_EVENT_TOPIC, PARTITION_LOST_EVENT_TOPIC, REPLICA_SYNC_RETRY_DELAY, SERVICE_NAME
Constructor and Description |
---|
InternalPartitionServiceImpl(Node node) |
Modifier and Type | Method and Description |
---|---|
String |
addMigrationListener(MigrationListener listener) |
String |
addPartitionLostListener(PartitionLostListener listener) |
void |
clearPartitionReplicaVersions(int partitionId) |
void |
dispatchEvent(PartitionEvent partitionEvent,
PartitionEventListener partitionEventListener) |
void |
firstArrangement() |
Collection<MigrationInfo> |
getActiveMigrations() |
int |
getMaxBackupCount() |
MemberImpl |
getMember(Address address) |
int |
getMemberGroupsSize() |
List<Integer> |
getMemberPartitions(Address target) |
Map<Address,List<Integer>> |
getMemberPartitionsMap()
Gets member partition IDs.
|
InternalPartitionServiceState |
getMemberState() |
long |
getMigrationQueueSize() |
Node |
getNode() |
List<ReplicaSyncInfo> |
getOngoingReplicaSyncRequests() |
com.hazelcast.partition.impl.InternalPartitionImpl |
getPartition(int partitionId)
Returns the InternalPartition for a given partitionId.
|
com.hazelcast.partition.impl.InternalPartitionImpl |
getPartition(int partitionId,
boolean triggerOwnerAssignment)
Returns the InternalPartition for a given partitionId.
|
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.
|
long |
getPartitionMigrationTimeout() |
Address |
getPartitionOwner(int partitionId)
Gets the owner of the partition if it's set.
|
Address |
getPartitionOwnerOrWait(int partition)
Gets the owner of the partition.
|
long[] |
getPartitionReplicaVersions(int partitionId) |
InternalPartition[] |
getPartitions() |
PartitionServiceProxy |
getPartitionServiceProxy() |
int |
getPartitionStateVersion() |
List<ScheduledEntry<Integer,ReplicaSyncInfo>> |
getScheduledReplicaSyncRequests() |
boolean |
hasOnGoingMigration()
Checks if there currently are any migrations.
|
boolean |
hasOnGoingMigrationLocal() |
long[] |
incrementPartitionReplicaVersions(int partitionId,
int backupCount) |
void |
init(NodeEngine nodeEngine,
Properties properties)
Initializes this ManagedService
|
boolean |
isMemberStateSafe()
Query and return if this member in a safe state or not.
|
boolean |
isMigrationActive() |
boolean |
isPartitionOwner(int partitionId)
Check if this node is the owner of a partition
|
void |
memberAdded(MemberImpl member) |
void |
memberRemoved(MemberImpl member) |
void |
onPartitionLost(InternalPartitionLostEvent event)
Invoked when a partition lost is detected
|
void |
pauseMigration() |
boolean |
prepareToSafeShutdown(long timeout,
TimeUnit unit) |
boolean |
removeMigrationListener(String registrationId) |
boolean |
removePartitionLostListener(String registrationId) |
void |
reset()
reset this ManagedService back to initial state.
|
void |
resumeMigration() |
void |
setPartitionReplicaVersions(int partitionId,
long[] versions,
int replicaOffset) |
void |
shutdown(boolean terminate)
Shuts down this ManagedService.
|
String |
toString() |
void |
updatePartitionReplicaVersions(int partitionId,
long[] versions,
int replicaIndex) |
public InternalPartitionServiceImpl(Node node)
public void init(NodeEngine nodeEngine, Properties properties)
ManagedService
init
in interface ManagedService
nodeEngine
- the NodeEngine that this ManagedService belongs to.properties
- the Properties. Can be used to pass settings to the service.public Address getPartitionOwner(int partitionId)
InternalPartitionService
getPartitionOwner
in interface InternalPartitionService
partitionId
- the partitionIdpublic Address getPartitionOwnerOrWait(int partition)
InternalPartitionService
getPartitionOwnerOrWait
in interface InternalPartitionService
partition
- the partitionIdpublic void firstArrangement()
firstArrangement
in interface InternalPartitionService
public int getMemberGroupsSize()
getMemberGroupsSize
in interface InternalPartitionService
public int getMaxBackupCount()
getMaxBackupCount
in interface InternalPartitionService
public void memberAdded(MemberImpl member)
memberAdded
in interface InternalPartitionService
public void memberRemoved(MemberImpl member)
memberRemoved
in interface InternalPartitionService
public Collection<MigrationInfo> getActiveMigrations()
getActiveMigrations
in interface InternalPartitionService
public InternalPartition[] getPartitions()
getPartitions
in interface InternalPartitionService
public MemberImpl getMember(Address address)
getMember
in interface InternalPartitionService
public com.hazelcast.partition.impl.InternalPartitionImpl getPartition(int partitionId)
InternalPartitionService
getPartition
in interface InternalPartitionService
partitionId
- the partitionIdpublic com.hazelcast.partition.impl.InternalPartitionImpl getPartition(int partitionId, boolean triggerOwnerAssignment)
InternalPartitionService
triggerOwnerAssignment
is true,
it will trigger partition assignment.
The InternalPartition for a given partitionId wil never change; so it can be cached safely.getPartition
in interface InternalPartitionService
partitionId
- the partitionIdtriggerOwnerAssignment
- flag to trigger partition assignmentpublic boolean prepareToSafeShutdown(long timeout, TimeUnit unit)
prepareToSafeShutdown
in interface InternalPartitionService
public boolean isMemberStateSafe()
InternalPartitionService
isMemberStateSafe
in interface InternalPartitionService
true
if this member in a safe state, otherwise false
public InternalPartitionServiceState getMemberState()
public boolean hasOnGoingMigration()
InternalPartitionService
hasOnGoingMigration
in interface InternalPartitionService
public boolean hasOnGoingMigrationLocal()
hasOnGoingMigrationLocal
in interface InternalPartitionService
public final int getPartitionId(Data key)
InternalPartitionService
getPartitionId
in interface InternalPartitionService
key
- the Data key.public final int getPartitionId(Object key)
InternalPartitionService
getPartitionId
in interface InternalPartitionService
key
- the object key.public final int getPartitionCount()
InternalPartitionService
getPartitionCount
in interface InternalPartitionService
public long getPartitionMigrationTimeout()
public long[] incrementPartitionReplicaVersions(int partitionId, int backupCount)
incrementPartitionReplicaVersions
in interface InternalPartitionService
public void updatePartitionReplicaVersions(int partitionId, long[] versions, int replicaIndex)
updatePartitionReplicaVersions
in interface InternalPartitionService
public long[] getPartitionReplicaVersions(int partitionId)
getPartitionReplicaVersions
in interface InternalPartitionService
public void setPartitionReplicaVersions(int partitionId, long[] versions, int replicaOffset)
setPartitionReplicaVersions
in interface InternalPartitionService
public void clearPartitionReplicaVersions(int partitionId)
clearPartitionReplicaVersions
in interface InternalPartitionService
public Map<Address,List<Integer>> getMemberPartitionsMap()
InternalPartitionService
getMemberPartitionsMap
in interface InternalPartitionService
public List<Integer> getMemberPartitions(Address target)
getMemberPartitions
in interface InternalPartitionService
public void reset()
ManagedService
reset
in interface ManagedService
public void pauseMigration()
pauseMigration
in interface InternalPartitionService
public void resumeMigration()
resumeMigration
in interface InternalPartitionService
public boolean isMigrationActive()
public void shutdown(boolean terminate)
ManagedService
shutdown
in interface ManagedService
terminate
- true to shut down the ManagedServicepublic long getMigrationQueueSize()
getMigrationQueueSize
in interface InternalPartitionService
public PartitionServiceProxy getPartitionServiceProxy()
getPartitionServiceProxy
in interface InternalPartitionService
public String addMigrationListener(MigrationListener listener)
addMigrationListener
in interface InternalPartitionService
public boolean removeMigrationListener(String registrationId)
removeMigrationListener
in interface InternalPartitionService
public String addPartitionLostListener(PartitionLostListener listener)
addPartitionLostListener
in interface InternalPartitionService
public boolean removePartitionLostListener(String registrationId)
removePartitionLostListener
in interface InternalPartitionService
public void dispatchEvent(PartitionEvent partitionEvent, PartitionEventListener partitionEventListener)
dispatchEvent
in interface EventPublishingService<PartitionEvent,PartitionEventListener<PartitionEvent>>
public Node getNode()
public boolean isPartitionOwner(int partitionId)
InternalPartitionService
isPartitionOwner
in interface InternalPartitionService
public int getPartitionStateVersion()
getPartitionStateVersion
in interface InternalPartitionService
public void onPartitionLost(InternalPartitionLostEvent event)
PartitionAwareService
onPartitionLost
in interface PartitionAwareService
event
- The event object that contains the partition id and the number of replicas that is lostpublic List<ReplicaSyncInfo> getOngoingReplicaSyncRequests()
public List<ScheduledEntry<Integer,ReplicaSyncInfo>> getScheduledReplicaSyncRequests()
Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.