Search in sources :

Example 1 with WrongTargetException

use of com.hazelcast.spi.exception.WrongTargetException in project hazelcast by hazelcast.

the class ReplicaSyncResponse method nodeNotOwnsBackup.

/** Fail all replication operations with the exception that this node is no longer the replica with the sent index */
private void nodeNotOwnsBackup(InternalPartitionImpl partition) {
    int partitionId = getPartitionId();
    int replicaIndex = getReplicaIndex();
    Address thisAddress = getNodeEngine().getThisAddress();
    int currentReplicaIndex = partition.getReplicaIndex(thisAddress);
    ILogger logger = getLogger();
    if (logger.isFinestEnabled()) {
        logger.finest("This node is not backup replica of partitionId=" + partitionId + ", replicaIndex=" + replicaIndex + " anymore. current replicaIndex=" + currentReplicaIndex);
    }
    if (tasks != null) {
        Throwable throwable = new WrongTargetException(thisAddress, partition.getReplicaAddress(replicaIndex), partitionId, replicaIndex, getClass().getName());
        for (Operation op : tasks) {
            prepareOperation(op);
            onOperationFailure(op, throwable);
        }
    }
}
Also used : Address(com.hazelcast.nio.Address) ILogger(com.hazelcast.logging.ILogger) UrgentSystemOperation(com.hazelcast.spi.UrgentSystemOperation) PartitionAwareOperation(com.hazelcast.spi.PartitionAwareOperation) Operation(com.hazelcast.spi.Operation) BackupOperation(com.hazelcast.spi.BackupOperation) WrongTargetException(com.hazelcast.spi.exception.WrongTargetException)

Example 2 with WrongTargetException

use of com.hazelcast.spi.exception.WrongTargetException in project hazelcast by hazelcast.

the class PartitionReplicaSyncResponse method nodeNotOwnsBackup.

/**
 * Fail all replication operations with the exception that this node is no longer the replica with the sent index
 */
private void nodeNotOwnsBackup(InternalPartitionImpl partition) {
    int partitionId = getPartitionId();
    int replicaIndex = getReplicaIndex();
    NodeEngine nodeEngine = getNodeEngine();
    ILogger logger = getLogger();
    if (logger.isFinestEnabled()) {
        int currentReplicaIndex = partition.getReplicaIndex(PartitionReplica.from(nodeEngine.getLocalMember()));
        logger.finest("This node is not backup replica of partitionId=" + partitionId + ", replicaIndex=" + replicaIndex + " anymore. current replicaIndex=" + currentReplicaIndex);
    }
    if (operations != null) {
        PartitionReplica replica = partition.getReplica(replicaIndex);
        Member targetMember = null;
        if (replica != null) {
            ClusterServiceImpl clusterService = (ClusterServiceImpl) nodeEngine.getClusterService();
            targetMember = clusterService.getMember(replica.address(), replica.uuid());
        }
        Throwable throwable = new WrongTargetException(nodeEngine.getLocalMember(), targetMember, partitionId, replicaIndex, getClass().getName());
        for (Operation op : operations) {
            prepareOperation(op);
            onOperationFailure(op, throwable);
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) ILogger(com.hazelcast.logging.ILogger) Operation(com.hazelcast.spi.impl.operationservice.Operation) PartitionAwareOperation(com.hazelcast.spi.impl.operationservice.PartitionAwareOperation) UrgentSystemOperation(com.hazelcast.spi.impl.operationservice.UrgentSystemOperation) BackupOperation(com.hazelcast.spi.impl.operationservice.BackupOperation) Member(com.hazelcast.cluster.Member) WrongTargetException(com.hazelcast.spi.exception.WrongTargetException)

Example 3 with WrongTargetException

use of com.hazelcast.spi.exception.WrongTargetException in project hazelcast by hazelcast.

the class OperationRunnerImpl method ensureNoPartitionProblems.

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());
    }
}
Also used : PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) Member(com.hazelcast.cluster.Member) WrongTargetException(com.hazelcast.spi.exception.WrongTargetException) PartitionMigratingException(com.hazelcast.spi.exception.PartitionMigratingException)

Aggregations

WrongTargetException (com.hazelcast.spi.exception.WrongTargetException)3 Member (com.hazelcast.cluster.Member)2 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)2 ILogger (com.hazelcast.logging.ILogger)2 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)1 Address (com.hazelcast.nio.Address)1 BackupOperation (com.hazelcast.spi.BackupOperation)1 Operation (com.hazelcast.spi.Operation)1 PartitionAwareOperation (com.hazelcast.spi.PartitionAwareOperation)1 UrgentSystemOperation (com.hazelcast.spi.UrgentSystemOperation)1 PartitionMigratingException (com.hazelcast.spi.exception.PartitionMigratingException)1 NodeEngine (com.hazelcast.spi.impl.NodeEngine)1 BackupOperation (com.hazelcast.spi.impl.operationservice.BackupOperation)1 Operation (com.hazelcast.spi.impl.operationservice.Operation)1 PartitionAwareOperation (com.hazelcast.spi.impl.operationservice.PartitionAwareOperation)1 UrgentSystemOperation (com.hazelcast.spi.impl.operationservice.UrgentSystemOperation)1