Florin Neamtu
Florin Neamtu

Reputation: 25

Hazelcast: can I configure a hazelcast client to connect only to a single lite member of the cluster?

I have a Hazelcast cluster formed of 2 full members and a Lite member, multicast enabled. I want to connect multiple Hazelcast (.NET) clients exclusively to the Hazelcast Lite member. The thing is that even if I configure the address and port of this Lite member on the client side I still see connections from the client to the other 2 Hazelcast full cluster members:

<hazelcast-client>
    <network>
        <cluster-members>
            <address>10.28.0.106:5701</address>
        </cluster-members>
    </network>
    ...
</hazelcast-client>

Can this be done?

The idea is to have the Lite member store a large amount of mostly read-only data (near-client will be enabled on the Lite member) and will be running on the same machine as the clients so the access will be much faster than client->cluster connections.

Let's ignore the fact that this Lite member becomes a single point of failure here, the system as whole won't be impacted.

Upvotes: 0

Views: 3274

Answers (2)

sancar
sancar

Reputation: 505

If you set smart routing to false on client and only configure lite member on client side, client will be connected to lite member only. See http://docs.hazelcast.org/docs/3.6/manual/html-single/index.html#setting-smart-routing

But when that lite member dies, client will connect to one of the other nodes. If you want your client to shutdown when it disconnects from lite member, you can use lifecycle listener on client side. When you see LifecycleEvent.LifecycleState.CLIENT_DISCONNECTED event call hazelcastClient.shutdown().

Upvotes: 2

yevtsy
yevtsy

Reputation: 574

I think you can use GroupConfig for this purpose. From JavaDoc:

With groups it is possible to create multiple clusters where each cluster has its own group and doesn't interfere with other clusters.

You should declare group config for the client (2 times - for Lite member and full members) and for Lite & full members correspondingly.

<group>
    <name>liteGroup</name>
    <password>pswd1</password>
<group>
<group>
    <name>fullGroup</name>
    <password>pswd2</password>
<group>

Look at Group Config Doc

Feel free to contact me if you have any questions.

Upvotes: 1

Related Questions