ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manu <maxn...@hotmail.com>
Subject Re: grid name in ignite configuration file
Date Tue, 25 Oct 2016 09:41:33 GMT

Grid name allows to identify different ignite instances within same JVM
(commonly with different configuration: discovery, etc, but not always, you
could have n clients ignite instances with same internal configuration and
different grid names, i.e. on ignite JdbcConnection, if no gridName is
provided on first time starting connection). 

You could find this (use of gridName) really helpful, particularly, on
client side (client nodes) to access different clusters within same JVM and
get ignite instances using Ignition.ignite("gridName"). Imagine that you
have this architecture: 

a. server nodes - cluster 1 (data grid) -  discovery config 1
b. server nodes - cluster 2 (analytics grid) - discovery config 2
c. server nodes - cluster 3 (compute grid) - discovery config 3
d. 1 (to n) clients on same JVM that access and move data between clusters

On one client (ignite client starter role), you could define 3 configuration
files, with different grid name on each one (or set it by code, remember
that grid name allows you to identify a ignite instance within same JVM),
for example:
a. igniteConfigurationFile1.xml - "gridName1" - discovery config 1 (cluster
1 data grid)
b. igniteConfigurationFile2.xml - "gridName2" - discovery config 2 (cluster
2 analytics grid)
c. igniteConfigurationFile3.xml - "gridName3" - discovery config 3 (cluster
3 compute grid)

to access a particular ignite grid, you could do:

	try{ //try to attach to existing ignite instance
	}catch (IllegalStateException e){

"attached" flag could be useful to close a ignite instance on
org.springframework.beans.factory.DisposableBean and free resources on JVM
from "starter"

	public void destroy() {
		if (this.ignite!=null && !this.attached){ 
			//this is a ignite instance "starter" bean

IMPORTANT: On JDBC connection behavior is the same... this means that if
grid-name is provided on xml configuration file, instance will be created
with this name, otherwise a random grid-name will be generated... this is
the method that JdbcConnection use to load client configuration file... so
take care with this, an exception will be thrown trying to start
(Ignition.start) a ignite instance with same gridName within same JVM...

    private IgniteConfiguration loadConfiguration(String cfgUrl) {
        try {
            IgniteBiTuple<Collection&lt;IgniteConfiguration>, ? extends
GridSpringResourceContext> cfgMap =

            IgniteConfiguration cfg = F.first(cfgMap.get1());

            if (cfg.getGridName() == null)
                cfg.setGridName("ignite-jdbc-driver-" +

            cfg.setClientMode(true); // Force client mode.

            return cfg;
        catch (IgniteCheckedException e) {
            throw new IgniteException(e);

View this message in context: http://apache-ignite-users.70518.x6.nabble.com/grid-name-in-ignite-configuration-file-tp8380p8466.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

View raw message