IGNITE-1924 Incomplete marshaller cache rebalancing causes Grid hangs under SSL


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

Branch: refs/heads/ignite-ssl-hotfix
Commit: 447e07c0bb5af75bce6a14612606904e4e3d9705
Parents: b1ec58f
Author: Anton Vinogradov <a...@apache.org>
Authored: Fri Oct 14 11:40:41 2016 +0300
Committer: Anton Vinogradov <a...@apache.org>
Committed: Fri Oct 14 11:40:41 2016 +0300

----------------------------------------------------------------------
 .../dht/GridDhtAffinityAssignmentRequest.java   |  2 +-
 .../util/nio/GridNioSessionMetaKey.java         |  7 +-
 .../util/nio/ssl/BlockingSslHandler.java        |  9 +-
 .../internal/util/nio/ssl/GridNioSslFilter.java | 63 ++++++++++---
 .../util/nio/ssl/GridNioSslHandler.java         | 17 ++--
 .../internal/util/nio/ssl/GridSslMeta.java      | 94 ++++++++++++++++++++
 .../communication/tcp/TcpCommunicationSpi.java  | 49 ++++++----
 ...mmunicationSpiConcurrentConnectSelfTest.java | 14 +++
 ...nicationSpiConcurrentConnectSslSelfTest.java | 35 ++++++++
 ...GridTcpCommunicationSpiRecoverySelfTest.java | 14 +++
 ...dTcpCommunicationSpiRecoverySslSelfTest.java | 35 ++++++++
 .../tcp/IgniteCacheSslStartStopSelfTest.java    |  1 -
 .../IgniteSpiCommunicationSelfTestSuite.java    |  4 +
 13 files changed, 301 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java
index 0ef7606..6959906 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtAffinityAssignmentRequest.java
@@ -130,6 +130,6 @@ public class GridDhtAffinityAssignmentRequest extends 
GridCacheMessage {
 
     /** {@inheritDoc} */
     @Override public String toString() {
-        return S.toString(GridDhtAffinityAssignmentRequest.class, this);
+        return S.toString(GridDhtAffinityAssignmentRequest.class, this, 
super.toString());
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKey.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKey.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKey.java
index b5387d9..bdb3a29 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKey.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioSessionMetaKey.java
@@ -26,8 +26,8 @@ public enum GridNioSessionMetaKey {
     /** NIO parser state. */
     PARSER_STATE,
 
-    /** SSL handler. */
-    SSL_HANDLER,
+    /** SSL Meta. */
+    SSL_META,
 
     /** NIO operation (request type). */
     NIO_OPERATION,
@@ -44,9 +44,6 @@ public enum GridNioSessionMetaKey {
     /** Message writer. */
     MSG_WRITER,
 
-    /** SSL engine. */
-    SSL_ENGINE,
-
     /** Ack closure. */
     ACK_CLOSURE;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
index bb566cd..273df5d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/BlockingSslHandler.java
@@ -113,6 +113,13 @@ public class BlockingSslHandler {
     }
 
     /**
+     *
+     */
+    public ByteBuffer inputBuffer(){
+        return inNetBuf;
+    }
+
+    /**
      * Performs handshake procedure with remote peer.
      *
      * @throws GridNioException If filter processing has thrown an exception.
@@ -255,7 +262,7 @@ public class BlockingSslHandler {
      * @throws SSLException If failed to process SSL data.
      */
     public ByteBuffer decode(ByteBuffer buf) throws IgniteCheckedException, 
SSLException {
-        inNetBuf.clear();
+        appBuf.clear();
 
         if (buf.limit() > inNetBuf.remaining()) {
             inNetBuf = expandBuffer(inNetBuf, inNetBuf.capacity() + 
buf.limit() * 2);

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
index 63cdd83..d6f9d10 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslFilter.java
@@ -35,7 +35,7 @@ import org.apache.ignite.internal.util.nio.GridNioSession;
 import org.apache.ignite.internal.util.nio.GridNioSessionMetaKey;
 import org.apache.ignite.internal.util.typedef.internal.U;
 
-import static 
org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.SSL_HANDLER;
+import static 
org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.SSL_META;
 
 /**
  * Implementation of SSL filter using {@link SSLEngine}
@@ -154,28 +154,61 @@ public class GridNioSslFilter extends 
GridNioFilterAdapter {
         if (log.isDebugEnabled())
             log.debug("Remote client connected, creating SSL handler and 
performing initial handshake: " + ses);
 
-        SSLEngine engine = sslCtx.createSSLEngine();
+        SSLEngine engine;
 
-        engine.setUseClientMode(clientMode);
+        boolean handshake;
 
-        if (!clientMode) {
-            engine.setWantClientAuth(wantClientAuth);
+        GridSslMeta sslMeta = ses.meta(SSL_META.ordinal());
 
-            engine.setNeedClientAuth(needClientAuth);
+        if (sslMeta == null) {
+            engine = sslCtx.createSSLEngine();
+
+            engine.setUseClientMode(clientMode);
+
+            if (!clientMode) {
+                engine.setWantClientAuth(wantClientAuth);
+
+                engine.setNeedClientAuth(needClientAuth);
+            }
+
+            if (enabledCipherSuites != null)
+                engine.setEnabledCipherSuites(enabledCipherSuites);
+
+            if (enabledProtos != null)
+                engine.setEnabledProtocols(enabledProtos);
+
+            sslMeta = new GridSslMeta();
+
+            ses.addMeta(SSL_META.ordinal(), sslMeta);
+
+            handshake = true;
         }
+        else {
+            engine = sslMeta.sslEngine();
 
-        if (enabledCipherSuites != null)
-            engine.setEnabledCipherSuites(enabledCipherSuites);
+            assert engine != null;
 
-        if (enabledProtos != null)
-            engine.setEnabledProtocols(enabledProtos);
+            handshake = false;
+        }
 
         try {
-            GridNioSslHandler hnd = new GridNioSslHandler(this, ses, engine, 
directBuf, order, log);
+            GridNioSslHandler hnd = new GridNioSslHandler(this,
+                ses,
+                engine,
+                directBuf,
+                order,
+                log,
+                handshake,
+                sslMeta.encodedBuffer());
 
-            ses.addMeta(SSL_HANDLER.ordinal(), hnd);
+            sslMeta.handler(hnd);
 
             hnd.handshake();
+
+            ByteBuffer alreadyDecoded = sslMeta.decodedBuffer();
+
+            if (alreadyDecoded != null)
+                proceedMessageReceived(ses, alreadyDecoded);
         }
         catch (SSLException e) {
             U.error(log, "Failed to start SSL handshake (will close inbound 
connection): " + ses, e);
@@ -379,7 +412,11 @@ public class GridNioSslFilter extends GridNioFilterAdapter 
{
      * @return SSL handler.
      */
     private GridNioSslHandler sslHandler(GridNioSession ses) {
-        GridNioSslHandler hnd = ses.meta(SSL_HANDLER.ordinal());
+        GridSslMeta sslMeta = ses.meta(SSL_META.ordinal());
+
+        assert sslMeta != null;
+
+        GridNioSslHandler hnd = sslMeta.handler();
 
         if (hnd == null)
             throw new IgniteException("Failed to process incoming message 
(received message before SSL handler " +

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
index 3272b8e..eb8dad4 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridNioSslHandler.java
@@ -43,7 +43,6 @@ import static 
javax.net.ssl.SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING;
 import static javax.net.ssl.SSLEngineResult.Status;
 import static javax.net.ssl.SSLEngineResult.Status.BUFFER_UNDERFLOW;
 import static javax.net.ssl.SSLEngineResult.Status.CLOSED;
-import static 
org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.SSL_ENGINE;
 import static 
org.apache.ignite.internal.util.nio.ssl.GridNioSslFilter.HANDSHAKE_FUT_META_KEY;
 
 /**
@@ -104,6 +103,8 @@ class GridNioSslHandler extends ReentrantLock {
      * @param log Logger to use.
      * @param directBuf Direct buffer flag.
      * @param order Byte order.
+     * @param handshake is handshake required.
+     * @param encBuf encoded buffer to be used.
      * @throws SSLException If exception occurred when starting SSL handshake.
      */
     GridNioSslHandler(GridNioSslFilter parent,
@@ -111,7 +112,9 @@ class GridNioSslHandler extends ReentrantLock {
         SSLEngine engine,
         boolean directBuf,
         ByteOrder order,
-        IgniteLogger log) throws SSLException {
+        IgniteLogger log,
+        boolean handshake,
+        ByteBuffer encBuf) throws SSLException {
         assert parent != null;
         assert ses != null;
         assert engine != null;
@@ -125,11 +128,9 @@ class GridNioSslHandler extends ReentrantLock {
 
         sslEngine = engine;
 
-        if (ses.meta(SSL_ENGINE.ordinal()) == null)
+        if (handshake)
             sslEngine.beginHandshake();
         else {
-            sslEngine = ses.meta(SSL_ENGINE.ordinal());
-
             handshakeFinished = true;
             initHandshakeComplete = true;
         }
@@ -147,6 +148,12 @@ class GridNioSslHandler extends ReentrantLock {
 
         inNetBuf.order(order);
 
+        if (encBuf != null) {
+            encBuf.flip();
+
+            inNetBuf.put(encBuf); // Buffer contains bytes read but not 
handled by sslEngine at BlockingSslHandler.
+        }
+
         // Initially buffer is empty.
         outNetBuf.position(0);
         outNetBuf.limit(0);

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridSslMeta.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridSslMeta.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridSslMeta.java
new file mode 100644
index 0000000..5ca68b7
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/ssl/GridSslMeta.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.nio.ssl;
+
+import java.nio.ByteBuffer;
+import javax.net.ssl.SSLEngine;
+
+/**
+ *
+ */
+public class GridSslMeta {
+    /** GridNioSslHandler. */
+    private GridNioSslHandler hnd;
+
+    /** Data already decoded by blocking ssl handler. */
+    private ByteBuffer decodedBuf;
+
+    /** Data read but not decoded by blocking ssl handler. */
+    private ByteBuffer encodedBuf;
+
+    /** Ssl engine. */
+    private SSLEngine sslEngine;
+
+    /**
+     *
+     */
+    public SSLEngine sslEngine() {
+        return sslEngine;
+    }
+
+    /**
+     * @param sslEngine Ssl engine.
+     */
+    public void sslEngine(SSLEngine sslEngine) {
+        this.sslEngine = sslEngine;
+    }
+
+    /**
+     *
+     */
+    public GridNioSslHandler handler() {
+        return hnd;
+    }
+
+    /**
+     * @param hnd Handler.
+     */
+    public void handler(GridNioSslHandler hnd) {
+        this.hnd = hnd;
+    }
+
+    /**
+     *
+     */
+    public ByteBuffer decodedBuffer() {
+        return decodedBuf;
+    }
+
+    /**
+     * @param decodedBuf Decoded buffer.
+     */
+    public void decodedBuffer(ByteBuffer decodedBuf) {
+        this.decodedBuf = decodedBuf;
+    }
+
+    /**
+     *
+     */
+    public ByteBuffer encodedBuffer() {
+        return encodedBuf;
+    }
+
+    /**
+     * @param encodedBuf Encoded buffer.
+     */
+    public void encodedBuffer(ByteBuffer encodedBuf) {
+        this.encodedBuf = encodedBuf;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
 
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index d61cee6..0bbb4d3 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -90,6 +90,7 @@ import 
org.apache.ignite.internal.util.nio.GridShmemCommunicationClient;
 import org.apache.ignite.internal.util.nio.GridTcpNioCommunicationClient;
 import org.apache.ignite.internal.util.nio.ssl.BlockingSslHandler;
 import org.apache.ignite.internal.util.nio.ssl.GridNioSslFilter;
+import org.apache.ignite.internal.util.nio.ssl.GridSslMeta;
 import org.apache.ignite.internal.util.typedef.CI2;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.X;
@@ -131,6 +132,7 @@ import org.jsr166.LongAdder8;
 
 import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
 import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
+import static 
org.apache.ignite.internal.util.nio.GridNioSessionMetaKey.SSL_META;
 
 /**
  * <tt>TcpCommunicationSpi</tt> is default communication SPI which uses
@@ -2376,19 +2378,28 @@ public class TcpCommunicationSpi extends 
IgniteSpiAdapter
 
                     long rcvCnt = -1;
 
-                    SSLEngine sslEngine = null;
+                    Map<Integer, Object> meta = new HashMap<>();
+
+                    GridSslMeta sslMeta = null;
 
                     try {
                         ch.socket().connect(addr, 
(int)timeoutHelper.nextTimeoutChunk(connTimeout));
 
                         if (isSslEnabled()) {
-                            sslEngine = 
ignite.configuration().getSslContextFactory().create().createSSLEngine();
+                            meta.put(SSL_META.ordinal(), sslMeta = new 
GridSslMeta());
+
+                            SSLEngine sslEngine = 
ignite.configuration().getSslContextFactory().create().createSSLEngine();
 
                             sslEngine.setUseClientMode(true);
+
+                            sslMeta.sslEngine(sslEngine);
                         }
 
-                        rcvCnt = safeHandshake(ch, recoveryDesc, node.id(),
-                            timeoutHelper.nextTimeoutChunk(connTimeout0), 
sslEngine);
+                        rcvCnt = safeHandshake(ch,
+                            recoveryDesc,
+                            node.id(),
+                            timeoutHelper.nextTimeoutChunk(connTimeout0),
+                            sslMeta);
 
                         if (rcvCnt == -1)
                             return null;
@@ -2399,16 +2410,8 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
                     }
 
                     try {
-                        Map<Integer, Object> meta = new HashMap<>();
-
                         meta.put(NODE_ID_META, node.id());
 
-                        if (isSslEnabled()) {
-                            assert sslEngine != null;
-
-                            
meta.put(GridNioSessionMetaKey.SSL_ENGINE.ordinal(), sslEngine);
-                        }
-
                         if (recoveryDesc != null) {
                             recoveryDesc.onHandshake(rcvCnt);
 
@@ -2560,7 +2563,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
      * @param recovery Recovery descriptor if use recovery handshake, 
otherwise {@code null}.
      * @param rmtNodeId Remote node.
      * @param timeout Timeout for handshake.
-     * @param ssl SSL engine if used cryptography, otherwise {@code null}.
+     * @param sslMeta Session meta.
      * @throws IgniteCheckedException If handshake failed or wasn't completed 
withing timeout.
      * @return Handshake response.
      */
@@ -2570,7 +2573,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
         @Nullable GridNioRecoveryDescriptor recovery,
         UUID rmtNodeId,
         long timeout,
-        @Nullable SSLEngine ssl
+        GridSslMeta sslMeta
     ) throws IgniteCheckedException {
         HandshakeTimeoutObject<T> obj = new HandshakeTimeoutObject<>(client, 
U.currentTimeMillis() + timeout);
 
@@ -2592,7 +2595,9 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
                     ByteBuffer buf;
 
                     if (isSslEnabled()) {
-                        sslHnd = new BlockingSslHandler(ssl, ch, directBuf, 
ByteOrder.nativeOrder(), log);
+                        assert sslMeta != null;
+
+                        sslHnd = new BlockingSslHandler(sslMeta.sslEngine(), 
ch, directBuf, ByteOrder.nativeOrder(), log);
 
                         if (!sslHnd.handshake())
                             throw new IgniteCheckedException("SSL handshake is 
not completed.");
@@ -2710,11 +2715,21 @@ public class TcpCommunicationSpi extends 
IgniteSpiAdapter
 
                                 i += decode.remaining();
 
-                                buf.flip();
-                                buf.compact();
+                                buf.clear();
                             }
 
                             rcvCnt = decode.getLong(1);
+
+                            if (decode.limit() > 9) {
+                                decode.position(9);
+
+                                sslMeta.decodedBuffer(decode);
+                            }
+
+                            ByteBuffer inBuf = sslHnd.inputBuffer();
+
+                            if (inBuf.position() > 0)
+                                sslMeta.encodedBuffer(inBuf);
                         }
                         else {
                             buf = ByteBuffer.allocate(9);

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java
index 97eb34c..8635d94 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSelfTest.java
@@ -33,6 +33,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.managers.communication.GridIoMessageFactory;
 import org.apache.ignite.internal.util.lang.GridAbsPredicate;
@@ -49,6 +50,7 @@ import org.apache.ignite.spi.communication.GridTestMessage;
 import org.apache.ignite.testframework.GridSpiTestContext;
 import org.apache.ignite.testframework.GridTestNode;
 import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.IgniteMock;
 import org.apache.ignite.testframework.junits.IgniteTestResources;
 import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest;
 import org.apache.ignite.testframework.junits.spi.GridSpiTest;
@@ -78,6 +80,9 @@ public class 
GridTcpCommunicationSpiConcurrentConnectSelfTest<T extends Communic
     /** */
     private static int port = 60_000;
 
+    /** Use ssl. */
+    protected boolean useSsl;
+
     /**
      *
      */
@@ -351,6 +356,15 @@ public class 
GridTcpCommunicationSpiConcurrentConnectSelfTest<T extends Communic
 
             rsrcs.inject(spi);
 
+            if (useSsl) {
+                IgniteMock ignite = GridTestUtils.getFieldValue(spi, 
IgniteSpiAdapter.class, "ignite");
+
+                IgniteConfiguration cfg = ignite.configuration()
+                    .setSslContextFactory(GridTestUtils.sslFactory());
+
+                ignite.setStaticCfg(cfg);
+            }
+
             spi.setListener(lsnr);
 
             node.setAttributes(spi.getNodeAttributes());

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSslSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSslSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSslSelfTest.java
new file mode 100644
index 0000000..f2b9a50
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiConcurrentConnectSslSelfTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.spi.communication.tcp;
+
+/**
+ *
+ */
+public class GridTcpCommunicationSpiConcurrentConnectSslSelfTest extends 
GridTcpCommunicationSpiConcurrentConnectSelfTest {
+    /**
+     * Default constructor.
+     */
+    public GridTcpCommunicationSpiConcurrentConnectSslSelfTest() {
+        useSsl = true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return super.getTestTimeout() * 4;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java
index 94dc665..3234d74 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySelfTest.java
@@ -29,6 +29,7 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.managers.communication.GridIoMessageFactory;
 import org.apache.ignite.internal.util.lang.GridAbsPredicate;
@@ -46,6 +47,7 @@ import org.apache.ignite.spi.communication.GridTestMessage;
 import org.apache.ignite.testframework.GridSpiTestContext;
 import org.apache.ignite.testframework.GridTestNode;
 import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.IgniteMock;
 import org.apache.ignite.testframework.junits.IgniteTestResources;
 import org.apache.ignite.testframework.junits.spi.GridSpiAbstractTest;
 import org.apache.ignite.testframework.junits.spi.GridSpiTest;
@@ -74,6 +76,9 @@ public class GridTcpCommunicationSpiRecoverySelfTest<T 
extends CommunicationSpi>
     /** */
     protected static int port = 30_000;
 
+    /** Use ssl. */
+    protected boolean useSsl;
+
     /**
      *
      */
@@ -670,6 +675,15 @@ public class GridTcpCommunicationSpiRecoverySelfTest<T 
extends CommunicationSpi>
 
             rsrcs.inject(spi);
 
+            if (useSsl) {
+                IgniteMock ignite = GridTestUtils.getFieldValue(spi, 
IgniteSpiAdapter.class, "ignite");
+
+                IgniteConfiguration cfg = ignite.configuration()
+                    .setSslContextFactory(GridTestUtils.sslFactory());
+
+                ignite.setStaticCfg(cfg);
+            }
+
             spi.setListener(new TestListener());
 
             node.setAttributes(spi.getNodeAttributes());

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySslSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySslSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySslSelfTest.java
new file mode 100644
index 0000000..4182ea1
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiRecoverySslSelfTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.spi.communication.tcp;
+
+/**
+ *
+ */
+public class GridTcpCommunicationSpiRecoverySslSelfTest extends 
GridTcpCommunicationSpiRecoverySelfTest {
+    /**
+     * Default constructor.
+     */
+    public GridTcpCommunicationSpiRecoverySslSelfTest() {
+        useSsl = true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return super.getTestTimeout() * 2;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteCacheSslStartStopSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteCacheSslStartStopSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteCacheSslStartStopSelfTest.java
index 12bd020..3324fcc 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteCacheSslStartStopSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/IgniteCacheSslStartStopSelfTest.java
@@ -32,7 +32,6 @@ public class IgniteCacheSslStartStopSelfTest extends 
IgniteCachePutRetryAbstract
     @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        fail("https://issues.apache.org/jira/browse/IGNITE-1924";);
         cfg.setSslContextFactory(GridTestUtils.sslFactory());
 
         return cfg;

http://git-wip-us.apache.org/repos/asf/ignite/blob/447e07c0/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java
 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java
index d48c2c4..eb88524 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiCommunicationSelfTestSuite.java
@@ -19,12 +19,14 @@ package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
 import 
org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiConcurrentConnectSelfTest;
+import 
org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiConcurrentConnectSslSelfTest;
 import 
org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiConfigSelfTest;
 import 
org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiMultithreadedSelfTest;
 import 
org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiMultithreadedShmemTest;
 import 
org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiRecoveryAckSelfTest;
 import 
org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiRecoveryFailureDetectionSelfTest;
 import 
org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiRecoverySelfTest;
+import 
org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiRecoverySslSelfTest;
 import 
org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiShmemSelfTest;
 import 
org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiStartStopSelfTest;
 import 
org.apache.ignite.spi.communication.tcp.GridTcpCommunicationSpiTcpFailureDetectionSelfTest;
@@ -46,8 +48,10 @@ public class IgniteSpiCommunicationSelfTestSuite extends 
TestSuite {
         suite.addTest(new 
TestSuite(GridTcpCommunicationSpiRecoveryAckSelfTest.class));
         suite.addTest(new 
TestSuite(IgniteTcpCommunicationRecoveryAckClosureSelfTest.class));
         suite.addTest(new 
TestSuite(GridTcpCommunicationSpiRecoverySelfTest.class));
+        suite.addTest(new 
TestSuite(GridTcpCommunicationSpiRecoverySslSelfTest.class));
 
         suite.addTest(new 
TestSuite(GridTcpCommunicationSpiConcurrentConnectSelfTest.class));
+        suite.addTest(new 
TestSuite(GridTcpCommunicationSpiConcurrentConnectSslSelfTest.class));
 
         suite.addTest(new TestSuite(GridTcpCommunicationSpiTcpSelfTest.class));
         suite.addTest(new 
TestSuite(GridTcpCommunicationSpiTcpNoDelayOffSelfTest.class));

Reply via email to