I must to deploy a web application with hazelcast client even if the hazelcast server is down

691 views
Skip to first unread message

Adriano Tavares

unread,
Aug 27, 2014, 3:02:34 PM8/27/14
to haze...@googlegroups.com
Hi guys,
I must to deploy a web application with hazelcast client even if the hazelcast server is down. Is it possible?
 
...
    <!-- Hazelcast config -->
    <hz:client id="hzClient" lazy-init="true">
        <hz:group name="dev" password="dev-pass" />
        <hz:network connection-attempt-limit="5" 
                    connection-attempt-period="3000" 
                    connection-timeout="60000"
                    redo-operation="true"
                    smart-routing="true">
            <hz:member>127.0.0.1:5701</hz:member>
            <hz:member>127.0.0.1:5702</hz:member>
        </hz:network>
     </hz:client>
...

For now, if the server is down, my app throws the exceptions and deploy failed.

27/08/2014 15:50:33 com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.2.4] is STARTING
27/08/2014 15:50:33 com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.2.4] is STARTED
27/08/2014 15:50:35 com.hazelcast.client.spi.ClientClusterService
AVISO: Unable to get alive cluster connection, try in 985 ms later, attempt 1 of 5.
27/08/2014 15:50:38 com.hazelcast.client.spi.ClientClusterService
AVISO: Unable to get alive cluster connection, try in 994 ms later, attempt 2 of 5.
27/08/2014 15:50:41 com.hazelcast.client.spi.ClientClusterService
AVISO: Unable to get alive cluster connection, try in 995 ms later, attempt 3 of 5.
<27/08/2014 15h50min42s BRT> <Warning> <Socket> <BEA-000449> <Closing the socket, as no data read from it on 127.0.0.1:55.577 during the configured idle timeout of 5 seconds.> 
27/08/2014 15:50:44 com.hazelcast.client.spi.ClientClusterService
AVISO: Unable to get alive cluster connection, try in 992 ms later, attempt 4 of 5.
27/08/2014 15:50:47 com.hazelcast.client.spi.ClientClusterService
AVISO: Unable to get alive cluster connection, try in 997 ms later, attempt 5 of 5.
27/08/2014 15:50:50 com.hazelcast.client.spi.ClientClusterService
GRAVE: Error while connecting to cluster!
java.lang.IllegalStateException: Unable to connect to any address in the config!
at com.hazelcast.client.spi.impl.ClientClusterServiceImpl$ClusterListenerThread.connectToOne(ClientClusterServiceImpl.java:434)
at com.hazelcast.client.spi.impl.ClientClusterServiceImpl$ClusterListenerThread.run(ClientClusterServiceImpl.java:223)
Caused by: com.hazelcast.spi.exception.RetryableIOException: java.util.concurrent.ExecutionException: com.hazelcast.core.HazelcastException: java.net.ConnectException: Connection refused: no further information
at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl.ownerConnection(ClientConnectionManagerImpl.java:248)
at com.hazelcast.client.spi.impl.ClientClusterServiceImpl$ClusterListenerThread.connectToOne(ClientClusterServiceImpl.java:406)
... 1 more
Caused by: java.util.concurrent.ExecutionException: com.hazelcast.core.HazelcastException: java.net.ConnectException: Connection refused: no further information
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:232)
at java.util.concurrent.FutureTask.get(FutureTask.java:91)
at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl.ownerConnection(ClientConnectionManagerImpl.java:240)
... 2 more
Caused by: com.hazelcast.core.HazelcastException: java.net.ConnectException: Connection refused: no further information
at com.hazelcast.util.ExceptionUtil.rethrow(ExceptionUtil.java:45)
at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl$ConnectionProcessor.call(ClientConnectionManagerImpl.java:384)
at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl$ConnectionProcessor.call(ClientConnectionManagerImpl.java:332)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at com.hazelcast.util.executor.CompletableFutureTask.run(CompletableFutureTask.java:57)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
at com.hazelcast.util.executor.PoolExecutorThreadFactory$ManagedThread.run(PoolExecutorThreadFactory.java:59)
Caused by: java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:599)
at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:100)
at com.hazelcast.client.connection.nio.ClientConnectionManagerImpl$ConnectionProcessor.call(ClientConnectionManagerImpl.java:365)
... 11 more
27/08/2014 15:50:50 com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.2.4] is SHUTTING_DOWN
27/08/2014 15:50:50 com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.2.4] is SHUTDOWN

Next step is to reconnect when the server get alive

Thanks in advance,
Adriano.

Bilal Yaşar

unread,
Aug 28, 2014, 12:57:38 PM8/28/14
to haze...@googlegroups.com
no, it is not possible. after attemps, client throws exception and doesn't connect again.

27 Ağustos 2014 Çarşamba 22:02:34 UTC+3 tarihinde Adriano Tavares yazdı:

Adriano Tavares

unread,
Aug 28, 2014, 3:07:00 PM8/28/14
to haze...@googlegroups.com
Thanks for answer Bilal.

Karussell

unread,
Aug 29, 2014, 9:48:18 AM8/29/14
to haze...@googlegroups.com
You could use Provider<HazelcastInstance> (if you use e.g. Google Guice) or a similar technic to create the client only on demand

Peter.
Reply all
Reply to author
Forward
0 new messages