Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C27D3200BAD for ; Tue, 25 Oct 2016 11:41:46 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C1259160AF3; Tue, 25 Oct 2016 09:41:46 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 11FC9160AE6 for ; Tue, 25 Oct 2016 11:41:45 +0200 (CEST) Received: (qmail 13791 invoked by uid 500); 25 Oct 2016 09:41:45 -0000 Mailing-List: contact user-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ignite.apache.org Delivered-To: mailing list user@ignite.apache.org Received: (qmail 13781 invoked by uid 99); 25 Oct 2016 09:41:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Oct 2016 09:41:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 9C08C1A0282 for ; Tue, 25 Oct 2016 09:41:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.409 X-Spam-Level: ** X-Spam-Status: No, score=2.409 tagged_above=-999 required=6.31 tests=[FORGED_HOTMAIL_RCVD2=1.187, FREEMAIL_ENVFROM_END_DIGIT=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_SOFTFAIL=0.972] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id g-i64KX8Rep3 for ; Tue, 25 Oct 2016 09:41:40 +0000 (UTC) Received: from mbob.nabble.com (mbob.nabble.com [162.253.133.15]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 621975FC5F for ; Tue, 25 Oct 2016 09:41:40 +0000 (UTC) Received: from static.162.255.23.37.macminivault.com (unknown [162.255.23.37]) by mbob.nabble.com (Postfix) with ESMTP id 0B5DD34713EF for ; Tue, 25 Oct 2016 02:34:14 -0700 (PDT) Date: Tue, 25 Oct 2016 02:41:33 -0700 (MST) From: Manu To: user@ignite.apache.org Message-ID: <1477388493238-8466.post@n6.nabble.com> In-Reply-To: <1476986566098-8388.post@n6.nabble.com> References: <1476986566098-8388.post@n6.nabble.com> Subject: Re: grid name in ignite configuration file MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit archived-at: Tue, 25 Oct 2016 09:41:46 -0000 Hi, 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 this.ignite=Ignition.ignite("gridNameX"); this.attached=true; }catch (IllegalStateException e){ this.ignite=Ignition.start("igniteConfigurationFileX.xml"); this.attached=false; } "attached" flag could be useful to close a ignite instance on org.springframework.beans.factory.DisposableBean and free resources on JVM from "starter" @Override public void destroy() { if (this.ignite!=null && !this.attached){ //this is a ignite instance "starter" bean this.ignite.close(); } } 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, ? extends GridSpringResourceContext> cfgMap = IgnitionEx.loadConfigurations(cfgUrl); IgniteConfiguration cfg = F.first(cfgMap.get1()); if (cfg.getGridName() == null) cfg.setGridName("ignite-jdbc-driver-" + UUID.randomUUID().toString()); 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.