Most of the functionality provided by GridGain is accessible through Grid ![]()
Grid interface defines a grid instance. In GridGain, a notion of grid instance is synonymous to grid node as node and grid instance have one-to-one relationship. Grid node defines a logical location of the grid instance, and grid instance defines Java runtime operating on that logical node. GridGain support multiple grid instances (and thus nodes) on the same VM, on the same computer or on different computers over various types of networks.
Grid instance can be obtains from GridFactory ![]()
GridFactory.start(); try { Grid grid = GridFactory.getGrid(); // Using grid instance. } finally { GridFactory.stop(true); }
Grid interface provides several areas of functionality:
- Grid task Management
- Topology Management
- Message Exchange
- System Events Management
Grid Task Management
Grid interface main functional goal is to execute grid tasks. In GridGain you can execute grid task asynchronously and synchronously.
- execute(String, Object)
Javadoc 
- execute(String, Object, long)
Javadoc 
- execute(String, Object, GridTaskListener)
Javadoc 
- execute(String, Object, long, GridTaskListener)
Javadoc 
- execute(Class<? extends GridTask<T,R>>, T)
Javadoc 
- execute(Class<? extends GridTask<T,R>>, T, long)
Javadoc 
- execute(Class<? extends GridTask<T,R>>, T, GridTaskListener)
Javadoc 
- execute(Class<? extends GridTask<T,R>>, T, long, GridTaskListener)
Javadoc 
- execute(GridTask<T,R>, T)
Javadoc 
- execute(GridTask<T,R>, T, long)
Javadoc 
- execute(GridTask<T,R>, T, GridTaskListener)
Javadoc 
- execute(GridTask<T,R>, T, long, GridTaskListener)
Javadoc 
Grid interface also allows manual deployment and undeployment of grid tasks (apart from deployment managed by deployment SPI). Note that if Peer Class Loading is enabled (default behavior), then tasks will be deployed automatically. Also note that tasks are auto-deployed first time they get executed via any of the execute(..) methods listed above.
- deployTask(Class<? extends GridTask<?>>)
Javadoc 
- getLocalTasks()
Javadoc 
- undeployTask(String)
Javadoc 
Topology Management
Topology management is one of the key functional areas provided by Grid interface. GridGain provides basic set of operations such as topology listeners and access to all grid nodes:
- getLocalNode()
Javadoc 
- getAllNodes()
Javadoc 
- getRemoteNodes()
Javadoc 
- getNode(UUID)
Javadoc 
- pingNode(UUID)
Javadoc 
- addDiscoveryListener(GridDiscoveryListener)
Javadoc 
- removeDiscoveryListener(GridDiscoveryListener)
Javadoc 
Message Exchange
Message exchange is not direct grid functionality but often required in real-life systems. Along with topology management, message exchange (implemented via communication SPI) provides developer with basic cluster operations. Using the following methods user can send message to one or multiple nodes and subscribe the listener for receiving messages:
- sendMessage(GridNode, Serializable)
Javadoc 
- sendMessage(Collection<GridNode>, Serializable)
Javadoc 
- addMessageListener(GridMessageListener)
Javadoc 
- removeMessageListener(GridMessageListener)
Javadoc 
System Events Management
Every significant action in GridGain generates event. All events are stored locally on the node where they were generated. User can use distributed query facility in GridGain to query events on the grid:
