ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [01/17] ignite git commit: IGNITE-3027 - TcpDiscoveryImpl.registerLocalNodeAddress() has an infinite loop (cherry picked from commit 1f8b394)
Date Wed, 04 May 2016 09:08:16 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-3024 6d1fa2168 -> 7d6eb1f50


IGNITE-3027 - TcpDiscoveryImpl.registerLocalNodeAddress() has an infinite loop
(cherry picked from commit 1f8b394)


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

Branch: refs/heads/ignite-3024
Commit: 1b4d57ab3d9421914a7efa09c17b59b61a828485
Parents: ab1f194
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Thu Apr 28 14:32:30 2016 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Thu Apr 28 14:36:14 2016 +0300

----------------------------------------------------------------------
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  5 ++-
 .../spi/discovery/tcp/TcpDiscoveryImpl.java     | 10 ++++++
 .../spi/discovery/tcp/TcpDiscoverySelfTest.java | 34 ++++++++++++++++++++
 3 files changed, 46 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1b4d57ab/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 d7dd8c8..05bb1e6 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
@@ -160,7 +160,6 @@ import static org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryStatusChe
 /**
  *
  */
-@SuppressWarnings("All")
 class ServerImpl extends TcpDiscoveryImpl {
     /** */
     private static final int ENSURED_MSG_HIST_SIZE = getInteger(IGNITE_DISCOVERY_HISTORY_SIZE,
1024 * 10);
@@ -1643,7 +1642,7 @@ class ServerImpl extends TcpDiscoveryImpl {
      * @return {@code True} if given parameters contain the same permissions, {@code False}
otherwise.
      */
     private boolean permissionsEqual(SecurityPermissionSet locPerms, SecurityPermissionSet
rmtPerms) {
-        boolean dfltAllowMatch = !(locPerms.defaultAllowAll() ^ rmtPerms.defaultAllowAll());
+        boolean dfltAllowMatch = locPerms.defaultAllowAll() == rmtPerms.defaultAllowAll();
 
         boolean bothHaveSamePerms = F.eqNotOrdered(rmtPerms.systemPermissions(), locPerms.systemPermissions())
&&
             F.eqNotOrdered(rmtPerms.cachePermissions(), locPerms.cachePermissions()) &&
@@ -1964,7 +1963,7 @@ class ServerImpl extends TcpDiscoveryImpl {
         private final Queue<TcpDiscoveryAbstractMessage> msgs = new ArrayDeque<>(MAX
* 2);
 
         /** Processed custom message IDs. */
-        private Set<IgniteUuid> procCustomMsgs = new GridBoundedLinkedHashSet<IgniteUuid>(MAX
* 2);
+        private Set<IgniteUuid> procCustomMsgs = new GridBoundedLinkedHashSet<>(MAX
* 2);
 
         /** Discarded message ID. */
         private IgniteUuid discardId;

http://git-wip-us.apache.org/repos/asf/ignite/blob/1b4d57ab/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 1aef728..41086d1 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
@@ -260,6 +260,9 @@ abstract class TcpDiscoveryImpl {
     @SuppressWarnings("BusyWait")
     protected final void registerLocalNodeAddress() throws IgniteSpiException {
         // Make sure address registration succeeded.
+        // ... but limit it if join timeout is configured.
+        long start = spi.getJoinTimeout() > 0 ? U.currentTimeMillis() : 0;
+
         while (true) {
             try {
                 spi.ipFinder.initializeLocalAddresses(locNode.socketAddresses());
@@ -276,6 +279,13 @@ abstract class TcpDiscoveryImpl {
                     "(retrying every 2000 ms).");
             }
 
+            if (start > 0 && (U.currentTimeMillis() - start) > spi.getJoinTimeout())
+                throw new IgniteSpiException(
+                    "Failed to register local addresses with IP finder within join timeout
" +
+                        "(make sure IP finder configuration is correct, and operating system
firewalls are disabled " +
+                        "on all host machines, or consider increasing 'joinTimeout' configuration
property) " +
+                        "[joinTimeout=" + spi.getJoinTimeout() + ']');
+
             try {
                 U.sleep(2000);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/1b4d57ab/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
index 45cd276..96c0e66 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
@@ -1058,6 +1058,40 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @throws Exception If any error occurs.
+     */
+    public void testJoinTimeoutForIpFinder() throws Exception {
+        try {
+            // This start will fail as expected.
+            Throwable t = GridTestUtils.assertThrows(log, new Callable<Object>() {
+                @Override public Object call() throws Exception {
+                    IgniteConfiguration c = getConfiguration("test-grid");
+
+                    TcpDiscoverySpi disco = (TcpDiscoverySpi)c.getDiscoverySpi();
+
+                    disco.setJoinTimeout(3000);
+                    disco.setIpFinder(
+                        new TcpDiscoveryVmIpFinder(true) {
+                            @Override public void initializeLocalAddresses(Collection<InetSocketAddress>
addrs)
+                                throws IgniteSpiException {
+                                throw new IgniteSpiException("Test exception.");
+                            }
+                        });
+
+                    startGrid("test-grid", c);
+
+                    return null;
+                }
+            }, IgniteException.class, null);
+
+            assert X.hasCause(t, IgniteSpiException.class) : "Unexpected exception: " + t;
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
      * @throws Exception If failed.
      */
     public void testDirtyIpFinder() throws Exception {


Mime
View raw message