private void ensureNoPartitionProblems(Operation op) {
int partitionId = op.getPartitionId();
if (partitionId < 0) {
return;
}
if (partitionId != getPartitionId()) {
throw new IllegalStateException("wrong partition, expected: " + getPartitionId() + " but found:" + partitionId);
}
if (internalPartition == null) {
internalPartition = nodeEngine.getPartitionService().getPartition(partitionId);
}
if (!isAllowedToRetryDuringMigration(op) && internalPartition.isMigrating()) {
throw new PartitionMigratingException(thisAddress, partitionId,
op.getClass().getName(), op.getServiceName());
}
PartitionReplica owner = internalPartition.getReplica(op.getReplicaIndex());
if (op.validatesTarget() && (owner == null || !owner.isIdentical(node.getLocalMember()))) {
Member target = owner != null ? node.getClusterService().getMember(owner.address(), owner.uuid()) : null;
throw new WrongTargetException(node.getLocalMember(), target, partitionId, op.getReplicaIndex(),
op.getClass().getName(), op.getServiceName());
}
}