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 |
addLocalPartitionLostListener(PartitionLostListener listener) |
String |
addMigrationListener(MigrationListener listener) |
void |
addPartitionListener(PartitionListener listener) |
String |
addPartitionLostListener(PartitionLostListener listener) |
void |
cancelReplicaSyncRequestsTo(Address deadAddress) |
void |
clearPartitionReplicaVersions(int partitionId) |
void |
clearPartitionReplicaVersionsExceptSyncWaitingReplicas(int partitionId) |
PartitionRuntimeState |
createPartitionState() |
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 partitionId)
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 are any cluster-wide migrations.
|
boolean |
hasOnGoingMigrationLocal()
Checks if there are any local migrations.
|
long[] |
incrementPartitionReplicaVersions(int partitionId,
int backupCount) |
void |
init(NodeEngine nodeEngine,
Properties properties)
Initializes this ManagedService
|
Future |
invokeCheckReplicaSyncOperationIfOwnPartition(int partitionId,
int replicaIndex) |
boolean |
isMemberStateSafe()
Query and return if this member in a safe state or not.
|
boolean |
isMigrationAllowed() |
boolean |
isPartitionOwner(int partitionId)
Check if this node is the owner of a partition
|
boolean |
isPartitionReplicaVersionStale(int partitionId,
long[] versions,
int replicaIndex) |
boolean |
isReplicaSyncAllowed() |
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) |
void |
processPartitionRuntimeState(PartitionRuntimeState partitionState) |
boolean |
removeMigrationListener(String registrationId) |
boolean |
removePartitionLostListener(String registrationId) |
void |
reset()
reset this ManagedService back to initial state.
|
void |
resumeMigration() |
void |
setInitialState(Address[][] newState,
int partitionStateVersion) |
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)
ManagedServiceinit in interface ManagedServicenodeEngine - the NodeEngine that this ManagedService belongs to.properties - the Properties. Can be used to pass settings to the service.public Address getPartitionOwner(int partitionId)
InternalPartitionServicegetPartitionOwner in interface InternalPartitionServicepartitionId - the partitionIdpublic Address getPartitionOwnerOrWait(int partitionId)
InternalPartitionServicegetPartitionOwnerOrWait in interface InternalPartitionServicepartitionId - the partitionIdpublic void firstArrangement()
firstArrangement in interface InternalPartitionServicepublic void setInitialState(Address[][] newState, int partitionStateVersion)
public int getMemberGroupsSize()
getMemberGroupsSize in interface InternalPartitionServicepublic int getMaxBackupCount()
getMaxBackupCount in interface InternalPartitionServicepublic void memberAdded(MemberImpl member)
memberAdded in interface InternalPartitionServicepublic void memberRemoved(MemberImpl member)
memberRemoved in interface InternalPartitionServicepublic void cancelReplicaSyncRequestsTo(Address deadAddress)
public PartitionRuntimeState createPartitionState()
public void processPartitionRuntimeState(PartitionRuntimeState partitionState)
public Collection<MigrationInfo> getActiveMigrations()
getActiveMigrations in interface InternalPartitionServicepublic InternalPartition[] getPartitions()
getPartitions in interface InternalPartitionServicepublic MemberImpl getMember(Address address)
getMember in interface InternalPartitionServicepublic com.hazelcast.partition.impl.InternalPartitionImpl getPartition(int partitionId)
InternalPartitionServicegetPartition in interface InternalPartitionServicepartitionId - the partitionIdpublic com.hazelcast.partition.impl.InternalPartitionImpl getPartition(int partitionId,
boolean triggerOwnerAssignment)
InternalPartitionServicetriggerOwnerAssignment 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 InternalPartitionServicepartitionId - the partitionIdtriggerOwnerAssignment - flag to trigger partition assignmentpublic boolean prepareToSafeShutdown(long timeout,
TimeUnit unit)
prepareToSafeShutdown in interface InternalPartitionServicepublic boolean isMemberStateSafe()
InternalPartitionServiceisMemberStateSafe in interface InternalPartitionServicetrue if this member in a safe state, otherwise falsepublic InternalPartitionServiceState getMemberState()
public boolean hasOnGoingMigration()
InternalPartitionServicehasOnGoingMigration in interface InternalPartitionServicepublic boolean hasOnGoingMigrationLocal()
InternalPartitionServicehasOnGoingMigrationLocal in interface InternalPartitionServicepublic Future invokeCheckReplicaSyncOperationIfOwnPartition(int partitionId, int replicaIndex)
public final int getPartitionId(Data key)
InternalPartitionServicegetPartitionId in interface InternalPartitionServicekey - the Data key.public final int getPartitionId(Object key)
InternalPartitionServicegetPartitionId in interface InternalPartitionServicekey - the object key.public final int getPartitionCount()
InternalPartitionServicegetPartitionCount in interface InternalPartitionServicepublic long getPartitionMigrationTimeout()
public long[] incrementPartitionReplicaVersions(int partitionId,
int backupCount)
incrementPartitionReplicaVersions in interface InternalPartitionServicepublic void updatePartitionReplicaVersions(int partitionId,
long[] versions,
int replicaIndex)
updatePartitionReplicaVersions in interface InternalPartitionServicepublic boolean isPartitionReplicaVersionStale(int partitionId,
long[] versions,
int replicaIndex)
isPartitionReplicaVersionStale in interface InternalPartitionServicepublic long[] getPartitionReplicaVersions(int partitionId)
getPartitionReplicaVersions in interface InternalPartitionServicepublic void setPartitionReplicaVersions(int partitionId,
long[] versions,
int replicaOffset)
setPartitionReplicaVersions in interface InternalPartitionServicepublic void clearPartitionReplicaVersions(int partitionId)
clearPartitionReplicaVersions in interface InternalPartitionServicepublic void clearPartitionReplicaVersionsExceptSyncWaitingReplicas(int partitionId)
clearPartitionReplicaVersionsExceptSyncWaitingReplicas in interface InternalPartitionServicepublic Map<Address,List<Integer>> getMemberPartitionsMap()
InternalPartitionServicegetMemberPartitionsMap in interface InternalPartitionServicepublic List<Integer> getMemberPartitions(Address target)
getMemberPartitions in interface InternalPartitionServicepublic void reset()
ManagedServicereset in interface ManagedServicepublic void pauseMigration()
pauseMigration in interface InternalPartitionServicepublic void resumeMigration()
resumeMigration in interface InternalPartitionServicepublic boolean isReplicaSyncAllowed()
public boolean isMigrationAllowed()
public void shutdown(boolean terminate)
ManagedServiceshutdown in interface ManagedServiceterminate - true to shut down the ManagedServicepublic long getMigrationQueueSize()
getMigrationQueueSize in interface InternalPartitionServicepublic PartitionServiceProxy getPartitionServiceProxy()
getPartitionServiceProxy in interface InternalPartitionServicepublic String addMigrationListener(MigrationListener listener)
addMigrationListener in interface InternalPartitionServicepublic boolean removeMigrationListener(String registrationId)
removeMigrationListener in interface InternalPartitionServicepublic String addPartitionLostListener(PartitionLostListener listener)
addPartitionLostListener in interface InternalPartitionServicepublic String addLocalPartitionLostListener(PartitionLostListener listener)
addLocalPartitionLostListener in interface InternalPartitionServicepublic boolean removePartitionLostListener(String registrationId)
removePartitionLostListener in interface InternalPartitionServicepublic void dispatchEvent(PartitionEvent partitionEvent, PartitionEventListener partitionEventListener)
dispatchEvent in interface EventPublishingService<PartitionEvent,PartitionEventListener<PartitionEvent>>public void addPartitionListener(PartitionListener listener)
public Node getNode()
public boolean isPartitionOwner(int partitionId)
InternalPartitionServiceisPartitionOwner in interface InternalPartitionServicepublic int getPartitionStateVersion()
getPartitionStateVersion in interface InternalPartitionServicepublic void onPartitionLost(InternalPartitionLostEvent event)
PartitionAwareServiceonPartitionLost in interface PartitionAwareServiceevent - 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 © 2016 Hazelcast, Inc.. All Rights Reserved.