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);
}
}
}
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);
}
}
}
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());
}
}
Aggregations