GridGain™ 2.0.3
Java API Specification

org.gridgain.grid.spi.communication.coherence
Class GridCoherenceCommunicationSpi

java.lang.Object
  extended by org.gridgain.grid.spi.GridSpiAdapter
      extended by org.gridgain.grid.spi.communication.coherence.GridCoherenceCommunicationSpi
All Implemented Interfaces:
GridCoherenceCommunicationSpiMBean, GridCommunicationSpi, GridSpi, GridSpiManagementMBean

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

Oracle Coherence implementation of GridCommunicationSpi SPI. It uses Coherence data grid framework to communicate with remote nodes.

SPI uses Coherence asynchronous call InvocationService.execute(Invocable, Set, InvocationObserver) to send a message to remote node. If parameter GridCoherenceCommunicationSpi.setAcknowledgment(boolean) is set to true, then this SPI will use Coherence InvocationObserver to wait for request completion acknowledgment.

This SPI has no mandatory parameters.

This SPI has the following optional parameters:

Java Example

GridCoherenceCommunicationSpi needs to be explicitely configured to override default TCP communication SPI.
 GridCoherenceCommunicationSpi commSpi = new GridCoherenceCommunicationSpi();

 // Override default false setting.
 commSpi.setAcknowledgement(true);

 GridConfigurationAdapter cfg = new GridConfigurationAdapter();

 // Override default communication SPI.
 cfg.setCommunicationSpi(commSpi);

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

Spring Example

GridCoherenceCommunicationSpi can be configured from Spring XML configuration file:
 <bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
       ...
       <property name="communicationSpi">
           <bean class="org.gridgain.grid.spi.communication.coherence.GridCoherenceCommunicationSpi">
               <property name="acknowledgment" value="true"/>
           </bean>
       </property>
       ...
 </bean>
 

Note: Coherence is not shipped with GridGain. If you don't have Coherence, you need to download it separately. See http://www.oracle.com/tangosol/index.html for more information. Once installed, Coherence should be available on the classpath for GridGain. If you use [GRIDGAIN_HOME]/bin/gridgain.{sh|bat} script to start a grid node you can simply add Coherence JARs to [GRIDGAIN_HOME]/bin/setenv.{sh|bat} scripts that's used to set up class path for the main scripts.

Note: When using Coherence SPIs (communication or discovery) you cannot start multiple GridGain instances in the same VM due to limitations of Coherence. GridGain runtime will detect this situation and prevent GridGain from starting in such case. See GridSpiMultipleInstancesSupport for details.


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:
GridCommunicationSpi
 

Field Summary
static String ATTR_NODE_UID
          Name of cluster member Id attribute added to local node attributes at startup (value is comm.coherence.member.uid).
static String DFLT_GRIDGAIN_SRVC
          Default Coherence invocation service name (value is gridgain.comm.srvc).
 
Constructor Summary
GridCoherenceCommunicationSpi()
           
 
Method Summary
protected  void checkConfigurationConsistency(GridNode node)
          Checks remote node SPI configuration and prints warnings if necessary.
 String getLocalUid()
          Gets Coherence member identifier string representation.
 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.
 String getServiceName()
          Gets Coherence service invocation name.
 boolean isAcknowledgment()
          Gets sending acknowledgment property.
 void onContextInitialized(GridSpiContext spiCtx)
          Callback invoked when SPI context is initialized. SPI implementation may store SPI context for future access.

This method is invoked after GridSpi.spiStart(String) method is completed, so SPI should be fully functional at this point. Use this method for post-start initialization, such as subscribing a discovery listener, sending a message to remote node, etc...

 void sendMessage(Collection<GridNode> destNodes, Serializable msg)
          Sends given message to destination nodes.
 void sendMessage(GridNode destNode, Serializable msg)
          Sends given message to destination node.
 void setAcknowledgment(boolean ack)
          Sets sending acknowledgment property.
 void setListener(GridMessageListener listener)
          Set communication listener.
 void setServiceName(String srvcName)
          Sets name for Coherence service invocation used in grid.
 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, getAuthor, getGridGainHome, getLocalNodeId, getSpiContext, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion, onContextDestroyed, 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
onContextDestroyed
 
Methods inherited from interface org.gridgain.grid.spi.GridSpiManagementMBean
getAuthor, getGridGainHome, getLocalNodeId, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion
 

Field Detail

ATTR_NODE_UID

public static final String ATTR_NODE_UID
Name of cluster member Id attribute added to local node attributes at startup (value is comm.coherence.member.uid).

See Also:
Constant Field Values

DFLT_GRIDGAIN_SRVC

public static final String DFLT_GRIDGAIN_SRVC
Default Coherence invocation service name (value is gridgain.comm.srvc).

See Also:
Constant Field Values
Constructor Detail

GridCoherenceCommunicationSpi

public GridCoherenceCommunicationSpi()
Method Detail

setAcknowledgment

@GridSpiConfiguration(optional=true)
public void setAcknowledgment(boolean ack)
Sets sending acknowledgment property. This configuration parameter is optional. Used in GridCoherenceCommunicationSpi.sendMessage(Collection, Serializable) to send message to remote nodes with or without waiting for completion.

If not provided, default value is false.

Parameters:
ack - Sending acknowledgment.

setServiceName

@GridSpiConfiguration(optional=true)
public void setServiceName(String srvcName)
Sets name for Coherence service invocation used in grid.

If not provided, default value is GridCoherenceCommunicationSpi.DFLT_GRIDGAIN_SRVC.

Parameters:
srvcName - Invocation service name.

getLocalUid

public String getLocalUid()
Gets Coherence member identifier string representation.

Specified by:
getLocalUid in interface GridCoherenceCommunicationSpiMBean
Returns:
Coherence member identifier string representation.

isAcknowledgment

public boolean isAcknowledgment()
Gets sending acknowledgment property.

Specified by:
isAcknowledgment in interface GridCoherenceCommunicationSpiMBean
Returns:
Sending acknowledgment property.

getServiceName

public String getServiceName()
Gets Coherence service invocation name.

Specified by:
getServiceName in interface GridCoherenceCommunicationSpiMBean
Returns:
Coherence service invocation name

getNodeAttributes

public Map<String,Serializable> getNodeAttributes()
                                           throws GridSpiException
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.

Specified by:
getNodeAttributes in interface GridSpi
Overrides:
getNodeAttributes in class GridSpiAdapter
Throws:
GridSpiException - Throws in case of any error.
Returns:
Map of local node attributes this SPI wants to add.

onContextInitialized

public void onContextInitialized(GridSpiContext spiCtx)
                          throws GridSpiException
Callback invoked when SPI context is initialized. SPI implementation may store SPI context for future access.

This method is invoked after GridSpi.spiStart(String) method is completed, so SPI should be fully functional at this point. Use this method for post-start initialization, such as subscribing a discovery listener, sending a message to remote node, etc...

Specified by:
onContextInitialized in interface GridSpi
Overrides:
onContextInitialized in class GridSpiAdapter
Throws:
GridSpiException - If context initialization failed (grid will be stopped).
Parameters:
spiCtx - Spi context.

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.

sendMessage

public void sendMessage(GridNode destNode,
                        Serializable msg)
                 throws GridSpiException
Sends given message to destination node. Note that characteristics of the exchange such as durability, guaranteed delivery or error notification is dependant on SPI implementation.

Specified by:
sendMessage in interface GridCommunicationSpi
Throws:
GridSpiException - Thrown in case of any error during sending the message. Note that this is not guaranteed that failed communication will result in thrown exception as this is dependant on SPI implementation.
Parameters:
destNode - Destination node.
msg - Message to send.

sendMessage

public void sendMessage(Collection<GridNode> destNodes,
                        Serializable msg)
                 throws GridSpiException
Sends given message to destination nodes. Note that characteristics of the exchange such as durability, guaranteed delivery or error notification is dependant on SPI implementation.

Specified by:
sendMessage in interface GridCommunicationSpi
Throws:
GridSpiException - Thrown in case of any error during sending the message. Note that this is not guaranteed that failed communication will result in thrown exception as this is dependant on SPI implementation.
Parameters:
destNodes - Destination nodes.
msg - Message to send.

setListener

public void setListener(GridMessageListener listener)
Set communication listener.

Specified by:
setListener in interface GridCommunicationSpi
Parameters:
listener - Listener to set or null to unset the listener.

checkConfigurationConsistency

protected void checkConfigurationConsistency(GridNode node)
Checks remote node SPI configuration and prints warnings if necessary.

Overrides:
checkConfigurationConsistency in class GridSpiAdapter
Parameters:
node - Remote node.

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.