|
GridGain 2.0.3
Java API Specification |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gridgain.grid.GridFactory
public final class GridFactory
This interface defines a factory for the main GridGain API. It controls Grid life cycle and allows listening for grid events. Although user can call grid factory directly to start and stop grid, grid is usually started and stopped by grid loaders. Some examples of Grid loaders are:
GridCommandLineLoaderGridJbossLoaderGridWeblogicStartup and GridWeblogicShutdownGridWebsphereLoaderGridGlassfishLoaderGridServletLoader
Note that all parameters passed in GridConfiguration to GridFactory.start(GridConfiguration)
method are optional. If not provided, default values will be used. Below is the table that provides
default value for every configuration parameter.
| GridConfiguration Method | Default Value | Description |
|---|---|---|
GridConfiguration.getGridName() |
null | Grid name (null is a default value). |
GridConfiguration.getUserAttributes() |
Empty set. | Attributes to be set on local node. |
GridConfiguration.getGridLogger() |
Log4J logger initialized to log only to console (see GridLog4jLogger.GridLog4jLogger(boolean)) |
Logger to use within grid. |
getExecutorService() |
Grid thread pool with default initialization
(see GridThreadPoolExecutorService).
|
Thread pool used by grid. |
GridConfiguration.getGridGainHome() |
Inferred (see GridConfiguration.getGridGainHome() for details). |
Path to GridGain installation folder. |
GridConfiguration.getMBeanServer() |
Platform MBean server (see ManagementFactory.getPlatformMBeanServer()). |
MBean server used by grid. |
GridConfiguration.getNodeId() |
Randomly generated node ID (see UUID.randomUUID()). |
Local node unique identifier. |
GridConfiguration.isPeerClassLoadingEnabled() |
true | Boolean flag to control peer class loading. When enabled, if a task is not deployed on a node, the system will attempt to load it from a peer node (usually from the node that initiated task execution). |
GridConfiguration.getP2PLocalClassPathExclude() |
Empty list. | List of packages to exclude from local classpath when executing grid tasks. All classes within these packages will be loaded on demand from the node that initiated task execution. |
GridConfiguration.getMetricsExpireTime() |
Long.MAX_VALUE |
Maximum time until node metrics from remote nodes are considered expired.
Node metrics are frequently updated (usually with every heartbeat) and
provide runtime information about remote nodes (see GridNode.getMetrics()).
|
GridConfiguration.getMetricsHistorySize() |
10,000 |
Maximum number of metrics to keep in the memory. The larger this number,
the more precise the metrics calculations are (at the expense of more memory
consumption). Node metrics are frequently updated (usually with every heartbeat)
and provide runtime information about remote nodes (see GridNode.getMetrics()).
|
GridConfiguration.getDiscoverySpi() |
Multicast-based grid discovery (see GridMulticastDiscoverySpi). |
Fully configured SPI used for discovering remote grid nodes. |
GridConfiguration.getCommunicationSpi() |
TCP-based communication (see GridTcpCommunicationSpi). |
Fully configured SPI used for communication between grid nodes. |
GridConfiguration.getDeploymentSpi() |
Local (in-memory) deployment SPI (see GridLocalDeploymentSpi). |
Fully configured SPI used for deploying grid tasks. |
GridConfiguration.getCheckpointSpi() |
Shared file system checkpoint SPI which (see GridSharedFsCheckpointSpi).
|
Fully configured SPI used for storing intermediate job state to safeguard against failures. |
GridConfiguration.getEventStorageSpi() |
In-memory limited event storage (see GridMemoryEventStorageSpi). |
Fully configured SPI used for storing grid events. |
GridConfiguration.getTopologySpi() |
Basic topology spi that provides all discovered grid nodes (see GridBasicTopologySpi). |
Fully configured SPI used for determining grid task execution topology. |
GridConfiguration.getFailoverSpi() |
Failover SPI that always fails over jobs to another node (see GridAlwaysFailoverSpi). |
Fully configured SPI used for failing over jobs to another node in case of node failure. |
GridConfiguration.getCollisionSpi() |
Job collision SPI that executes all incoming jobs in FIFO order (see GridFifoQueueCollisionSpi). |
Fully configured SPI used for handling job collisions. |
GridConfiguration.getMetricsSpi() |
Basic JDK-based local VM Metrics implementation (see GridJdkLocalMetricsSpi). |
Fully configured SPI used for providing local VM metrics. |
GridConfiguration.getLoadBalancingSpi() |
Round-Robin implementation that will pick a random start node for every task and will
iterate through all nodes starting at the start node sequentially for every grid job.
(see GridRoundRobinLoadBalancingSpi).
|
Fully configured SPI used for load balancing of jobs within grid. |
GridConfiguration.getTracingSpi() |
If not provided, then tracing will not be performed. | Fully configured SPI used for tracing public grid method invocations. |
GridFactory.start() method to start grid with default configuration. You can also use
GridConfigurationAdapter to override some default configuration. Below is an
example on how to start grid with URI deployment and
JGroups-based discovery SPI's.
GridConfigurationAdapter cfg = new GridConfigurationAdapter();
GridUriDeployment deploySpi = new GridUriDeployment();
deploySpi.setUriList(Collections.singletonList("classes://tmp/ideoutput/classes"));
GridJgroupsDiscovery discoSpi = new GridJgroupsDiscovery();
discoSpi.setConfigurationFile("/config/jgroups/multicast/jgroups.xml");
cfg.setDeploymentSpi(deploySpi);
cfg.setDiscoverySpi(discoSpi);
GridFactroy.start(cfg);
Note that you can start multiple grid nodes within same VM by specifying
grid name (see GridFactory.start(GridConfiguration)). This may be useful
for testing whenever it is needed to check internal job parameters when jobs
are running on different nodes. In most cases, however, you should use default
no-name grid.
See Also:
Documentation
Email Support
Online Forums
Issue Tracking
Author: 2005-2008 Copyright © GridGain Systems. All Rights Reserved. ver. 2.0.3
![]() |
![]() |
| Method Summary | |
|---|---|
static void |
addListener(GridFactoryListener listener)
Adds a listener for grid life cycle events. |
static List<Grid> |
getAllGrids()
Gets a list of all grids started so far. |
static Grid |
getGrid()
Gets an instance of default no-name grid. |
static Grid |
getGrid(String name)
Gets an instance named grid. |
static GridFactoryState |
getState()
Gets state of grid default grid. |
static GridFactoryState |
getState(String name)
Gets states of named grid. |
static boolean |
removeListener(GridFactoryListener listener)
Removes listener added by GridFactory.addListener(GridFactoryListener) method. |
static Grid |
start()
Starts grid with default configuration. |
static Grid |
start(GridConfiguration cfg)
Starts grid with given configuration. |
static Grid |
start(GridConfiguration cfg,
org.springframework.context.ApplicationContext springCtx)
Starts grid with given configuration. |
static Grid |
start(String springCfgPath)
Starts all grids specified within given Spring XML configuration file. |
static boolean |
stop(boolean cancel)
Stops default grid. |
static boolean |
stop(String name,
boolean cancel)
Stops named grid. |
static void |
stopAll(boolean cancel)
Stops all started grids. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static GridFactoryState getState()
public static GridFactoryState getState(String name)
name - Grid name. If name is null, then state of
default no-name grid is returned.
public static boolean stop(boolean cancel)
cancel - If true then all jobs currently executing on
default grid will be cancelled by calling GridJob.cancel()
method. Note that just like with Thread.interrupt(), it is
up to the actual job to exit from execution
public static boolean stop(String name,
boolean cancel)
name - Grid name. If null, then default no-name grid will
be stopped.cancel - If true then all jobs currently will be cancelled
by calling GridJob.cancel() method. Note that just like with
Thread.interrupt(), it is up to the actual job to exit from
execution. If false, then jobs currently running will not be
canceled. In either case, grid node will wait for completion of all
jobs running on it before stopping.
public static void stopAll(boolean cancel)
Note: it is usually safer and more appropriate to stop grid instances individually instead of blanket operation. In most cases, the party that started the grid instance should be responsible for stopping it.
cancel - If true then all jobs currently executing on
all grids will be cancelled by calling GridJob.cancel()
method. Note that just like with Thread.interrupt(), it is
up to the actual job to exit from execution
public static Grid start()
throws GridException
GridException - If default grid could not be started. This exception will be thrown
also if default grid has already been started.
public static Grid start(GridConfiguration cfg)
throws GridException
GridException - If grid could not be started. This exception will be thrown
also if named grid has already been started.cfg - Grid configuration. This cannot be null.
public static Grid start(GridConfiguration cfg,
org.springframework.context.ApplicationContext springCtx)
throws GridException
GridException - If grid could not be started. This exception will be thrown
also if named grid has already been started.cfg - Grid configuration. This cannot be null.springCtx - Spring application context, possibly null. If provided, this
context can be injected into grid tasks and grid jobs using
@GridSpringApplicationContextResource annotation.
public static Grid start(String springCfgPath)
throws GridException
Most commonly, Spring XML configuration file will contain only one Grid definition. Note that Grid configuration bean(s) is retrieved form configuration file by type, so the name of the Grid configuration bean is ignored.
GridException - If grid could not be started or configuration
read. This exception will be thrown also if grid with given name has already
been started or Spring XML configuration file is invalid.springCfgPath - Spring XML configuration file path. This cannot be null.
public static Grid getGrid()
throws IllegalStateException
This method is identical to GridFactory.stop(null) call.
IllegalStateException - Thrown if default grid was not properly
initialized or grid instance was stopped or was not started.
public static List<Grid> getAllGrids()
public static Grid getGrid(String name)
throws IllegalStateException
IllegalStateException - Thrown if default grid was not properly
initialized or grid instance was stopped or was not started.name - Grid name. If null, then default no-name grid will
be returned.
public static void addListener(GridFactoryListener listener)
listener - Listener for grid life cycle events.public static boolean removeListener(GridFactoryListener listener)
GridFactory.addListener(GridFactoryListener) method.
listener - Listener to remove.
|
GridGain 2.0.3
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.0.3.20052008
2005-2008 Copyright © GridGain Systems. All Rights Reserved. |
|