theme
theme

Reputation: 361

If 2 nodes started simultaneously, they don't see each other

I was trying to start 2 hazelcast nodes simultaneously, and they can not discover each other. It's true for both multicast and tcp-ip discovery. If I restart one node later - they see each other. Is there a way to make them discover each other without restarting? Or how to postpone discovery during node start-up?

Configuration:

    <network>
    <port auto-increment="true">5701</port>
    <outbound-ports>
        <!--
        Allowed port range when connecting to other nodes.
        0 or * means use system provided port.
        -->
        <ports>0</ports>
    </outbound-ports>
    <join>
        <multicast enabled="true">
            <multicast-group>224.3.3.6</multicast-group>
            <multicast-port>5705</multicast-port>
        </multicast>
    </join>
</network>

or

        <multicast enabled="false">
            <multicast-group>224.3.3.6</multicast-group>
            <multicast-port>5705</multicast-port>
        </multicast>
        <tcp-ip enabled="true">
            <member>host1:5701</member>
            <member>host2:5701</member>
            <member>host3:5701</member>
            <member>host4:5701</member>
        </tcp-ip>

UPD: Solved by manually add random sleep on startup before cluster init.

Upvotes: 2

Views: 2013

Answers (1)

DaveFar
DaveFar

Reputation: 7447

Are your nodes running sufficiently long? In my experience, it can take quite a while (30 seconds) until the nodes find each other - independent of the discovery communication (multicast vs TCPIP).

After several trials and erros, Hazelcast.com and me found quite a simple solution:

config.setProperty("hazelcast.initial.min.cluster.size","2");

In my experiments, the solution is faster and more stable than waiting for a while.

Upvotes: 1

Related Questions