This class defines a factory for the main GridGain API. It controls Grid life cycle
and allows listening for grid events.
Grid Loaders
Although user can apply grid factory directly to start and stop grid, grid is
often started and stopped by grid loaders. Grid loaders can be found in
org.gridgain.grid.startup package, for example:
-
GridCommandLineStartup
-
org.gridgain.grid.startup.servlet.GridServletStartup
Examples
Use
#start() method to start grid with default configuration. You can also use
GridConfiguration to override some default configuration. Below is an
example on how to start grid with custom configuration for
URI deployment.
GridConfiguration cfg = new GridConfiguration();
GridUriDeployment deploySpi = new GridUriDeployment();
deploySpi.setUriList(Collections.singletonList("classes://tmp/output/classes"));
cfg.setDeploymentSpi(deploySpi);
GridGain.start(cfg);
Here is how a grid instance can be configured from Spring XML configuration file. The
example below configures a grid instance with additional user attributes
(see
GridNode#attributes()) and specifies a grid name:
<bean id="grid.cfg" class="org.gridgain.grid.GridConfiguration">
...
<property name="gridName" value="grid"/>
<property name="userAttributes">
<map>
<entry key="group" value="worker"/>
</map>
</property>
...
</bean>
A grid instance with Spring configuration above can be started as following. Note that
you do not need to pass path to Spring XML file if you are using
GRIDGAIN_HOME/config/default-config.xml. Also note, that the path can be
absolute or relative to GRIDGAIN_HOME.
...
GridGain.start("/path/to/spring/xml/file.xml");
...
You can also instantiate grid directly from Spring without using
GridGain.
For more information refer to
org.gridgain.grid.GridSpringBean documentation.