Hi all,
I just did a test about the hazelcast cluster semaphore:
I start 2 hazelcast instances with the same configuration file:
<semaphore name="SMSBINDS">
<initial-permits>1</initial-permits>
</semaphore>
And I start 2 HzClient, which will loop to get the semaphore, so the 1st started HzClient will get the semaphore and the other is looping.
However, when I stop one hazelcast instance(the 2nd one in my test), there will be an extra semaphore in the hazelcast cluster.
So the 2nd started HzClient can get the semaphore before the 1st started HzClient release the semaphore.
So I think, the 1nd hazelcast instance create a semaphore when the 2nd instance stop, that’s why the 2nd started HzClient can get a semaphore.
I doubt if the hazelcast can guarantee only one semaphore in the cluster, of maybe we need to use Lock instead. Thank you for your comments!
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-----------------------------------------------1st hazelcast instance log when 2nd instance stop
WARNING: [10.36.98.156]:5701 [local] Removing connection to endpoint Address[10.36.98.156]:5702 Cause => java.net.ConnectException {Connection refused: connect}, Error-Count: 5
Jul 24, 2013 2:29:50 PM com.hazelcast.cluster.ClusterManager
INFO: [10.36.98.156]:5701 [local] Removing Address Address[10.36.98.156]:5702
Jul 24, 2013 2:29:50 PM com.hazelcast.impl.PartitionManager
INFO: [10.36.98.156]:5701 [local] Starting to send partition replica diffs...true
Jul 24, 2013 2:29:50 PM com.hazelcast.cluster.ClusterManager
INFO: [10.36.98.156]:5701 [local]
Members [1] {
Member [10.36.98.156]:5701 this
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-------------------------------------------------1st started HzClient
Logger>>Wed Jul 24 14:29:34 CST 2013 com.hazelcast.client.HazelcastClient@42704baa
Logger>>Wed Jul 24 14:29:34 CST 2013 Cluster [2] {
Member [10.36.98.156]:5701
Member [10.36.98.156]:5702
}
Created SEMAPHORE,4:SMSBINDS
Logger>>Wed Jul 24 14:29:35 CST 2013 Lock status: SMSBINDS, attached:0 available:1
Logger>>Wed Jul 24 14:29:35 CST 2013 Got Semaphore: SMSBINDS
Jul 24, 2013 2:29:46 PM com.hazelcast.client.ConnectionManager
WARNING: Connection to Connection [0] [CNBJADM0026L.int.asurion.com/10.36.98.156:5702 -> 10.36.98.156:5702] is lost
Jul 24, 2013 2:29:46 PM com.hazelcast.client.LifecycleServiceClientImpl
INFO: HazelcastClient is CLIENT_CONNECTION_LOST
Jul 24, 2013 2:29:46 PM com.hazelcast.client.LifecycleServiceClientImpl
INFO: HazelcastClient is CLIENT_CONNECTION_OPENING
Jul 24, 2013 2:29:47 PM com.hazelcast.client.LifecycleServiceClientImpl
INFO: HazelcastClient is CLIENT_CONNECTION_OPENED
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-------------------------------------------------2nd started HzClient
Logger>>Wed Jul 24 14:29:40 CST 2013 com.hazelcast.client.HazelcastClient@4139eeda
Logger>>Wed Jul 24 14:29:40 CST 2013 Cluster [2] {
Member [10.36.98.156]:5701
Member [10.36.98.156]:5702
}
Logger>>Wed Jul 24 14:29:40 CST 2013 Lock status: SMSBINDS, attached:1 available:0
Logger>>Wed Jul 24 14:29:40 CST 2013 Can't get Semaphore, sleep 3s.
Logger>>Wed Jul 24 14:29:43 CST 2013 Can't get Semaphore, sleep 3s.
Jul 24, 2013 2:29:46 PM com.hazelcast.client.ConnectionManager
WARNING: Connection to Connection [0] [CNBJADM0026L.int.asurion.com/10.36.98.156:5702 -> 10.36.98.156:5702] is lost
Jul 24, 2013 2:29:46 PM com.hazelcast.client.LifecycleServiceClientImpl
INFO: HazelcastClient is CLIENT_CONNECTION_LOST
Jul 24, 2013 2:29:46 PM com.hazelcast.client.LifecycleServiceClientImpl
INFO: HazelcastClient is CLIENT_CONNECTION_OPENING
Jul 24, 2013 2:29:47 PM com.hazelcast.client.LifecycleServiceClientImpl
INFO: HazelcastClient is CLIENT_CONNECTION_OPENED
Logger>>Wed Jul 24 14:29:51 CST 2013 Got Semaphore: SMSBINDS
Regards,
Austin
--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at http://groups.google.com/group/hazelcast.
For more options, visit https://groups.google.com/groups/opt_out.
That was a client design problem in version 2.x, only occurs when clients are involved and not easy to fix in 2.x architecture.
By 3.0 we redesigned nearly every aspect of server and client (even client will get a further improvement by 3.2). One of the design changes is related to resource (lock, semaphore..) ownership in cluster.
@mmdogan
~Sent from mobile
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/636367d7-7329-44cc-abff-4c2dec0129c9%40googlegroups.com.