ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject [1/3] incubator-ignite git commit: IGNITE-1157 Fix.
Date Mon, 03 Aug 2015 13:22:03 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-1.3.3 015d9cd53 -> 7d747d2ac


IGNITE-1157 Fix.


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

Branch: refs/heads/ignite-1.3.3
Commit: 45aa5985bfe0ca3b9a537f9b7ef2136a64d97d28
Parents: 32f84c1
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Fri Jul 24 18:44:46 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Fri Jul 24 18:44:46 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/util/GridLogThrottle.java   | 53 +++++++++++++-------
 .../ignite/spi/discovery/tcp/ClientImpl.java    |  5 +-
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  5 +-
 .../spi/discovery/tcp/TcpDiscoveryImpl.java     | 15 ++++++
 4 files changed, 57 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/45aa5985/modules/core/src/main/java/org/apache/ignite/internal/util/GridLogThrottle.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLogThrottle.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/GridLogThrottle.java
index 89b02b4..f37cfea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridLogThrottle.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridLogThrottle.java
@@ -18,9 +18,9 @@
 package org.apache.ignite.internal.util;
 
 import org.apache.ignite.*;
+import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lang.*;
 import org.jetbrains.annotations.*;
 import org.jsr166.*;
 
@@ -42,7 +42,7 @@ public class GridLogThrottle {
     private static int throttleTimeout = DFLT_THROTTLE_TIMEOUT;
 
     /** Errors. */
-    private static final ConcurrentMap<IgniteBiTuple<Class<? extends Throwable>,
String>, Long> errors =
+    private static final ConcurrentMap<GridTuple3<Class<? extends Throwable>,
String, Boolean>, Long> errors =
         new ConcurrentHashMap8<>();
 
     /**
@@ -73,7 +73,7 @@ public class GridLogThrottle {
     public static void error(@Nullable IgniteLogger log, @Nullable Throwable e, String msg)
{
         assert !F.isEmpty(msg);
 
-        log(log, e, msg, null, LogLevel.ERROR);
+        log(log, e, msg, null, LogLevel.ERROR, false);
     }
 
     /**
@@ -86,7 +86,20 @@ public class GridLogThrottle {
     public static void warn(@Nullable IgniteLogger log, @Nullable Throwable e, String msg)
{
         assert !F.isEmpty(msg);
 
-        log(log, e, msg, null, LogLevel.WARN);
+        log(log, e, msg, null, LogLevel.WARN, false);
+    }
+
+    /**
+     * Logs warning if needed.
+     *
+     * @param log Logger.
+     * @param e Error (optional).
+     * @param msg Message.
+     */
+    public static void warn(@Nullable IgniteLogger log, @Nullable Throwable e, String msg,
boolean quite) {
+        assert !F.isEmpty(msg);
+
+        log(log, e, msg, null, LogLevel.WARN, quite);
     }
 
     /**
@@ -100,7 +113,7 @@ public class GridLogThrottle {
     public static void warn(@Nullable IgniteLogger log, @Nullable Throwable e, String longMsg,
@Nullable String shortMsg) {
         assert !F.isEmpty(longMsg);
 
-        log(log, e, longMsg, shortMsg, LogLevel.WARN);
+        log(log, e, longMsg, shortMsg, LogLevel.WARN, false);
     }
 
     /**
@@ -112,7 +125,7 @@ public class GridLogThrottle {
     public static void info(@Nullable IgniteLogger log, String msg) {
         assert !F.isEmpty(msg);
 
-        log(log, null, msg, null, LogLevel.INFO);
+        log(log, null, msg, null, LogLevel.INFO, false);
     }
 
     /**
@@ -133,12 +146,12 @@ public class GridLogThrottle {
      */
     @SuppressWarnings({"RedundantTypeArguments"})
     private static void log(@Nullable IgniteLogger log, @Nullable Throwable e, String longMsg,
@Nullable String shortMsg,
-        LogLevel level) {
+        LogLevel level, boolean quiet) {
         assert !F.isEmpty(longMsg);
 
-        IgniteBiTuple<Class<? extends Throwable>, String> tup =
-            e != null ? F.<Class<? extends Throwable>, String>t(e.getClass(),
e.getMessage()) :
-                F.<Class<? extends Throwable>, String>t(null, longMsg);
+        GridTuple3<Class<? extends Throwable>, String, Boolean> tup =
+            e != null ? F.<Class<? extends Throwable>, String, Boolean>t(e.getClass(),
e.getMessage(), quiet) :
+                F.<Class<? extends Throwable>, String, Boolean>t(null, longMsg,
quiet);
 
         while (true) {
             Long loggedTs = errors.get(tup);
@@ -147,7 +160,7 @@ public class GridLogThrottle {
 
             if (loggedTs == null || loggedTs < curTs - throttleTimeout) {
                 if (replace(tup, loggedTs, curTs)) {
-                    level.doLog(log, longMsg, shortMsg, e);
+                    level.doLog(log, longMsg, shortMsg, e, quiet);
 
                     break;
                 }
@@ -164,7 +177,7 @@ public class GridLogThrottle {
      * @param newStamp New timestamp.
      * @return {@code True} if throttle value was replaced.
      */
-    private static boolean replace(IgniteBiTuple<Class<? extends Throwable>, String>
t, @Nullable Long oldStamp,
+    private static boolean replace(GridTuple3<Class<? extends Throwable>, String,
Boolean> t, @Nullable Long oldStamp,
         Long newStamp) {
         assert newStamp != null;
 
@@ -182,10 +195,13 @@ public class GridLogThrottle {
         // No-op.
     }
 
+    /**
+     *
+     */
     private enum LogLevel {
         /** Error level. */
         ERROR {
-            @Override public void doLog(IgniteLogger log, String longMsg, String shortMsg,
Throwable e) {
+            @Override public void doLog(IgniteLogger log, String longMsg, String shortMsg,
Throwable e, boolean quiet) {
                 if (e != null)
                     U.error(log, longMsg, e);
                 else
@@ -195,14 +211,17 @@ public class GridLogThrottle {
 
         /** Warn level. */
         WARN {
-            @Override public void doLog(IgniteLogger log, String longMsg, String shortMsg,
Throwable e) {
-                U.warn(log, longMsg, F.isEmpty(shortMsg) ? longMsg : shortMsg);
+            @Override public void doLog(IgniteLogger log, String longMsg, String shortMsg,
Throwable e, boolean quiet) {
+                if (quiet)
+                    U.quietAndWarn(log, longMsg, F.isEmpty(shortMsg) ? longMsg : shortMsg);
+                else
+                    U.warn(log, longMsg, F.isEmpty(shortMsg) ? longMsg : shortMsg);
             }
         },
 
         /** Info level. */
         INFO {
-            @Override public void doLog(IgniteLogger log, String longMsg, String shortMsg,
Throwable e) {
+            @Override public void doLog(IgniteLogger log, String longMsg, String shortMsg,
Throwable e, boolean quiet) {
                 if (log.isInfoEnabled())
                     log.info(longMsg);
             }
@@ -216,6 +235,6 @@ public class GridLogThrottle {
          * @param shortMsg Short message.
          * @param e Exception to attach to log.
          */
-        public abstract void doLog(IgniteLogger log, String longMsg, String shortMsg, Throwable
e);
+        public abstract void doLog(IgniteLogger log, String longMsg, String shortMsg, Throwable
e, boolean quiet);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/45aa5985/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index f9c4a4d..a052e58 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -384,7 +384,8 @@ class ClientImpl extends TcpDiscoveryImpl {
                     if (timeout > 0 && (U.currentTimeMillis() - startTime) >
timeout)
                         return null;
 
-                    U.warn(log, "No addresses registered in the IP finder (will retry in
2000ms): " + spi.ipFinder);
+                    LT.warn(log, null, "No addresses registered in the IP finder (will retry
in 2000ms): "
+                            + spi.ipFinder, true);
 
                     Thread.sleep(2000);
                 }
@@ -435,7 +436,7 @@ class ClientImpl extends TcpDiscoveryImpl {
                     return null;
 
                 LT.warn(log, null, "Failed to connect to any address from IP finder (will
retry to join topology " +
-                    "in 2000ms): " + addrs0);
+                    "in 2000ms): " + toOrderedList(addrs0), true);
 
                 Thread.sleep(2000);
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/45aa5985/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 68552a6..75436fa 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -830,10 +830,11 @@ class ServerImpl extends TcpDiscoveryImpl {
                         e.addSuppressed(err);
                 }
 
-                if (e != null && X.hasCause(e, ConnectException.class))
+                if (e != null && X.hasCause(e, ConnectException.class)) {
                     LT.warn(log, null, "Failed to connect to any address from IP finder "
+
                         "(make sure IP finder addresses are correct and firewalls are disabled
on all host machines): " +
-                        addrs);
+                        toOrderedList(addrs), true);
+                }
 
                 if (spi.joinTimeout > 0) {
                     if (noResStart == 0)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/45aa5985/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
index ace917f..e8ee798 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
@@ -26,6 +26,7 @@ import org.apache.ignite.spi.discovery.*;
 import org.apache.ignite.spi.discovery.tcp.internal.*;
 import org.jetbrains.annotations.*;
 
+import java.net.*;
 import java.text.*;
 import java.util.*;
 import java.util.concurrent.*;
@@ -276,4 +277,18 @@ abstract class TcpDiscoveryImpl {
 
         return true;
     }
+
+    /**
+     * @param addrs Addresses.
+     */
+    protected static List<String> toOrderedList(Collection<InetSocketAddress>
addrs) {
+        List<String> res = new ArrayList<>(addrs.size());
+
+        for (InetSocketAddress addr : addrs)
+            res.add(addr.toString());
+
+        Collections.sort(res);
+
+        return res;
+    }
 }


Mime
View raw message