HazelCast Tcp-IP的编程配置无需在集群中添加成员 [英] HazelCast Programmatic Configuration of Tcp-IP is no adding members in cluster

查看:431
本文介绍了HazelCast Tcp-IP的编程配置无需在集群中添加成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是文档中提供的HazelCast编程配置,但无法在HazelCast群集中添加成员。

Below is the HazelCast Programmatic Configuration given in Documentation but it is unable to add members in HazelCast Cluster.

    Config cfg = new Config();
    Hazelcast.newHazelcastInstance(cfg);

    cfg.setProperty("hazelcast.initial.min.cluster.size","3"); 
    cfg.getGroupConfig().setName("DEV").setPassword("DEV-pass");
    NetworkConfig network = cfg.getNetworkConfig();
    JoinConfig join = network.getJoin();
    TcpIpConfig tcpipConfig=join.getTcpIpConfig();
    tcpipConfig.addMember("172.17.153.87").addMember("10.45.67.100")
    .setRequiredMember("192.168.10.100").setEnabled(true);
    network.getInterfaces().setEnabled(true).addInterface("10.45.67.*");
     System.out.println(tcpipConfig.isEnabled());
     System.out.println(tcpipConfig.getMembers());

    MapConfig mapCfg = new MapConfig();
    mapCfg.setName("testMap");
    mapCfg.setBackupCount(2);
    mapCfg.getMaxSizeConfig().setSize(10000);
    mapCfg.setTimeToLiveSeconds(300);

    MapStoreConfig mapStoreCfg = new MapStoreConfig();
    mapStoreCfg.setClassName("com.hazelcast.examples.DummyStore").setEnabled(true);
    mapCfg.setMapStoreConfig(mapStoreCfg);

    NearCacheConfig nearCacheConfig = new NearCacheConfig();
    nearCacheConfig.setMaxSize(1000).setMaxIdleSeconds(120).setTimeToLiveSeconds(300);
    mapCfg.setNearCacheConfig(nearCacheConfig);

    cfg.addMapConfig(mapCfg);

请查看代码,如果需要进一步修改则需要将成员添加到hazelcast集群中

please look at the code and let me if any thing further modification is required to add members to hazelcast cluster

推荐答案

添加此行以关闭多播以支持TCP,

Add this line to turn off multicast in favour of TCP,

join.getMulticastConfig()。setEnabled(false);

将此行移至末尾,

Hazelcast.newHazelcastInstance(cfg);

你应该在构建实例之前完成配置。

You should finish the config before building the instance.

这篇关于HazelCast Tcp-IP的编程配置无需在集群中添加成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆