1

我有一个带有 hazelcast 版本的 spring-hibernate Web 应用程序:1.9.4.8 我使用默认的 hazelcast 配置而不是 spring 集成。我使用 JUnit 非事务性测试进行单元测试。我首先使用 @Before 关闭 Hazelcast 的所有实例。同样@After 进行清理。

由于我的计算机在我公司的网络中,我正在配置启用了 hazelcast tcp-ip 的相应 IP,这些 IP 将在其自己的本地测试和使用该应用程序。

但是,每当我将 IP 从网络 ip 更改为 127.0.0.1 时,我都无法加入多个成员。但之前,当 ip 的 conf. 就像:192.168.24.27

我需要将其从特定的 ip 地址更改为 127.0.0.1 之类的标准,以使不同的开发人员也可以在自己的计算机上进行测试...

这是我的示例单元测试的一部分:

  ///
        LOG.info("test is begining");
        Map map;
        int memberSize = 0;
        Config config = new Config();
        // Hazelcast cluster member 1
        final HazelcastInstance customInstance1 = Hazelcast.newHazelcastInstance(null);  
        assertEquals(2, clusterListener.getMemberSize());   
        getApplicationMap().put("member2", 2);  

        // shutdown member 1
        customInstance1.getLifecycleService().shutdown(); 

        // Hazelcast cluster new member 1
        final HazelcastInstance customInstance2 = Hazelcast.newHazelcastInstance(null); 
        assertEquals(2, clusterListener.getMemberSize());   
        getApplicationMap().put("member2_new", 2);  

        assertEquals(3, getApplicationMap().size()); 

        LOG.info("\n\n *** Hazelcast test is OK. *** \n");
  ///

这是我的问题的hazelcast配置的简短但相关的部分:...

<port auto-increment="true">5701</port>
    <join>
        <multicast enabled="false">
            <multicast-group>224.2.2.3</multicast-group>
            <multicast-port>54327</multicast-port>
        </multicast>
        <tcp-ip enabled="true">
            <interface>127.0.0.1</interface>  // it was 192.168.24.27 before and was working
        </tcp-ip>
    </join>
    <interfaces enabled="true">
            <interface>127.0.0.*</interface> 
    </interfaces>

...

这里是相关日志:...

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


28.Eyl.2012 16:01:40 com.hazelcast.impl.management.ManagementCenterService
INFO: /127.0.0.1:5701 [elekCluster] Hazelcast Management Center started at port 5801.
28.Eyl.2012 16:01:40 com.hazelcast.impl.LifecycleServiceImpl
INFO: /127.0.0.1:5701 [elekCluster] Address[127.0.0.1:5701] is STARTED
16:01:40,149  INFO HazelcastTest:35 - test is begining
28.Eyl.2012 16:01:40 com.hazelcast.config.XmlConfigBuilder
INFO: Looking for hazelcast.xml config file in classpath.
28.Eyl.2012 16:01:40 com.hazelcast.config.XmlConfigBuilder
INFO: Using configuration file /C:/dev/WORKSPACE_Myeclipse/elek_workspace/elek/elek_core_service/target/test-classes/hazelcast.xml in the classpath.
28.Eyl.2012 16:01:40 com.hazelcast.system
INFO: /127.0.0.1:5702 [elekCluster] Hazelcast 1.9.4.8 (20120209) starting at Address[127.0.0.1:5702]
28.Eyl.2012 16:01:40 com.hazelcast.system
INFO: /127.0.0.1:5702 [elekCluster] Copyright (C) 2008-2011 Hazelcast.com
28.Eyl.2012 16:01:40 com.hazelcast.impl.LifecycleServiceImpl
INFO: /127.0.0.1:5702 [elekCluster] Address[127.0.0.1:5702] is STARTING
28.Eyl.2012 16:01:40 com.hazelcast.impl.TcpIpJoiner
INFO: /127.0.0.1:5702 [elekCluster] connecting to Address[127.0.0.1:5703]
28.Eyl.2012 16:01:40 com.hazelcast.impl.TcpIpJoiner
INFO: /127.0.0.1:5702 [elekCluster] connecting to Address[127.0.0.1:5701]
28.Eyl.2012 16:01:40 com.hazelcast.nio.InSelector
INFO: /127.0.0.1:5701 [elekCluster] 5701 is accepting socket connection from /127.0.0.1:63486
28.Eyl.2012 16:01:40 com.hazelcast.nio.InSelector
INFO: /127.0.0.1:5701 [elekCluster] 5701 accepted socket connection from /127.0.0.1:63486
28.Eyl.2012 16:01:40 com.hazelcast.nio.ConnectionManager
WARNING: /127.0.0.1:5701 [elekCluster] Two connections from the same endpoint Address[127.0.0.1:5702], acceptTypeConnection=true,  now accept=false
28.Eyl.2012 16:01:40 com.hazelcast.nio.InSelector
INFO: /127.0.0.1:5702 [elekCluster] 5702 is accepting socket connection from /127.0.0.1:63479
28.Eyl.2012 16:01:40 com.hazelcast.nio.InSelector
INFO: /127.0.0.1:5702 [elekCluster] 5702 accepted socket connection from /127.0.0.1:63479
28.Eyl.2012 16:01:40 com.hazelcast.cluster.ClusterManager
INFO: /127.0.0.1:5702 [elekCluster] Removing Address Address[127.0.0.1:5701]
28.Eyl.2012 16:01:45 com.hazelcast.impl.TcpIpJoiner
INFO: /127.0.0.1:5702 [elekCluster] 


Members [1] {
    Member [127.0.0.1:5702] this
}
...

我会很感激任何帮助,在此先感谢..

4

2 回答 2

0

请参阅邮件组中的相关邮件线程

于 2012-10-17T09:42:57.820 回答
0

当我将 hazelcast 的版本从 1.9.4.8 升级到 2.3.1 时,问题就消失了。

于 2012-10-17T12:16:48.113 回答