use of com.hazelcast.spi.exception.PartitionMigratingException 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 (retryDuringMigration(op) && internalPartition.isMigrating()) {
throw new PartitionMigratingException(thisAddress, partitionId, op.getClass().getName(), op.getServiceName());
}
Address owner = internalPartition.getReplicaAddress(op.getReplicaIndex());
if (op.validatesTarget() && !thisAddress.equals(owner)) {
throw new WrongTargetException(thisAddress, owner, partitionId, op.getReplicaIndex(), op.getClass().getName(), op.getServiceName());
}
}
use of com.hazelcast.spi.exception.PartitionMigratingException in project hazelcast by hazelcast.
the class OperationParkerImpl method onPartitionMigrate.
// This is executed under partition migration lock!
public void onPartitionMigrate(Address thisAddress, MigrationInfo migrationInfo) {
if (!thisAddress.equals(migrationInfo.getSource())) {
return;
}
int partitionId = migrationInfo.getPartitionId();
for (Queue<ParkedOperation> parkQueue : parkQueueMap.values()) {
Iterator<ParkedOperation> it = parkQueue.iterator();
while (it.hasNext()) {
if (Thread.interrupted()) {
return;
}
ParkedOperation parkedOperation = it.next();
if (!parkedOperation.isValid()) {
continue;
}
Operation op = parkedOperation.getOperation();
if (partitionId == op.getPartitionId()) {
parkedOperation.setValid(false);
PartitionMigratingException pme = new PartitionMigratingException(thisAddress, partitionId, op.getClass().getName(), op.getServiceName());
OperationResponseHandler responseHandler = op.getOperationResponseHandler();
responseHandler.sendResponse(op, pme);
it.remove();
}
}
}
}
use of com.hazelcast.spi.exception.PartitionMigratingException in project hazelcast by hazelcast.
the class StaleReadDuringMigrationTest method testReadOperationFailsWhenStaleReadDisabledDuringMigration.
@Test
public void testReadOperationFailsWhenStaleReadDisabledDuringMigration() throws ExecutionException, InterruptedException {
final Config config = new Config();
config.setProperty(GroupProperty.DISABLE_STALE_READ_ON_PARTITION_MIGRATION.getName(), "true");
final InternalCompletableFuture<Boolean> future = invokeOperation(config);
try {
future.get();
fail();
} catch (ExecutionException e) {
assertTrue(e.getCause() instanceof PartitionMigratingException);
}
}
Aggregations