Search in sources :

Example 1 with DistributedObjectDestroyedException

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

the class ReliableMessageListenerRunner method onFailure.

// This method is called from the provided executor.
@Override
public void onFailure(Throwable t) {
    if (cancelled) {
        return;
    }
    if (t instanceof StaleSequenceException) {
        StaleSequenceException staleSequenceException = (StaleSequenceException) t;
        if (listener.isLossTolerant()) {
            if (logger.isFinestEnabled()) {
                logger.finest("MessageListener " + listener + " on topic: " + topicName + " ran into a stale sequence. " + "Jumping from oldSequence: " + sequence + " to sequence: " + staleSequenceException.getHeadSeq());
            }
            sequence = staleSequenceException.getHeadSeq();
            next();
            return;
        }
        logger.warning("Terminating MessageListener:" + listener + " on topic: " + topicName + ". " + "Reason: The listener was too slow or the retention period of the message has been violated. " + "head: " + staleSequenceException.getHeadSeq() + " sequence:" + sequence);
    } else if (t instanceof HazelcastInstanceNotActiveException) {
        if (logger.isFinestEnabled()) {
            logger.finest("Terminating MessageListener " + listener + " on topic: " + topicName + ". " + " Reason: HazelcastInstance is shutting down");
        }
    } else if (t instanceof DistributedObjectDestroyedException) {
        if (logger.isFinestEnabled()) {
            logger.finest("Terminating MessageListener " + listener + " on topic: " + topicName + ". " + "Reason: Topic is destroyed");
        }
    } else {
        logger.warning("Terminating MessageListener " + listener + " on topic: " + topicName + ". " + "Reason: Unhandled exception, message: " + t.getMessage(), t);
    }
    cancel();
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) DistributedObjectDestroyedException(com.hazelcast.spi.exception.DistributedObjectDestroyedException) StaleSequenceException(com.hazelcast.ringbuffer.StaleSequenceException)

Example 2 with DistributedObjectDestroyedException

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

the class ProxyServiceImpl method destroyLocalDistributedObject.

public void destroyLocalDistributedObject(String serviceName, String name, boolean fireEvent) {
    ProxyRegistry registry = registries.get(serviceName);
    if (registry != null) {
        registry.destroyProxy(name, fireEvent);
        destroyedCounter.inc();
    }
    RemoteService service = nodeEngine.getService(serviceName);
    service.destroyDistributedObject(name);
    String message = "DistributedObject[" + service + " -> " + name + "] has been destroyed!";
    Throwable cause = new DistributedObjectDestroyedException(message);
    nodeEngine.getOperationParker().cancelParkedOperations(serviceName, name, cause);
}
Also used : DistributedObjectDestroyedException(com.hazelcast.spi.exception.DistributedObjectDestroyedException) RemoteService(com.hazelcast.spi.RemoteService)

Example 3 with DistributedObjectDestroyedException

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

the class QueueEvictionTest method testQueueEviction_whenTtlIsSet_thenTakeThrowsException.

@Test
public void testQueueEviction_whenTtlIsSet_thenTakeThrowsException() throws Exception {
    String queueName = randomString();
    Config config = smallInstanceConfig();
    config.getQueueConfig(queueName).setPriorityComparatorClassName(comparatorClassName).setEmptyQueueTtl(2);
    HazelcastInstance hz = createHazelcastInstance(config);
    IQueue<VersionedObject<String>> queue = hz.getQueue(queueName);
    try {
        assertTrue(queue.offer(new VersionedObject<>("item")));
        assertEquals(new VersionedObject<>("item"), queue.poll());
        queue.take();
        fail();
    } catch (DistributedObjectDestroyedException expected) {
        ignore(expected);
    }
    assertEquals(0, queue.size());
}
Also used : VersionedObject(com.hazelcast.collection.impl.queue.model.VersionedObject) DistributedObjectDestroyedException(com.hazelcast.spi.exception.DistributedObjectDestroyedException) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with DistributedObjectDestroyedException

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

the class ProxyServiceImpl method destroyLocalDistributedObject.

@Override
public void destroyLocalDistributedObject(String serviceName, String name, UUID source, boolean fireEvent) {
    ProxyRegistry registry = registries.get(serviceName);
    if (registry != null) {
        registry.destroyProxy(name, source, fireEvent);
        destroyedCounter.inc();
    }
    RemoteService service = nodeEngine.getService(serviceName);
    service.destroyDistributedObject(name);
    String message = "DistributedObject[" + service + " -> " + name + "] has been destroyed!";
    Throwable cause = new DistributedObjectDestroyedException(message);
    nodeEngine.getOperationParker().cancelParkedOperations(serviceName, name, cause);
}
Also used : DistributedObjectDestroyedException(com.hazelcast.spi.exception.DistributedObjectDestroyedException) RemoteService(com.hazelcast.internal.services.RemoteService)

Example 5 with DistributedObjectDestroyedException

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

the class AbstractBlockingService method onRaftNodeTerminated.

@Override
public final void onRaftNodeTerminated(CPGroupId groupId) {
    ResourceRegistry<W, R> registry = registries.get(groupId);
    if (registry != null) {
        Collection<Long> indices = registry.destroy();
        completeFutures(groupId, indices, new DistributedObjectDestroyedException(groupId + " is destroyed"));
    }
}
Also used : DistributedObjectDestroyedException(com.hazelcast.spi.exception.DistributedObjectDestroyedException)

Aggregations

DistributedObjectDestroyedException (com.hazelcast.spi.exception.DistributedObjectDestroyedException)9 Config (com.hazelcast.config.Config)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Future (java.util.concurrent.Future)2 Test (org.junit.Test)2 VersionedObject (com.hazelcast.collection.impl.queue.model.VersionedObject)1 ServiceConfig (com.hazelcast.config.ServiceConfig)1 DistributedObject (com.hazelcast.core.DistributedObject)1 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)1 IExecutorService (com.hazelcast.core.IExecutorService)1 RemoteService (com.hazelcast.internal.services.RemoteService)1 RootCauseMatcher (com.hazelcast.internal.util.RootCauseMatcher)1 StaleSequenceException (com.hazelcast.ringbuffer.StaleSequenceException)1 RemoteService (com.hazelcast.spi.RemoteService)1 AbstractDistributedObject (com.hazelcast.spi.impl.AbstractDistributedObject)1 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)1 EventService (com.hazelcast.spi.impl.eventservice.EventService)1 Accessors.getNodeEngineImpl (com.hazelcast.test.Accessors.getNodeEngineImpl)1