Cluster sample test fails

123 views
Skip to first unread message

Yuval R

unread,
Feb 28, 2014, 12:09:51 PM2/28/14
to haze...@googlegroups.com

I am trying to run Hazelcast cluster sample test:
http://code.google.com/p/hazelcast/wiki/ClusterTestHowTo

   @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());
   
}

The following assert fails:
assertEquals(1000, map2.size());
Because map2.size() is 0, and indeed, if adding:
assertEquals(h1.getCluster(), h2.getCluster());
it fails because the clusters are not equal…

I am running this on a plain JUnit test without any other configurations. I did notice however the following warning in trace, which I am not sure if is the cause:
WARNING: [10.130.79.32]:5702 [dev] Config seed port is 5701 and cluster size is 1. Some of the ports seem occupied!

The full trace:
Feb 28, 2014 6:00:35 PM com.hazelcast.config.XmlConfigBuilder
INFO
: Looking for hazelcast.xml config file in classpath.
Feb 28, 2014 6:00:35 PM com.hazelcast.config.XmlConfigBuilder
WARNING
: Could not find hazelcast.xml in classpath.
Hazelcast will use hazelcast-default.xml config file in jar.
Feb 28, 2014 6:00:35 PM com.hazelcast.config.XmlConfigBuilder
INFO
: Using configuration file file:/Users/myuser/.m2/repository/com/hazelcast/hazelcast/3.1.6/hazelcast-3.1.6.jar!/hazelcast-default.xml in the classpath.
Feb 28, 2014 6:00:36 PM com.hazelcast.instance.DefaultAddressPicker
INFO: Prefer IPv4 stack is true.
Feb 28, 2014 6:00:36 PM com.hazelcast.instance.DefaultAddressPicker
INFO: Picked Address[10.130.79.32]:5701, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0%0,localport=5701], bind any local is true
Feb 28, 2014 6:00:36 PM com.hazelcast.system
INFO: [10.130.79.32]:5701 [dev] Hazelcast Community Edition 3.1.6 (20140221) starting at Address[10.130.79.32]:5701
Feb 28, 2014 6:00:36 PM com.hazelcast.system
INFO: [10.130.79.32]:5701 [dev] Copyright (C) 2008-2013 Hazelcast.com
Feb 28, 2014 6:00:36 PM com.hazelcast.instance.Node
INFO: [10.130.79.32]:5701 [dev] Creating MulticastJoiner
Feb 28, 2014 6:00:36 PM com.hazelcast.core.LifecycleService
INFO: [10.130.79.32]:5701 [dev] Address[10.130.79.32]:5701 is STARTING
Feb 28, 2014 6:00:41 PM com.hazelcast.cluster.MulticastJoiner
INFO: [10.130.79.32]:5701 [dev]




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


Feb 28, 2014 6:00:41 PM com.hazelcast.core.LifecycleService
INFO: [10.130.79.32]:5701 [dev] Address[10.130.79.32]:5701 is STARTED
Feb 28, 2014 6:00:41 PM com.hazelcast.partition.PartitionService
INFO: [10.130.79.32]:5701 [dev] Initializing cluster partition table first arrangement...
Feb 28, 2014 6:00:41 PM com.hazelcast.config.XmlConfigBuilder
INFO: Looking for hazelcast.xml config file in classpath.
Feb 28, 2014 6:00:41 PM com.hazelcast.config.XmlConfigBuilder
WARNING: Could not find hazelcast.xml in classpath.
Hazelcast will use hazelcast-default.xml config file in jar.
Feb 28, 2014 6:00:41 PM com.hazelcast.config.XmlConfigBuilder
INFO: Using configuration file file:/
Users/myuser/.m2/repository/com/hazelcast/hazelcast/3.1.6/hazelcast-3.1.6.jar!/hazelcast-default.xml in the classpath.
Feb 28, 2014 6:00:41 PM com.hazelcast.instance.DefaultAddressPicker
INFO
: Prefer IPv4 stack is true.
Feb 28, 2014 6:00:41 PM com.hazelcast.instance.DefaultAddressPicker
INFO
: Picked Address[10.130.79.32]:5702, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0%0,localport=5702], bind any local is true
Feb 28, 2014 6:00:41 PM com.hazelcast.system
INFO
: [10.130.79.32]:5702 [dev] Hazelcast Community Edition 3.1.6 (20140221) starting at Address[10.130.79.32]:5702
Feb 28, 2014 6:00:41 PM com.hazelcast.system
INFO
: [10.130.79.32]:5702 [dev] Copyright (C) 2008-2013 Hazelcast.com
Feb 28, 2014 6:00:41 PM com.hazelcast.instance.Node
INFO
: [10.130.79.32]:5702 [dev] Creating MulticastJoiner
Feb 28, 2014 6:00:41 PM com.hazelcast.core.LifecycleService
INFO
: [10.130.79.32]:5702 [dev] Address[10.130.79.32]:5702 is STARTING
Feb 28, 2014 6:00:47 PM com.hazelcast.cluster.MulticastJoiner
INFO
: [10.130.79.32]:5702 [dev]




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


Feb 28, 2014 6:00:47 PM com.hazelcast.instance.Node
WARNING
: [10.130.79.32]:5702 [dev] Config seed port is 5701 and cluster size is 1. Some of the ports seem occupied!
Feb 28, 2014 6:00:47 PM com.hazelcast.core.LifecycleService
INFO
: [10.130.79.32]:5702 [dev] Address[10.130.79.32]:5702 is STARTED
Feb 28, 2014 6:00:47 PM com.hazelcast.partition.PartitionService
INFO
: [10.130.79.32]:5702 [dev] Initializing cluster partition table first arrangement...


java
.lang.AssertionError:
Expected :1000
Actual   :0
 
<Click to see difference>
    at org
.junit.Assert.fail(Assert.java:93)
    at org
.junit.Assert.failNotEquals(Assert.java:647)
    at org
.junit.Assert.assertEquals(Assert.java:128)
    at org
.junit.Assert.assertEquals(Assert.java:472)
    at org
.junit.Assert.assertEquals(Assert.java:456)
    at com
.mypackage.HazelcastTest.testTwoMemberMapSizes(HazelcastTest.java:38)
    at sun
.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun
.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at org
.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org
.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org
.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org
.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org
.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org
.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org
.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org
.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org
.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org
.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org
.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org
.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org
.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org
.junit.runner.JUnitCore.run(JUnitCore.java:157)
    at com
.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)


Disconnected from the target VM, address: '127.0.0.1:62239', transport: 'socket'


Process finished with exit code 255


Any idea?

Yuval

Noctarius

unread,
Feb 28, 2014, 12:17:25 PM2/28/14
to haze...@googlegroups.com
Your two instances are not discovered each other.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/8e3124f4-685d-4d9a-bd0b-7025995863d2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Peter Veentjer

unread,
Feb 28, 2014, 12:20:57 PM2/28/14
to haze...@googlegroups.com
The cause of the problem is that no cluster is formed. So the h2 you are asking, doesn't know anything about the data inserted on h1.

Switch to use tcp ip based discovery and your problem is solved. Because apparently multicast is not working on your environment. 

   Config config = new Config();
        config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true);



Reply all
Reply to author
Forward
Message has been deleted
0 new messages