com.hazelcast.config
Class MulticastConfig

java.lang.Object
  extended by com.hazelcast.config.MulticastConfig

public class MulticastConfig
extends Object

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; otherwise you need to have a look at the tcp/ip cluster: TcpIpConfig.


Field Summary
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 Summary
MulticastConfig()
           
 
Method Summary
 MulticastConfig addTrustedInterface(String ip)
          Adds a trusted interface.
 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 of the multicast package.
 Set<String> getTrustedInterfaces()
          Gets the trusted interfaces.
 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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_ENABLED

public static final boolean DEFAULT_ENABLED
Whether the multicast discovery mechanism has been enabled

See Also:
Constant Field Values

DEFAULT_MULTICAST_GROUP

public static final String DEFAULT_MULTICAST_GROUP
Default group of multicast.

See Also:
Constant Field Values

DEFAULT_MULTICAST_PORT

public static final int DEFAULT_MULTICAST_PORT
Default value of port.

See Also:
Constant Field Values

DEFAULT_MULTICAST_TIMEOUT_SECONDS

public static final int DEFAULT_MULTICAST_TIMEOUT_SECONDS
Default timeout of multicast in seconds.

See Also:
Constant Field Values

DEFAULT_MULTICAST_TTL

public static final int DEFAULT_MULTICAST_TTL
Default value of time to live of multicast.

See Also:
Constant Field Values

DEFAULT_LOOPBACK_MODE_ENABLED

public static final boolean DEFAULT_LOOPBACK_MODE_ENABLED
Default flag that indicates if the loopback mode is turned on or off.

See Also:
Constant Field Values
Constructor Detail

MulticastConfig

public MulticastConfig()
Method Detail

isEnabled

public boolean isEnabled()
Check if the multicast discovery mechanism has been enabled.

Returns:
the enabled

setEnabled

public MulticastConfig setEnabled(boolean enabled)
Enables or disables the multicast discovery mechanism

Parameters:
enabled - the enabled to set true when disabled, false when disabled.
Returns:
the updated MulticastConfig

getMulticastGroup

public String getMulticastGroup()
Gets the multicast group.

Returns:
the multicastGroup

setMulticastGroup

public MulticastConfig setMulticastGroup(String multicastGroup)
Sets the multicast-group.

Parameters:
multicastGroup - the multicastGroup to set
Returns:
the updated MulticastConfig
Throws:
IllegalArgumentException - if multicastGroup is null or empty.
See Also:
getMulticastGroup(), setMulticastPort(int)

getMulticastPort

public int getMulticastPort()
Gets the multicast port.

Returns:
the multicastPort
See Also:
setMulticastPort(int)

setMulticastPort

public MulticastConfig setMulticastPort(int multicastPort)
Sets the multicast port.

Parameters:
multicastPort - the multicastPort to set
Returns:
the updated MulticastConfig
Throws:
IllegalArgumentException - if multicastPort is smaller than 0.
See Also:
getMulticastPort(), setMulticastGroup(String)

getMulticastTimeoutSeconds

public int getMulticastTimeoutSeconds()
Gets the multicast timeout in seconds.

Returns:
the multicastTimeoutSeconds
See Also:
setMulticastTimeoutSeconds(int)

setMulticastTimeoutSeconds

public 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. 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, it might be that nodes are giving up too early and will create their own cluster.

Parameters:
multicastTimeoutSeconds - the multicastTimeoutSeconds to set
See Also:
getMulticastTimeoutSeconds()

getTrustedInterfaces

public Set<String> getTrustedInterfaces()
Gets the trusted interfaces.

Returns:
the trusted interface.
See Also:
setTrustedInterfaces(java.util.Set)

setTrustedInterfaces

public MulticastConfig setTrustedInterfaces(Set<String> interfaces)
Sets the trusted interfaces.

By default, so 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 request from.

The interface is an ip address where the last octet can be a wildcard '*' or a range '10-20'.

Parameters:
interfaces - the new trusted interfaces.
Returns:
the updated MulticastConfig.
See Also:
if interfaces is null.

addTrustedInterface

public MulticastConfig addTrustedInterface(String ip)
Adds a trusted interface.

Parameters:
ip - the ip of the trusted interface.
Returns:
the updated MulticastConfig.
Throws:
IllegalArgumentException - if ip is null.
See Also:
setTrustedInterfaces(java.util.Set)

getMulticastTimeToLive

public int getMulticastTimeToLive()
Gets the time to live of the multicast package.

Returns:
the time to live
See Also:
MulticastSocket.setTimeToLive(int), setMulticastTimeToLive(int)

setMulticastTimeToLive

public MulticastConfig setMulticastTimeToLive(int multicastTimeToLive)
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.
Returns:
the updated MulticastConfig.
Throws:
IllegalArgumentException - if time to live is smaller than 0 or larger than 255.
See Also:
getMulticastTimeToLive(), MulticastSocket.setTimeToLive(int)

isLoopbackModeEnabled

public boolean isLoopbackModeEnabled()
Check if the loopback mode is enabled in the multicast discovery mechanism.

Returns:
the enabled

setLoopbackModeEnabled

public MulticastConfig setLoopbackModeEnabled(boolean enabled)
Enables or disables the loopback mode in the multicast discovery mechanism.

Parameters:
enabled - the enabled to set true when disabled, false when disabled.
Returns:
the updated MulticastConfig

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.