PartitionReplica checkAndGetPrimaryReplicaOwner ( int partitionId , int replicaIndex ) { InternalPartitionImpl partition = partitionStateManager . getPartitionImpl ( partitionId ) ; PartitionReplica owner = partition . getOwnerReplicaOrNull ( ) ; if ( owner == null ) { logger . info ( "Sync replica target is null, no need to sync -> partitionId=" + partitionId + ", replicaIndex=" + replicaIndex ) ; return null ; } PartitionReplica localReplica = PartitionReplica . from ( nodeEngine . getLocalMember ( ) ) ; if ( owner . equals ( localReplica ) ) { if ( logger . isFinestEnabled ( ) ) { logger . finest ( "This node is now owner of partition, cannot sync replica -> partitionId=" + partitionId + ", replicaIndex=" + replicaIndex + ", partition-info=" + partitionStateManager . getPartitionImpl ( partitionId ) ) ; } return null ; } if ( ! partition . isOwnerOrBackup ( localReplica ) ) { if ( logger . isFinestEnabled ( ) ) { logger . finest ( "This node is not backup replica of partitionId=" + partitionId + ", replicaIndex=" + replicaIndex + " anymore." ) ; } return null ; } return owner ; }
Checks preconditions for replica sync - if we don t know the owner yet if this node is the owner or not a replica