Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 751AF17FC5 for ; Mon, 2 Mar 2015 18:45:31 +0000 (UTC) Received: (qmail 25528 invoked by uid 500); 2 Mar 2015 18:45:31 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 25488 invoked by uid 500); 2 Mar 2015 18:45:31 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 25426 invoked by uid 99); 2 Mar 2015 18:45:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Mar 2015 18:45:31 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 02 Mar 2015 18:45:29 +0000 Received: (qmail 23942 invoked by uid 99); 2 Mar 2015 18:45:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Mar 2015 18:45:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 96581E101B; Mon, 2 Mar 2015 18:45:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vkulichenko@apache.org To: commits@ignite.incubator.apache.org Date: Mon, 02 Mar 2015 18:45:32 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [26/50] incubator-ignite git commit: #ignite-239: small refactoring. X-Virus-Checked: Checked by ClamAV on apache.org #ignite-239: small refactoring. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/55669d46 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/55669d46 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/55669d46 Branch: refs/heads/ignite-141 Commit: 55669d46b838a1312e1067c8608243b89462fc54 Parents: ba010da Author: ivasilinets Authored: Sun Mar 1 15:39:37 2015 +0300 Committer: ivasilinets Committed: Sun Mar 1 15:39:37 2015 +0300 ---------------------------------------------------------------------- .../org/apache/ignite/internal/IgnitionEx.java | 172 +++++++++---------- 1 file changed, 86 insertions(+), 86 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/55669d46/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java index c7e7cb6..9770205 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java @@ -1295,29 +1295,14 @@ public class IgnitionEx { private void start0(GridStartContext startCtx) throws IgniteCheckedException { assert grid == null : "Grid is already started: " + name; - // Set configuration URL, if any, into system property. - if (startCtx.configUrl() != null) - System.setProperty(IGNITE_CONFIG_URL, startCtx.configUrl().toString()); - IgniteConfiguration cfg = startCtx.config() != null ? startCtx.config() : new IgniteConfiguration(); - // Ensure invariant. - // It's a bit dirty - but this is a result of late refactoring - // and I don't want to reshuffle a lot of code. - assert F.eq(name, cfg.getGridName()); - - // Validate segmentation configuration. - GridSegmentationPolicy segPlc = cfg.getSegmentationPolicy(); - - // 1. Warn on potential configuration problem: grid is not configured to wait - // for correct segment after segmentation happens. - if (!F.isEmpty(cfg.getSegmentationResolvers()) && segPlc == RESTART_JVM && !cfg.isWaitForSegmentOnStart()) { - U.warn(log, "Found potential configuration problem (forgot to enable waiting for segment" + - "on start?) [segPlc=" + segPlc + ", wait=false]"); - } - IgniteConfiguration myCfg = initializeConfiguration(cfg); + // Set configuration URL, if any, into system property. + if (startCtx.configUrl() != null) + System.setProperty(IGNITE_CONFIG_URL, startCtx.configUrl().toString()); + // Ensure that SPIs support multiple grid instances, if required. if (!startCtx.single()) { ensureMultiInstanceSupport(myCfg.getDeploymentSpi()); @@ -1331,17 +1316,6 @@ public class IgnitionEx { ensureMultiInstanceSupport(myCfg.getSwapSpaceSpi()); } - try { - // Use reflection to avoid loading undesired classes. - Class helperCls = Class.forName("org.apache.ignite.util.GridConfigurationHelper"); - - helperCls.getMethod("overrideConfiguration", IgniteConfiguration.class, Properties.class, - String.class, IgniteLogger.class).invoke(helperCls, myCfg, System.getProperties(), name, log); - } - catch (Exception ignored) { - // No-op. - } - execSvc = new IgniteThreadPoolExecutor( "pub-" + cfg.getGridName(), cfg.getPublicThreadPoolSize(), @@ -1414,6 +1388,17 @@ public class IgnitionEx { // Register Ignite MBean for current grid instance. registerFactoryMbean(myCfg.getMBeanServer()); + try { + // Use reflection to avoid loading undesired classes. + Class helperCls = Class.forName("org.apache.ignite.util.GridConfigurationHelper"); + + helperCls.getMethod("overrideConfiguration", IgniteConfiguration.class, Properties.class, + String.class, IgniteLogger.class).invoke(helperCls, myCfg, System.getProperties(), name, log); + } + catch (Exception ignored) { + // No-op. + } + boolean started = false; try { @@ -1489,16 +1474,7 @@ public class IgnitionEx { */ private IgniteConfiguration initializeConfiguration(IgniteConfiguration cfg) throws IgniteCheckedException { - // Initialize factory's log. - UUID nodeId = cfg.getNodeId() != null ? cfg.getNodeId() : UUID.randomUUID(); - - IgniteLogger cfgLog = initLogger(cfg.getGridLogger(), nodeId); - - assert cfgLog != null; - - cfgLog = new GridLoggerProxy(cfgLog, null, name, U.id8(nodeId)); - - log = cfgLog.getLogger(G.class); + IgniteConfiguration myCfg = new IgniteConfiguration(cfg); String ggHome = cfg.getIgniteHome(); @@ -1511,6 +1487,24 @@ public class IgnitionEx { U.setWorkDirectory(cfg.getWorkDirectory(), ggHome); + // Ensure invariant. + // It's a bit dirty - but this is a result of late refactoring + // and I don't want to reshuffle a lot of code. + assert F.eq(name, cfg.getGridName()); + + UUID nodeId = cfg.getNodeId() != null ? cfg.getNodeId() : UUID.randomUUID(); + + IgniteLogger cfgLog = initLogger(cfg.getGridLogger(), nodeId); + + assert cfgLog != null; + + cfgLog = new GridLoggerProxy(cfgLog, null, name, U.id8(nodeId)); + + // Initialize factory's log. + log = cfgLog.getLogger(G.class); + + myCfg.setGridLogger(cfgLog); + // Check Ignite home folder (after log is available). if (ggHome != null) { File ggHomeFile = new File(ggHome); @@ -1519,11 +1513,23 @@ public class IgnitionEx { throw new IgniteCheckedException("Invalid Ignite installation home folder: " + ggHome); } - IgniteConfiguration myCfg = new IgniteConfiguration(cfg); - myCfg.setIgniteHome(ggHome); - myCfg.setGridLogger(cfgLog); + // Validate segmentation configuration. + GridSegmentationPolicy segPlc = cfg.getSegmentationPolicy(); + + // 1. Warn on potential configuration problem: grid is not configured to wait + // for correct segment after segmentation happens. + if (!F.isEmpty(cfg.getSegmentationResolvers()) && segPlc == RESTART_JVM && !cfg.isWaitForSegmentOnStart()) { + U.warn(log, "Found potential configuration problem (forgot to enable waiting for segment" + + "on start?) [segPlc=" + segPlc + ", wait=false]"); + } + + myCfg.setTransactionConfiguration(myCfg.getTransactionConfiguration() != null ? + new TransactionConfiguration(myCfg.getTransactionConfiguration()) : null); + + myCfg.setConnectorConfiguration(myCfg.getConnectorConfiguration() != null ? + new ConnectorConfiguration(myCfg.getConnectorConfiguration()) : null); // Local host. String locHost = IgniteSystemProperties.getString(IGNITE_LOCAL_HOST); @@ -1534,6 +1540,37 @@ public class IgnitionEx { if (daemon) myCfg.setDaemon(true); + // Check for deployment mode override. + String depModeName = IgniteSystemProperties.getString(IGNITE_DEP_MODE_OVERRIDE); + + if (!F.isEmpty(depModeName)) { + if (!F.isEmpty(myCfg.getCacheConfiguration())) { + U.quietAndInfo(log, "Skipping deployment mode override for caches (custom closure " + + "execution may not work for console Visor)"); + } + else { + try { + DeploymentMode depMode = DeploymentMode.valueOf(depModeName); + + if (myCfg.getDeploymentMode() != depMode) + myCfg.setDeploymentMode(depMode); + } + catch (IllegalArgumentException e) { + throw new IgniteCheckedException("Failed to override deployment mode using system property " + + "(are there any misspellings?)" + + "[name=" + IGNITE_DEP_MODE_OVERRIDE + ", value=" + depModeName + ']', e); + } + } + } + + if (myCfg.getUserAttributes() == null) { + Map emptyAttr = Collections.emptyMap(); + myCfg.setUserAttributes(emptyAttr); + } + + if (myCfg.getMBeanServer() == null) + myCfg.setMBeanServer(ManagementFactory.getPlatformMBeanServer()); + Marshaller marsh = myCfg.getMarshaller(); if (marsh == null) { @@ -1564,33 +1601,12 @@ public class IgnitionEx { "Using GridOptimizedMarshaller on untested JVM."); } - // Check for deployment mode override. - String depModeName = IgniteSystemProperties.getString(IGNITE_DEP_MODE_OVERRIDE); - - if (!F.isEmpty(depModeName)) { - if (!F.isEmpty(myCfg.getCacheConfiguration())) { - U.quietAndInfo(log, "Skipping deployment mode override for caches (custom closure " + - "execution may not work for console Visor)"); - } - else { - try { - DeploymentMode depMode = DeploymentMode.valueOf(depModeName); - - if (myCfg.getDeploymentMode() != depMode) - myCfg.setDeploymentMode(depMode); - } - catch (IllegalArgumentException e) { - throw new IgniteCheckedException("Failed to override deployment mode using system property " + - "(are there any misspellings?)" + - "[name=" + IGNITE_DEP_MODE_OVERRIDE + ", value=" + depModeName + ']', e); - } - } - } - myCfg.setMarshaller(marsh); - myCfg.setConnectorConfiguration(myCfg.getConnectorConfiguration() != null ? - new ConnectorConfiguration(myCfg.getConnectorConfiguration()) : null); + if (myCfg.getPeerClassLoadingLocalClassPathExclude() == null) + myCfg.setPeerClassLoadingLocalClassPathExclude(EMPTY_STR_ARR); + + myCfg.setNodeId(nodeId); IgfsConfiguration[] igfsCfgs = myCfg.getIgfsConfiguration(); @@ -1603,14 +1619,6 @@ public class IgnitionEx { myCfg.setIgfsConfiguration(clone); } - if (myCfg.getMBeanServer() == null) - myCfg.setMBeanServer(ManagementFactory.getPlatformMBeanServer()); - - myCfg.setNodeId(nodeId); - - if (myCfg.getPeerClassLoadingLocalClassPathExclude() == null) - myCfg.setPeerClassLoadingLocalClassPathExclude(EMPTY_STR_ARR); - StreamerConfiguration[] streamerCfgs = myCfg.getStreamerConfiguration(); if (streamerCfgs != null) { @@ -1622,18 +1630,10 @@ public class IgnitionEx { myCfg.setStreamerConfiguration(clone); } - myCfg.setTransactionConfiguration(myCfg.getTransactionConfiguration() != null ? - new TransactionConfiguration(myCfg.getTransactionConfiguration()) : null); - - if (myCfg.getUserAttributes() == null) { - Map emptyAttr = Collections.emptyMap(); - myCfg.setUserAttributes(emptyAttr); - } + initializeDefaultSpi(myCfg); initializeDefaultCacheConfiguration(myCfg); - initializeDefaultSpi(myCfg); - return myCfg; } @@ -1722,7 +1722,7 @@ public class IgnitionEx { } /** - * Initialize default values for spi. + * Initialize default SPI implementations. * * @param cfg Ignite configuration. */