Can't seem to test with multiple hazelcast instances.

2,469 views
Skip to first unread message

dko...@gmail.com

unread,
Mar 7, 2012, 6:34:01 PM3/7/12
to haze...@googlegroups.com
Basically, the problem is that this example doesn't work: map2 never has 1000 items in it. The second instance of hazelcast doesn't join the cluster Log output follows

   @Test
    public void testTwoMemberMapSizes() {
        // start the first member
        HazelcastInstance h1 = Hazelcast.newHazelcastInstance(null);
        // get the map and put 1000 entries
        Map map1 = h1.getMap("testmap");
        for (int i = 0; i < 1000; i++) {
            map1.put(i, "value" + i);
        }
        // check the map size
        assertEquals(1000, map1.size());
        // start the second member
        HazelcastInstance h2 = Hazelcast.newHazelcastInstance(null);
        // get the same map from the second member
        Map map2 = h2.getMap("testmap");
        // check the size of map2
        assertEquals(1000, map2.size());
        // check the size of map1 again
        assertEquals(1000, map1.size());
    }

Doesn't work. I've tried various permutations of new Config() instead of null, but it's not happening.

Maybe it's because I'm using spock, but I don't think so. My actual test code is here:

    def "can glue together multiple hazelcast to test"() {
        given:
        HazelcastInstance h1 = Hazelcast.newHazelcastInstance(new Config());
        // start the second member
        HazelcastInstance h2 = Hazelcast.newHazelcastInstance(new Config());

        Thread.sleep(1000)
        // get the map and put 1000 entries
        Map map1 = h1.getMap("testmap");
        for (int i = 0; i < 1000; i++) {
            map1.put(i, "value" + i);
        }

        when:
        true

        then:
        // check the map size
        map1.size() == 1000

        // get the same map from the second member
        Map map2 = h2.getMap("testmap");
        // check the size of map2
        map2.size() == 1000
        // check the size of map1 again
        map1.size() == 1000
    }


Thanks in advance,
David


LOG OUTPUT:
Mar 7, 2012 5:33:45 PM com.hazelcast.system
INFO: /10.4.224.104:5701 [dev] Hazelcast 1.9.4.4 (20111011) starting at Address[10.4.224.104:5701]
Mar 7, 2012 5:33:45 PM com.hazelcast.system
INFO: /10.4.224.104:5701 [dev] Copyright (C) 2008-2011 Hazelcast.com
Mar 7, 2012 5:33:45 PM com.hazelcast.impl.LifecycleServiceImpl
INFO: /10.4.224.104:5701 [dev] Address[10.4.224.104:5701] is STARTING
Mar 7, 2012 5:33:47 PM com.hazelcast.impl.MulticastJoiner
INFO: /10.4.224.104:5701 [dev]


Members [1] {
    Member [10.4.224.104:5701] this
}

Mar 7, 2012 5:33:47 PM com.hazelcast.impl.management.ManagementCenterService
INFO: /10.4.224.104:5701 [dev] Hazelcast Management Center started at port 5801.
Mar 7, 2012 5:33:47 PM com.hazelcast.impl.LifecycleServiceImpl
INFO: /10.4.224.104:5701 [dev] Address[10.4.224.104:5701] is STARTED
Mar 7, 2012 5:33:47 PM com.hazelcast.system
INFO: /10.4.224.104:5702 [dev] Hazelcast 1.9.4.4 (20111011) starting at Address[10.4.224.104:5702]
Mar 7, 2012 5:33:47 PM com.hazelcast.system
INFO: /10.4.224.104:5702 [dev] Copyright (C) 2008-2011 Hazelcast.com
Mar 7, 2012 5:33:47 PM com.hazelcast.impl.LifecycleServiceImpl
INFO: /10.4.224.104:5702 [dev] Address[10.4.224.104:5702] is STARTING
Mar 7, 2012 5:33:50 PM com.hazelcast.impl.MulticastJoiner
INFO: /10.4.224.104:5702 [dev]


Members [1] {
    Member [10.4.224.104:5702] this
}

Mar 7, 2012 5:33:50 PM com.hazelcast.impl.Node
WARNING: /10.4.224.104:5702 [dev] Config seed port is 5701 and cluster size is 1. Some of the ports seem occupied!
Mar 7, 2012 5:33:50 PM com.hazelcast.impl.management.ManagementCenterService
INFO: /10.4.224.104:5702 [dev] Hazelcast Management Center started at port 5802.
Mar 7, 2012 5:33:50 PM com.hazelcast.impl.LifecycleServiceImpl
INFO: /10.4.224.104:5702 [dev] Address[10.4.224.104:5702] is STARTED

Condition not satisfied:

map2.size() == 1000
|    |      |
[:]  0      false
 <Click to see difference>

    at com.rackspace.incident.integration.IntegrationGatewayTest.can glue together multiple hazelcast to test(IntegrationGatewayTest.groovy:190)


Process finished with exit code 255

Enes Akar

unread,
Mar 8, 2012, 2:17:40 AM3/8/12
to haze...@googlegroups.com
The log show your members could not join.

Members [1] {
    Member [10.4.224.104:5702] this
}

In usual scenario, there should be 2 members above.

So there should be a problem about connection among members.
Firewalls may cause this, you can try close if there is one.





--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To view this discussion on the web visit https://groups.google.com/d/msg/hazelcast/-/QXp5gZsa5oEJ.
To post to this group, send email to haze...@googlegroups.com.
To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.

Fuad Malikov

unread,
Mar 8, 2012, 2:26:53 AM3/8/12
to haze...@googlegroups.com
The default configuration uses multicast. It can be that it is disabled. Try to run with TCP/IP enabled. 
Here is the config for your case;
 Config config = new Config();
        config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true);
        config.getNetworkConfig().getJoin().getTcpIpConfig().addMember("10.4.224.104");

dko...@gmail.com

unread,
Mar 8, 2012, 11:33:04 AM3/8/12
to haze...@googlegroups.com
That does indeed work.

Is there a way to specify membership without having to know the IP address of the box? Ah, answered my own question

Configuring it to use 127.0.0.1 will work and be portable enough to use just about anywhere.

Thanks for that. I guess the documentation should be updated to indicate this, or it's a bug, since the docs show it just using connectivity via multicast and that doesn't seem to work (at least for me)

Thanks again,
David
To unsubscribe from this group, send email to hazelcast+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.

--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To post to this group, send email to haze...@googlegroups.com.
To unsubscribe from this group, send email to hazelcast+unsubscribe@googlegroups.com.

dko...@gmail.com

unread,
Mar 22, 2012, 11:28:06 AM3/22/12
to haze...@googlegroups.com
 
Having a problem testing multiple hazelcast in a cluster again.
Code to build the configuration is as follows:


        Config config = new Config();
        config.setInstanceName(instanceName)
        config.setGroupConfig(new GroupConfig(uuid, "lol"))
        config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true);
        config.getNetworkConfig().getJoin().getTcpIpConfig().addMember("127.0.0.1");
        config.getNetworkConfig().getInterfaces().clear();
        config.getNetworkConfig().getInterfaces().addInterface("127.0.0.1")
        config.getNetworkConfig().getInterfaces().setEnabled(true);
        def hazelcastInstance = Hazelcast.newHazelcastInstance(config)


I call this method a couple times, uuid is always the same for each test execution run, so that they all end up in the same group.
Unfortunately, during the mvn test execution, they don't cluster together. Running the test standalone in the IDE (IDEA) it works just fine.

I'm at a loss to understand why this fails. I'll see if I can get a simple test project alive and post the code to it, if this is insufficient.

Thanks,
David

David Kowis

unread,
Mar 22, 2012, 2:58:26 PM3/22/12
to haze...@googlegroups.com
Aha.

Turns out I had evilness in my test suite where some hazelcast
instances weren't being properly shut down, and that was causing
problems. Everything seems to be peachy now.

--
David

>>>>> hazelcast+...@googlegroups.com.


>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/hazelcast?hl=en.
>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Hazelcast" group.
>>>> To post to this group, send email to haze...@googlegroups.com.
>>>> To unsubscribe from this group, send email to

>>>> hazelcast+...@googlegroups.com.


>>>> For more options, visit this group at
>>>> http://groups.google.com/group/hazelcast?hl=en.
>>>
>>>
> --
> You received this message because you are subscribed to the Google Groups
> "Hazelcast" group.

> To view this discussion on the web visit

> https://groups.google.com/d/msg/hazelcast/-/SID_L4EjGOUJ.


>
> To post to this group, send email to haze...@googlegroups.com.
> To unsubscribe from this group, send email to

> hazelcast+...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages