Class TcpIpConfig

java.lang.Object
com.hazelcast.config.TcpIpConfig

public class TcpIpConfig extends Object
Contains the configuration for the Tcp/Ip join mechanism.

The Tcp/Ip join mechanism relies on one or more well known members. So when a new member wants to join a cluster, it will try to connect to one of the well known members. If it is able to connect, it will know about all members in the cluster and won't rely on these well known members anymore.

  • Field Details

    • MEMBER_TEXT_SPLIT_PATTERN

      public static final Pattern MEMBER_TEXT_SPLIT_PATTERN
      A pattern for splitting member texts defined in tcp-ip configuration by comma(,) semicolon(;) space( ).
  • Constructor Details

    • TcpIpConfig

      public TcpIpConfig()
  • Method Details

    • getConnectionTimeoutSeconds

      public int getConnectionTimeoutSeconds()
      Returns the connection timeout.
      Returns:
      the connectionTimeoutSeconds
      See Also:
    • setConnectionTimeoutSeconds

      public TcpIpConfig setConnectionTimeoutSeconds(int connectionTimeoutSeconds)
      Sets the connection timeout. This is the maximum amount of time Hazelcast will try to connect to a well known member before giving up. Setting it to a too low value could mean that a member is not able to connect to a cluster. Setting it as too high a value means that member startup could slow down because of longer timeouts (e.g. when a well known member is not up).
      Parameters:
      connectionTimeoutSeconds - the connection timeout in seconds
      Returns:
      the updated TcpIpConfig
      Throws:
      IllegalArgumentException - if connectionTimeoutSeconds is smaller than 0
      See Also:
    • isEnabled

      public boolean isEnabled()
      Checks if the Tcp/Ip join mechanism is enabled.
      Returns:
      true if enabled, false otherwise
    • setEnabled

      public TcpIpConfig setEnabled(boolean enabled)
      Enables or disables the Tcp/Ip join mechanism.
      Parameters:
      enabled - true to enable the Tcp/Ip join mechanism, false to disable
      Returns:
      TcpIpConfig the updated TcpIpConfig config
    • getMembers

      public List<String> getMembers()
      Gets a list of all the well known members. If there are no well known members, the list will be empty.
      Returns:
      the list members
      See Also:
    • setMembers

      public TcpIpConfig setMembers(List<String> members)
      Sets the well known members.

      If members are empty, calling this method will have the same effect as calling clear().

      A member can be a comma(,) semicolon(;) space( ) separated string, e.g. "10.11.12.1,10.11.12.2" which indicates multiple members are going to be added.

      Parameters:
      members - the members to set
      Returns:
      the updated TcpIpConfig
      Throws:
      IllegalArgumentException - if members is null
    • addMember

      public TcpIpConfig addMember(String member)
      Adds a 'well known' member.

      Each HazelcastInstance will try to connect to at least one of the members, to find all other members, and create a cluster.

      A member can be a comma(,) semicolon(;) space( ) separated string, e.g. "10.11.12.1,10.11.12.2" which indicates multiple members are going to be added.

      Parameters:
      member - the member to add
      Returns:
      the updated configuration
      Throws:
      IllegalArgumentException - if member is null or empty
      See Also:
    • clear

      public TcpIpConfig clear()
      Removes all members.

      Can safely be called when there are no members.

      Returns:
      the updated configuration
      See Also:
    • getRequiredMember

      public String getRequiredMember()
      Gets the required member. If no required member is configured, null is returned.
      Returns:
      the requiredMember
      See Also:
    • setRequiredMember

      public TcpIpConfig setRequiredMember(String requiredMember)
      Sets the required member. If a null value is passed, it means that there is no required member.

      With a required member configured, the cluster will only start up when this required member is up. Setting the required member can be tricky, since if that member doesn't come up, the cluster won't start.

      Parameters:
      requiredMember - the requiredMember to set
      Returns:
      TcpIpConfig the updated configuration
      See Also:
    • equals

      public final boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object