ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [22/46] incubator-ignite git commit: # ignite-121 : fix review comments
Date Tue, 03 Feb 2015 15:45:15 GMT
# ignite-121 : fix review comments


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7c7ec7dc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7c7ec7dc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7c7ec7dc

Branch: refs/heads/ignite-106
Commit: 7c7ec7dc5b0d20cf19b2c9a0b1d647896c96909f
Parents: b9722c4
Author: Artem SHutak <ashutak@gridgain.com>
Authored: Mon Feb 2 19:35:03 2015 +0300
Committer: Artem SHutak <ashutak@gridgain.com>
Committed: Mon Feb 2 19:35:03 2015 +0300

----------------------------------------------------------------------
 .../impl/GridRouterCommandLineStartup.java      | 16 +++++---
 .../org/apache/ignite/internal/IgnitionEx.java  | 40 ++++++++++----------
 2 files changed, 32 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7c7ec7dc/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridRouterCommandLineStartup.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridRouterCommandLineStartup.java
b/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridRouterCommandLineStartup.java
index 255e563..6dfe62b 100644
--- a/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridRouterCommandLineStartup.java
+++ b/modules/core/src/main/java/org/apache/ignite/client/router/impl/GridRouterCommandLineStartup.java
@@ -18,19 +18,19 @@
 package org.apache.ignite.client.router.impl;
 
 import org.apache.ignite.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.lifecycle.*;
 import org.apache.ignite.client.router.*;
 import org.apache.ignite.internal.processors.spring.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.lifecycle.*;
 
 import java.net.*;
 import java.util.*;
 import java.util.logging.*;
 
-import static org.apache.ignite.internal.IgniteComponentType.*;
 import static org.apache.ignite.internal.GridProductImpl.*;
+import static org.apache.ignite.internal.IgniteComponentType.*;
 
 /**
  * Loader class for router.
@@ -134,8 +134,14 @@ public class GridRouterCommandLineStartup {
         Collection<Handler> savedHnds = null;
 
         if (isLog4jUsed)
-            t = U.addLog4jNoOpLogger();
-        else
+            try {
+                t = U.addLog4jNoOpLogger();
+            }
+            catch (Exception e) {
+                isLog4jUsed = false;
+            }
+
+        if (!isLog4jUsed)
             savedHnds = U.addJavaNoOpLogger();
 
         Map<Class<?>, Object> beans;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7c7ec7dc/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 f8e0992..605bce0 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
@@ -725,17 +725,15 @@ public class IgnitionEx {
 
         Collection<Handler> savedHnds = null;
 
-        boolean log4jAdditionFailed = false;
-
-        if (isLog4jUsed) {
+        if (isLog4jUsed)
             try {
                 t = U.addLog4jNoOpLogger();
-            } catch (IgniteCheckedException e) {
-                System.out.println("[WARNING] Could not initialize log4j. Fallback to standard
java logging.");
-                log4jAdditionFailed = true;
             }
-        }
-        if (!isLog4jUsed || log4jAdditionFailed)
+            catch (IgniteCheckedException e) {
+                isLog4jUsed = false;
+            }
+
+        if (!isLog4jUsed)
             savedHnds = U.addJavaNoOpLogger();
 
         IgniteBiTuple<Collection<IgniteConfiguration>, ? extends GridSpringResourceContext>
cfgMap;
@@ -2005,19 +2003,19 @@ public class IgnitionEx {
          */
         private IgniteLogger initLogger(@Nullable IgniteLogger cfgLog, UUID nodeId) throws
IgniteCheckedException {
             try {
-                boolean log4jInitFailed = false;
+                Exception log4jInitException = null;
 
                 if (cfgLog == null) {
                     Class<?> log4jCls = null;
 
                     try {
-                        try {
-                            log4jCls = Class.forName("org.apache.ignite.logger.log4j.IgniteLog4jLogger");
-                        }
-                        catch (ClassNotFoundException | NoClassDefFoundError ignored) {
-                            log4jCls = null;
-                        }
+                        log4jCls = Class.forName("org.apache.ignite.logger.log4j.IgniteLog4jLogger");
+                    }
+                    catch (ClassNotFoundException | NoClassDefFoundError ignored) {
+                        log4jCls = null;
+                    }
 
+                    try {
                         if (log4jCls != null) {
                             URL url = U.resolveGridGainUrl("config/ignite-log4j.xml");
 
@@ -2052,12 +2050,12 @@ public class IgnitionEx {
                             else
                                 cfgLog = (IgniteLogger)log4jCls.newInstance();
                         }
-                    } catch (Exception e) {
-                        System.out.println("[WARNING] Could not initialize log4j. Fallback
to standard java logging.");
-                        log4jInitFailed = true;
+                    }
+                    catch (Exception e) {
+                        log4jInitException = e;
                     }
 
-                    if (log4jCls == null || log4jInitFailed)
+                    if (log4jCls == null || log4jInitException != null)
                         cfgLog = new IgniteJavaLogger();
                 }
 
@@ -2065,6 +2063,10 @@ public class IgnitionEx {
                 if (cfgLog instanceof IgniteLoggerNodeIdAware)
                     ((IgniteLoggerNodeIdAware)cfgLog).setNodeId(nodeId);
 
+                if (log4jInitException != null)
+                    U.warn(cfgLog, "Failed to initialize IgniteLog4jLogger (falling back
to standard java logging): " +
+                            log4jInitException.getCause());
+
                 return cfgLog;
             }
             catch (Exception e) {


Mime
View raw message