GridGain™ 2.0.3
Java API Specification

org.gridgain.grid.spi.discovery.jboss
Class GridJbossDiscoverySpi

java.lang.Object
  extended by org.gridgain.grid.spi.GridSpiAdapter
      extended by org.gridgain.grid.spi.discovery.jboss.GridJbossDiscoverySpi
All Implemented Interfaces:
GridDiscoverySpi, GridJbossDiscoverySpiMBean, GridSpi, GridSpiManagementMBean

@GridSpiInfo(author="GridGain Systems",
             url="www.gridgain.org",
             email="support@gridgain.com",
             version="x.x")
@GridSpiMultipleInstancesSupport(value=false)
public class GridJbossDiscoverySpi
extends GridSpiAdapter
implements GridDiscoverySpi, GridJbossDiscoverySpiMBean

JBoss implementation of GridDiscoverySpi SPI. It uses JBoss cluster capabilities to discover remote nodes in grid. SPI registers in cluster service with name GridJbossDiscoverySpi.DISCO_SERVICE_NAME and every node in the cluster makes cluster method call with name GridJbossDiscoverySpi.DISCO_METHOD_NAME to receive the remote node data.

Configuration

Mandatory

This SPI has no mandatory configuration parameters.

Optional

This SPI has the following optional parameters:

Java Example

GridJbossDiscoverySpi needs to be explicitly configured to override default Multicast discovery SPI.
 GridJbossDiscoverySpi spi = new GridJbossDiscoverySpi();

 GridConfigurationAdapter cfg = new GridConfigurationAdapter();

 // Override default discovery SPI.
 cfg.setDiscoverySpi(spi);

 // Start grid.
 GridFactory.start(cfg);
 

Spring Example

GridJbossDiscoverySpi can be configured from Spring XML configuration file:
 <bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
         ...
         <property name="discoverySpi">
             <bean class="org.gridgain.grid.spi.discovery.jboss.GridJbossDiscoverySpi"/>
         </property>
         ...
 </bean>
 

Note: JBoss is not shipped with GridGain. If you don't have JBoss, you need to download it separately. See http://www.jboss.com for more information. Once installed, JBoss should be available on the classpath for GridGain. Most likely you will be starting GridGain from JBoss (you can use supplied loader for JBoss). Alternatively, if you use [GRIDGAIN_HOME]/bin/gridgain.{sh|bat} script to start a grid node you can simply add JBoss JARs to [GRIDGAIN_HOME]/bin/setenv.{sh|bat} scripts that's used to set up class path for the main scripts.

Note: When using JBoss discovery SPI you cannot start multiple GridGain instances in the same VM due to limitations of JBoss. GridGain runtime will detect this situation and prevent GridGain from starting in such case. See GridSpiMultipleInstancesSupport for detail.

Note: This SPI use HAPartition.HAMembershipExtendedListener from JBoss Cluster API. See bug http://jira.jboss.com/jira/browse/JBAS-3833 and fixed JBoss AS versions: JBossAS-5.0.0.Beta1, JBossAS-4.2.0.CR1, JBossAS-4.0.5.SP1 and higher.


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.0.3

See Also:
GridDiscoverySpi
 

Field Summary
static long DFLT_METRICS_FREQ
          Default metrics heartbeat delay (value is 3000).
static String DFLT_PARTITION_JNDI_NAME
          Default JBoss cluster partition JNDI name (value is /HAPartition/DefaultPartition).
static String DISCO_METHOD_NAME
          Method name of service registered in cluster (value is remoteExec).
static String DISCO_SERVICE_NAME
          Name of service registered in cluster (value is attrInfoService).
 
Constructor Summary
GridJbossDiscoverySpi()
           
 
Method Summary
 GridNode getLocalNode()
          Gets local node.
 long getMetricsFrequency()
          Gets delay between metrics requests.
 GridNode getNode(UUID nodeId)
          Gets node by ID.
 int getRemoteNodeCount()
          Gets the number of remote nodes.
 Collection<UUID> getRemoteNodeIds()
          Gets a collection of remote nodes' IDs.
 List<GridNode> getRemoteNodes()
          Gets collection of remote nodes in grid or empty collection if no remote nodes found.
 boolean pingNode(UUID nodeId)
          Pings the remote node to see if it's alive.
 byte[] remoteExec(org.gridgain.grid.spi.discovery.jboss.GridJbossDiscoveryNodeData data)
          Method called by Spi in cluster.
 void setListener(GridDiscoveryListener listener)
          Sets a listener for discovery events.
 void setMetricsFrequency(long metricsFreq)
          Sets delay between metrics requests.
 void setMetricsProvider(GridDiscoveryMetricsProvider metricsProvider)
          Sets discovery metrics provider.
 void setNodeAttributes(Map<String,Serializable> attrs)
          Sets node attributes which will be distributed in grid during join process.
 void setPartitionJndiName(String partJndiName)
          IoC configuration parameter to specify JNDI name for partition.
 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, checkConfigurationConsistency, configInfo, getAuthor, getGridGainHome, getLocalNodeId, getNodeAttributes, getSpiContext, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion, onContextDestroyed, onContextInitialized, registerMBean, setSpiContext, startInfo, startStopwatch, stopInfo, unregisterMBean, warnSpi, warnSpiParameter
 
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
getNodeAttributes, onContextDestroyed, onContextInitialized
 
Methods inherited from interface org.gridgain.grid.spi.GridSpiManagementMBean
getAuthor, getGridGainHome, getLocalNodeId, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion
 

Field Detail

DFLT_PARTITION_JNDI_NAME

public static final String DFLT_PARTITION_JNDI_NAME
Default JBoss cluster partition JNDI name (value is /HAPartition/DefaultPartition).

See Also:
Constant Field Values

DISCO_SERVICE_NAME

public static final String DISCO_SERVICE_NAME
Name of service registered in cluster (value is attrInfoService).

See Also:
Constant Field Values

DISCO_METHOD_NAME

public static final String DISCO_METHOD_NAME
Method name of service registered in cluster (value is remoteExec).

See Also:
Constant Field Values

DFLT_METRICS_FREQ

public static final long DFLT_METRICS_FREQ
Default metrics heartbeat delay (value is 3000).

See Also:
Constant Field Values
Constructor Detail

GridJbossDiscoverySpi

public GridJbossDiscoverySpi()
Method Detail

setPartitionJndiName

@GridSpiConfiguration(optional=true)
public void setPartitionJndiName(String partJndiName)
IoC configuration parameter to specify JNDI name for partition.

Parameters:
partJndiName - Sets JNDI partition name.

remoteExec

public byte[] remoteExec(org.gridgain.grid.spi.discovery.jboss.GridJbossDiscoveryNodeData data)
Method called by Spi in cluster. NOTE: Method should be public. It is used in cluster by Java reflection.

Parameters:
data - Called node data.
Returns:
Local node data.

getRemoteNodes

public List<GridNode> getRemoteNodes()
Gets collection of remote nodes in grid or empty collection if no remote nodes found.

Specified by:
getRemoteNodes in interface GridDiscoverySpi
Returns:
Collection of remote nodes.

getNode

public GridNode getNode(UUID nodeId)
Gets node by ID.

Specified by:
getNode in interface GridDiscoverySpi
Parameters:
nodeId - Node ID.
Returns:
Node with given ID or null if node is not found.

getRemoteNodeIds

public Collection<UUID> getRemoteNodeIds()
Gets a collection of remote nodes' IDs.

Specified by:
getRemoteNodeIds in interface GridJbossDiscoverySpiMBean
Returns:
Collection of remote nodes IDs.

getRemoteNodeCount

public int getRemoteNodeCount()
Gets the number of remote nodes.

Specified by:
getRemoteNodeCount in interface GridJbossDiscoverySpiMBean
Returns:
Number of remote nodes.

pingNode

public boolean pingNode(UUID nodeId)
Pings the remote node to see if it's alive.

Specified by:
pingNode in interface GridDiscoverySpi
Parameters:
nodeId - Node Id.
Returns:
true if node alive, false otherwise.

setMetricsFrequency

@GridSpiConfiguration(optional=true)
public void setMetricsFrequency(long metricsFreq)
Sets delay between metrics requests. SPI sends broadcast messages in configurable time interval to other nodes to notify them about its metrics.

If not provided the default value is GridJbossDiscoverySpi.DFLT_METRICS_FREQ.

Parameters:
metricsFreq - Time in milliseconds.

getMetricsFrequency

public long getMetricsFrequency()
Gets delay between metrics requests. SPI sends broadcast messages in configurable time interval to another nodes to notify them about node metrics.

Specified by:
getMetricsFrequency in interface GridJbossDiscoverySpiMBean
Returns:
Time period in milliseconds.

getLocalNode

public GridNode getLocalNode()
Gets local node.

Specified by:
getLocalNode in interface GridDiscoverySpi
Returns:
Local node.

setListener

public void setListener(GridDiscoveryListener listener)
Sets a listener for discovery events. Refer to GridDiscoveryEventType for a set of all possible discovery events.

Specified by:
setListener in interface GridDiscoverySpi
Parameters:
listener - Listener to discovery events.

setMetricsProvider

public void setMetricsProvider(GridDiscoveryMetricsProvider metricsProvider)
Sets discovery metrics provider. Use metrics provided by GridDiscoveryMetricsProvider.getMetrics() method to exchange dynamic metrics between nodes.

Specified by:
setMetricsProvider in interface GridDiscoverySpi
Parameters:
metricsProvider - Provider of metrics data.

setNodeAttributes

public void setNodeAttributes(Map<String,Serializable> attrs)
Sets node attributes which will be distributed in grid during join process. Note that these attributes cannot be changed and set only once.

Specified by:
setNodeAttributes in interface GridDiscoverySpi
Parameters:
attrs - Map of node attributes.

spiStart

public void spiStart(String gridName)
              throws GridSpiException
This method is called to start SPI. After this method returns successfully kernel assumes that SPI is fully operational.

Specified by:
spiStart in interface GridSpi
Throws:
GridSpiException - Throws in case of any error during SPI start.
Parameters:
gridName - Name of grid instance this SPI is being started for (null for default grid).

spiStop

public void spiStop()
             throws GridSpiException
This method is called to stop SPI. After this method returns kernel assumes that this SPI is finished and all resources acquired by it are released. Note that this method can be called at any point including during recovery of failed start. It should make no assumptions on what state SPI will be in when this method is called.

Specified by:
spiStop in interface GridSpi
Throws:
GridSpiException - Thrown in case of any error during SPI stop.

toString

public String toString()

Overrides:
toString in class Object

GridGain™ 2.0.3
Java API Specification

GridGain™ - Grid Computing Made Simple, ver. 2.0.3.20052008
2005-2008 Copyright © GridGain Systems. All Rights Reserved.