Click on Javadoc link to open Javadoc documentation.
Package
org.gridgain.grid ![]()
Description
GridConfiguration ![]()
![]()
![]()
Note, that absolutely every configuration property in GridConfiguration ![]()
![]()
![]()
![]()
| Configuring Cache Caches are configured via setCacheConfiguration(org.gridgain.grid.cache.GridCacheConfiguration...) |
The following configuration parameters can be used to configure grid node with GridConfigurationAdapter ![]()
| Setter Method | Description | Optional | Default |
|---|---|---|---|
| setGridName(String)
|
Grid name. | Yes | null |
| setGridGainHome(String) |
GridGain installation folder. | Yes | GRIDGAIN_HOME system property or environment variable |
| setNodeId(UUID) |
Unique identifier for local node. | Yes | Random UUID |
| setLocalhost(String) | Local IP address or host to bind to. | Yes | GG_LOCAL_HOST system property or environment variable |
| setDaemon(boolean) |
Daemon flag. | Yes | false |
| setNetworkTimeout(long) |
Maximum timeout in milliseconds for network requests. | Yes | 5000 |
| setLicenseUrl(String) | Location of the license file. | Yes | GRIDGAIN_HOME/gridgain-license.xml |
| setUserAttributes(Map<String,? extends Serializable>)
|
User specific attributes to attach to this node. Available via GridNode.getAttribute(String) |
Yes | All System Properties and Environment Variables are set as node attributes automatically by GridGain. |
| setGridLogger(GridLogger)
|
Logger to use within grid. | Yes | GridLog4jLogger
|
| setMarshaller(GridMarshaller)
|
Marshaller to use for serialization/deserialization of objects. (available from ver. 2.1) |
Yes | GridJbossMarshaller
|
| setDeploymentMode(GridDeploymentMode)
|
Deployment mode for task/query requests initiated from this node. (available from ver. 2.1) |
Yes | ISOLATED
|
| setPeerClassLoadingEnabled(boolean)
|
Enables/disables peer class loading. | Yes | true |
| setPeerClassLoadingTimeout(long)
|
Specifies timeout for peer-class-loading requests in milliseconds. (available from ver. 2.1) |
Yes | 2000ms |
| setPeerClassLoadingMissedResourcesCacheSize(int)
|
Specifies internal cache size for missed resources. If attempt to load a resource failed, then it will be cached, and following attempts will not make remote calls. (available from ver. 2.1) |
Yes | 200 |
| setP2PLocalClassPathExclude(List<String>)
|
List of packages in a system class path that should be to P2P loaded even if they exist locally. | Yes | null |
| setMetricsExpireTime(long)
|
Time in milliseconds after which a certain metric value is considered expired. | Yes | 0, which means that metrics don't expire. |
| setMetricsHistorySize(int)
|
Number of metrics kept in history to compute totals and averages. | Yes | 0, which means to use system default of 10,000 |
| setExecutorService(ExecutorService)
|
Thread pool to use mainly for task and job execution. | Yes | GridThreadPoolExecutorService |
| setExecutorServiceShutdown(boolean) |
Executor service shutdown flag. | Yes | true |
| setSystemExecutorService(ExecutorService)
|
Thread pool to use for processing job and task session asynchronous responses. (available from ver. 2.1) |
Yes | GridThreadPoolExecutorService |
| setSystemExecutorServiceShutdown(boolean) |
System executor service shutdown flag. | Yes | true |
| setPeerClassLoadingExecutorService(ExecutorService)
|
Thread pool to use for processing peer class loading requests and responses. (available from ver. 2.1) |
Yes | GridThreadPoolExecutorService |
| setPeerClassLoadingExecutorServiceShutdown(boolean) |
Peer class loading executor service shutdown flag. | Yes | true |
| setMBeanServer(MBeanServer)
|
MBean server for exposing GridGain MBeans. | Yes | The default MBean Server provided by JDK. |
| setCloudPolicies(GridCloudPolicy[]) |
Cloud policies. | Yes | null |
| setCloudStrategies(GridCloudStrategy[]) |
Cloud strategies. | Yes | null |
| setDisableCloudCoordinator(boolean) |
Exclude this node from consideration for being cloud coordinator. | Yes | true |
| setExcludeEventTypes(int...) |
Events which will not be recorded. | Yes | null |
| setIncludeEventTypes(int...) |
Events which will be recorded. | Yes | null |
| setIncludeProperties(String...) | System or environment properties to include into node attributes. | Yes | null |
| setDiscoveryStartupDelay(long) |
Time in milliseconds after which a certain metric value is considered expired. | Yes | 600,000 |
| setLifecycleBeans(GridLifecycleBean...) |
Lifecycle beans. | Yes | null |
| setLifecycleEmailNotification(boolean) | Enable lifecycle email notifications. | Yes | true |
| setRestEnabled(boolean) | Enable external REST access. | Yes | true |
| setRestJettyPath(String) | Path to JETTY XML configuration file (either absolute or relative to GRIDGAIN_HOME). | Yes | null |
| setRestSecretKey(String) | Secret key to authenticate REST requests. | Yes | null (authentication is disabled) |
| setSmtpHost(String) | SMTP host. | Yes | null |
| setSmtpPort(int) | SMTP port. | Yes | 25 |
| setSmtpUsername(String) | SMTP username. | Yes | null |
| setSmtpPassword(String) | SMTP password. | Yes | null |
| setSmtpSsl(boolean) | Enable SSL for SMTP. | Yes | false |
| setSmtpStartTls(boolean) | Enable STARTTLS for SMTP. | Yes | false |
| setAdminEmails(String[]) | Admin emails where notifications will be sent. | Yes | null |
| setLoadBalancingSpi(GridLoadBalancingSpi...)
|
Fully configured instances of GridLoadBalancingSpi. Starting with GridGain 2.1 you can provide multiple instances of Load Balancing SPIs and then specify which one to use on per-task level via @GridTaskSpis |
Yes | GridRoundRobinLoadBalancingSpi |
| setCheckpointSpi(GridCheckpointSpi...)
|
Fully configured instances of GridCheckpointSpi. Starting with GridGain 2.1 you can provide multiple instances of Checkpoint SPIs and then specify which one to use on per-task level via @GridTaskSpis |
Yes | GridSharedFsCheckpointSpi |
| setCollisionSpi(GridCollisionSpi)
|
Fully configured instance of GridCollisionSpi. | Yes | GridFifoQueueCollisionSpi |
| setCommunicationSpi(GridCommunicationSpi)
|
Fully configured instance of GridCommunicationSpi. | Yes | GridTcpCommunicationSpi |
| setDeploymentSpi(GridDeploymentSpi)
|
Fully configured instance of GridDeploymentSpi. | Yes | GridLocalDeploymentSpi |
| setDiscoverySpi(GridDiscoverySpi)
|
Fully configured instance of GridDiscoverySpi. | Yes | GridMulticastDiscoverySpi |
| setEventStorageSpi(GridEventStorageSpi)
|
Fully configured instance of GridEventStorageSpi. | Yes | GridMemoryEventStorageSpi |
| setFailoverSpi(GridFailoverSpi...)
|
Fully configured instances of GridFailoverSpi. Starting with GridGain 2.1 you can provide multiple instances of Failover SPIs and then specify which one to use on per-task level via @GridTaskSpis |
Yes | GridAlwaysFailoverSpi |
| setTopologySpi(GridTopologySpi...)
|
Fully configured instances of GridTopologySpi. Starting with GridGain 2.1 you can provide multiple instances of Topology SPIs and then specify which one to use on per-task level via @GridTaskSpis |
Yes | GridBasicTopologySpi |
| setMetricsSpi(GridLocalMetricsSpi)
|
Fully configured instance of GridLocalMetricsSpi. | Yes | GridJdkLocalMetricsSpi |
| setTracingSpi(GridTracingSpi...)
|
Fully configured instances of GridTracingSpi. | Yes | null |
| setCloudSpi(GridCloudSpi...) |
Fully configured instances of GridCloudSpi. | Yes | [GridJvmCloudSpi] |
| setSwapSpaceSpi(GridSwapSpaceSpi...) |
Fully configured instances of GridSwapSpaceSpi. | Yes | [GridFileSwapSpaceSpi] |
Some of the most commonly used configuration properties are explained in more detail below.
Grid Name
Use grid name configuration property whenever you would like to identify your grid by name. Usually, if you have only one grid node within your VM, you don't have to configure grid name explicitly and use the default no-name grid node. However, if you start multiple grid node instances in the same VM, say for unit testing or debugging, then properly configuring grid name for every grid node instance will allow you to access multiple grid nodes by name via GridFactory.getGrid(String gridName) ![]()
method.
User Attributes
User attributes allow you to attach various custom attributes to your nodes. This attributes can then be used to identify node topology for your task execution or load balancing, segmenting your grid into multiple sub-grids, etc... By default, GridGain will automatically attach or System and Environment properties to your node.
You can query node attributes practically from anywhere in your code, be that your task or job logic, or implementation of topology or load-balacing SPI's. Simply get a handle on GridNode and check its attributes via GridNode.getAttribute(String) ![]()
See GridNode Interface for examples on how to configure user node attributes.
See Segmenting Grid Nodes documentation for more information on how grid can be segmented.
See GridAttributesTopologySpi and GridNodeFilterTopologySpi documentation for information on how node attributes can be used for picking custom grid node topology for task execution.
Grid Logger
Configuring proper grid logger will allow you to integrate your logging with any environment. By default, GridLog4jLogger ![]()
For information on how to inject loggers into your code refer to Logger Injection documentation.
Below is the list of supported loggers:
- GridLog4jLogger
Javadoc - Log4j-based implementation for logging. This logger should be used by loaders that have prefer log4j-based logging. By default, GridGain will use this logger with configuration from GRIDGAIN_HOME/config/default-log4j.xml.
- GridJavaLogger
Javadoc - Logger to use with Java logging. Implementation simply delegates to Java Logging.
- GridJbossLogger
Javadoc - Logger to use in JBoss loaders. Implementation simply delegates to JBoss logging.
- GridJclLogger
Javadoc - This logger wraps any JCL (Jakarta Commons Logging) loggers. Implementation simply delegates to underlying JCL logger. This logger should be used by loaders that have JCL-based internal logging (e.g., Websphere).
Grid Mashaller
Starting with GridGain 2.1 release you are able to configure different marshallers, and if needed provide your own. GridMarshaller ![]()
allows to marshal or unmarshal objects. It provides serialization/deserialization mechanism for all instances that are sent across network or are otherwise serialized.
For information on how to inject marshallers into your code refer to Marshaller Injection documentation.
Gridgain provides the following GridMarshaller implementations:
- GridJBossMarshaller
Javadoc 
- this is the default marshaller used by GridGain. It used JBoss implementation of java.io.ObjectOutputStream for object serialization. All marshalled instances must implement java.io.Serializable.
- GridJdkMarshaller
Javadoc 
- this marshaller uses standard JDK java.io.ObjectOutputStream for object serialization.. All marshalled instances must implement java.io.Serializable.
- GridXstreamMarshaller
Javadoc 
- this marshaller uses Codehaus XStream
for serialization of objects into XML. It does not require that marshalled instances implement java.io.Serializable, however, it performs slower than other marshaller implementations as XML is a verbose protocol.
Deployment Mode
See Deployment Modes documentation for information about different deployment modes and how user-version is used.
Executor Services
Starting with version 2.1, GridGain exposes configuration for 3 threads pools:
- ExecutorService
Javadoc 
- Implementation of java.util.concurrent.ExecutorService to be used for task and job executions. By default, standard ThreadPoolExecutor thread pool is provided configured to use 100 threads. Change this configuration parameter whenever you need to change the number of threads participating in GridTask/GridJob execution. - SystemExecutorService
Javadoc 
- Implementation of java.util.concurrent.ExecutorService to be used for processing of asynchronous job and task session responses. By default, standard ThreadPoolExecutor thread pool is provided configured to use 5 threads. Change this configuration parameter whenever you set task session attributes frequently or feel that responses are not processed fast enough. - PeerClassLoadingExecutorService
Javadoc 
- Implementation of java.util.concurrent.ExecutorService to be used for processing of all Peer Class Loading requests. By default, standard ThreadPoolExecutor thread pool is provided configured to use 20 threads. Change this configuration parameter whenever you feel that class-loading requests don't get processed fast enough.
Do not confuse executor services provided in configuration for thread pooling with grid-enabled executor service provided by GridGain.
| Typos in default-spring.xml Note that default-spring.xml configuration file has commented-out examples for executor service configuration which are slightly wrong. Whenever explicitly configuring any of the executor services, make sure to specify org.gridgain.grid.thread.GridThreadPoolExecutorService class instead of org.util.concurrent.ThreadPoolExecutor specified in the examples. |
Grid Lifecycle Beans
See Grid Lifecycle Beans documentation for information on how to specify lifecycle beans and examples.
SPIs - Server Provided Interfaces
Sever Provider Interfaces allow you to configure virtually every aspect of GridGain, such as communication, discovery, topology and failover, load-balancing, etc... in LEGO-like fashion. For information on available SPI's and their configuration refer to SPI - Service Provider Interfaces documentation.
Specifying Different SPIs Per GridTask
Starting with GridGain 2.1 you can start multiple instances of GridTopologySpi, GridLoadBalancingSpi, GridFailoverSpi, and GridCheckpointSpi. If you do that, you need to tell a task which SPI to use (by default it will use the fist SPI in the list).
Add @GridTaskSpis ![]()
This example shows how to configure different SPI's for different tasks. Let's assume that you have two worker nodes, Node1 and Node2. Let's also assume that you configure Node1 to belong to SegmentA and Node2 to belong to SegmentB. Here is a sample configuration for Node1
<bean id="grid.cfg" class="org.gridgain.grid.GridConfigurationAdapter" scope="singleton"> <property name="userAttributes"> <map> <entry key="segment" value="A"/> </map> </property> </bean>
Node2 configuration looks similar to Node1 with 'segment' attribute set to 'B'.
<bean id="grid.cfg" class="org.gridgain.grid.GridConfigurationAdapter" scope="singleton"> <property name="userAttributes"> <map> <entry key="segment" value="B"/> </map> </property> </bean>
Now, if you have Task1 and Task2 starting from some master node NodeM, you can easily configure Task1 to only run on SegmentA and Task2 to only run on SegmentB. Here is how configuration on master node NodeM would look like:
<bean id="grid.cfg" class="org.gridgain.grid.GridConfigurationAdapter" scope="singleton"> <!-- Topology SPIs. We have two named SPIs: One picks up nodes that have attribute "segment" set to "A" and another one sees nodes that have attribute "segment" set to "B". --> <property name="topologySpi"> <list> <bean class="org.gridgain.grid.spi.topology.nodefilter.GridNodeFilterTopologySpi"> <property name="name" value="topologyA"/> <property name="filter"> <bean class="org.gridgain.grid.GridJexlNodeFilter"> <property name="expression" value="node.attributes['segment'] == 'A'"/> </bean> </property> </bean> <bean class="org.gridgain.grid.spi.topology.nodefilter.GridNodeFilterTopologySpi"> <property name="name" value="topologyB"/> <property name="filter"> <bean class="org.gridgain.grid.GridJexlNodeFilter"> <property name="expression" value="node.attributes['segment'] == 'B'"/> </bean> </property> </bean> </list> </property> </bean>
Then your Task1 and Task2 would look as follows (note the @GridTaskSpis annotation).
@GridTaskSpis(topologySpi="topologyA") public class GridSegmentATask extends GridTaskSplitAdapter<String, Integer> { ... }
and
@GridTaskSpis(topologySpi="topologyB") public class GridSegmentBTask extends GridTaskSplitAdapter<String, Integer> { ... }
GridSpringBean
Grid Spring bean allows to bypass GridFactory ![]()
methods. In other words, this bean class allows to inject new grid instance from Spring configuration file directly without invoking static GridFactory ![]()
methods. This class can be wired directly from Spring and can be referenced from within other Spring beans. By virtue of implementing org.springframework.beans.factory.DisposableBean and org.springframework.beans.factory.InitializingBean interfaces, GridSpringBean automatically starts and stops underlying grid instance.
The following configuration parameters are optional:
- Grid configuration (see setConfiguration(GridConfiguration)
Javadoc 
Spring Configuration Example
<bean id="mySpringBean" class="org.gridgain.grid.GridSpringBean" scope="singleton"> <property name="configuration"> <bean id="grid.cfg" class="org.gridgain.grid.GridConfigurationAdapter" scope="singleton"> <property name="gridName" value="mySpringGrid"/> </bean> </property> </bean>
Or use default configuration:
<bean id="mySpringBean" class="org.gridgain.grid.GridSpringBean" scope="singleton"/>
Java Example
Here is how you may access this bean from code:
AbstractApplicationContext ctx = new FileSystemXmlApplicationContext("/path/to/spring/file"); // Register Spring hook to destroy bean automatically. ctx.registerShutdownHook(); Grid grid = (Grid)ctx.getBean("mySpringBean");
Examples
GridConfiguration may be defined in code
GridConfigurationAdapter cfg = new GridConfigurationAdapter(); // Override default values for grid node. cfg.setGridName("mygrid"); ... // Start grid. GridFactory.start(cfg);
or from Spring configuration file (default Spring configuration file can be found in GRIDGAIN_HOME/config/default-spring.xml file).
<bean id="grid.cfg" class="org.gridgain.grid.GridConfigurationAdapter" scope="singleton"> ... <property name="gridName" value="mygrid"/> ... </bean>

For more information about using Spring framework for configuration click here.
