use of com.hazelcast.client.spi.impl.ClientServiceNotFoundException in project hazelcast by hazelcast.
the class ClientICacheManagerTest method getCache_when_clientServiceNotFoundExceptionIsThrown_then_illegalStateExceptionIsThrown.
@Test
public void getCache_when_clientServiceNotFoundExceptionIsThrown_then_illegalStateExceptionIsThrown() {
// when ClientServiceNotFoundException was thrown by hzInstance.getDistributedObject
// (i.e. cache support is not available on the client-side)
HazelcastInstance hzInstance = mock(HazelcastInstance.class);
when(hzInstance.getDistributedObject(anyString(), anyString())).thenThrow(new ClientServiceNotFoundException("mock exception"));
ClientICacheManager clientCacheManager = new ClientICacheManager(hzInstance);
// then an IllegalStateException will be thrown by getCache
thrown.expect(IllegalStateException.class);
clientCacheManager.getCache("any-cache");
}
use of com.hazelcast.client.spi.impl.ClientServiceNotFoundException in project hazelcast by hazelcast.
the class ProxyManager method getOrCreateProxy.
public ClientProxy getOrCreateProxy(String service, String id) {
final ObjectNamespace ns = new DefaultObjectNamespace(service, id);
ClientProxyFuture proxyFuture = proxies.get(ns);
if (proxyFuture != null) {
return proxyFuture.get();
}
final ClientProxyFactory factory = proxyFactories.get(service);
if (factory == null) {
throw new ClientServiceNotFoundException("No factory registered for service: " + service);
}
final ClientProxy clientProxy = factory.create(id);
proxyFuture = new ClientProxyFuture();
final ClientProxyFuture current = proxies.putIfAbsent(ns, proxyFuture);
if (current != null) {
return current.get();
}
try {
initializeWithRetry(clientProxy);
} catch (Throwable e) {
proxies.remove(ns);
proxyFuture.set(e);
throw ExceptionUtil.rethrow(e);
}
proxyFuture.set(clientProxy);
return clientProxy;
}
Aggregations