You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/03/02 17:36:17 UTC
[25/50] incubator-ignite git commit: #ignite-239: small refactoring.
#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-337
Commit: 55669d46b838a1312e1067c8608243b89462fc54
Parents: ba010da
Author: ivasilinets <va...@gmail.com>
Authored: Sun Mar 1 15:39:37 2015 +0300
Committer: ivasilinets <va...@gmail.com>
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<String, ?> 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<String, ?> 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.
*/