ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [1/2] ignite git commit: IGNITE-6291: JDBC thin driver: fixed borken handshake compatibility. This closes #2630.
Date Mon, 11 Sep 2017 13:00:43 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-5896 d4021b56c -> 6e0fc714e


IGNITE-6291: JDBC thin driver: fixed borken handshake compatibility. This closes #2630.


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

Branch: refs/heads/ignite-5896
Commit: d9481b59349e8d43d449bf8426ea3b17768a62e2
Parents: e383dc4
Author: tledkov-gridgain <tledkov@gridgain.com>
Authored: Mon Sep 11 13:05:58 2017 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Mon Sep 11 13:05:58 2017 +0300

----------------------------------------------------------------------
 .../internal/jdbc/thin/JdbcThinTcpIo.java       | 59 ++++++++++++++++++++
 1 file changed, 59 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d9481b59/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
index b9dce05..f29f8b1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
@@ -68,6 +68,9 @@ public class JdbcThinTcpIo {
     /** Current version. */
     private static final SqlListenerProtocolVersion CURRENT_VER = SqlListenerProtocolVersion.create(2,
1, 5);
 
+    /** Version 2.1.0. */
+    private static final SqlListenerProtocolVersion VER_2_1_0 = SqlListenerProtocolVersion.create(2,
1, 0);
+
     /** Initial output stream capacity for handshake. */
     private static final int HANDSHAKE_MSG_SIZE = 13;
 
@@ -134,6 +137,9 @@ public class JdbcThinTcpIo {
     /** Ignite server version. */
     private IgniteProductVersion igniteVer;
 
+    /** Ignite server protocol version. */
+    private SqlListenerProtocolVersion srvProtocolVer;
+
     /**
      * Constructor.
      *
@@ -240,6 +246,8 @@ public class JdbcThinTcpIo {
             }
             else
                 igniteVer = new IgniteProductVersion((byte)2, (byte)0, (byte)0, "Unknown",
0L, null);
+
+            srvProtocolVer = CURRENT_VER;
         }
         else {
             short maj = reader.readShort();
@@ -248,6 +256,57 @@ public class JdbcThinTcpIo {
 
             String err = reader.readString();
 
+            srvProtocolVer = SqlListenerProtocolVersion.create(maj, min, maintenance);
+
+            if (VER_2_1_0.equals(srvProtocolVer))
+                handshake_2_1_0();
+            else {
+                throw new IgniteCheckedException("Handshake failed [driverProtocolVer=" +
CURRENT_VER +
+                    ", remoteNodeProtocolVer=" + srvProtocolVer + ", err=" + err + ']');
+            }
+        }
+    }
+
+    /**
+     * Compatibility handshake for server version 2.1.0
+     *
+     * @throws IOException On error.
+     * @throws IgniteCheckedException On error.
+     */
+    public void handshake_2_1_0() throws IOException, IgniteCheckedException {
+        BinaryWriterExImpl writer = new BinaryWriterExImpl(null, new BinaryHeapOutputStream(HANDSHAKE_MSG_SIZE),
+            null, null);
+
+        writer.writeByte((byte)SqlListenerRequest.HANDSHAKE);
+
+        writer.writeShort(VER_2_1_0.major());
+        writer.writeShort(VER_2_1_0.minor());
+        writer.writeShort(VER_2_1_0.maintenance());
+
+        writer.writeByte(SqlListenerNioListener.JDBC_CLIENT);
+
+        writer.writeBoolean(distributedJoins);
+        writer.writeBoolean(enforceJoinOrder);
+        writer.writeBoolean(collocated);
+        writer.writeBoolean(replicatedOnly);
+        writer.writeBoolean(autoCloseServerCursor);
+
+        send(writer.array());
+
+        BinaryReaderExImpl reader = new BinaryReaderExImpl(null, new BinaryHeapInputStream(read()),
+            null, null, false);
+
+        boolean accepted = reader.readBoolean();
+
+        if (accepted)
+            igniteVer = new IgniteProductVersion((byte)2, (byte)1, (byte)0, "Unknown", 0L,
null);
+        else {
+            short maj = reader.readShort();
+            short min = reader.readShort();
+            short maintenance = reader.readShort();
+
+            String err = reader.readString();
+
             SqlListenerProtocolVersion ver = SqlListenerProtocolVersion.create(maj, min,
maintenance);
 
             throw new IgniteCheckedException("Handshake failed [driverProtocolVer=" + CURRENT_VER
+


Mime
View raw message