Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 87F88200D04 for ; Mon, 11 Sep 2017 15:00:45 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 868F51609C5; Mon, 11 Sep 2017 13:00:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id CAF231609C3 for ; Mon, 11 Sep 2017 15:00:44 +0200 (CEST) Received: (qmail 92379 invoked by uid 500); 11 Sep 2017 13:00:43 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 92370 invoked by uid 99); 11 Sep 2017 13:00:43 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Sep 2017 13:00:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4F832F32A9; Mon, 11 Sep 2017 13:00:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.apache.org Date: Mon, 11 Sep 2017 13:00:43 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] ignite git commit: IGNITE-6291: JDBC thin driver: fixed borken handshake compatibility. This closes #2630. archived-at: Mon, 11 Sep 2017 13:00:45 -0000 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 Authored: Mon Sep 11 13:05:58 2017 +0300 Committer: devozerov 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 +