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