Search in sources :

Example 6 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)

Example 7 with DistributedObjectDestroyedException

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

the class AbstractBlockingService method destroyRaftObject.

@Override
public boolean destroyRaftObject(CPGroupId groupId, String name) {
    Collection<W> keys = getOrInitRegistry(groupId).destroyResource(name);
    if (keys == null) {
        return false;
    }
    List<Long> commitIndices = new ArrayList<>();
    for (W key : keys) {
        commitIndices.add(key.commitIndex());
    }
    completeFutures(groupId, commitIndices, new DistributedObjectDestroyedException(name + " is destroyed"));
    return true;
}
Also used : DistributedObjectDestroyedException(com.hazelcast.spi.exception.DistributedObjectDestroyedException) ArrayList(java.util.ArrayList)

Example 8 with DistributedObjectDestroyedException

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

the class ExecutorServiceCreateDestroyTest method test_createUse_thenDestroy.

private void test_createUse_thenDestroy(final ExecutorServiceCommand command) throws Exception {
    Future[] futures = new Future[INSTANCE_COUNT];
    for (int i = 0; i < INSTANCE_COUNT; i++) {
        final HazelcastInstance instance = instances[i];
        futures[i] = spawn(() -> {
            Random rand = new Random();
            for (int i1 = 0; i1 < 1000; i1++) {
                LockSupport.parkNanos(1 + rand.nextInt(100));
                IExecutorService ex = instance.getExecutorService("executor");
                command.run(ex);
                ex.destroy();
            }
            return null;
        });
    }
    for (Future future : futures) {
        try {
            future.get(ASSERT_TRUE_EVENTUALLY_TIMEOUT, TimeUnit.SECONDS);
        } catch (ExecutionException e) {
            // when executor is destroyed as it is being created from another thread
            if (!(e.getCause() instanceof DistributedObjectDestroyedException)) {
                throw e;
            }
        }
    }
}
Also used : DistributedObjectDestroyedException(com.hazelcast.spi.exception.DistributedObjectDestroyedException) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Random(java.util.Random) Future(java.util.concurrent.Future) IExecutorService(com.hazelcast.core.IExecutorService) ExecutionException(java.util.concurrent.ExecutionException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 9 with DistributedObjectDestroyedException

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

the class DistributedObjectTest method testDistributedObjectDestroyed_whenDestroyDuringInitialization.

@Test
public void testDistributedObjectDestroyed_whenDestroyDuringInitialization() throws InterruptedException, ExecutionException {
    final CountDownLatch initializationStarted = new CountDownLatch(1);
    final CountDownLatch objectDestroyed = new CountDownLatch(1);
    Config config = new Config();
    ConfigAccessor.getServicesConfig(config).addServiceConfig(new ServiceConfig().setEnabled(true).setName(TestInitializingObjectService.NAME).setImplementation(new TestInitializingObjectService(() -> {
        initializationStarted.countDown();
        try {
            objectDestroyed.await();
        } catch (InterruptedException e) {
            ignore(e);
        }
    })));
    String serviceName = TestInitializingObjectService.NAME;
    String objectName = "test-object";
    HazelcastInstance instance = createHazelcastInstance(config);
    Future f = spawn(() -> {
        // must fail with DistributedObjectDestroyedException
        instance.getDistributedObject(serviceName, objectName);
    });
    initializationStarted.await();
    NodeEngineImpl nodeEngine = getNodeEngineImpl(instance);
    UUID source = nodeEngine.getLocalMember().getUuid();
    nodeEngine.getProxyService().destroyDistributedObject(serviceName, objectName, source);
    objectDestroyed.countDown();
    expectedException.expect(ExecutionException.class);
    expectedException.expectCause(new RootCauseMatcher(DistributedObjectDestroyedException.class));
    f.get();
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) DistributedObjectDestroyedException(com.hazelcast.spi.exception.DistributedObjectDestroyedException) ServiceConfig(com.hazelcast.config.ServiceConfig) Config(com.hazelcast.config.Config) ServiceConfig(com.hazelcast.config.ServiceConfig) Future(java.util.concurrent.Future) CountDownLatch(java.util.concurrent.CountDownLatch) UUID(java.util.UUID) RootCauseMatcher(com.hazelcast.internal.util.RootCauseMatcher) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

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