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 4A1D3200D1B for ; Wed, 6 Sep 2017 16:34:33 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 48D0D16171A; Wed, 6 Sep 2017 14:34:33 +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 7D954161D0D for ; Wed, 6 Sep 2017 16:34:31 +0200 (CEST) Received: (qmail 19406 invoked by uid 500); 6 Sep 2017 14:34:30 -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 19328 invoked by uid 99); 6 Sep 2017 14:34:30 -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; Wed, 06 Sep 2017 14:34:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A42EBF566F; Wed, 6 Sep 2017 14:34:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Wed, 06 Sep 2017 14:34:33 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [05/14] ignite git commit: IGNITE-6119: Added 'lazy' flag to ODBC driver. archived-at: Wed, 06 Sep 2017 14:34:33 -0000 IGNITE-6119: Added 'lazy' flag to ODBC driver. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d6cbc50f Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d6cbc50f Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d6cbc50f Branch: refs/heads/ignite-3484 Commit: d6cbc50f8418eac2cf11ea52a8c42a24937d0bb3 Parents: d7e215d Author: Igor Sapego Authored: Tue Sep 5 17:20:51 2017 +0300 Committer: Igor Sapego Committed: Tue Sep 5 17:20:51 2017 +0300 ---------------------------------------------------------------------- .../odbc/SqlListenerConnectionContext.java | 37 ++++--- .../processors/odbc/SqlListenerNioListener.java | 95 +++++------------ .../odbc/jdbc/JdbcConnectionContext.java | 101 +++++++++++++++++++ .../odbc/odbc/OdbcConnectionContext.java | 99 ++++++++++++++++++ .../odbc/odbc/OdbcRequestHandler.java | 54 ++++++---- .../cpp/odbc-test/src/configuration_test.cpp | 11 ++ .../include/ignite/odbc/config/configuration.h | 26 +++++ .../cpp/odbc/include/ignite/odbc/message.h | 6 +- .../odbc/include/ignite/odbc/protocol_version.h | 1 + .../odbc/system/ui/dsn_configuration_window.h | 4 + .../src/system/ui/dsn_configuration_window.cpp | 34 ++++++- .../cpp/odbc/src/config/configuration.cpp | 2 + modules/platforms/cpp/odbc/src/connection.cpp | 6 +- modules/platforms/cpp/odbc/src/dsn_config.cpp | 3 + modules/platforms/cpp/odbc/src/message.cpp | 15 ++- .../platforms/cpp/odbc/src/protocol_version.cpp | 8 +- 16 files changed, 384 insertions(+), 118 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerConnectionContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerConnectionContext.java index 759f3d4..144e978 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerConnectionContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerConnectionContext.java @@ -17,40 +17,39 @@ package org.apache.ignite.internal.processors.odbc; +import org.apache.ignite.internal.binary.BinaryReaderExImpl; + /** * SQL listener connection context. */ -public class SqlListenerConnectionContext { - /** Request handler. */ - private final SqlListenerRequestHandler handler; +public interface SqlListenerConnectionContext { + /** + * @param ver Version to check. + * @return {@code true} if version is supported. + */ + boolean isVersionSupported(SqlListenerProtocolVersion ver); - /** Message parser. */ - private final SqlListenerMessageParser parser; + /** + * @return Current context version. + */ + SqlListenerProtocolVersion currentVersion(); /** - * Constructor. - * - * @param handler Handler. - * @param parser Parser. + * Init from handshake message. + * @param ver Protocol version. + * @param reader Reader set to the configuration part of the handshake message. */ - public SqlListenerConnectionContext(SqlListenerRequestHandler handler, SqlListenerMessageParser parser) { - this.handler = handler; - this.parser = parser; - } + void initFromHandshake(SqlListenerProtocolVersion ver, BinaryReaderExImpl reader); /** * Handler getter. * @return Request handler for the connection. */ - public SqlListenerRequestHandler handler() { - return handler; - } + SqlListenerRequestHandler handler(); /** * Parser getter * @return Message parser for the connection. */ - public SqlListenerMessageParser parser() { - return parser; - } + SqlListenerMessageParser parser(); } http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/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 8dad71b..ec7d4eb 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 @@ -17,8 +17,6 @@ package org.apache.ignite.internal.processors.odbc; -import java.util.HashSet; -import java.util.Set; import java.util.concurrent.atomic.AtomicLong; import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; @@ -28,10 +26,8 @@ import org.apache.ignite.internal.binary.BinaryWriterExImpl; import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream; import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream; import org.apache.ignite.internal.binary.streams.BinaryInputStream; -import org.apache.ignite.internal.processors.odbc.jdbc.JdbcMessageParser; -import org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler; -import org.apache.ignite.internal.processors.odbc.odbc.OdbcMessageParser; -import org.apache.ignite.internal.processors.odbc.odbc.OdbcRequestHandler; +import org.apache.ignite.internal.processors.odbc.jdbc.JdbcConnectionContext; +import org.apache.ignite.internal.processors.odbc.odbc.OdbcConnectionContext; import org.apache.ignite.internal.util.GridSpinBusyLock; import org.apache.ignite.internal.util.nio.GridNioServerListenerAdapter; import org.apache.ignite.internal.util.nio.GridNioSession; @@ -48,18 +44,6 @@ public class SqlListenerNioListener extends GridNioServerListenerAdapter /** 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 = VER_2_1_5; - - /** Supported versions. */ - private static final Set SUPPORTED_VERS = new HashSet<>(); - /** Connection-related metadata key. */ private static final int CONN_CTX_META_KEY = GridNioSessionMetaKey.nextUniqueKey(); @@ -78,11 +62,6 @@ public class SqlListenerNioListener extends GridNioServerListenerAdapter /** Logger. */ private final IgniteLogger log; - static { - SUPPORTED_VERS.add(CURRENT_VER); - SUPPORTED_VERS.add(VER_2_1_0); - } - /** * Constructor. * @@ -152,8 +131,8 @@ public class SqlListenerNioListener extends GridNioServerListenerAdapter if (log.isDebugEnabled()) { startTime = System.nanoTime(); - log.debug("SQL client request received [reqId=" + req.requestId() + ", addr=" + ses.remoteAddress() + - ", req=" + req + ']'); + log.debug("SQL client request received [reqId=" + req.requestId() + ", addr=" + + ses.remoteAddress() + ", req=" + req + ']'); } SqlListenerResponse resp = handler.handle(req); @@ -203,13 +182,14 @@ public class SqlListenerNioListener extends GridNioServerListenerAdapter SqlListenerProtocolVersion ver = SqlListenerProtocolVersion.create(verMajor, verMinor, verMaintenance); - String errMsg = null; + byte clientType = reader.readByte(); - SqlListenerConnectionContext connCtx = null; + SqlListenerConnectionContext connCtx = prepareContext(clientType); + + String errMsg = null; - if (SUPPORTED_VERS.contains(ver)) { - // Prepare context. - connCtx = prepareContext(ver, reader); + if (connCtx.isVersionSupported(ver)) { + connCtx.initFromHandshake(ver, reader); ses.addMeta(CONN_CTX_META_KEY, connCtx); } @@ -222,14 +202,16 @@ public class SqlListenerNioListener extends GridNioServerListenerAdapter // Send response. BinaryWriterExImpl writer = new BinaryWriterExImpl(null, new BinaryHeapOutputStream(8), null, null); - if (connCtx != null) + if (errMsg == null) connCtx.handler().writeHandshake(writer); else { + SqlListenerProtocolVersion currentVer = connCtx.currentVersion(); + // Failed handshake response writer.writeBoolean(false); - writer.writeShort(CURRENT_VER.major()); - writer.writeShort(CURRENT_VER.minor()); - writer.writeShort(CURRENT_VER.maintenance()); + writer.writeShort(currentVer.major()); + writer.writeShort(currentVer.minor()); + writer.writeShort(currentVer.maintenance()); writer.doWriteString(errMsg); } @@ -239,46 +221,19 @@ public class SqlListenerNioListener extends GridNioServerListenerAdapter /** * Prepare context. * - * @param ver Version. - * @param reader Reader. + * @param clientType Client type. * @return Context. */ - private SqlListenerConnectionContext prepareContext(SqlListenerProtocolVersion ver, BinaryReaderExImpl reader) { - byte clientType = reader.readByte(); - - if (clientType == ODBC_CLIENT) { - boolean distributedJoins = reader.readBoolean(); - boolean enforceJoinOrder = reader.readBoolean(); - boolean replicatedOnly = reader.readBoolean(); - boolean collocated = reader.readBoolean(); - - SqlListenerRequestHandler handler = new OdbcRequestHandler(ctx, busyLock, maxCursors, distributedJoins, - enforceJoinOrder, replicatedOnly, collocated); - - SqlListenerMessageParser parser = new OdbcMessageParser(ctx); - - return new SqlListenerConnectionContext(handler, parser); - } - else if (clientType == JDBC_CLIENT) { - boolean distributedJoins = reader.readBoolean(); - boolean enforceJoinOrder = reader.readBoolean(); - boolean collocated = reader.readBoolean(); - 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, lazyExec); + private SqlListenerConnectionContext prepareContext(byte clientType) { + switch (clientType) { + case ODBC_CLIENT: + return new OdbcConnectionContext(ctx, busyLock, maxCursors); - SqlListenerMessageParser parser = new JdbcMessageParser(ctx); + case JDBC_CLIENT: + return new JdbcConnectionContext(ctx, busyLock, maxCursors); - return new SqlListenerConnectionContext(handler, parser); + default: + throw new IgniteException("Unknown client type: " + clientType); } - else - throw new IgniteException("Unknown client type: " + clientType); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java new file mode 100644 index 0000000..89f90f0 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/jdbc/JdbcConnectionContext.java @@ -0,0 +1,101 @@ +package org.apache.ignite.internal.processors.odbc.jdbc; + +import java.util.HashSet; +import java.util.Set; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.binary.BinaryReaderExImpl; +import org.apache.ignite.internal.processors.odbc.SqlListenerConnectionContext; +import org.apache.ignite.internal.processors.odbc.SqlListenerMessageParser; +import org.apache.ignite.internal.processors.odbc.SqlListenerProtocolVersion; +import org.apache.ignite.internal.processors.odbc.SqlListenerRequestHandler; +import org.apache.ignite.internal.util.GridSpinBusyLock; + +/** + * ODBC Connection Context. + */ +public class JdbcConnectionContext implements SqlListenerConnectionContext { + /** 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 = VER_2_1_5; + + /** Supported versions. */ + private static final Set SUPPORTED_VERS = new HashSet<>(); + + /** Context. */ + private final GridKernalContext ctx; + + /** Shutdown busy lock. */ + private final GridSpinBusyLock busyLock; + + /** Maximum allowed cursors. */ + private final int maxCursors; + + /** Message parser. */ + private JdbcMessageParser parser = null; + + /** Request handler. */ + private JdbcRequestHandler handler = null; + + static { + SUPPORTED_VERS.add(CURRENT_VER); + SUPPORTED_VERS.add(VER_2_1_0); + } + + @Override + public boolean isVersionSupported(SqlListenerProtocolVersion ver) { + return SUPPORTED_VERS.contains(ver); + } + + @Override + public SqlListenerProtocolVersion currentVersion() { + return CURRENT_VER; + } + + @Override + public void initFromHandshake(SqlListenerProtocolVersion ver, BinaryReaderExImpl reader) { + assert SUPPORTED_VERS.contains(ver): "Unsupported JDBC protocol version."; + + boolean distributedJoins = reader.readBoolean(); + boolean enforceJoinOrder = reader.readBoolean(); + boolean collocated = reader.readBoolean(); + boolean replicatedOnly = reader.readBoolean(); + boolean autoCloseCursors = reader.readBoolean(); + + boolean lazyExec = false; + + if (ver.compareTo(VER_2_1_5) >= 0) + lazyExec = reader.readBoolean(); + + handler = new JdbcRequestHandler(ctx, busyLock, maxCursors, distributedJoins, + enforceJoinOrder, collocated, replicatedOnly, autoCloseCursors, lazyExec); + + parser = new JdbcMessageParser(ctx); + } + + /** + * Constructor. + * @param ctx Kernal Context. + * @param busyLock Shutdown busy lock. + * @param maxCursors Maximum allowed cursors. + */ + public JdbcConnectionContext(GridKernalContext ctx, GridSpinBusyLock busyLock, int maxCursors) { + this.ctx = ctx; + this.busyLock = busyLock; + this.maxCursors = maxCursors; + } + + @Override + public SqlListenerRequestHandler handler() { + return handler; + } + + @Override + public SqlListenerMessageParser parser() { + return parser; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java new file mode 100644 index 0000000..4e9dfbb --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcConnectionContext.java @@ -0,0 +1,99 @@ +package org.apache.ignite.internal.processors.odbc.odbc; + +import java.util.HashSet; +import java.util.Set; +import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.binary.BinaryReaderExImpl; +import org.apache.ignite.internal.processors.odbc.SqlListenerConnectionContext; +import org.apache.ignite.internal.processors.odbc.SqlListenerMessageParser; +import org.apache.ignite.internal.processors.odbc.SqlListenerProtocolVersion; +import org.apache.ignite.internal.processors.odbc.SqlListenerRequestHandler; +import org.apache.ignite.internal.util.GridSpinBusyLock; + +/** + * ODBC Connection Context. + */ +public class OdbcConnectionContext implements SqlListenerConnectionContext { + /** 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 = VER_2_1_5; + + /** Supported versions. */ + private static final Set SUPPORTED_VERS = new HashSet<>(); + + /** Context. */ + private final GridKernalContext ctx; + + /** Shutdown busy lock. */ + private final GridSpinBusyLock busyLock; + + /** Maximum allowed cursors. */ + private final int maxCursors; + + /** Message parser. */ + private OdbcMessageParser parser = null; + + /** Request handler. */ + private OdbcRequestHandler handler = null; + + static { + SUPPORTED_VERS.add(CURRENT_VER); + SUPPORTED_VERS.add(VER_2_1_0); + } + + @Override + public boolean isVersionSupported(SqlListenerProtocolVersion ver) { + return SUPPORTED_VERS.contains(ver); + } + + @Override + public SqlListenerProtocolVersion currentVersion() { + return CURRENT_VER; + } + + @Override + public void initFromHandshake(SqlListenerProtocolVersion ver, BinaryReaderExImpl reader) { + assert SUPPORTED_VERS.contains(ver): "Unsupported ODBC protocol version."; + + boolean distributedJoins = reader.readBoolean(); + boolean enforceJoinOrder = reader.readBoolean(); + boolean replicatedOnly = reader.readBoolean(); + boolean collocated = reader.readBoolean(); + boolean lazy = false; + + if (ver.compareTo(VER_2_1_5) >= 0) + lazy = reader.readBoolean(); + + handler = new OdbcRequestHandler(ctx, busyLock, maxCursors, distributedJoins, + enforceJoinOrder, replicatedOnly, collocated, lazy); + + parser = new OdbcMessageParser(ctx); + } + + /** + * Constructor. + * @param ctx Kernal Context. + * @param busyLock Shutdown busy lock. + * @param maxCursors Maximum allowed cursors. + */ + public OdbcConnectionContext(GridKernalContext ctx, GridSpinBusyLock busyLock, int maxCursors) { + this.ctx = ctx; + this.busyLock = busyLock; + this.maxCursors = maxCursors; + } + + @Override + public SqlListenerRequestHandler handler() { + return handler; + } + + @Override + public SqlListenerMessageParser parser() { + return parser; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java index 679a2e6..1aa4309 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcRequestHandler.java @@ -27,7 +27,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; - import org.apache.ignite.IgniteException; import org.apache.ignite.IgniteLogger; import org.apache.ignite.cache.query.QueryCursor; @@ -48,7 +47,13 @@ import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.internal.util.typedef.internal.U; import org.apache.ignite.lang.IgniteBiTuple; -import static org.apache.ignite.internal.processors.odbc.odbc.OdbcRequest.*; +import static org.apache.ignite.internal.processors.odbc.odbc.OdbcRequest.META_COLS; +import static org.apache.ignite.internal.processors.odbc.odbc.OdbcRequest.META_PARAMS; +import static org.apache.ignite.internal.processors.odbc.odbc.OdbcRequest.META_TBLS; +import static org.apache.ignite.internal.processors.odbc.odbc.OdbcRequest.QRY_CLOSE; +import static org.apache.ignite.internal.processors.odbc.odbc.OdbcRequest.QRY_EXEC; +import static org.apache.ignite.internal.processors.odbc.odbc.OdbcRequest.QRY_EXEC_BATCH; +import static org.apache.ignite.internal.processors.odbc.odbc.OdbcRequest.QRY_FETCH; /** * SQL query handler. @@ -84,6 +89,9 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler { /** Collocated flag. */ private final boolean collocated; + /** Lazy flag. */ + private final boolean lazy; + /** * Constructor. * @param ctx Context. @@ -93,10 +101,11 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler { * @param enforceJoinOrder Enforce join order flag. * @param replicatedOnly Replicated only flag. * @param collocated Collocated flag. + * @param lazy Lazy flag. */ public OdbcRequestHandler(GridKernalContext ctx, GridSpinBusyLock busyLock, int maxCursors, boolean distributedJoins, boolean enforceJoinOrder, boolean replicatedOnly, - boolean collocated) { + boolean collocated, boolean lazy) { this.ctx = ctx; this.busyLock = busyLock; this.maxCursors = maxCursors; @@ -104,6 +113,7 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler { this.enforceJoinOrder = enforceJoinOrder; this.replicatedOnly = replicatedOnly; this.collocated = collocated; + this.lazy = lazy; log = ctx.log(getClass()); } @@ -160,6 +170,28 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler { } /** + * Make query considering handler configuration. + * @param schema Schema. + * @param sql SQL request. + * @param args Arguments. + * @return Query instance. + */ + private SqlFieldsQuery makeQuery(String schema, String sql, Object[] args) { + SqlFieldsQuery qry = new SqlFieldsQuery(sql); + + qry.setArgs(args); + + qry.setDistributedJoins(distributedJoins); + qry.setEnforceJoinOrder(enforceJoinOrder); + qry.setReplicatedOnly(replicatedOnly); + qry.setCollocated(collocated); + qry.setLazy(lazy); + qry.setSchema(schema); + + return qry; + } + + /** * {@link OdbcQueryExecuteRequest} command handler. * * @param req Execute query request. @@ -182,15 +214,7 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler { log.debug("ODBC query parsed [reqId=" + req.requestId() + ", original=" + req.sqlQuery() + ", parsed=" + sql + ']'); - SqlFieldsQuery qry = new SqlFieldsQuery(sql); - - qry.setArgs(req.arguments()); - - qry.setDistributedJoins(distributedJoins); - qry.setEnforceJoinOrder(enforceJoinOrder); - qry.setReplicatedOnly(replicatedOnly); - qry.setCollocated(collocated); - qry.setSchema(req.schema()); + SqlFieldsQuery qry = makeQuery(req.schema(), sql, req.arguments()); QueryCursor qryCur = ctx.query().querySqlFieldsNoCache(qry, true); @@ -228,11 +252,7 @@ public class OdbcRequestHandler implements SqlListenerRequestHandler { log.debug("ODBC query parsed [reqId=" + req.requestId() + ", original=" + req.sqlQuery() + ", parsed=" + sql + ']'); - SqlFieldsQuery qry = new SqlFieldsQuery(sql); - - qry.setDistributedJoins(distributedJoins); - qry.setEnforceJoinOrder(enforceJoinOrder); - qry.setSchema(req.schema()); + SqlFieldsQuery qry = makeQuery(req.schema(), sql, req.arguments()); Object[][] paramSet = req.arguments(); http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/platforms/cpp/odbc-test/src/configuration_test.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc-test/src/configuration_test.cpp b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp index d00d8b3..7da6757 100644 --- a/modules/platforms/cpp/odbc-test/src/configuration_test.cpp +++ b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp @@ -42,6 +42,7 @@ namespace const bool testEnforceJoinOrder = true; const bool testReplicatedOnly = true; const bool testCollocated = true; + const bool testLazy = true; const std::string testAddress = testServerHost + ':' + ignite::common::LexicalCast(testServerPort); } @@ -130,6 +131,7 @@ void CheckConnectionConfig(const Configuration& cfg) BOOST_CHECK_EQUAL(cfg.IsEnforceJoinOrder(), testEnforceJoinOrder); BOOST_CHECK_EQUAL(cfg.IsReplicatedOnly(), testReplicatedOnly); BOOST_CHECK_EQUAL(cfg.IsCollocated(), testCollocated); + BOOST_CHECK_EQUAL(cfg.IsLazy(), testLazy); std::stringstream constructor; @@ -138,6 +140,7 @@ void CheckConnectionConfig(const Configuration& cfg) << "distributed_joins=" << BoolToStr(testDistributedJoins) << ';' << "driver={" << testDriverName << "};" << "enforce_join_order=" << BoolToStr(testEnforceJoinOrder) << ';' + << "lazy=" << BoolToStr(testLazy) << ';' << "page_size=" << testPageSize << ';' << "replicated_only=" << BoolToStr(testReplicatedOnly) << ';' << "schema=" << testSchemaName << ';'; @@ -160,6 +163,7 @@ void CheckDsnConfig(const Configuration& cfg) BOOST_CHECK_EQUAL(cfg.IsEnforceJoinOrder(), false); BOOST_CHECK_EQUAL(cfg.IsReplicatedOnly(), false); BOOST_CHECK_EQUAL(cfg.IsCollocated(), false); + BOOST_CHECK_EQUAL(cfg.IsLazy(), false); } BOOST_AUTO_TEST_SUITE(ConfigurationTestSuite) @@ -185,6 +189,7 @@ BOOST_AUTO_TEST_CASE(TestConnectStringUppercase) std::stringstream constructor; constructor << "DRIVER={" << testDriverName << "};" + << "LAZY=" << BoolToStr(testLazy, false) << ';' << "ADDRESS=" << testAddress << ';' << "DISTRIBUTED_JOINS=" << BoolToStr(testDistributedJoins, false) << ';' << "ENFORCE_JOIN_ORDER=" << BoolToStr(testEnforceJoinOrder, false) << ';' @@ -207,6 +212,7 @@ BOOST_AUTO_TEST_CASE(TestConnectStringLowercase) std::stringstream constructor; constructor << "driver={" << testDriverName << "};" + << "lazy=" << BoolToStr(testLazy) << ';' << "address=" << testAddress << ';' << "page_size=" << testPageSize << ';' << "distributed_joins=" << BoolToStr(testDistributedJoins) << ';' @@ -230,6 +236,7 @@ BOOST_AUTO_TEST_CASE(TestConnectStringZeroTerminated) constructor << "driver={" << testDriverName << "};" << "address=" << testAddress << ';' + << "lazy=" << BoolToStr(testLazy) << ';' << "page_size=" << testPageSize << ';' << "replicated_only=" << BoolToStr(testReplicatedOnly) << ';' << "collocated=" << BoolToStr(testCollocated) << ';' @@ -251,6 +258,7 @@ BOOST_AUTO_TEST_CASE(TestConnectStringMixed) std::stringstream constructor; constructor << "Driver={" << testDriverName << "};" + << "Lazy=" << BoolToStr(testLazy) << ';' << "Address=" << testAddress << ';' << "Page_Size=" << testPageSize << ';' << "Distributed_Joins=" << BoolToStr(testDistributedJoins, false) << ';' @@ -276,6 +284,7 @@ BOOST_AUTO_TEST_CASE(TestConnectStringWhitepaces) << " ADDRESS =" << testAddress << "; " << " PAGE_SIZE= " << testPageSize << ';' << " DISTRIBUTED_JOINS=" << BoolToStr(testDistributedJoins, false) << ';' + << "LAZY=" << BoolToStr(testLazy, false) << ';' << "COLLOCATED =" << BoolToStr(testCollocated, false) << " ;" << " REPLICATED_ONLY= " << BoolToStr(testReplicatedOnly, false) << ';' << "ENFORCE_JOIN_ORDER= " << BoolToStr(testEnforceJoinOrder, false) << " ;" @@ -348,6 +357,7 @@ BOOST_AUTO_TEST_CASE(TestConnectStringInvalidBoolKeys) keys.insert("enforce_join_order"); keys.insert("replicated_only"); keys.insert("collocated"); + keys.insert("lazy"); for (Set::const_iterator it = keys.begin(); it != keys.end(); ++it) { @@ -374,6 +384,7 @@ BOOST_AUTO_TEST_CASE(TestConnectStringValidBoolKeys) keys.insert("enforce_join_order"); keys.insert("replicated_only"); keys.insert("collocated"); + keys.insert("lazy"); for (Set::const_iterator it = keys.begin(); it != keys.end(); ++it) { http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h b/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h index e024275..b334141 100644 --- a/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h +++ b/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h @@ -79,6 +79,9 @@ namespace ignite /** Connection attribute keyword for collocated attribute. */ static const std::string collocated; + + /** Connection attribute keyword for lazy attribute. */ + static const std::string lazy; }; /** Default values for configuration. */ @@ -119,6 +122,9 @@ namespace ignite /** Default value for collocated attribute. */ static const bool collocated; + + /** Default value for lazy attribute. */ + static const bool lazy; }; /** @@ -358,6 +364,26 @@ namespace ignite } /** + * Check lazy flag. + * + * @return True if lazy is enabled. + */ + bool IsLazy() const + { + return GetBoolValue(Key::lazy, DefaultValue::lazy); + } + + /** + * Set lazy. + * + * @param val Value to set. + */ + void SetLazy(bool val) + { + SetBoolValue(Key::lazy, val); + } + + /** * Get protocol version. * * @return Protocol version. http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/platforms/cpp/odbc/include/ignite/odbc/message.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/message.h b/modules/platforms/cpp/odbc/include/ignite/odbc/message.h index c6df0c9..836f2b6 100644 --- a/modules/platforms/cpp/odbc/include/ignite/odbc/message.h +++ b/modules/platforms/cpp/odbc/include/ignite/odbc/message.h @@ -88,9 +88,10 @@ namespace ignite * @param enforceJoinOrder Enforce join order flag. * @param replicatedOnly Replicated only flag. * @param collocated Collocated flag. + * @param lazy Lazy flag. */ HandshakeRequest(const ProtocolVersion& version, bool distributedJoins, bool enforceJoinOrder, - bool replicatedOnly, bool collocated); + bool replicatedOnly, bool collocated, bool lazy); /** * Destructor. @@ -118,6 +119,9 @@ namespace ignite /** Collocated flag. */ bool collocated; + + /** Lazy flag. */ + bool lazy; }; /** http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h b/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h index a3cb88e..c36d5dd 100644 --- a/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h +++ b/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h @@ -33,6 +33,7 @@ namespace ignite public: /** Current protocol version. */ static const ProtocolVersion VERSION_2_1_0; + static const ProtocolVersion VERSION_2_1_5; typedef std::set VersionSet; http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h b/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h index 87f5806..2974b67 100644 --- a/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h +++ b/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h @@ -54,6 +54,7 @@ namespace ignite ENFORCE_JOIN_ORDER_CHECK_BOX, REPLICATED_ONLY_CHECK_BOX, COLLOCATED_CHECK_BOX, + LAZY_CHECK_BOX, PROTOCOL_VERSION_LABEL, PROTOCOL_VERSION_COMBO_BOX, OK_BUTTON, @@ -145,6 +146,9 @@ namespace ignite /** Collocated CheckBox. */ std::auto_ptr collocatedCheckBox; + /** Lazy CheckBox. */ + std::auto_ptr lazyCheckBox; + /** Protocol version edit field. */ std::auto_ptr protocolVersionLabel; http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp b/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp index c8bb9f8..9b13481 100644 --- a/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp +++ b/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp @@ -32,7 +32,7 @@ namespace ignite DsnConfigurationWindow::DsnConfigurationWindow(Window* parent, config::Configuration& config): CustomWindow(parent, "IgniteConfigureDsn", "Configure Apache Ignite DSN"), width(360), - height(280), + height(300), connectionSettingsGroupBox(), nameLabel(), nameEdit(), @@ -142,13 +142,17 @@ namespace ignite const ProtocolVersion::VersionSet& supported = ProtocolVersion::GetSupported(); + ProtocolVersion version = ProtocolVersion::GetCurrent(); ProtocolVersion::VersionSet::const_iterator it; for (it = supported.begin(); it != supported.end(); ++it) { protocolVersionComboBox->AddString(it->ToString()); if (*it == config.GetProtocolVersion()) + { protocolVersionComboBox->SetSelection(id); + version = *it; + } ++id; } @@ -169,6 +173,13 @@ namespace ignite collocatedCheckBox = CreateCheckBox(editPosX + checkBoxSize + interval, rowPos, checkBoxSize, rowSize, "Collocated", ChildId::COLLOCATED_CHECK_BOX, config.IsCollocated()); + rowPos += rowSize; + + lazyCheckBox = CreateCheckBox(editPosX, rowPos, checkBoxSize, rowSize, + "Lazy", ChildId::LAZY_CHECK_BOX, config.IsLazy()); + + lazyCheckBox->SetEnabled(version >= ProtocolVersion::VERSION_2_1_5); + rowPos += interval * 2 + rowSize; connectionSettingsGroupBox = CreateGroupBox(margin, sectionBegin, width - 2 * margin, @@ -246,7 +257,24 @@ namespace ignite break; } + case ChildId::LAZY_CHECK_BOX: + { + lazyCheckBox->SetChecked(!lazyCheckBox->IsChecked()); + + break; + } + case ChildId::PROTOCOL_VERSION_COMBO_BOX: + { + std::string versionStr; + protocolVersionComboBox->GetText(versionStr); + + ProtocolVersion version = ProtocolVersion::FromString(versionStr); + lazyCheckBox->SetEnabled(version >= ProtocolVersion::VERSION_2_1_5); + + break; + } + default: return false; } @@ -280,6 +308,7 @@ namespace ignite bool enforceJoinOrder; bool replicatedOnly; bool collocated; + bool lazy; nameEdit->GetText(dsn); addressEdit->GetText(address); @@ -299,6 +328,7 @@ namespace ignite enforceJoinOrder = enforceJoinOrderCheckBox->IsEnabled() && enforceJoinOrderCheckBox->IsChecked(); replicatedOnly = replicatedOnlyCheckBox->IsEnabled() && replicatedOnlyCheckBox->IsChecked(); collocated = collocatedCheckBox->IsEnabled() && collocatedCheckBox->IsChecked(); + lazy = lazyCheckBox->IsEnabled() && lazyCheckBox->IsChecked(); LOG_MSG("Retriving arguments:"); LOG_MSG("DSN: " << dsn); @@ -310,6 +340,7 @@ namespace ignite LOG_MSG("Enforce Join Order: " << (enforceJoinOrder ? "true" : "false")); LOG_MSG("Replicated only: " << (replicatedOnly ? "true" : "false")); LOG_MSG("Collocated: " << (collocated ? "true" : "false")); + LOG_MSG("Lazy: " << (lazy ? "true" : "false")); if (dsn.empty()) throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "DSN name can not be empty."); @@ -323,6 +354,7 @@ namespace ignite cfg.SetEnforceJoinOrder(enforceJoinOrder); cfg.SetReplicatedOnly(replicatedOnly); cfg.SetCollocated(collocated); + cfg.SetLazy(lazy); } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/platforms/cpp/odbc/src/config/configuration.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/config/configuration.cpp b/modules/platforms/cpp/odbc/src/config/configuration.cpp index 1863197..95ed964 100644 --- a/modules/platforms/cpp/odbc/src/config/configuration.cpp +++ b/modules/platforms/cpp/odbc/src/config/configuration.cpp @@ -44,6 +44,7 @@ namespace ignite const std::string Configuration::Key::pageSize = "page_size"; const std::string Configuration::Key::replicatedOnly = "replicated_only"; const std::string Configuration::Key::collocated = "collocated"; + const std::string Configuration::Key::lazy = "lazy"; const std::string Configuration::DefaultValue::dsn = "Apache Ignite DSN"; const std::string Configuration::DefaultValue::driver = "Apache Ignite"; @@ -58,6 +59,7 @@ namespace ignite const bool Configuration::DefaultValue::enforceJoinOrder = false; const bool Configuration::DefaultValue::replicatedOnly = false; const bool Configuration::DefaultValue::collocated = false; + const bool Configuration::DefaultValue::lazy = false; const ProtocolVersion& Configuration::DefaultValue::protocolVersion = ProtocolVersion::GetCurrent(); http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/platforms/cpp/odbc/src/connection.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/connection.cpp b/modules/platforms/cpp/odbc/src/connection.cpp index d281f3b..80d1695 100644 --- a/modules/platforms/cpp/odbc/src/connection.cpp +++ b/modules/platforms/cpp/odbc/src/connection.cpp @@ -325,6 +325,7 @@ namespace ignite bool enforceJoinOrder = false; bool replicatedOnly = false; bool collocated = false; + bool lazy = false; ProtocolVersion protocolVersion; try @@ -334,6 +335,7 @@ namespace ignite enforceJoinOrder = config.IsEnforceJoinOrder(); replicatedOnly = config.IsReplicatedOnly(); collocated = config.IsCollocated(); + lazy = config.IsLazy(); } catch (const IgniteError& err) { @@ -350,7 +352,7 @@ namespace ignite return SqlResult::AI_ERROR; } - HandshakeRequest req(protocolVersion, distributedJoins, enforceJoinOrder, replicatedOnly, collocated); + HandshakeRequest req(protocolVersion, distributedJoins, enforceJoinOrder, replicatedOnly, collocated, lazy); HandshakeResponse rsp; try @@ -373,7 +375,7 @@ namespace ignite constructor << "Node rejected handshake message. "; if (!rsp.GetError().empty()) - constructor << "Additional info: " << rsp.GetError(); + constructor << "Additional info: " << rsp.GetError() << " "; constructor << "Current node Apache Ignite version: " << rsp.GetCurrentVer().ToString() << ", " << "driver protocol version introduced in version: " http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/platforms/cpp/odbc/src/dsn_config.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/dsn_config.cpp b/modules/platforms/cpp/odbc/src/dsn_config.cpp index 9d6e385..c91cd8c 100644 --- a/modules/platforms/cpp/odbc/src/dsn_config.cpp +++ b/modules/platforms/cpp/odbc/src/dsn_config.cpp @@ -106,6 +106,8 @@ namespace ignite bool collocated = ReadDsnBool(dsn, Configuration::Key::collocated, config.IsCollocated()); + bool lazy = ReadDsnBool(dsn, Configuration::Key::lazy, config.IsLazy()); + std::string version = ReadDsnString(dsn, Configuration::Key::protocolVersion, config.GetProtocolVersion().ToString().c_str()); @@ -122,6 +124,7 @@ namespace ignite config.SetEnforceJoinOrder(enforceJoinOrder); config.SetReplicatedOnly(replicatedOnly); config.SetCollocated(collocated); + config.SetLazy(lazy); config.SetProtocolVersion(version); config.SetPageSize(pageSize); } http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/platforms/cpp/odbc/src/message.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/message.cpp b/modules/platforms/cpp/odbc/src/message.cpp index 79bf9c2..1bd0be5 100644 --- a/modules/platforms/cpp/odbc/src/message.cpp +++ b/modules/platforms/cpp/odbc/src/message.cpp @@ -23,12 +23,13 @@ namespace ignite namespace odbc { HandshakeRequest::HandshakeRequest(const ProtocolVersion& version, bool distributedJoins, - bool enforceJoinOrder, bool replicatedOnly, bool collocated): + bool enforceJoinOrder, bool replicatedOnly, bool collocated, bool lazy): version(version), distributedJoins(distributedJoins), enforceJoinOrder(enforceJoinOrder), replicatedOnly(replicatedOnly), - collocated(collocated) + collocated(collocated), + lazy(lazy) { // No-op. } @@ -52,9 +53,11 @@ namespace ignite writer.WriteBool(enforceJoinOrder); writer.WriteBool(replicatedOnly); writer.WriteBool(collocated); + writer.WriteBool(lazy); } - QueryExecuteRequest::QueryExecuteRequest(const std::string& schema, const std::string& sql, const app::ParameterSet& params): + QueryExecuteRequest::QueryExecuteRequest(const std::string& schema, const std::string& sql, + const app::ParameterSet& params): schema(schema), sql(sql), params(params) @@ -147,7 +150,8 @@ namespace ignite writer.WriteInt32(pageSize); } - QueryGetColumnsMetaRequest::QueryGetColumnsMetaRequest(const std::string& schema, const std::string& table, const std::string& column): + QueryGetColumnsMetaRequest::QueryGetColumnsMetaRequest(const std::string& schema, const std::string& table, + const std::string& column): schema(schema), table(table), column(column) @@ -169,7 +173,8 @@ namespace ignite writer.WriteObject(column); } - QueryGetTablesMetaRequest::QueryGetTablesMetaRequest(const std::string& catalog, const std::string& schema, const std::string& table, const std::string& tableTypes): + QueryGetTablesMetaRequest::QueryGetTablesMetaRequest(const std::string& catalog, const std::string& schema, + const std::string& table, const std::string& tableTypes): catalog(catalog), schema(schema), table(table), http://git-wip-us.apache.org/repos/asf/ignite/blob/d6cbc50f/modules/platforms/cpp/odbc/src/protocol_version.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/odbc/src/protocol_version.cpp b/modules/platforms/cpp/odbc/src/protocol_version.cpp index aa8915d..b668fb8 100644 --- a/modules/platforms/cpp/odbc/src/protocol_version.cpp +++ b/modules/platforms/cpp/odbc/src/protocol_version.cpp @@ -26,10 +26,12 @@ namespace ignite { namespace odbc { - const ProtocolVersion ProtocolVersion::VERSION_2_1_0(ProtocolVersion(2,1,0)); + const ProtocolVersion ProtocolVersion::VERSION_2_1_0(2, 1, 0); + const ProtocolVersion ProtocolVersion::VERSION_2_1_5(2, 1, 5); ProtocolVersion::VersionSet::value_type supportedArray[] = { - ProtocolVersion::VERSION_2_1_0 + ProtocolVersion::VERSION_2_1_0, + ProtocolVersion::VERSION_2_1_5 }; const ProtocolVersion::VersionSet ProtocolVersion::supported(supportedArray, @@ -58,7 +60,7 @@ namespace ignite const ProtocolVersion& ProtocolVersion::GetCurrent() { - return VERSION_2_1_0; + return VERSION_2_1_5; } void ThrowParseError()