Class TcpIpConfig
- java.lang.Object
-
- com.hazelcast.config.TcpIpConfig
-
public class TcpIpConfig extends java.lang.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 Summary
Fields Modifier and Type Field Description static java.util.regex.Pattern
MEMBER_TEXT_SPLIT_PATTERN
A pattern for splitting member texts defined in tcp-ip configuration by comma(,) semicolon(;) space( ).
-
Constructor Summary
Constructors Constructor Description TcpIpConfig()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TcpIpConfig
addMember(java.lang.String member)
Adds a 'well known' member.TcpIpConfig
clear()
Removes all members.boolean
equals(java.lang.Object o)
int
getConnectionTimeoutSeconds()
Returns the connection timeout.java.util.List<java.lang.String>
getMembers()
Gets a list of all the well known members.java.lang.String
getRequiredMember()
Gets the required member.int
hashCode()
boolean
isEnabled()
Checks if the Tcp/Ip join mechanism is enabled.TcpIpConfig
setConnectionTimeoutSeconds(int connectionTimeoutSeconds)
Sets the connection timeout.TcpIpConfig
setEnabled(boolean enabled)
Enables or disables the Tcp/Ip join mechanism.TcpIpConfig
setMembers(java.util.List<java.lang.String> members)
Sets the well known members.TcpIpConfig
setRequiredMember(java.lang.String requiredMember)
Sets the required member.java.lang.String
toString()
-
-
-
Method Detail
-
getConnectionTimeoutSeconds
public int getConnectionTimeoutSeconds()
Returns the connection timeout.- Returns:
- the connectionTimeoutSeconds
- See Also:
setConnectionTimeoutSeconds(int)
-
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:
java.lang.IllegalArgumentException
- if connectionTimeoutSeconds is smaller than 0- See Also:
getConnectionTimeoutSeconds()
-
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 java.util.List<java.lang.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(java.util.List)
-
setMembers
public TcpIpConfig setMembers(java.util.List<java.lang.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:
java.lang.IllegalArgumentException
- if members isnull
-
addMember
public TcpIpConfig addMember(java.lang.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:
java.lang.IllegalArgumentException
- if member isnull
or empty- See Also:
getMembers()
-
clear
public TcpIpConfig clear()
Removes all members.Can safely be called when there are no members.
- Returns:
- the updated configuration
- See Also:
addMember(String)
-
getRequiredMember
public java.lang.String getRequiredMember()
Gets the required member. If no required member is configured, null is returned.- Returns:
- the requiredMember
- See Also:
setRequiredMember(String)
-
setRequiredMember
public TcpIpConfig setRequiredMember(java.lang.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:
getRequiredMember()
-
equals
public final boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public final int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-