Vladsz83 commented on code in PR #12671:
URL: https://github.com/apache/ignite/pull/12671#discussion_r2757716901


##########
modules/compatibility/src/test/java/org/apache/ignite/compatibility/spi/discovery/TcpDiscoveryDifferentClusterVersionsTest.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.compatibility.spi.discovery;
+
+import org.apache.ignite.compatibility.IgniteReleasedVersion;
+import 
org.apache.ignite.compatibility.testframework.junits.IgniteCompatibilityAbstractTest;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.junit.Test;
+
+/** */
+public class TcpDiscoveryDifferentClusterVersionsTest extends 
IgniteCompatibilityAbstractTest {
+    /** */
+    private static final String LEGACY_PROTOCOL_MSG = "Remote node uses legacy 
discovery protocol";
+
+    /** */
+    private static final IgniteReleasedVersion OLD_VERSION = 
IgniteReleasedVersion.VER_2_17_0;
+
+    /** */
+    private ListeningTestLogger listeningLog;
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        if (listeningLog != null)
+            cfg.setGridLogger(listeningLog);
+
+        return cfg;
+    }
+
+    /**
+     * Compatibility test that ensures previous-version client fails to 
connect to current server

Review Comment:
   suggestion: 'Tests that connection from client of old version is properly 
refused.'



##########
modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridConnectionBytesVerifyFilter.java:
##########
@@ -99,27 +99,27 @@ public GridConnectionBytesVerifyFilter(IgniteLogger log) {
 
         Integer magic = ses.meta(MAGIC_META_KEY);
 
-        if (magic == null || magic < U.IGNITE_HEADER.length) {
+        if (magic == null || magic < U.IGNITE_HEADER_V1.length) {
             byte[] magicBuf = ses.meta(MAGIC_BUF_KEY);
 
             if (magicBuf == null)
-                magicBuf = new byte[U.IGNITE_HEADER.length];
+                magicBuf = new byte[U.IGNITE_HEADER_V1.length];

Review Comment:
   Do we need to use V2 header here?



##########
modules/compatibility/src/test/java/org/apache/ignite/compatibility/spi/discovery/TcpDiscoveryDifferentClusterVersionsTest.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.compatibility.spi.discovery;
+
+import org.apache.ignite.compatibility.IgniteReleasedVersion;
+import 
org.apache.ignite.compatibility.testframework.junits.IgniteCompatibilityAbstractTest;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.ListeningTestLogger;
+import org.apache.ignite.testframework.LogListener;
+import org.junit.Test;
+
+/** */
+public class TcpDiscoveryDifferentClusterVersionsTest extends 
IgniteCompatibilityAbstractTest {
+    /** */
+    private static final String LEGACY_PROTOCOL_MSG = "Remote node uses legacy 
discovery protocol";
+
+    /** */
+    private static final IgniteReleasedVersion OLD_VERSION = 
IgniteReleasedVersion.VER_2_17_0;
+
+    /** */
+    private ListeningTestLogger listeningLog;
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String 
igniteInstanceName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        if (listeningLog != null)
+            cfg.setGridLogger(listeningLog);
+
+        return cfg;
+    }
+
+    /**
+     * Compatibility test that ensures previous-version client fails to 
connect to current server
+     * and server reports different IGNITE_HEADER.
+     */
+    @Test
+    public void testOldClientRejected() throws Exception {
+        setLoggerDebugLevel();
+
+        listeningLog = new ListeningTestLogger(log);
+
+        LogListener logListener = 
LogListener.matches(LEGACY_PROTOCOL_MSG).build();
+
+        listeningLog.registerListener(logListener);
+
+        startGrid(0);
+
+        GridTestUtils.assertThrows(
+            log,
+            () -> startGrid("old-client", OLD_VERSION.toString(), cfg -> 
cfg.setClientMode(true)),

Review Comment:
   Why do we check only client node?



##########
modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java:
##########
@@ -348,7 +348,10 @@ public abstract class IgniteUtils extends CommonUtils {
         indexOf('.', IgniteUtils.class.getName().indexOf('.') + 1));
 
     /** Network packet header. */
-    public static final byte[] IGNITE_HEADER = intToBytes(0x00004747);
+    public static final byte[] IGNITE_HEADER_V1 = intToBytes(0x00004747);
+
+    /** Network packet header. */

Review Comment:
   Let's describe in the javadoc what is this new header for.



##########
modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java:
##########
@@ -621,7 +621,12 @@ private T2<Collection<InetSocketAddress>, Boolean> 
requestAddresses(InetAddress
 
                             byte[] data = resPckt.getData();
 
-                            if (!U.bytesEqual(U.IGNITE_HEADER, 0, data, 0, 
U.IGNITE_HEADER.length)) {
+                            if (!U.bytesEqual(U.IGNITE_HEADER_V2, 0, data, 0, 
U.IGNITE_HEADER_V2.length)) {
+                                if (U.bytesEqual(U.IGNITE_HEADER_V1, 0, data, 
0, U.IGNITE_HEADER_V1.length)) {
+                                    log.warning("Received message with old 
header.");

Review Comment:
   Suggestion: 'old header' -> 'the old header'



##########
modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java:
##########
@@ -6638,7 +6638,16 @@ private class SocketReader extends IgniteSpiThread {
                         }
                     }
 
-                    if (!Arrays.equals(buf, U.IGNITE_HEADER)) {
+                    if (!Arrays.equals(buf, U.IGNITE_HEADER_V2)) {
+                        if (Arrays.equals(buf, U.IGNITE_HEADER_V1)) {
+                            if (log.isDebugEnabled())
+                                log.debug("Remote node uses legacy discovery 
protocol (V1), local expects V2 " +

Review Comment:
   Suggestion: 'Remote node uses legacy discovery protocol (V1), local expects 
V2' -> 'Remote node uses legacy discovery protocol (V1) (before the rolling 
upgrade compatibility). Local node expects V2.'



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to