本文整理汇总了Java中com.hazelcast.config.InterfacesConfig类的典型用法代码示例。如果您正苦于以下问题:Java InterfacesConfig类的具体用法?Java InterfacesConfig怎么用?Java InterfacesConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InterfacesConfig类属于com.hazelcast.config包,在下文中一共展示了InterfacesConfig类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildInterfaces
import com.hazelcast.config.InterfacesConfig; //导入依赖的package包/类
private InterfacesConfig buildInterfaces(String interfaces) {
InterfacesConfig interfacesConfig = new InterfacesConfig();
interfacesConfig.setEnabled(Boolean.TRUE);
if (interfaces == null || interfaces.trim().isEmpty()) {
log.warn("Hazelcast interfaces list is empty");
return interfacesConfig;
}
for (String ip : interfaces.split(",")) {
if (ip != null && !ip.trim().isEmpty()) {
interfacesConfig.addInterface(ip);
}
}
return interfacesConfig;
}
开发者ID:xm-online,项目名称:xm-commons,代码行数:18,代码来源:XmConfigHazelcastConfiguration.java
示例2: testBuilder
import com.hazelcast.config.InterfacesConfig; //导入依赖的package包/类
@Test
public void testBuilder() {
final Config config = new YamlConfigBuilder(getResource()).build();
assertNotNull(config);
// Group Config
assertNotNull(config.getGroupConfig());
assertEquals("group-name", config.getGroupConfig().getName());
assertEquals("group-password", config.getGroupConfig().getPassword());
// Network Config
final NetworkConfig netCfg = config.getNetworkConfig();
assertEquals(true, netCfg.isReuseAddress());
assertEquals(5900, netCfg.getPort());
assertEquals(false, netCfg.isPortAutoIncrement());
assertEquals(100, netCfg.getPortCount());
assertFalse(netCfg.getOutboundPortDefinitions().isEmpty());
assertEquals(2, netCfg.getOutboundPortDefinitions().size());
assertTrue(netCfg.getOutboundPortDefinitions().contains("10100"));
assertTrue(netCfg.getOutboundPortDefinitions().contains("9000-10000"));
assertEquals("127.0.0.1", netCfg.getPublicAddress());
// Multicast Config
final MulticastConfig mcastCfg = netCfg.getJoin().getMulticastConfig();
assertEquals(false, mcastCfg.isEnabled());
assertEquals(false, mcastCfg.isLoopbackModeEnabled());
assertFalse(mcastCfg.getTrustedInterfaces().isEmpty());
assertEquals(2, mcastCfg.getTrustedInterfaces().size());
assertTrue(mcastCfg.getTrustedInterfaces().contains("eth0"));
assertTrue(mcastCfg.getTrustedInterfaces().contains("eth1"));
// TcpIp Config
final TcpIpConfig tcpCfg = netCfg.getJoin().getTcpIpConfig();
assertEquals(false, tcpCfg.isEnabled());
assertEquals(10, tcpCfg.getConnectionTimeoutSeconds());
assertFalse(tcpCfg.getMembers().isEmpty());
assertEquals(3, tcpCfg.getMembers().size());
assertTrue(tcpCfg.getMembers().contains("192.168.0.1"));
assertTrue(tcpCfg.getMembers().contains("192.168.0.2"));
assertTrue(tcpCfg.getMembers().contains("192.168.0.3"));
assertEquals("127.0.0.1", tcpCfg.getRequiredMember());
// Interfaces Config
final InterfacesConfig ifacesCfg = netCfg.getInterfaces();
assertEquals(false, ifacesCfg.isEnabled());
assertEquals(3, ifacesCfg.getInterfaces().size());
assertTrue(ifacesCfg.getInterfaces().contains("10.3.16.*"));
assertTrue(ifacesCfg.getInterfaces().contains("10.3.10.4-18"));
assertTrue(ifacesCfg.getInterfaces().contains("192.168.1.3"));
}
开发者ID:lburgazzoli,项目名称:lb-hazelcast,代码行数:52,代码来源:YamlConfigTest.java
示例3: HazelcastCache
import com.hazelcast.config.InterfacesConfig; //导入依赖的package包/类
private HazelcastCache() {
final AppConfig config = AppConfig.getInstance();
final Map<String, MapConfig> mapconfigs = new HashMap<>();
GroupConfig groupconfig = new GroupConfig();
groupconfig.setName(config.getString("cluster.name", "gw2live"));
groupconfig.setPassword(config.getString("cluster.password", "gw2live"));
final MapConfig mapconfig = new MapConfig();
mapconfig.getMaxSizeConfig().setMaxSizePolicy(MaxSizePolicy.PER_PARTITION);
mapconfig.getMaxSizeConfig().setSize(0);
mapconfig.setEvictionPolicy(MapConfig.DEFAULT_EVICTION_POLICY);
mapconfig.setBackupCount(1);
mapconfigs.put("*-cache", mapconfig);
final NetworkConfig nwconfig = new NetworkConfig();
if(config.containsKey("cluster.interface")) {
final InterfacesConfig interfaces = new InterfacesConfig();
interfaces.addInterface(config.getString("cluster.interface"));
interfaces.setEnabled(true);
nwconfig.setInterfaces(interfaces);
}
nwconfig.setPort(config.getInteger("cluster.port", 5801));
nwconfig.setPortAutoIncrement(true);
final MulticastConfig mcconfig = new MulticastConfig();
mcconfig.setEnabled(true);
mcconfig.setMulticastGroup(config.getString("cluster.multicast.group", "224.2.2.3"));
mcconfig.setMulticastPort(config.getInteger("cluster.multicast.port", 58011));
mcconfig.setMulticastTimeToLive(MulticastConfig.DEFAULT_MULTICAST_TTL);
mcconfig.setMulticastTimeoutSeconds(MulticastConfig.DEFAULT_MULTICAST_TIMEOUT_SECONDS);
final JoinConfig join = new JoinConfig();
join.setMulticastConfig(mcconfig);
nwconfig.setJoin(join);
final ExecutorConfig execconfig = new ExecutorConfig();
execconfig.setName("default");
execconfig.setPoolSize(4);
execconfig.setQueueCapacity(100);
final Map<String, ExecutorConfig> execmap = new HashMap<>();
execmap.put("default", execconfig);
final Config hconfig = new Config();
hconfig.setInstanceName("gw2live");
hconfig.setGroupConfig(groupconfig);
hconfig.setMapConfigs(mapconfigs);
hconfig.setNetworkConfig(nwconfig);
hconfig.setExecutorConfigs(execmap);
hconfig.setProperty("hazelcast.shutdownhook.enabled", "false");
hconfig.setProperty("hazelcast.wait.seconds.before.join", "0");
hconfig.setProperty("hazelcast.rest.enabled", "false");
hconfig.setProperty("hazelcast.memcache.enabled", "false");
hconfig.setProperty("hazelcast.mancenter.enabled", "false");
hconfig.setProperty("hazelcast.logging.type", "none");
cache = Hazelcast.newHazelcastInstance(hconfig);
LOG.debug("Hazelcast initialized");
}
开发者ID:zyclonite,项目名称:gw2live,代码行数:53,代码来源:HazelcastCache.java
注:本文中的com.hazelcast.config.InterfacesConfig类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论