|
GridGain 2.1.0
Java API Specification |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gridgain.grid.spi.GridSpiAdapter
org.gridgain.grid.spi.discovery.multicast.GridMulticastDiscoverySpi
@GridSpiInfo(author="GridGain Systems",
url="www.gridgain.org",
email="support@gridgain.com",
version="x.x")
@GridSpiMultipleInstancesSupport(value=true)
public class GridMulticastDiscoverySpiDiscovery SPI implementation that uses IP-multicast for node discovery. At startup SPI starts sending IP/Multicast heartbeat messages. Once other nodes receive these messages, they use TCP/IP to exchange node attributes and then add the new node to their topology. When a node shuts down, it sends LEAVE heartbeat to other nodes, so every node in the grid can gracefully remove this node from topology.
Note that since IP/Multicast is not a reliable protocol, there is no guarantee that a node will be discovered by other grid members. However, IP/Multicast works very reliably within LANs and in most cases this SPI provides a very light weight and easy to use grid node discovery.
GridMulticastDiscoverySpi.setHeartbeatFrequency(long))GridMulticastDiscoverySpi.setLeaveAttempts(int))GridMulticastDiscoverySpi.setLocalAddress(String))GridMulticastDiscoverySpi.setTcpPort(int))GridMulticastDiscoverySpi.setTimeToLive(int))GridMulticastDiscoverySpi.setMaxMissedHeartbeats(int))GridMulticastDiscoverySpi.setMulticastGroup(String))GridMulticastDiscoverySpi.setMulticastPort(int))GridMulticastDiscoverySpi.setLocalPortRange(int)GridMulticastDiscoverySpi.setCheckMulticastEnabled(boolean)
GridMulticastDiscoverySpi spi = new GridMulticastDiscoverySpi();
// Put another multicast group.
spi.setMulticastGroup("228.10.10.157");
GridConfigurationAdapter cfg = new GridConfigurationAdapter();
// Override default discovery SPI.
cfg.setDiscoverySpi(spi);
// Start grid.
GridFactory.start(cfg);
<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
...
<property name="discoverySpi">
<bean class="org.gridgain.grid.spi.discovery.multicast.GridMulticastDiscoverySpi">
<property name="multicastGroup" value="228.10.10.157"/>
</bean>
</property>
...
</bean>
For information about Spring framework visit www.springframework.org
See Also:
Documentation
Email Support
Online Forums
Issue Tracking
Author: 2005-2008 Copyright © GridGain Systems. All Rights Reserved. ver. 2.1.0
GridDiscoverySpi
![]() |
![]() |
![]() |
![]() |
| Field Summary | |
|---|---|
static long |
DFLT_HEARTBEAT_FREQ
Default heartbeat delay (value is 3000). |
static int |
DFLT_LEAVE_ATTEMPTS
Default number of attempts to send leaving notification (value is 3). |
static int |
DFLT_MAX_MISSED_HEARTBEATS
Default number of heartbeat messages that could be missed (value is 3). |
static String |
DFLT_MCAST_GROUP
Default multicast IP address (value is 228.1.2.4). |
static int |
DFLT_MCAST_PORT
Default multicast port number (value is 47200). |
static int |
DFLT_PORT_RANGE
Default local port range (value is 10). |
static int |
DFLT_TCP_PORT
Default local port number for SPI (value is 47300). |
static int |
DFLT_TTL
Default multicast messages time-to-live value (value is 8). |
| Constructor Summary | |
|---|---|
GridMulticastDiscoverySpi()
|
|
| Method Summary | |
|---|---|
protected List<String> |
getConsistentAttributeNames()
Returns back list of attributes that should be consistent for this SPI. |
long |
getHeartbeatFrequency()
Gets delay between heartbeat requests. |
int |
getLeaveAttempts()
Gets number of attempts to notify another nodes that this one is leaving grid. |
String |
getLocalHost()
Gets local host IP address that discovery SPI uses. |
GridNode |
getLocalNode()
Gets local node. |
int |
getLocalPortRange()
Gets local port range for either TCP or multicast ports. |
int |
getMaximumMissedHeartbeats()
Gets number of heartbeat requests that could be missed before remote node is considered to be failed. |
String |
getMulticastGroup()
Gets IP address of multicast group. |
int |
getMulticastPort()
Gets port number which multicast messages are sent to. |
GridNode |
getNode(UUID nodeId)
Gets node by ID. |
Map<String,Serializable> |
getNodeAttributes()
This method is called before SPI starts (before method GridSpi.spiStart(String)
is called). It allows SPI implementation to add attributes to a local
node. Kernel collects these attributes from all SPI implementations
loaded up and then passes it to discovery SPI so that they can be
exchanged with other nodes. |
int |
getRemoteNodeCount()
Gets the number of remote nodes. |
Collection<UUID> |
getRemoteNodeIds()
Gets set of remote nodes IDs that have READY state. |
List<GridNode> |
getRemoteNodes()
Gets collection of remote nodes in grid or empty collection if no remote nodes found. |
int |
getTcpPort()
Gets local port number that is used by discovery SPI. |
int |
getTimeToLive()
Gets TCP messages time-to-live. |
boolean |
isCheckMulticastEnabled()
By default this value is true. |
boolean |
pingNode(UUID nodeId)
Pings the remote node to see if it's alive. |
void |
setCheckMulticastEnabled(boolean isCheckMulticastEnabled)
Enables or disabled check whether multicast is enabled on local node. |
void |
setHeartbeatFrequency(long beatFreq)
Sets delay between heartbeat requests. |
void |
setLeaveAttempts(int leaveAttempts)
Sets number of attempts to notify another nodes that this one is leaving grid. |
void |
setListener(GridDiscoveryListener listener)
Sets a listener for discovery events. |
void |
setLocalAddress(String localAddr)
Sets local host IP address that discovery SPI uses. |
void |
setLocalPortRange(int localPortRange)
Sets local port range for TCP and Multicast ports (value must greater than or equal to 0). |
void |
setMaxMissedHeartbeats(int maxMissedBeats)
Sets number of heartbeat requests that could be missed before remote node is considered to be failed. |
void |
setMetricsProvider(GridDiscoveryMetricsProvider metricsProvider)
Sets discovery metrics provider. |
void |
setMulticastGroup(String mcastGroup)
Sets IP address of multicast group. |
void |
setMulticastPort(int mcastPort)
Sets port number which multicast messages are sent to. |
void |
setNodeAttributes(Map<String,Serializable> attrs)
Sets node attributes which will be distributed in grid during join process. |
void |
setTcpPort(int tcpPort)
Sets local TCP port number to be used for node attribute exchange upon discovery. |
void |
setTimeToLive(int ttl)
Sets Multicast messages time-to-live in router hops. |
void |
spiStart(String gridName)
This method is called to start SPI. |
void |
spiStop()
This method is called to stop SPI. |
String |
toString()
|
| Methods inherited from class org.gridgain.grid.spi.GridSpiAdapter |
|---|
assertParameter, configInfo, createSpiAttributeName, getAuthor, getGridGainHome, getLocalNodeId, getName, getSpiContext, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion, onContextDestroyed, onContextInitialized, registerMBean, setName, setSpiContext, startInfo, startStopwatch, stopInfo, unregisterMBean |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.gridgain.grid.spi.GridSpi |
|---|
getName, onContextDestroyed, onContextInitialized |
| Methods inherited from interface org.gridgain.grid.spi.GridSpiManagementMBean |
|---|
getAuthor, getGridGainHome, getLocalNodeId, getName, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion |
| Field Detail |
|---|
public static final long DFLT_HEARTBEAT_FREQ
public static final int DFLT_MAX_MISSED_HEARTBEATS
public static final String DFLT_MCAST_GROUP
public static final int DFLT_MCAST_PORT
public static final int DFLT_TCP_PORT
public static final int DFLT_PORT_RANGE
GridMulticastDiscoverySpi.setLocalPortRange(int) for details.
public static final int DFLT_LEAVE_ATTEMPTS
public static final int DFLT_TTL
| Constructor Detail |
|---|
public GridMulticastDiscoverySpi()
| Method Detail |
|---|
@GridSpiConfiguration(optional=true) public void setMulticastGroup(String mcastGroup)
If not provided, default value is GridMulticastDiscoverySpi.DFLT_MCAST_GROUP.
mcastGroup - Multicast IP address.public String getMulticastGroup()
getMulticastGroup in interface GridMulticastDiscoverySpiMBean@GridSpiConfiguration(optional=true) public void setMulticastPort(int mcastPort)
If not provided, default value is GridMulticastDiscoverySpi.DFLT_MCAST_PORT.
mcastPort - Multicast port number.public int getMulticastPort()
getMulticastPort in interface GridMulticastDiscoverySpiMBean@GridSpiConfiguration(optional=true) public void setTcpPort(int tcpPort)
If not provided, default value is GridMulticastDiscoverySpi.DFLT_TCP_PORT.
tcpPort - Port number.public int getTcpPort()
getTcpPort in interface GridMulticastDiscoverySpiMBean@GridSpiConfiguration(optional=true) public void setHeartbeatFrequency(long beatFreq)
If not provided, default value is GridMulticastDiscoverySpi.DFLT_HEARTBEAT_FREQ.
beatFreq - Time in milliseconds.public long getHeartbeatFrequency()
getHeartbeatFrequency in interface GridMulticastDiscoverySpiMBean@GridSpiConfiguration(optional=true) public void setMaxMissedHeartbeats(int maxMissedBeats)
If not provided, default value is GridMulticastDiscoverySpi.DFLT_MAX_MISSED_HEARTBEATS.
maxMissedBeats - Number of missed requests.public int getMaximumMissedHeartbeats()
getMaximumMissedHeartbeats in interface GridMulticastDiscoverySpiMBean@GridSpiConfiguration(optional=true) public void setLeaveAttempts(int leaveAttempts)
If not provided, default value is GridMulticastDiscoverySpi.DFLT_LEAVE_ATTEMPTS.
leaveAttempts - Number of attempts.public int getLeaveAttempts()
getLeaveAttempts in interface GridMulticastDiscoverySpiMBean@GridSpiConfiguration(optional=true) public void setLocalAddress(String localAddr)
If not provided, by default a first found non-loopback address
will be used. If there is no non-loopback address available,
then InetAddress.getLocalHost() will be used.
localAddr - IP address.public String getLocalHost()
getLocalHost in interface GridMulticastDiscoverySpiMBeanpublic int getTimeToLive()
getTimeToLive in interface GridMulticastDiscoverySpiMBean@GridSpiConfiguration(optional=true) public void setTimeToLive(int ttl)
If not provided, default value is GridMulticastDiscoverySpi.DFLT_TTL.
ttl - Messages TTL.@GridSpiConfiguration(optional=true) public void setLocalPortRange(int localPortRange)
GridMulticastDiscoverySpi.setMulticastPort(int) or GridMulticastDiscoverySpi.setTcpPort(int) is occupied,
implementation will try to increment the port number for as long as it is less than
initial value plus this range.
If port range value is 0, then implementation will try bind only to the port provided by
GridMulticastDiscoverySpi.setMulticastPort(int) or GridMulticastDiscoverySpi.setTcpPort(int) methods and fail if binding to these
ports did not succeed.
Local port range is very useful during development when more than one grid nodes need to run on the same physical machine.
localPortRange - New local port range.GridMulticastDiscoverySpi.DFLT_PORT_RANGEpublic int getLocalPortRange()
GridMulticastDiscoverySpi.setLocalPortRange(int) for details.
getLocalPortRange in interface GridMulticastDiscoverySpiMBeanpublic boolean isCheckMulticastEnabled()
isCheckMulticastEnabled in interface GridMulticastDiscoverySpiMBeanpublic void setCheckMulticastEnabled(boolean isCheckMulticastEnabled)
This property should be disabled in rare cases when loopback multicast is disabled, but multicast to other remote boxes is enabled.
isCheckMulticastEnabled - True for enabling multicast check,
false for disabling it.public void setNodeAttributes(Map<String,Serializable> attrs)
setNodeAttributes in interface GridDiscoverySpiattrs - Map of node attributes.public List<GridNode> getRemoteNodes()
getRemoteNodes in interface GridDiscoverySpipublic GridNode getNode(UUID nodeId)
getNode in interface GridDiscoverySpinodeId - Node ID.
public Collection<UUID> getRemoteNodeIds()
getRemoteNodeIds in interface GridMulticastDiscoverySpiMBeanpublic int getRemoteNodeCount()
getRemoteNodeCount in interface GridMulticastDiscoverySpiMBeanpublic GridNode getLocalNode()
getLocalNode in interface GridDiscoverySpipublic void setListener(GridDiscoveryListener listener)
GridDiscoveryEventType for a set of all possible
discovery events.
setListener in interface GridDiscoverySpilistener - Listener to discovery events.public void setMetricsProvider(GridDiscoveryMetricsProvider metricsProvider)
GridDiscoveryMetricsProvider.getMetrics() method to exchange
dynamic metrics between nodes.
setMetricsProvider in interface GridDiscoverySpimetricsProvider - Provider of metrics data.
public Map<String,Serializable> getNodeAttributes()
throws GridSpiException
GridSpi.spiStart(String)
is called). It allows SPI implementation to add attributes to a local
node. Kernel collects these attributes from all SPI implementations
loaded up and then passes it to discovery SPI so that they can be
exchanged with other nodes.
getNodeAttributes in interface GridSpigetNodeAttributes in class GridSpiAdapterGridSpiException - Throws in case of any error.
public void spiStart(String gridName)
throws GridSpiException
spiStart in interface GridSpiGridSpiException - Throws in case of any error during SPI start.gridName - Name of grid instance this SPI is being started for
(null for default grid).
public void spiStop()
throws GridSpiException
spiStop in interface GridSpiGridSpiException - Thrown in case of any error during SPI stop.public boolean pingNode(UUID nodeId)
pingNode in interface GridDiscoverySpinodeId - Node Id.
protected List<String> getConsistentAttributeNames()
getConsistentAttributeNames in class GridSpiAdapterpublic String toString()
toString in class Object
|
GridGain 2.1.0
Java API Specification |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
|
GridGain - Grid Computing Made Simple, ver. 2.1.0.19122008
2005-2008 Copyright © GridGain Systems. All Rights Reserved. |
|
|