use of com.hazelcast.config.JoinConfig in project hazelcast by hazelcast.
the class RestTest method setup.
@Before
public void setup() {
config.setProperty(GroupProperty.REST_ENABLED.getName(), "true");
int firstPort = port.getAndIncrement();
int secondPort = port.getAndIncrement();
// we start pairs of HazelcastInstances which form a cluster to have remote invocations for all operations
JoinConfig join = config.getNetworkConfig().getJoin();
join.getMulticastConfig().setEnabled(false);
join.getTcpIpConfig().setEnabled(true).addMember("127.0.0.1:" + firstPort).addMember("127.0.0.1:" + secondPort);
config.getNetworkConfig().setPort(firstPort);
instance = Hazelcast.newHazelcastInstance(config);
config.getNetworkConfig().setPort(secondPort);
remoteInstance = Hazelcast.newHazelcastInstance(config);
communicator = new HTTPCommunicator(instance);
}
use of com.hazelcast.config.JoinConfig in project hazelcast by hazelcast.
the class DiscoverySpiTest method testNodeFilter_from_xml.
@Test
public void testNodeFilter_from_xml() throws Exception {
String xmlFileName = "test-hazelcast-discovery-spi.xml";
InputStream xmlResource = DiscoverySpiTest.class.getClassLoader().getResourceAsStream(xmlFileName);
Config config = new XmlConfigBuilder(xmlResource).build();
JoinConfig joinConfig = config.getNetworkConfig().getJoin();
DiscoveryConfig discoveryConfig = joinConfig.getDiscoveryConfig();
Address address = new Address("localhost", 5701);
DiscoveryServiceSettings settings = buildDiscoveryServiceSettings(address, discoveryConfig, DiscoveryMode.Client);
DiscoveryServiceProvider provider = new DefaultDiscoveryServiceProvider();
DiscoveryService discoveryService = provider.newDiscoveryService(settings);
discoveryService.start();
discoveryService.discoverNodes();
discoveryService.destroy();
Field nodeFilterField = DefaultDiscoveryService.class.getDeclaredField("nodeFilter");
nodeFilterField.setAccessible(true);
TestNodeFilter nodeFilter = (TestNodeFilter) nodeFilterField.get(discoveryService);
assertEquals(4, nodeFilter.getNodes().size());
}
use of com.hazelcast.config.JoinConfig in project cas by apereo.
the class HazelcastTicketRegistryConfiguration method getConfig.
private Config getConfig(final TicketCatalog ticketCatalog) {
final HazelcastProperties hz = casProperties.getTicket().getRegistry().getHazelcast();
final HazelcastProperties.Cluster cluster = hz.getCluster();
final Config config;
if (hz.getConfigLocation() != null && hz.getConfigLocation().exists()) {
try {
final URL configUrl = hz.getConfigLocation().getURL();
LOGGER.debug("Loading Hazelcast configuration from [{}]", configUrl);
config = new XmlConfigBuilder(hz.getConfigLocation().getInputStream()).build();
config.setConfigurationUrl(configUrl);
} catch (final Exception e) {
throw Throwables.propagate(e);
}
} else {
// No config location, so do a default config programmatically with handful of properties exposed by CAS
config = new Config();
config.setProperty("hazelcast.prefer.ipv4.stack", String.valueOf(cluster.isIpv4Enabled()));
// TCP config
final TcpIpConfig tcpIpConfig = new TcpIpConfig().setEnabled(cluster.isTcpipEnabled()).setMembers(cluster.getMembers()).setConnectionTimeoutSeconds(cluster.getTimeout());
LOGGER.debug("Created Hazelcast TCP/IP configuration [{}]", tcpIpConfig);
// Multicast config
final MulticastConfig multicastConfig = new MulticastConfig().setEnabled(cluster.isMulticastEnabled());
if (cluster.isMulticastEnabled()) {
multicastConfig.setMulticastGroup(cluster.getMulticastGroup());
multicastConfig.setMulticastPort(cluster.getMulticastPort());
final Set<String> trustedInterfaces = StringUtils.commaDelimitedListToSet(cluster.getMulticastTrustedInterfaces());
if (!trustedInterfaces.isEmpty()) {
multicastConfig.setTrustedInterfaces(trustedInterfaces);
}
multicastConfig.setMulticastTimeoutSeconds(cluster.getMulticastTimeout());
multicastConfig.setMulticastTimeToLive(cluster.getMulticastTimeToLive());
}
LOGGER.debug("Created Hazelcast Multicast configuration [{}]", multicastConfig);
// Join config
final JoinConfig joinConfig = new JoinConfig().setMulticastConfig(multicastConfig).setTcpIpConfig(tcpIpConfig);
LOGGER.debug("Created Hazelcast join configuration [{}]", joinConfig);
// Network config
final NetworkConfig networkConfig = new NetworkConfig().setPort(cluster.getPort()).setPortAutoIncrement(cluster.isPortAutoIncrement()).setJoin(joinConfig);
LOGGER.debug("Created Hazelcast network configuration [{}]", networkConfig);
// Finally aggregate all those config into the main Config
config.setMapConfigs(buildHazelcastMapConfigurations(ticketCatalog)).setNetworkConfig(networkConfig);
}
// Add additional default config properties regardless of the configuration source
return config.setInstanceName(cluster.getInstanceName()).setProperty(HazelcastProperties.LOGGING_TYPE_PROP, cluster.getLoggingType()).setProperty(HazelcastProperties.MAX_HEARTBEAT_SECONDS_PROP, String.valueOf(cluster.getMaxNoHeartbeatSeconds()));
}
use of com.hazelcast.config.JoinConfig in project hazelcast by hazelcast.
the class DiscoverySpiTest method testParsing.
@Test
public void testParsing() throws Exception {
String xmlFileName = "test-hazelcast-discovery-spi.xml";
InputStream xmlResource = DiscoverySpiTest.class.getClassLoader().getResourceAsStream(xmlFileName);
Config config = new XmlConfigBuilder(xmlResource).build();
JoinConfig joinConfig = config.getNetworkConfig().getJoin();
AwsConfig awsConfig = joinConfig.getAwsConfig();
assertFalse(awsConfig.isEnabled());
TcpIpConfig tcpIpConfig = joinConfig.getTcpIpConfig();
assertFalse(tcpIpConfig.isEnabled());
MulticastConfig multicastConfig = joinConfig.getMulticastConfig();
assertFalse(multicastConfig.isEnabled());
DiscoveryConfig discoveryConfig = joinConfig.getDiscoveryConfig();
assertTrue(discoveryConfig.isEnabled());
assertEquals(1, discoveryConfig.getDiscoveryStrategyConfigs().size());
DiscoveryStrategyConfig providerConfig = discoveryConfig.getDiscoveryStrategyConfigs().iterator().next();
assertEquals(3, providerConfig.getProperties().size());
assertEquals("foo", providerConfig.getProperties().get("key-string"));
assertEquals("123", providerConfig.getProperties().get("key-int"));
assertEquals("true", providerConfig.getProperties().get("key-boolean"));
}
use of com.hazelcast.config.JoinConfig in project hazelcast by hazelcast.
the class SplitBrainHandlerTest method buildConfig.
private Config buildConfig(final String groupName, final boolean liteMember) {
Config config = new Config();
config.setProperty(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS.getName(), "5");
config.setProperty(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS.getName(), "3");
config.getGroupConfig().setName(groupName);
config.setLiteMember(liteMember);
NetworkConfig networkConfig = config.getNetworkConfig();
JoinConfig join = networkConfig.getJoin();
join.getMulticastConfig().setEnabled(true);
config.getMapConfig("default").setMergePolicy(PassThroughMergePolicy.class.getName());
return config;
}
Aggregations