public class MulticastConfig extends Object
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
.
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_ENABLED
Whether the multicast discovery mechanism has been enabled
|
static boolean |
DEFAULT_LOOPBACK_MODE_ENABLED
Default flag that indicates if the loopback mode
is turned on or off.
|
static String |
DEFAULT_MULTICAST_GROUP
Default group of multicast.
|
static int |
DEFAULT_MULTICAST_PORT
Default value of port.
|
static int |
DEFAULT_MULTICAST_TIMEOUT_SECONDS
Default timeout of multicast in seconds.
|
static int |
DEFAULT_MULTICAST_TTL
Default value of time to live of multicast.
|
Constructor and Description |
---|
MulticastConfig() |
Modifier and Type | Method and Description |
---|---|
MulticastConfig |
addTrustedInterface(String ip)
Adds a trusted interface.
|
boolean |
equals(Object o) |
String |
getMulticastGroup()
Gets the multicast group.
|
int |
getMulticastPort()
Gets the multicast port.
|
int |
getMulticastTimeoutSeconds()
Gets the multicast timeout in seconds.
|
int |
getMulticastTimeToLive()
Gets the time to live for the multicast package.
|
Set<String> |
getTrustedInterfaces()
Gets the trusted interfaces.
|
int |
hashCode() |
boolean |
isEnabled()
Check if the multicast discovery mechanism has been enabled.
|
boolean |
isLoopbackModeEnabled()
Check if the loopback mode is enabled in the multicast discovery mechanism.
|
MulticastConfig |
setEnabled(boolean enabled)
Enables or disables the multicast discovery mechanism
|
MulticastConfig |
setLoopbackModeEnabled(boolean enabled)
Enables or disables the loopback mode in the multicast discovery mechanism.
|
MulticastConfig |
setMulticastGroup(String multicastGroup)
Sets the multicast group.
|
MulticastConfig |
setMulticastPort(int multicastPort)
Sets the multicast port.
|
MulticastConfig |
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.
|
MulticastConfig |
setMulticastTimeToLive(int multicastTimeToLive)
Sets the time to live for the multicast package; a value between 0..255.
|
MulticastConfig |
setTrustedInterfaces(Set<String> interfaces)
Sets the trusted interfaces.
|
String |
toString() |
public static final boolean DEFAULT_ENABLED
public static final String DEFAULT_MULTICAST_GROUP
public static final int DEFAULT_MULTICAST_PORT
public static final int DEFAULT_MULTICAST_TIMEOUT_SECONDS
public static final int DEFAULT_MULTICAST_TTL
public static final boolean DEFAULT_LOOPBACK_MODE_ENABLED
public boolean isEnabled()
public MulticastConfig setEnabled(boolean enabled)
enabled
- true
to enable, false
to disablepublic String getMulticastGroup()
public MulticastConfig setMulticastGroup(String multicastGroup)
multicastGroup
- the multicastGroup to setIllegalArgumentException
- if multicastGroup is null
or emptygetMulticastGroup()
,
setMulticastPort(int)
public int getMulticastPort()
setMulticastPort(int)
public MulticastConfig setMulticastPort(int multicastPort)
multicastPort
- the multicastPort to setIllegalArgumentException
- if multicastPort is smaller than 0getMulticastPort()
,
setMulticastGroup(String)
public int getMulticastTimeoutSeconds()
setMulticastTimeoutSeconds(int)
public MulticastConfig setMulticastTimeoutSeconds(int multicastTimeoutSeconds)
multicastTimeoutSeconds
- the multicastTimeoutSeconds to setgetMulticastTimeoutSeconds()
public Set<String> getTrustedInterfaces()
setTrustedInterfaces(java.util.Set)
public MulticastConfig setTrustedInterfaces(Set<String> 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'.
interfaces
- the new trusted interfacesif interfaces is {@code null}
public MulticastConfig addTrustedInterface(String ip)
ip
- the IP of the trusted interfaceIllegalArgumentException
- if IP is null
setTrustedInterfaces(java.util.Set)
public int getMulticastTimeToLive()
MulticastSocket.setTimeToLive(int)
,
setMulticastTimeToLive(int)
public MulticastConfig setMulticastTimeToLive(int multicastTimeToLive)
See this link for more information.
multicastTimeToLive
- the time to live for the multicast packageIllegalArgumentException
- if time to live is smaller than 0 or larger than 255getMulticastTimeToLive()
,
MulticastSocket.setTimeToLive(int)
public boolean isLoopbackModeEnabled()
true
if the the loopback mode is enabled, false
otherwisepublic MulticastConfig setLoopbackModeEnabled(boolean enabled)
enabled
- true
to enable the loopback mode, false
to disableCopyright © 2022 Hazelcast, Inc.. All rights reserved.