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_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) |
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)
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)
IPartitionService
getPartitionOwner
in interface IPartitionService
partitionId
- the partitionIdpublic Address getPartitionOwnerOrWait(int partitionId)
IPartitionService
getPartitionOwnerOrWait
in interface IPartitionService
partitionId
- the partitionIdpublic void firstArrangement()
firstArrangement
in interface InternalPartitionService
public void setInitialState(PartitionTableView partitionTable)
public int getMemberGroupsSize()
getMemberGroupsSize
in interface InternalPartitionService
public int getMaxAllowedBackupCount()
IPartitionService
IPartition.MAX_BACKUP_COUNT
].getMaxAllowedBackupCount
in interface IPartitionService
public boolean isMemberAllowedToJoin(Address address)
isMemberAllowedToJoin
in interface InternalPartitionService
public void memberAdded(MemberImpl member)
memberAdded
in interface InternalPartitionService
public void memberRemoved(MemberImpl member)
memberRemoved
in interface InternalPartitionService
public void cancelReplicaSyncRequestsTo(Address deadAddress)
public PartitionRuntimeState createPartitionState()
createPartitionState
in interface InternalPartitionService
public PartitionRuntimeState createPartitionStateInternal()
public boolean processPartitionRuntimeState(PartitionRuntimeState partitionState)
public IPartition[] getPartitions()
getPartitions
in interface IPartitionService
public InternalPartition[] getInternalPartitions()
getInternalPartitions
in interface InternalPartitionService
public InternalPartition getPartition(int partitionId)
IPartitionService
getPartition
in interface InternalPartitionService
getPartition
in interface IPartitionService
partitionId
- the partitionIdpublic InternalPartition getPartition(int partitionId, boolean triggerOwnerAssignment)
IPartitionService
triggerOwnerAssignment
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 InternalPartitionService
getPartition
in interface IPartitionService
partitionId
- the partitionIdtriggerOwnerAssignment
- flag to trigger partition assignmentpublic boolean prepareToSafeShutdown(long timeout, TimeUnit unit)
prepareToSafeShutdown
in interface InternalPartitionService
public void onShutdownRequest(Address address)
public void onShutdownResponse()
public boolean isMemberStateSafe()
IPartitionService
isMemberStateSafe
in interface IPartitionService
true
if this member in a safe state, otherwise false
public boolean hasOnGoingMigration()
IPartitionService
hasOnGoingMigration
in interface IPartitionService
public boolean hasOnGoingMigrationLocal()
IPartitionService
hasOnGoingMigrationLocal
in interface IPartitionService
public final int getPartitionId(Data key)
IPartitionService
getPartitionId
in interface IPartitionService
key
- the Data key.public final int getPartitionId(Object key)
IPartitionService
getPartitionId
in interface IPartitionService
key
- the object key.public final int getPartitionCount()
IPartitionService
getPartitionCount
in interface IPartitionService
public long getPartitionMigrationTimeout()
public long[] incrementPartitionReplicaVersions(int partitionId, int backupCount)
incrementPartitionReplicaVersions
in interface InternalPartitionService
public void updatePartitionReplicaVersions(int partitionId, long[] versions, int replicaIndex)
InternalPartitionService
updatePartitionReplicaVersions
in interface InternalPartitionService
partitionId
- 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 InternalPartitionService
public long[] getPartitionReplicaVersions(int partitionId)
getPartitionReplicaVersions
in interface InternalPartitionService
public Map<Address,List<Integer>> getMemberPartitionsMap()
IPartitionService
getMemberPartitionsMap
in interface IPartitionService
public List<Integer> getMemberPartitions(Address target)
IPartitionService
getMemberPartitions
in interface IPartitionService
public List<Integer> getMemberPartitionsIfAssigned(Address target)
InternalPartitionService
getMemberPartitionsIfAssigned
in interface InternalPartitionService
public void reset()
ManagedService
reset
in interface ManagedService
public void pauseMigration()
InternalPartitionService
pauseMigration
in interface InternalPartitionService
public void resumeMigration()
InternalPartitionService
resumeMigration
in interface InternalPartitionService
public boolean isReplicaSyncAllowed()
public void shutdown(boolean terminate)
ManagedService
shutdown
in interface ManagedService
terminate
- true to shut down the ManagedServicepublic long getMigrationQueueSize()
getMigrationQueueSize
in interface IPartitionService
public PartitionServiceProxy getPartitionServiceProxy()
public String addMigrationListener(MigrationListener listener)
addMigrationListener
in interface IPartitionService
public boolean removeMigrationListener(String registrationId)
removeMigrationListener
in interface IPartitionService
public String addPartitionLostListener(PartitionLostListener listener)
addPartitionLostListener
in interface IPartitionService
public String addLocalPartitionLostListener(PartitionLostListener listener)
addLocalPartitionLostListener
in interface IPartitionService
public boolean removePartitionLostListener(String registrationId)
removePartitionLostListener
in interface IPartitionService
public void dispatchEvent(PartitionEvent partitionEvent, PartitionEventListener partitionEventListener)
dispatchEvent
in interface EventPublishingService<PartitionEvent,PartitionEventListener<PartitionEvent>>
public void addPartitionListener(PartitionListener listener)
public boolean isPartitionOwner(int partitionId)
IPartitionService
isPartitionOwner
in interface IPartitionService
public int getPartitionStateVersion()
getPartitionStateVersion
in interface IPartitionService
public void onPartitionLost(IPartitionLostEvent event)
PartitionAwareService
onPartitionLost
in interface PartitionAwareService
event
- 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 InternalPartitionService
Copyright © 2017 Hazelcast, Inc.. All Rights Reserved.