public class InternalPartitionServiceImpl extends Object implements InternalPartitionService, ManagedService, EventPublishingService<PartitionEvent,PartitionEventListener<PartitionEvent>>, PartitionAwareService
InternalPartitionService implementation.DEFAULT_REPLICA_SYNC_DELAY, MIGRATION_EVENT_TOPIC, MIGRATION_RETRY_COUNT, MIGRATION_RETRY_PAUSE, PARTITION_LOST_EVENT_TOPIC, REPLICA_SYNC_RETRY_DELAYSERVICE_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) |
PartitionRuntimeState |
createPartitionState() |
PartitionRuntimeState |
createPartitionStateInternal() |
PartitionTableView |
createPartitionTableView() |
void |
dispatchEvent(PartitionEvent partitionEvent,
PartitionEventListener partitionEventListener) |
void |
firstArrangement() |
InternalMigrationListener |
getInternalMigrationListener() |
InternalPartition[] |
getInternalPartitions() |
int |
getMaxAllowedBackupCount()
Returns maximum allowed backup count according to current
cluster formation and partition group configuration.
|
int |
getMemberGroupsSize() |
List<Integer> |
getMemberPartitions(Address target)
Returns partition id list assigned to given target.
|
List<Integer> |
getMemberPartitionsIfAssigned(Address target)
Returns partition id list assigned to given target if partitions are assigned when method is called.
|
Map<Address,List<Integer>> |
getMemberPartitionsMap()
Gets member partition IDs.
|
MigrationManager |
getMigrationManager() |
long |
getMigrationQueueSize() |
List<ReplicaSyncInfo> |
getOngoingReplicaSyncRequests() |
InternalPartition |
getPartition(int partitionId)
Returns the IPartition for a given partitionId.
|
InternalPartition |
getPartition(int partitionId,
boolean triggerOwnerAssignment)
Returns the IPartition for a given partitionId.
|
int |
getPartitionCount()
Returns the number of partitions.
|
PartitionEventManager |
getPartitionEventManager() |
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.
|
PartitionReplicaStateChecker |
getPartitionReplicaStateChecker() |
long[] |
getPartitionReplicaVersions(int partitionId) |
IPartition[] |
getPartitions() |
PartitionServiceProxy |
getPartitionServiceProxy() |
PartitionStateManager |
getPartitionStateManager() |
int |
getPartitionStateVersion() |
PartitionReplicaManager |
getReplicaManager() |
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
|
boolean |
isMemberAllowedToJoin(Address address) |
boolean |
isMemberStateSafe()
Query and return if this member in a safe state or not.
|
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(IPartitionLostEvent event)
Invoked when a partition lost is detected
|
void |
onShutdownRequest(Address address) |
void |
onShutdownResponse() |
void |
pauseMigration()
Pause all migrations
|
boolean |
prepareToSafeShutdown(long timeout,
TimeUnit unit) |
boolean |
processPartitionRuntimeState(PartitionRuntimeState partitionState) |
boolean |
removeMigrationListener(String registrationId) |
boolean |
removePartitionLostListener(String registrationId) |
void |
replaceAddress(Address oldAddress,
Address newAddress) |
void |
reset()
reset this ManagedService back to initial state.
|
void |
resetInternalMigrationListener() |
void |
resumeMigration()
Resume all migrations
|
void |
setInitialState(PartitionTableView partitionTable) |
void |
setInternalMigrationListener(InternalMigrationListener listener) |
void |
shutdown(boolean terminate)
Shuts down this ManagedService.
|
String |
toString() |
void |
updatePartitionReplicaVersions(int partitionId,
long[] versions,
int replicaIndex)
Updates the partition replica version and triggers replica sync if the replica is dirty (e.g.
|
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)
IPartitionServicegetPartitionOwner in interface IPartitionServicepartitionId - the partitionIdpublic Address getPartitionOwnerOrWait(int partitionId)
IPartitionServicegetPartitionOwnerOrWait in interface IPartitionServicepartitionId - the partitionIdpublic void firstArrangement()
firstArrangement in interface InternalPartitionServicepublic void setInitialState(PartitionTableView partitionTable)
public int getMemberGroupsSize()
getMemberGroupsSize in interface InternalPartitionServicepublic int getMaxAllowedBackupCount()
IPartitionServiceIPartition.MAX_BACKUP_COUNT].getMaxAllowedBackupCount in interface IPartitionServicepublic boolean isMemberAllowedToJoin(Address address)
isMemberAllowedToJoin 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()
createPartitionState in interface InternalPartitionServicepublic PartitionRuntimeState createPartitionStateInternal()
public boolean processPartitionRuntimeState(PartitionRuntimeState partitionState)
public IPartition[] getPartitions()
getPartitions in interface IPartitionServicepublic InternalPartition[] getInternalPartitions()
getInternalPartitions in interface InternalPartitionServicepublic InternalPartition getPartition(int partitionId)
IPartitionServicegetPartition in interface InternalPartitionServicegetPartition in interface IPartitionServicepartitionId - the partitionIdpublic InternalPartition getPartition(int partitionId, boolean triggerOwnerAssignment)
IPartitionServicetriggerOwnerAssignment is true,
it will trigger partition assignment.
The IPartition for a given partitionId will never change, so it can be cached safely.getPartition in interface InternalPartitionServicegetPartition in interface IPartitionServicepartitionId - the partitionIdtriggerOwnerAssignment - flag to trigger partition assignmentpublic boolean prepareToSafeShutdown(long timeout,
TimeUnit unit)
prepareToSafeShutdown in interface InternalPartitionServicepublic void onShutdownRequest(Address address)
public void onShutdownResponse()
public boolean isMemberStateSafe()
IPartitionServiceisMemberStateSafe in interface IPartitionServicetrue if this member in a safe state, otherwise falsepublic boolean hasOnGoingMigration()
IPartitionServicehasOnGoingMigration in interface IPartitionServicepublic boolean hasOnGoingMigrationLocal()
IPartitionServicehasOnGoingMigrationLocal in interface IPartitionServicepublic final int getPartitionId(Data key)
IPartitionServicegetPartitionId in interface IPartitionServicekey - the Data key.public final int getPartitionId(Object key)
IPartitionServicegetPartitionId in interface IPartitionServicekey - the object key.public final int getPartitionCount()
IPartitionServicegetPartitionCount in interface IPartitionServicepublic long getPartitionMigrationTimeout()
public long[] incrementPartitionReplicaVersions(int partitionId,
int backupCount)
incrementPartitionReplicaVersions in interface InternalPartitionServicepublic void updatePartitionReplicaVersions(int partitionId,
long[] versions,
int replicaIndex)
InternalPartitionServiceupdatePartitionReplicaVersions in interface InternalPartitionServicepartitionId - the id of the partition for which we received a new versionversions - the received replica versionsreplicaIndex - the index of this replicapublic boolean isPartitionReplicaVersionStale(int partitionId,
long[] versions,
int replicaIndex)
isPartitionReplicaVersionStale in interface InternalPartitionServicepublic long[] getPartitionReplicaVersions(int partitionId)
getPartitionReplicaVersions in interface InternalPartitionServicepublic Map<Address,List<Integer>> getMemberPartitionsMap()
IPartitionServicegetMemberPartitionsMap in interface IPartitionServicepublic List<Integer> getMemberPartitions(Address target)
IPartitionServicegetMemberPartitions in interface IPartitionServicepublic List<Integer> getMemberPartitionsIfAssigned(Address target)
InternalPartitionServicegetMemberPartitionsIfAssigned in interface InternalPartitionServicepublic void reset()
ManagedServicereset in interface ManagedServicepublic void pauseMigration()
InternalPartitionServicepauseMigration in interface InternalPartitionServicepublic void resumeMigration()
InternalPartitionServiceresumeMigration in interface InternalPartitionServicepublic boolean isReplicaSyncAllowed()
public void shutdown(boolean terminate)
ManagedServiceshutdown in interface ManagedServiceterminate - true to shut down the ManagedServicepublic long getMigrationQueueSize()
getMigrationQueueSize in interface IPartitionServicepublic PartitionServiceProxy getPartitionServiceProxy()
public String addMigrationListener(MigrationListener listener)
addMigrationListener in interface IPartitionServicepublic boolean removeMigrationListener(String registrationId)
removeMigrationListener in interface IPartitionServicepublic String addPartitionLostListener(PartitionLostListener listener)
addPartitionLostListener in interface IPartitionServicepublic String addLocalPartitionLostListener(PartitionLostListener listener)
addLocalPartitionLostListener in interface IPartitionServicepublic boolean removePartitionLostListener(String registrationId)
removePartitionLostListener in interface IPartitionServicepublic void dispatchEvent(PartitionEvent partitionEvent, PartitionEventListener partitionEventListener)
dispatchEvent in interface EventPublishingService<PartitionEvent,PartitionEventListener<PartitionEvent>>public void addPartitionListener(PartitionListener listener)
public boolean isPartitionOwner(int partitionId)
IPartitionServiceisPartitionOwner in interface IPartitionServicepublic int getPartitionStateVersion()
getPartitionStateVersion in interface IPartitionServicepublic void onPartitionLost(IPartitionLostEvent event)
PartitionAwareServiceonPartitionLost in interface PartitionAwareServiceevent - The event object that contains the partition id and the number of replicas that is lostpublic void setInternalMigrationListener(InternalMigrationListener listener)
public InternalMigrationListener getInternalMigrationListener()
public void resetInternalMigrationListener()
public List<ReplicaSyncInfo> getOngoingReplicaSyncRequests()
public List<ScheduledEntry<Integer,ReplicaSyncInfo>> getScheduledReplicaSyncRequests()
public PartitionStateManager getPartitionStateManager()
public MigrationManager getMigrationManager()
public PartitionReplicaManager getReplicaManager()
public PartitionReplicaStateChecker getPartitionReplicaStateChecker()
public PartitionEventManager getPartitionEventManager()
public PartitionTableView createPartitionTableView()
createPartitionTableView in interface InternalPartitionServiceCopyright © 2017 Hazelcast, Inc.. All Rights Reserved.