use of com.hazelcast.spi.exception.RetryableHazelcastException in project hazelcast by hazelcast.
the class PromotionCommitOperation method beforePromotion.
/**
* Sends {@link BeforePromotionOperation}s for all promotions and register a callback on each operation to track when
* operations are finished.
*/
private CallStatus beforePromotion() {
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
OperationServiceImpl operationService = nodeEngine.getOperationService();
InternalPartitionServiceImpl partitionService = getService();
if (!partitionService.getMigrationManager().acquirePromotionPermit()) {
throw new RetryableHazelcastException("Another promotion is being run currently. " + "This is only expected when promotion is retried to an unresponsive destination.");
}
long partitionStateStamp;
partitionStateStamp = partitionService.getPartitionStateStamp();
if (partitionState.getStamp() == partitionStateStamp) {
return alreadyAppliedAllPromotions();
}
filterAlreadyAppliedPromotions();
if (promotions.isEmpty()) {
return alreadyAppliedAllPromotions();
}
ILogger logger = getLogger();
migrationState = new MigrationStateImpl(Clock.currentTimeMillis(), promotions.size(), 0, 0L);
partitionService.getMigrationInterceptor().onPromotionStart(MigrationParticipant.DESTINATION, promotions);
partitionService.getPartitionEventManager().sendMigrationProcessStartedEvent(migrationState);
if (logger.isFineEnabled()) {
logger.fine("Submitting BeforePromotionOperations for " + promotions.size() + " promotions. " + "Promotion partition state stamp: " + partitionState.getStamp() + ", current partition state stamp: " + partitionStateStamp);
}
PromotionOperationCallback beforePromotionsCallback = new BeforePromotionOperationCallback(this, promotions.size());
for (MigrationInfo promotion : promotions) {
if (logger.isFinestEnabled()) {
logger.finest("Submitting BeforePromotionOperation for promotion: " + promotion);
}
Operation op = new BeforePromotionOperation(promotion, beforePromotionsCallback);
op.setPartitionId(promotion.getPartitionId()).setNodeEngine(nodeEngine).setService(partitionService);
operationService.execute(op);
}
return CallStatus.VOID;
}
use of com.hazelcast.spi.exception.RetryableHazelcastException in project hazelcast by hazelcast.
the class MapFetchIndexOperation method runInternal.
@Override
protected void runInternal() {
Indexes indexes = mapContainer.getIndexes();
if (indexes == null) {
throw QueryException.error(SqlErrorCode.INDEX_INVALID, "Cannot use the index \"" + indexName + "\" of the IMap \"" + name + "\" because it is not global " + "(make sure the property \"" + ClusterProperty.GLOBAL_HD_INDEX_ENABLED + "\" is set to \"true\")");
}
InternalIndex index = indexes.getIndex(indexName);
if (index == null) {
throw QueryException.error(SqlErrorCode.INDEX_INVALID, "Index \"" + indexName + "\" does not exist");
}
PartitionStamp indexStamp = index.getPartitionStamp();
if (indexStamp == null) {
throw new RetryableHazelcastException("Index is being rebuilt");
}
if (indexStamp.partitions.equals(partitionIdSet)) {
// We clear the requested partitionIdSet, which means that we won't filter out any partitions.
// This is an optimization for the case when there was no concurrent migration.
partitionIdSet = null;
} else {
if (!indexStamp.partitions.containsAll(partitionIdSet)) {
throw new MissingPartitionException("some requested partitions are not indexed");
}
}
switch(index.getConfig().getType()) {
case HASH:
response = runInternalHash(index);
break;
case SORTED:
response = runInternalSorted(index);
break;
case BITMAP:
throw new UnsupportedOperationException("BITMAP index scan is not implemented");
default:
throw new UnsupportedOperationException("Unknown index type: \"" + index.getConfig().getType().name() + "\"");
}
if (!index.validatePartitionStamp(indexStamp.stamp)) {
throw new MissingPartitionException("partition timestamp has changed");
}
}
use of com.hazelcast.spi.exception.RetryableHazelcastException in project hazelcast by hazelcast.
the class Invocation_RetryTest method testNoStuckInvocationsWhenRetriedMultipleTimes.
@Test
public void testNoStuckInvocationsWhenRetriedMultipleTimes() throws Exception {
Config config = new Config();
config.setProperty(ClusterProperty.OPERATION_CALL_TIMEOUT_MILLIS.getName(), "3000");
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance local = factory.newHazelcastInstance(config);
HazelcastInstance remote = factory.newHazelcastInstance(config);
warmUpPartitions(local, remote);
NodeEngineImpl localNodeEngine = getNodeEngineImpl(local);
NodeEngineImpl remoteNodeEngine = getNodeEngineImpl(remote);
final OperationServiceImpl operationService = (OperationServiceImpl) localNodeEngine.getOperationService();
NonResponsiveOperation op = new NonResponsiveOperation();
op.setValidateTarget(false);
op.setPartitionId(1);
InvocationFuture future = (InvocationFuture) operationService.invokeOnTarget(null, op, remoteNodeEngine.getThisAddress());
Field invocationField = InvocationFuture.class.getDeclaredField("invocation");
invocationField.setAccessible(true);
Invocation invocation = (Invocation) invocationField.get(future);
invocation.notifyError(new RetryableHazelcastException());
invocation.notifyError(new RetryableHazelcastException());
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
Iterator<Invocation> invocations = operationService.invocationRegistry.iterator();
assertFalse(invocations.hasNext());
}
});
}
use of com.hazelcast.spi.exception.RetryableHazelcastException in project hazelcast by hazelcast.
the class CallerRunsPartitionScanExecutor method execute.
@Override
public Collection<QueryableEntry> execute(String mapName, Predicate predicate, Collection<Integer> partitions) {
RetryableHazelcastException storedException = null;
Collection<QueryableEntry> result = new ArrayList<QueryableEntry>();
for (Integer partitionId : partitions) {
try {
result.addAll(partitionScanRunner.run(mapName, predicate, partitionId));
} catch (RetryableHazelcastException e) {
// see discussion at https://github.com/hazelcast/hazelcast/pull/5049#discussion_r28773099 for details.
if (storedException == null) {
storedException = e;
}
}
}
if (storedException != null) {
throw storedException;
}
return result;
}
use of com.hazelcast.spi.exception.RetryableHazelcastException in project hazelcast by hazelcast.
the class FetchPartitionStateOperation method run.
@Override
public void run() {
final Address caller = getCallerAddress();
final Address master = getNodeEngine().getMasterAddress();
if (!caller.equals(master)) {
final String msg = caller + " requested our partition table but it's not our known master. " + "Master: " + master;
getLogger().warning(msg);
throw new RetryableHazelcastException(msg);
}
InternalPartitionServiceImpl service = getService();
partitionState = service.createPartitionStateInternal();
}
Aggregations