public static InterfacesConfig GetInstance() { if (instance == null) { instance = new InterfacesConfig(); } return(instance); }
private HazelcastInstance CreateHazelcastInstance() { JoinConfig joinConfig = new JoinConfig(); joinConfig.MulticastConfig.Enabled = false; TcpIpConfig tcpIpConfig = joinConfig.TcpIpConfig; tcpIpConfig.Enabled = true; //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: ICollection <string> initialMembers = _remoteMembersResolver.resolve(SocketAddress::toString); initialMembers.forEach(tcpIpConfig.addMember); ListenSocketAddress hazelcastAddress = Config.get(discovery_listen_address); NetworkConfig networkConfig = new NetworkConfig(); if (!hazelcastAddress.Wildcard) { InterfacesConfig interfaces = new InterfacesConfig(); interfaces.addInterface(hazelcastAddress.Hostname); interfaces.Enabled = true; networkConfig.Interfaces = interfaces; } networkConfig.Port = hazelcastAddress.Port; networkConfig.Join = joinConfig; networkConfig.PortAutoIncrement = false; // We'll use election_timeout as a base value to calculate HZ timeouts. We multiply by 1.5 long?electionTimeoutMillis = Config.get(CausalClusteringSettings.leader_election_timeout).toMillis(); long?baseHazelcastTimeoutMillis = (3 * electionTimeoutMillis) / 2; /* * Some HZ settings require the value in seconds. Adding the divider and subtracting 1 is equivalent to the * ceiling function for integers ( Math.ceil() returns double ). Anything < 0 will return 0, any * multiple of 1000 returns the result of the division by 1000, any non multiple of 1000 returns the result * of the division + 1. In other words, values in millis are rounded up. */ long baseHazelcastTimeoutSeconds = (baseHazelcastTimeoutMillis + 1000 - 1) / 1000; com.hazelcast.config.Config c = new com.hazelcast.config.Config(); c.setProperty(OPERATION_CALL_TIMEOUT_MILLIS.Name, baseHazelcastTimeoutMillis.ToString()); c.setProperty(MERGE_NEXT_RUN_DELAY_SECONDS.Name, baseHazelcastTimeoutSeconds.ToString()); c.setProperty(MERGE_FIRST_RUN_DELAY_SECONDS.Name, baseHazelcastTimeoutSeconds.ToString()); c.setProperty(INITIAL_MIN_CLUSTER_SIZE.Name, HAZELCAST_MIN_CLUSTER.ToString()); if (Config.get(disable_middleware_logging)) { c.setProperty(LOGGING_TYPE.Name, "none"); } if (hazelcastAddress.IPv6) { c.setProperty(PREFER_IPv4_STACK.Name, "false"); } c.NetworkConfig = networkConfig; MemberAttributeConfig memberAttributeConfig = HazelcastClusterTopology.BuildMemberAttributesForCore(MyselfConflict, Config); c.MemberAttributeConfig = memberAttributeConfig; LogConnectionInfo(initialMembers); c.addListenerConfig(new ListenerConfig(new OurMembershipListener(this))); JobHandle logJob = _scheduler.schedule(Group.HZ_TOPOLOGY_HEALTH, _hazelcastIsHealthyTimeoutMs, () => 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: {0} = {1}", discovery_listen_address.name(), Config.get(discovery_listen_address)); UserLog.error(errorMessage); Log.error(errorMessage, e); throw new Exception(e); } IList <string> groups = Config.get(CausalClusteringSettings.server_groups); refreshGroups(_hazelcastInstance, MyselfConflict.Uuid.ToString(), groups); return(_hazelcastInstance); }