JDBC thin driver: fixed borken handshake compatibility. This closes
@@ -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,7 +246,60 @@ public class JdbcThinTcpIo {
}
else
igniteVer = new IgniteProductVersion((byte)2, (byte)0, (byte)0, "Unknown", 0L, null);
+
+ srvProtocolVer = CURRENT_VER;
+ }
+ else {
+ short maj = reader.readShort();
+ short min = reader.readShort();
+ short maintenance = reader.readShort();
+
+ 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();
