ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject ignite git commit: IGNITE-6118: JDBC thin driver: added lazy execution flag. This closes #2491.
Date Tue, 29 Aug 2017 07:54:01 GMT
Repository: ignite
Updated Branches:
  refs/heads/master ebfa5557b -> d20f30203


IGNITE-6118: JDBC thin driver: added lazy execution flag. This closes #2491.


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

Branch: refs/heads/master
Commit: d20f302036206e6215d3ecea923747014f4e2bcf
Parents: ebfa555
Author: tledkov-gridgain <tledkov@gridgain.com>
Authored: Tue Aug 29 10:53:48 2017 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Tue Aug 29 10:53:48 2017 +0300

----------------------------------------------------------------------
 .../jdbc/thin/JdbcThinConnectionSelfTest.java     | 16 +++++++++++++++-
 .../org/apache/ignite/IgniteJdbcThinDriver.java   |  4 +++-
 .../internal/jdbc/thin/JdbcThinConnection.java    |  4 +++-
 .../ignite/internal/jdbc/thin/JdbcThinTcpIo.java  | 18 ++++++++++++++++--
 .../ignite/internal/jdbc/thin/JdbcThinUtils.java  | 14 ++++++++++----
 .../processors/odbc/SqlListenerNioListener.java   | 16 ++++++++++++++--
 .../processors/odbc/jdbc/JdbcRequestHandler.java  |  9 ++++++++-
 7 files changed, 69 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d20f3020/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSelfTest.java
b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSelfTest.java
index 8f1285b..a2e7be1 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinConnectionSelfTest.java
@@ -158,6 +158,7 @@ public class JdbcThinConnectionSelfTest extends JdbcThinAbstractSelfTest
{
             assertFalse(io(conn).enforceJoinOrder());
             assertFalse(io(conn).collocated());
             assertFalse(io(conn).replicatedOnly());
+            assertFalse(io(conn).lazy());
         }
 
         try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1?distributedJoins=true"))
{
@@ -165,6 +166,7 @@ public class JdbcThinConnectionSelfTest extends JdbcThinAbstractSelfTest
{
             assertFalse(io(conn).enforceJoinOrder());
             assertFalse(io(conn).collocated());
             assertFalse(io(conn).replicatedOnly());
+            assertFalse(io(conn).lazy());
         }
 
         try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1?enforceJoinOrder=true"))
{
@@ -172,6 +174,7 @@ public class JdbcThinConnectionSelfTest extends JdbcThinAbstractSelfTest
{
             assertTrue(io(conn).enforceJoinOrder());
             assertFalse(io(conn).collocated());
             assertFalse(io(conn).replicatedOnly());
+            assertFalse(io(conn).lazy());
         }
 
         try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1?collocated=true"))
{
@@ -179,6 +182,7 @@ public class JdbcThinConnectionSelfTest extends JdbcThinAbstractSelfTest
{
             assertFalse(io(conn).enforceJoinOrder());
             assertTrue(io(conn).collocated());
             assertFalse(io(conn).replicatedOnly());
+            assertFalse(io(conn).lazy());
         }
 
         try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1?replicatedOnly=true"))
{
@@ -186,14 +190,24 @@ public class JdbcThinConnectionSelfTest extends JdbcThinAbstractSelfTest
{
             assertFalse(io(conn).enforceJoinOrder());
             assertFalse(io(conn).collocated());
             assertTrue(io(conn).replicatedOnly());
+            assertFalse(io(conn).lazy());
+        }
+
+        try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1?lazy=true"))
{
+            assertFalse(io(conn).distributedJoins());
+            assertFalse(io(conn).enforceJoinOrder());
+            assertFalse(io(conn).collocated());
+            assertFalse(io(conn).replicatedOnly());
+            assertTrue(io(conn).lazy());
         }
 
         try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1?distributedJoins=true&"
+
-                "enforceJoinOrder=true&collocated=true&replicatedOnly=true")) {
+            "enforceJoinOrder=true&collocated=true&replicatedOnly=true&lazy=true"))
{
             assertTrue(io(conn).distributedJoins());
             assertTrue(io(conn).enforceJoinOrder());
             assertTrue(io(conn).collocated());
             assertTrue(io(conn).replicatedOnly());
+            assertTrue(io(conn).lazy());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d20f3020/modules/core/src/main/java/org/apache/ignite/IgniteJdbcThinDriver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteJdbcThinDriver.java b/modules/core/src/main/java/org/apache/ignite/IgniteJdbcThinDriver.java
index 1392d62..7e23d7a 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteJdbcThinDriver.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteJdbcThinDriver.java
@@ -186,7 +186,8 @@ public class IgniteJdbcThinDriver implements Driver {
             new JdbcDriverPropertyInfo("Distributed Joins", info.getProperty(JdbcThinUtils.PROP_DISTRIBUTED_JOINS),
""),
             new JdbcDriverPropertyInfo("Enforce Join Order", info.getProperty(JdbcThinUtils.PROP_ENFORCE_JOIN_ORDER),
""),
             new JdbcDriverPropertyInfo("Collocated", info.getProperty(JdbcThinUtils.PROP_COLLOCATED),
""),
-            new JdbcDriverPropertyInfo("Replicated only", info.getProperty(JdbcThinUtils.PROP_REPLICATED_ONLY),
"")
+            new JdbcDriverPropertyInfo("Replicated only", info.getProperty(JdbcThinUtils.PROP_REPLICATED_ONLY),
""),
+            new JdbcDriverPropertyInfo("Lazy query execution flag", info.getProperty(JdbcThinUtils.PROP_LAZY),"")
         );
 
         return props.toArray(new DriverPropertyInfo[0]);
@@ -217,6 +218,7 @@ public class IgniteJdbcThinDriver implements Driver {
      *
      * @param props Properties.
      * @param url URL.
+     * @throws SQLException On error.
      */
     private void parseUrl(String url, Properties props) throws SQLException {
         if (F.isEmpty(url))

http://git-wip-us.apache.org/repos/asf/ignite/blob/d20f3020/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
index 8836cd5..1ed0844 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinConnection.java
@@ -46,6 +46,7 @@ import static java.sql.ResultSet.TYPE_FORWARD_ONLY;
 
 import static org.apache.ignite.internal.jdbc.thin.JdbcThinUtils.PROP_AUTO_CLOSE_SERVER_CURSORS;
 import static org.apache.ignite.internal.jdbc.thin.JdbcThinUtils.PROP_HOST;
+import static org.apache.ignite.internal.jdbc.thin.JdbcThinUtils.PROP_LAZY;
 import static org.apache.ignite.internal.jdbc.thin.JdbcThinUtils.PROP_PORT;
 import static org.apache.ignite.internal.jdbc.thin.JdbcThinUtils.PROP_DISTRIBUTED_JOINS;
 import static org.apache.ignite.internal.jdbc.thin.JdbcThinUtils.PROP_ENFORCE_JOIN_ORDER;
@@ -119,6 +120,7 @@ public class JdbcThinConnection implements Connection {
         boolean collocated = extractBoolean(props, PROP_COLLOCATED, false);
         boolean replicatedOnly = extractBoolean(props, PROP_REPLICATED_ONLY, false);
         boolean autoCloseServerCursor = extractBoolean(props, PROP_AUTO_CLOSE_SERVER_CURSORS,
false);
+        boolean lazyExec = extractBoolean(props, PROP_LAZY, false);
 
         int sockSndBuf = extractIntNonNegative(props, PROP_SOCK_SND_BUF, 0);
         int sockRcvBuf = extractIntNonNegative(props, PROP_SOCK_RCV_BUF, 0);
@@ -127,7 +129,7 @@ public class JdbcThinConnection implements Connection {
 
         try {
             cliIo = new JdbcThinTcpIo(host, port, distributedJoins, enforceJoinOrder, collocated,
replicatedOnly,
-                autoCloseServerCursor, sockSndBuf, sockRcvBuf, tcpNoDelay);
+                autoCloseServerCursor, lazyExec, sockSndBuf, sockRcvBuf, tcpNoDelay);
 
             cliIo.start();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d20f3020/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 fdec77e..b9dce05 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
@@ -66,7 +66,7 @@ import org.apache.ignite.lang.IgniteProductVersion;
  */
 public class JdbcThinTcpIo {
     /** Current version. */
-    private static final SqlListenerProtocolVersion CURRENT_VER = SqlListenerProtocolVersion.create(2,
1, 0);
+    private static final SqlListenerProtocolVersion CURRENT_VER = SqlListenerProtocolVersion.create(2,
1, 5);
 
     /** Initial output stream capacity for handshake. */
     private static final int HANDSHAKE_MSG_SIZE = 13;
@@ -104,6 +104,9 @@ public class JdbcThinTcpIo {
     /** Replicated only flag. */
     private final boolean replicatedOnly;
 
+    /** Lazy execution query flag. */
+    private final boolean lazy;
+
     /** Flag to automatically close server cursor. */
     private final boolean autoCloseServerCursor;
 
@@ -141,12 +144,14 @@ public class JdbcThinTcpIo {
      * @param collocated Collocated flag.
      * @param replicatedOnly Replicated only flag.
      * @param autoCloseServerCursor Flag to automatically close server cursors.
+     * @param lazy Lazy execution query flag.
      * @param sockSndBuf Socket send buffer.
      * @param sockRcvBuf Socket receive buffer.
      * @param tcpNoDelay TCP no delay flag.
      */
     JdbcThinTcpIo(String host, int port, boolean distributedJoins, boolean enforceJoinOrder,
boolean collocated,
-        boolean replicatedOnly, boolean autoCloseServerCursor, int sockSndBuf, int sockRcvBuf,
boolean tcpNoDelay) {
+        boolean replicatedOnly, boolean autoCloseServerCursor, boolean lazy, int sockSndBuf,
int sockRcvBuf,
+        boolean tcpNoDelay) {
         this.host = host;
         this.port = port;
         this.distributedJoins = distributedJoins;
@@ -154,6 +159,7 @@ public class JdbcThinTcpIo {
         this.collocated = collocated;
         this.replicatedOnly = replicatedOnly;
         this.autoCloseServerCursor = autoCloseServerCursor;
+        this.lazy = lazy;
         this.sockSndBuf = sockSndBuf;
         this.sockRcvBuf = sockRcvBuf;
         this.tcpNoDelay = tcpNoDelay;
@@ -210,6 +216,7 @@ public class JdbcThinTcpIo {
         writer.writeBoolean(collocated);
         writer.writeBoolean(replicatedOnly);
         writer.writeBoolean(autoCloseServerCursor);
+        writer.writeBoolean(lazy);
 
         send(writer.array());
 
@@ -540,4 +547,11 @@ public class JdbcThinTcpIo {
     IgniteProductVersion igniteVersion() {
         return igniteVer;
     }
+
+    /**
+     * @return Lazy query execution flag.
+     */
+    public boolean lazy() {
+        return lazy;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/d20f3020/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinUtils.java
index 78e8c8f..675cf2d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinUtils.java
@@ -54,18 +54,21 @@ public class JdbcThinUtils {
     /** Hostname property name. */
     public static final String PROP_HOST = PROP_PREFIX + "host";
 
-    /** Parameter: distributed joins flag. */
+    /** Parameter: distributed joins flag (SQL hint). */
     public static final String PARAM_DISTRIBUTED_JOINS = "distributedJoins";
 
-    /** Parameter: enforce join order flag. */
+    /** Parameter: enforce join order flag (SQL hint). */
     public static final String PARAM_ENFORCE_JOIN_ORDER = "enforceJoinOrder";
 
-    /** Parameter: collocated flag. */
+    /** Parameter: collocated flag (SQL hint). */
     public static final String PARAM_COLLOCATED = "collocated";
 
-    /** Parameter: replicated only flag. */
+    /** Parameter: lazy query execution flag (SQL hint). */
     public static final String PARAM_REPLICATED_ONLY = "replicatedOnly";
 
+    /** Parameter: replicated only flag (SQL hint). */
+    public static final String PARAM_LAZY = "lazy";
+
     /** Parameter: socket send buffer. */
     public static final String PARAM_SOCK_SND_BUF = "socketSendBuffer";
 
@@ -87,6 +90,9 @@ public class JdbcThinUtils {
     /** Collocated property name. */
     public static final String PROP_COLLOCATED = PROP_PREFIX + PARAM_COLLOCATED;
 
+    /** Lazy property name. */
+    public static final String PROP_LAZY = PROP_PREFIX + PARAM_LAZY;
+
     /** Replicated only property name. */
     public static final String PROP_REPLICATED_ONLY = PROP_PREFIX + PARAM_REPLICATED_ONLY;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d20f3020/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioListener.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioListener.java
index 5a49e3f..8dad71b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerNioListener.java
@@ -48,8 +48,14 @@ public class SqlListenerNioListener extends GridNioServerListenerAdapter<byte[]>
     /** The value corresponds to JDBC driver of the parser field of the handshake request.
*/
     public static final byte JDBC_CLIENT = 1;
 
+    /** Version 2.1.0. */
+    private static final SqlListenerProtocolVersion VER_2_1_0 = SqlListenerProtocolVersion.create(2,
1, 0);
+
+    /** Version 2.1.5: added "lazy" flag. */
+    private static final SqlListenerProtocolVersion VER_2_1_5 = SqlListenerProtocolVersion.create(2,
1, 5);
+
     /** Current version. */
-    private static final SqlListenerProtocolVersion CURRENT_VER = SqlListenerProtocolVersion.create(2,
1, 0);
+    private static final SqlListenerProtocolVersion CURRENT_VER = VER_2_1_5;
 
     /** Supported versions. */
     private static final Set<SqlListenerProtocolVersion> SUPPORTED_VERS = new HashSet<>();
@@ -74,6 +80,7 @@ public class SqlListenerNioListener extends GridNioServerListenerAdapter<byte[]>
 
     static {
         SUPPORTED_VERS.add(CURRENT_VER);
+        SUPPORTED_VERS.add(VER_2_1_0);
     }
 
     /**
@@ -259,8 +266,13 @@ public class SqlListenerNioListener extends GridNioServerListenerAdapter<byte[]>
             boolean replicatedOnly = reader.readBoolean();
             boolean autoCloseCursors = reader.readBoolean();
 
+            boolean lazyExec = false;
+
+            if (ver.compareTo(VER_2_1_5) >= 0)
+                lazyExec = reader.readBoolean();
+
             SqlListenerRequestHandler handler = new JdbcRequestHandler(ctx, busyLock, maxCursors,
distributedJoins,
-                enforceJoinOrder, collocated, replicatedOnly, autoCloseCursors);
+                enforceJoinOrder, collocated, replicatedOnly, autoCloseCursors, lazyExec);
 
             SqlListenerMessageParser parser = new JdbcMessageParser(ctx);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d20f3020/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
index 7e58f99..d2508a6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcRequestHandler.java
@@ -94,6 +94,9 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
     /** Replicated only flag. */
     private final boolean replicatedOnly;
 
+    /** Lazy query execution flag. */
+    private final boolean lazy;
+
     /** Automatic close of cursors. */
     private final boolean autoCloseCursors;
 
@@ -108,10 +111,11 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler
{
      * @param collocated Collocated flag.
      * @param replicatedOnly Replicated only flag.
      * @param autoCloseCursors Flag to automatically close server cursors.
+     * @param lazy Lazy query execution flag.
      */
     public JdbcRequestHandler(GridKernalContext ctx, GridSpinBusyLock busyLock, int maxCursors,
         boolean distributedJoins, boolean enforceJoinOrder, boolean collocated, boolean replicatedOnly,
-        boolean autoCloseCursors) {
+        boolean autoCloseCursors, boolean lazy) {
         this.ctx = ctx;
         this.busyLock = busyLock;
         this.maxCursors = maxCursors;
@@ -120,6 +124,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
         this.collocated = collocated;
         this.replicatedOnly = replicatedOnly;
         this.autoCloseCursors = autoCloseCursors;
+        this.lazy = lazy;
 
         log = ctx.log(getClass());
     }
@@ -226,6 +231,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
             qry.setEnforceJoinOrder(enforceJoinOrder);
             qry.setCollocated(collocated);
             qry.setReplicatedOnly(replicatedOnly);
+            qry.setLazy(lazy);
 
             if (req.pageSize() <= 0)
                 return new JdbcResponse(SqlListenerResponse.STATUS_FAILED,
@@ -391,6 +397,7 @@ public class JdbcRequestHandler implements SqlListenerRequestHandler {
                 qry.setEnforceJoinOrder(enforceJoinOrder);
                 qry.setCollocated(collocated);
                 qry.setReplicatedOnly(replicatedOnly);
+                qry.setLazy(lazy);
 
                 qry.setSchema(schemaName);
 


Mime
View raw message