use of com.hazelcast.client.impl.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.impl.spi.impl.ClientServiceNotFoundException in project hazelcast by hazelcast.
the class ProxyManager method getOrCreateProxyInternal.
private ClientProxy getOrCreateProxyInternal(@Nonnull String service, @Nonnull String id, boolean remote) {
checkNotNull(service, "Service name is required!");
checkNotNull(id, "Object name is required!");
final ObjectNamespace ns = new DistributedObjectNamespace(service, id);
ClientProxyFuture proxyFuture = proxies.get(ns);
if (proxyFuture != null) {
return proxyFuture.get();
}
ClientProxyFactory factory = proxyFactories.get(service);
if (factory == null) {
throw new ClientServiceNotFoundException("No factory registered for service: " + service);
}
proxyFuture = new ClientProxyFuture();
ClientProxyFuture current = proxies.putIfAbsent(ns, proxyFuture);
if (current != null) {
return current.get();
}
try {
ClientProxy clientProxy = createClientProxy(id, factory);
if (remote) {
initialize(clientProxy);
} else {
clientProxy.onInitialize();
}
proxyFuture.set(clientProxy);
return clientProxy;
} catch (Throwable e) {
proxies.remove(ns);
proxyFuture.set(e);
throw rethrow(e);
}
}
Aggregations