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) |
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(Address[][] newState, int partitionStateVersion)
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)
updatePartitionReplicaVersions
in interface InternalPartitionService
public 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)
getMemberPartitions
in interface IPartitionService
public void reset()
ManagedService
reset
in interface ManagedService
public void pauseMigration()
pauseMigration
in interface InternalPartitionService
public void resumeMigration()
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()
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.