Package com.hazelcast.config
Class MulticastConfig
java.lang.Object
com.hazelcast.config.MulticastConfig
- All Implemented Interfaces:
TrustedInterfacesConfigurable<MulticastConfig>
public class MulticastConfig
extends Object
implements TrustedInterfacesConfigurable<MulticastConfig>
Contains the configuration for the multicast discovery mechanism.
With the multicast discovery mechanism Hazelcast allows Hazelcast members to find each other using multicast. So Hazelcast members do not need to know concrete addresses of members, they just multicast to everyone listening.
It depends on your environment if multicast is possible or allowed; you need to have a look at the
TCP/IP cluster: TcpIpConfig
.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
Whether the multicast discovery mechanism has been enabledstatic final String
Default group of multicast.static final int
Default value of port.static final int
Default timeout of multicast in seconds.static final int
Default value of time to live of multicast. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds a trusted interface.final boolean
Returns if explicit loopback mode configuration was requested (bysetLoopbackModeEnabled(Boolean)
).Gets the multicast group.int
Gets the multicast port.int
Gets the multicast timeout in seconds.int
Gets the time to live for the multicast package.Gets the trusted interfaces.final int
hashCode()
boolean
Check if the multicast discovery mechanism has been enabled.boolean
Deprecated.setEnabled
(boolean enabled) Enables or disables the multicast discovery mechanismsetLoopbackModeEnabled
(Boolean enabled) Explicitly enables or disables the loopback mode in the multicast discovery mechanism.setMulticastGroup
(String multicastGroup) Sets the multicast group.setMulticastPort
(int multicastPort) Sets the multicast port.setMulticastTimeoutSeconds
(int multicastTimeoutSeconds) Specifies the time in seconds that a node should wait for a valid multicast response from another node running in the network before declaring itself as master node and creating its own cluster.setMulticastTimeToLive
(int multicastTimeToLive) Sets the time to live for the multicast package; a value between 0..255.setTrustedInterfaces
(Set<String> interfaces) Sets the trusted interfaces.toString()
-
Field Details
-
DEFAULT_ENABLED
public static final boolean DEFAULT_ENABLEDWhether the multicast discovery mechanism has been enabled- See Also:
-
DEFAULT_MULTICAST_GROUP
Default group of multicast.- See Also:
-
DEFAULT_MULTICAST_PORT
public static final int DEFAULT_MULTICAST_PORTDefault value of port.- See Also:
-
DEFAULT_MULTICAST_TIMEOUT_SECONDS
public static final int DEFAULT_MULTICAST_TIMEOUT_SECONDSDefault timeout of multicast in seconds.- See Also:
-
DEFAULT_MULTICAST_TTL
public static final int DEFAULT_MULTICAST_TTLDefault value of time to live of multicast.- See Also:
-
-
Constructor Details
-
MulticastConfig
public MulticastConfig()
-
-
Method Details
-
isEnabled
public boolean isEnabled()Check if the multicast discovery mechanism has been enabled.- Returns:
- true if the multicast discovery mechanism has been enabled
-
setEnabled
Enables or disables the multicast discovery mechanism- Parameters:
enabled
-true
to enable,false
to disable- Returns:
- the updated MulticastConfig
-
getMulticastGroup
Gets the multicast group.- Returns:
- the multicastGroup
-
setMulticastGroup
Sets the multicast group.- Parameters:
multicastGroup
- the multicastGroup to set- Returns:
- the updated MulticastConfig
- Throws:
IllegalArgumentException
- if multicastGroup isnull
or empty- See Also:
-
getMulticastPort
public int getMulticastPort()Gets the multicast port.- Returns:
- the multicastPort
- See Also:
-
setMulticastPort
Sets the multicast port.- Parameters:
multicastPort
- the multicastPort to set- Returns:
- the updated MulticastConfig
- Throws:
IllegalArgumentException
- if multicastPort is smaller than 0- See Also:
-
getMulticastTimeoutSeconds
public int getMulticastTimeoutSeconds()Gets the multicast timeout in seconds.- Returns:
- the multicastTimeoutSeconds
- See Also:
-
setMulticastTimeoutSeconds
Specifies the time in seconds that a node should wait for a valid multicast response from another node running in the network before declaring itself as master node and creating its own cluster. This applies only to the startup of nodes where no master has been assigned yet. If you specify a high value, e.g. 60 seconds, it means until a master is selected, each node is going to wait 60 seconds before continuing, so be careful with providing a high value. If the value is set too low, nodes might give up too early and create their own cluster.- Parameters:
multicastTimeoutSeconds
- the multicastTimeoutSeconds to set- Returns:
- the updated MulticastConfig
- See Also:
-
getTrustedInterfaces
Gets the trusted interfaces.- Specified by:
getTrustedInterfaces
in interfaceTrustedInterfacesConfigurable<MulticastConfig>
- Returns:
- the trusted interfaces
- See Also:
-
setTrustedInterfaces
Sets the trusted interfaces.By default, when the set of trusted interfaces is empty, a Hazelcast member will accept join-requests from every member. With a trusted interface, you can control the members you want to receive join requests from.
The interface is an IP address where the last octet can be a wildcard '*' or a range '10-20'.
- Specified by:
setTrustedInterfaces
in interfaceTrustedInterfacesConfigurable<MulticastConfig>
- Parameters:
interfaces
- the new trusted interfaces- Returns:
- the updated MulticastConfig
- See Also:
-
addTrustedInterface
Adds a trusted interface.- Specified by:
addTrustedInterface
in interfaceTrustedInterfacesConfigurable<MulticastConfig>
- Parameters:
ip
- the IP of the trusted interface- Returns:
- the updated MulticastConfig
- Throws:
IllegalArgumentException
- if IP isnull
- See Also:
-
getMulticastTimeToLive
public int getMulticastTimeToLive()Gets the time to live for the multicast package.- Returns:
- the time to live for the multicast package
- See Also:
-
setMulticastTimeToLive
Sets the time to live for the multicast package; a value between 0..255.See this link for more information.
- Parameters:
multicastTimeToLive
- the time to live for the multicast package- Returns:
- the updated MulticastConfig
- Throws:
IllegalArgumentException
- if time to live is smaller than 0 or larger than 255- See Also:
-
isLoopbackModeEnabled
Deprecated.Use thegetLoopbackModeEnabled()
.Check if the loopback mode is enabled in the multicast discovery mechanism.- Returns:
true
if the the loopback mode is enabled,false
otherwise
-
getLoopbackModeEnabled
Returns if explicit loopback mode configuration was requested (bysetLoopbackModeEnabled(Boolean)
).- Returns:
TRUE
if the loopback mode should be enabled,FALSE
disabled,null
when it's left up to platform to decide.
-
setLoopbackModeEnabled
Explicitly enables or disables the loopback mode in the multicast discovery mechanism.- Parameters:
enabled
-true
to enable the loopback mode,false
to disable- Returns:
- the updated MulticastConfig
-
equals
-
hashCode
public final int hashCode() -
toString
-
getLoopbackModeEnabled()
.