Search in sources :

Example 1 with JoinConfig

use of com.hazelcast.config.JoinConfig in project neo4j by neo4j.

the class HazelcastCoreTopologyService method createHazelcastInstance.

private HazelcastInstance createHazelcastInstance() {
    System.setProperty(WAIT_SECONDS_BEFORE_JOIN.getName(), "1");
    JoinConfig joinConfig = new JoinConfig();
    joinConfig.getMulticastConfig().setEnabled(false);
    joinConfig.getAwsConfig().setEnabled(false);
    TcpIpConfig tcpIpConfig = joinConfig.getTcpIpConfig();
    tcpIpConfig.setEnabled(true);
    List<AdvertisedSocketAddress> initialMembers = config.get(CausalClusteringSettings.initial_discovery_members);
    for (AdvertisedSocketAddress address : initialMembers) {
        tcpIpConfig.addMember(address.toString());
    }
    Setting<ListenSocketAddress> discovery_listen_address = CausalClusteringSettings.discovery_listen_address;
    ListenSocketAddress hazelcastAddress = config.get(discovery_listen_address);
    InterfacesConfig interfaces = new InterfacesConfig();
    interfaces.addInterface(hazelcastAddress.getHostname());
    NetworkConfig networkConfig = new NetworkConfig();
    networkConfig.setInterfaces(interfaces);
    networkConfig.setPort(hazelcastAddress.getPort());
    networkConfig.setJoin(joinConfig);
    networkConfig.setPortAutoIncrement(false);
    com.hazelcast.config.Config c = new com.hazelcast.config.Config();
    c.setProperty(OPERATION_CALL_TIMEOUT_MILLIS.getName(), String.valueOf(10_000));
    c.setProperty(MERGE_NEXT_RUN_DELAY_SECONDS.getName(), "10");
    c.setProperty(MERGE_FIRST_RUN_DELAY_SECONDS.getName(), "10");
    c.setProperty(INITIAL_MIN_CLUSTER_SIZE.getName(), String.valueOf(minimumClusterSizeThatCanTolerateOneFaultForExpectedClusterSize()));
    c.setProperty(LOGGING_TYPE.getName(), "none");
    c.setNetworkConfig(networkConfig);
    MemberAttributeConfig memberAttributeConfig = HazelcastClusterTopology.buildMemberAttributesForCore(myself, config);
    c.setMemberAttributeConfig(memberAttributeConfig);
    logConnectionInfo(initialMembers);
    JobScheduler.JobHandle logJob = scheduler.schedule("HazelcastHealth", HAZELCAST_IS_HEALTHY_TIMEOUT_MS, () -> log.warn("The server has not been able to connect in a timely fashion to the " + "cluster. Please consult the logs for more details. Rebooting the server may " + "solve the problem."));
    try {
        hazelcastInstance = Hazelcast.newHazelcastInstance(c);
        logJob.cancel(true);
    } catch (HazelcastException e) {
        String errorMessage = String.format("Hazelcast was unable to start with setting: %s = %s", discovery_listen_address.name(), config.get(discovery_listen_address));
        userLog.error(errorMessage);
        log.error(errorMessage, e);
        throw new RuntimeException(e);
    }
    List<String> groups = config.get(CausalClusteringSettings.server_groups);
    refreshGroups(hazelcastInstance, myself.getUuid().toString(), groups);
    return hazelcastInstance;
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) InterfacesConfig(com.hazelcast.config.InterfacesConfig) HazelcastException(com.hazelcast.core.HazelcastException) JoinConfig(com.hazelcast.config.JoinConfig) MemberAttributeConfig(com.hazelcast.config.MemberAttributeConfig) Config(org.neo4j.kernel.configuration.Config) NetworkConfig(com.hazelcast.config.NetworkConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) InterfacesConfig(com.hazelcast.config.InterfacesConfig) NetworkConfig(com.hazelcast.config.NetworkConfig) AdvertisedSocketAddress(org.neo4j.helpers.AdvertisedSocketAddress) ListenSocketAddress(org.neo4j.helpers.ListenSocketAddress) JoinConfig(com.hazelcast.config.JoinConfig) MemberAttributeConfig(com.hazelcast.config.MemberAttributeConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig)

Example 2 with JoinConfig

use of com.hazelcast.config.JoinConfig in project hazelcast by hazelcast.

the class Node method createDiscoveryService.

private DiscoveryService createDiscoveryService(Config config) {
    JoinConfig joinConfig = config.getNetworkConfig().getJoin();
    DiscoveryConfig discoveryConfig = joinConfig.getDiscoveryConfig().getAsReadOnly();
    DiscoveryServiceProvider factory = discoveryConfig.getDiscoveryServiceProvider();
    if (factory == null) {
        factory = new DefaultDiscoveryServiceProvider();
    }
    ILogger logger = getLogger(DiscoveryService.class);
    DiscoveryServiceSettings settings = new DiscoveryServiceSettings().setConfigClassLoader(configClassLoader).setLogger(logger).setDiscoveryMode(DiscoveryMode.Member).setDiscoveryConfig(discoveryConfig).setDiscoveryNode(new SimpleDiscoveryNode(localMember.getAddress(), localMember.getAttributes()));
    return factory.newDiscoveryService(settings);
}
Also used : DiscoveryServiceProvider(com.hazelcast.spi.discovery.integration.DiscoveryServiceProvider) DefaultDiscoveryServiceProvider(com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider) DefaultDiscoveryServiceProvider(com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider) JoinConfig(com.hazelcast.config.JoinConfig) SimpleDiscoveryNode(com.hazelcast.spi.discovery.SimpleDiscoveryNode) ILogger(com.hazelcast.logging.ILogger) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) DiscoveryServiceSettings(com.hazelcast.spi.discovery.integration.DiscoveryServiceSettings)

Example 3 with JoinConfig

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);
}
Also used : JoinConfig(com.hazelcast.config.JoinConfig) Before(org.junit.Before)

Example 4 with JoinConfig

use of com.hazelcast.config.JoinConfig in project hazelcast by hazelcast.

the class ListSplitBrainTest method getConfig.

private Config getConfig(boolean multicast) {
    Config config = new Config();
    config.setProperty(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS.getName(), "30");
    config.setProperty(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS.getName(), "3");
    NetworkConfig networkConfig = config.getNetworkConfig();
    JoinConfig join = networkConfig.getJoin();
    join.getMulticastConfig().setEnabled(multicast);
    join.getTcpIpConfig().setEnabled(!multicast);
    join.getTcpIpConfig().addMember("127.0.0.1");
    return config;
}
Also used : JoinConfig(com.hazelcast.config.JoinConfig) Config(com.hazelcast.config.Config) NetworkConfig(com.hazelcast.config.NetworkConfig) NetworkConfig(com.hazelcast.config.NetworkConfig) JoinConfig(com.hazelcast.config.JoinConfig)

Example 5 with JoinConfig

use of com.hazelcast.config.JoinConfig in project hazelcast by hazelcast.

the class MemcacheTest method setup.

@Before
public void setup() throws Exception {
    config.setProperty(GroupProperty.MEMCACHE_ENABLED.getName(), "true");
    // Join is disabled intentionally. will start standalone HazelcastInstances.
    JoinConfig join = config.getNetworkConfig().getJoin();
    join.getMulticastConfig().setEnabled(false);
    join.getTcpIpConfig().setEnabled(false);
    instance = Hazelcast.newHazelcastInstance(config);
    client = getMemcacheClient(instance);
}
Also used : JoinConfig(com.hazelcast.config.JoinConfig) Before(org.junit.Before)

Aggregations

JoinConfig (com.hazelcast.config.JoinConfig)90 Config (com.hazelcast.config.Config)64 NetworkConfig (com.hazelcast.config.NetworkConfig)32 Test (org.junit.Test)32 TcpIpConfig (com.hazelcast.config.TcpIpConfig)27 QuickTest (com.hazelcast.test.annotation.QuickTest)20 InterfacesConfig (com.hazelcast.config.InterfacesConfig)18 HazelcastInstance (com.hazelcast.core.HazelcastInstance)18 MulticastConfig (com.hazelcast.config.MulticastConfig)15 PartitionGroupConfig (com.hazelcast.config.PartitionGroupConfig)15 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)13 SlowTest (com.hazelcast.test.annotation.SlowTest)12 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)11 RealmConfig (com.hazelcast.config.security.RealmConfig)11 ClientConfig (com.hazelcast.client.config.ClientConfig)9 ListenerConfig (com.hazelcast.config.ListenerConfig)8 AwsConfig (com.hazelcast.config.AwsConfig)7 MemberAttributeConfig (com.hazelcast.config.MemberAttributeConfig)7 ServerSocketEndpointConfig (com.hazelcast.config.ServerSocketEndpointConfig)6 CountDownLatch (java.util.concurrent.CountDownLatch)6