You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/06/05 14:39:44 UTC
[2/2] ignite git commit: IGNITE-5275: Implemented
SqlConnectorConfiguration. Deprecated OdbcConfiguration. This closes #2080.
IGNITE-5275: Implemented SqlConnectorConfiguration. Deprecated OdbcConfiguration. This closes #2080.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/776cc6e7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/776cc6e7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/776cc6e7
Branch: refs/heads/master
Commit: 776cc6e70a2a0a2d2e69f9bd89e3d44784402dec
Parents: 2485b98
Author: devozerov <vo...@gridgain.com>
Authored: Mon Jun 5 17:39:32 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Jun 5 17:39:32 2017 +0300
----------------------------------------------------------------------
.../JdbcThinAbstractDmlStatementSelfTest.java | 3 -
.../jdbc/thin/JdbcThinAbstractSelfTest.java | 11 -
.../jdbc/thin/JdbcThinEmptyCacheSelfTest.java | 3 -
.../thin/JdbcThinPreparedStatementSelfTest.java | 3 -
.../jdbc/thin/JdbcThinStatementSelfTest.java | 3 -
.../org/apache/ignite/IgniteJdbcThinDriver.java | 1 -
.../configuration/IgniteConfiguration.java | 30 ++
.../ignite/configuration/OdbcConfiguration.java | 4 +
.../SqlConnectorConfiguration.java | 275 +++++++++++++++++++
.../internal/jdbc/thin/JdbcThinUtils.java | 3 +-
.../internal/processors/odbc/OdbcTypes.java | 131 ---------
.../internal/processors/odbc/OdbcUtils.java | 141 ----------
.../processors/odbc/SqlListenerDataTypes.java | 30 +-
.../processors/odbc/SqlListenerNioListener.java | 2 +-
.../processors/odbc/SqlListenerProcessor.java | 187 +++++++++----
.../processors/odbc/odbc/OdbcColumnMeta.java | 1 -
.../odbc/odbc/OdbcRequestHandler.java | 1 -
.../processors/odbc/odbc/OdbcTableMeta.java | 1 -
.../processors/odbc/odbc/OdbcTypes.java | 131 +++++++++
.../processors/odbc/odbc/OdbcUtils.java | 142 ++++++++++
.../odbc/odbc/escape/OdbcEscapeUtils.java | 2 +-
.../OdbcConfigurationValidationSelfTest.java | 186 +++++++++++++
.../SqlListenerProcessorValidationSelfTest.java | 184 -------------
.../ignite/testsuites/IgniteBasicTestSuite.java | 4 +-
.../processors/query/h2/IgniteH2Indexing.java | 2 +-
...onnectorConfigurationValidationSelfTest.java | 245 +++++++++++++++++
.../IgniteCacheQuerySelfTestSuite.java | 3 +
.../odbc-example/config/example-odbc.xml | 6 -
.../odbc-test/config/queries-test-default.xml | 9 +-
.../odbc-test/config/queries-test-noodbc-32.xml | 4 +
.../odbc-test/config/queries-test-noodbc.xml | 6 +-
31 files changed, 1188 insertions(+), 566 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractDmlStatementSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractDmlStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractDmlStatementSelfTest.java
index eddf61b..b5760dd 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractDmlStatementSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractDmlStatementSelfTest.java
@@ -26,7 +26,6 @@ import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.ConnectorConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.OdbcConfiguration;
import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -105,8 +104,6 @@ public abstract class JdbcThinAbstractDmlStatementSelfTest extends JdbcThinAbstr
cfg.setConnectorConfiguration(new ConnectorConfiguration());
- cfg.setOdbcConfiguration(new OdbcConfiguration());
-
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractSelfTest.java
index bbefbd4..99b79ea 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinAbstractSelfTest.java
@@ -17,8 +17,6 @@
package org.apache.ignite.jdbc.thin;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.OdbcConfiguration;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
/**
@@ -29,13 +27,4 @@ public class JdbcThinAbstractSelfTest extends GridCommonAbstractTest {
@Override protected void beforeTestsStarted() throws Exception {
Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
}
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- cfg.setOdbcConfiguration(new OdbcConfiguration());
-
- return cfg;
- }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinEmptyCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinEmptyCacheSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinEmptyCacheSelfTest.java
index 4775a79..1ede536 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinEmptyCacheSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinEmptyCacheSelfTest.java
@@ -23,7 +23,6 @@ import java.sql.ResultSet;
import java.sql.Statement;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.OdbcConfiguration;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -69,8 +68,6 @@ public class JdbcThinEmptyCacheSelfTest extends JdbcThinAbstractSelfTest {
cfg.setDiscoverySpi(disco);
- cfg.setOdbcConfiguration(new OdbcConfiguration());
-
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementSelfTest.java
index aead436..6f18c75 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementSelfTest.java
@@ -33,7 +33,6 @@ import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.OdbcConfiguration;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -98,8 +97,6 @@ public class JdbcThinPreparedStatementSelfTest extends JdbcThinAbstractSelfTest
cfg.setDiscoverySpi(disco);
- cfg.setOdbcConfiguration(new OdbcConfiguration());
-
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStatementSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStatementSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStatementSelfTest.java
index a9a7e7b..92f7255 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStatementSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinStatementSelfTest.java
@@ -26,7 +26,6 @@ import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.OdbcConfiguration;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
@@ -75,8 +74,6 @@ public class JdbcThinStatementSelfTest extends JdbcThinAbstractSelfTest {
cfg.setDiscoverySpi(disco);
- cfg.setOdbcConfiguration(new OdbcConfiguration());
-
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/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 665ac69..3e3511b 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteJdbcThinDriver.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteJdbcThinDriver.java
@@ -133,7 +133,6 @@ import org.apache.ignite.internal.util.typedef.F;
*/
@SuppressWarnings("JavadocReference")
public class IgniteJdbcThinDriver implements Driver {
-
/** Major version. */
private static final int MAJOR_VER = IgniteVersionUtils.VER.major();
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index 89ab43e..8e531e2 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -419,6 +419,7 @@ public class IgniteConfiguration {
private ConnectorConfiguration connectorCfg = new ConnectorConfiguration();
/** ODBC configuration. */
+ @Deprecated
private OdbcConfiguration odbcCfg;
/** Warmup closure. Will be invoked before actual grid start. */
@@ -463,6 +464,9 @@ public class IgniteConfiguration {
/** */
private long longQryWarnTimeout = DFLT_LONG_QRY_WARN_TIMEOUT;
+ /** SQL connector configuration. */
+ private SqlConnectorConfiguration sqlConnCfg = new SqlConnectorConfiguration();
+
/**
* Creates valid grid configuration with all default values.
*/
@@ -554,6 +558,7 @@ public class IgniteConfiguration {
segResolvers = cfg.getSegmentationResolvers();
sndRetryCnt = cfg.getNetworkSendRetryCount();
sndRetryDelay = cfg.getNetworkSendRetryDelay();
+ sqlConnCfg = cfg.getSqlConnectorConfiguration();
sslCtxFactory = cfg.getSslContextFactory();
storeSesLsnrs = cfg.getCacheStoreSessionListenerFactories();
stripedPoolSize = cfg.getStripedPoolSize();
@@ -2438,7 +2443,9 @@ public class IgniteConfiguration {
* Gets configuration for ODBC.
*
* @return ODBC configuration.
+ * @deprecated Use {@link #getSqlConnectorConfiguration()} instead.
*/
+ @Deprecated
public OdbcConfiguration getOdbcConfiguration() {
return odbcCfg;
}
@@ -2448,7 +2455,9 @@ public class IgniteConfiguration {
*
* @param odbcCfg ODBC configuration.
* @return {@code this} for chaining.
+ * @deprecated Use {@link #setSqlConnectorConfiguration(SqlConnectorConfiguration)} instead.
*/
+ @Deprecated
public IgniteConfiguration setOdbcConfiguration(OdbcConfiguration odbcCfg) {
this.odbcCfg = odbcCfg;
@@ -2742,6 +2751,27 @@ public class IgniteConfiguration {
return this;
}
+ /**
+ * Sets SQL connector configuration.
+ *
+ * @param sqlConnCfg SQL connector configuration.
+ * @return {@code this} for chaining.
+ */
+ public IgniteConfiguration setSqlConnectorConfiguration(SqlConnectorConfiguration sqlConnCfg) {
+ this.sqlConnCfg = sqlConnCfg;
+
+ return this;
+ }
+
+ /**
+ * Gets SQL connector configuration.
+ *
+ * @return SQL connector configuration.
+ */
+ public SqlConnectorConfiguration getSqlConnectorConfiguration() {
+ return sqlConnCfg;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgniteConfiguration.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
index 8fe1665..6d7ab38 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/OdbcConfiguration.java
@@ -21,7 +21,11 @@ import org.apache.ignite.internal.util.typedef.internal.S;
/**
* ODBC configuration.
+ * <p>
+ * Deprecated as of Apache Ignite 2.1. Please use {@link SqlConnectorConfiguration} and
+ * {@link IgniteConfiguration#setSqlConnectorConfiguration(SqlConnectorConfiguration)} instead.
*/
+@Deprecated
public class OdbcConfiguration {
/** Default TCP host. */
public static final String DFLT_TCP_HOST = "0.0.0.0";
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/main/java/org/apache/ignite/configuration/SqlConnectorConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/SqlConnectorConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/SqlConnectorConfiguration.java
new file mode 100644
index 0000000..15563c8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/SqlConnectorConfiguration.java
@@ -0,0 +1,275 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.configuration;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * SQL connector configuration.
+ */
+public class SqlConnectorConfiguration {
+ /** Default port. */
+ public static final int DFLT_PORT = 10800;
+
+ /** Default port range. */
+ public static final int DFLT_PORT_RANGE = 100;
+
+ /** Default socket send and receive buffer size. */
+ public static final int DFLT_SOCK_BUF_SIZE = 0;
+
+ /** Default value for {@code TCP_NODELAY} socket option (value is <tt>true</tt>). */
+ public static final boolean DFLT_TCP_NO_DELAY = true;
+
+ /** Default max number of open cursors per connection. */
+ public static final int DFLT_MAX_OPEN_CURSORS_PER_CONN = 128;
+
+ /** Default size of thread pool. */
+ public static final int DFLT_THREAD_POOL_SIZE = IgniteConfiguration.DFLT_PUBLIC_THREAD_CNT;
+
+ /** Host. */
+ private String host;
+
+ /** Port. */
+ private int port = DFLT_PORT;
+
+ /** Poart range. */
+ private int portRange = DFLT_PORT_RANGE;
+
+ /** Socket send buffer size. */
+ private int sockSndBufSize = DFLT_SOCK_BUF_SIZE;
+
+ /** Socket receive buffer size. */
+ private int sockRcvBufSize = DFLT_SOCK_BUF_SIZE;
+
+ /** TCP no delay. */
+ private boolean tcpNoDelay = DFLT_TCP_NO_DELAY;
+
+ /** Max number of opened cursors per connection. */
+ private int maxOpenCursorsPerConn = DFLT_MAX_OPEN_CURSORS_PER_CONN;
+
+ /** Thread pool size. */
+ private int threadPoolSize = DFLT_THREAD_POOL_SIZE;
+
+ /**
+ * Creates SQL connector configuration with all default values.
+ */
+ public SqlConnectorConfiguration() {
+ // No-op.
+ }
+
+ /**
+ * Creates SQL connector configuration by copying all properties from given configuration.
+ *
+ * @param cfg Configuration to copy.
+ */
+ public SqlConnectorConfiguration(SqlConnectorConfiguration cfg) {
+ assert cfg != null;
+
+ host = cfg.getHost();
+ maxOpenCursorsPerConn = cfg.getMaxOpenCursorsPerConnection();
+ port = cfg.getPort();
+ portRange = cfg.getPortRange();
+ sockRcvBufSize = cfg.getSocketReceiveBufferSize();
+ sockSndBufSize = cfg.getSocketSendBufferSize();
+ tcpNoDelay = cfg.isTcpNoDelay();
+ threadPoolSize = cfg.getThreadPoolSize();
+ }
+
+ /**
+ * Get host.
+ *
+ * @return Host.
+ */
+ @Nullable public String getHost() {
+ return host;
+ }
+
+ /**
+ * Set host.
+ *
+ * @param host Host.
+ * @return This instance for chaining.
+ */
+ public SqlConnectorConfiguration setHost(@Nullable String host) {
+ this.host = host;
+
+ return this;
+ }
+
+ /**
+ * Get port.
+ *
+ * @return Port.
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * Set port.
+ *
+ * @param port Port.
+ * @return This instance for chaining.
+ */
+ public SqlConnectorConfiguration setPort(int port) {
+ this.port = port;
+
+ return this;
+ }
+
+ /**
+ * Get port range.
+ *
+ * @return Port range.
+ */
+ public int getPortRange() {
+ return portRange;
+ }
+
+ /**
+ * Set port range.
+ *
+ * @param portRange Port range.
+ * @return This instance for chaining.
+ */
+ public SqlConnectorConfiguration setPortRange(int portRange) {
+ this.portRange = portRange;
+
+ return this;
+ }
+
+ /**
+ * Gets socket send buffer size. When set to zero, operation system default will be used.
+ * <p>
+ * Defaults to {@link #DFLT_SOCK_BUF_SIZE}
+ *
+ * @return Socket send buffer size in bytes.
+ */
+ public int getSocketSendBufferSize() {
+ return sockSndBufSize;
+ }
+
+ /**
+ * Sets socket send buffer size. See {@link #getSocketSendBufferSize()} for more information.
+ *
+ * @param sockSndBufSize Socket send buffer size in bytes.
+ * @return This instance for chaining.
+ */
+ public SqlConnectorConfiguration setSocketSendBufferSize(int sockSndBufSize) {
+ this.sockSndBufSize = sockSndBufSize;
+
+ return this;
+ }
+
+ /**
+ * Gets socket receive buffer size. When set to zero, operation system default will be used.
+ * <p>
+ * Defaults to {@link #DFLT_SOCK_BUF_SIZE}.
+ *
+ * @return Socket receive buffer size in bytes.
+ */
+ public int getSocketReceiveBufferSize() {
+ return sockRcvBufSize;
+ }
+
+ /**
+ * Sets socket receive buffer size. See {@link #getSocketReceiveBufferSize()} for more information.
+ *
+ * @param sockRcvBufSize Socket receive buffer size in bytes.
+ * @return This instance for chaining.
+ */
+ public SqlConnectorConfiguration setSocketReceiveBufferSize(int sockRcvBufSize) {
+ this.sockRcvBufSize = sockRcvBufSize;
+
+ return this;
+ }
+
+ /**
+ * Get TCP NO_DELAY flag.
+ *
+ * @return TCP NO_DELAY flag.
+ */
+ public boolean isTcpNoDelay() {
+ return tcpNoDelay;
+ }
+
+ /**
+ * Set TCP NO_DELAY flag.
+ *
+ * @param tcpNoDelay TCP NO_DELAY flag.
+ * @return This instance for chaining.
+ */
+ public SqlConnectorConfiguration setTcpNoDelay(boolean tcpNoDelay) {
+ this.tcpNoDelay = tcpNoDelay;
+
+ return this;
+ }
+
+ /**
+ * Gets maximum number of opened cursors per connection.
+ * <p>
+ * Defaults to {@link #DFLT_MAX_OPEN_CURSORS_PER_CONN}.
+ *
+ * @return Maximum number of opened cursors.
+ */
+ public int getMaxOpenCursorsPerConnection() {
+ return maxOpenCursorsPerConn;
+ }
+
+ /**
+ * Sets maximum number of opened cursors per connection.
+ *
+ * @param maxOpenCursorsPerConn Maximum number of opened cursors.
+ * @return This instance for chaining.
+ */
+ public SqlConnectorConfiguration setMaxOpenCursorsPerConnection(int maxOpenCursorsPerConn) {
+ this.maxOpenCursorsPerConn = maxOpenCursorsPerConn;
+
+ return this;
+ }
+
+ /**
+ * Size of thread pool that is in charge of processing SQL requests.
+ * <p>
+ * Defaults {@link #DFLT_THREAD_POOL_SIZE}.
+ *
+ * @return Thread pool that is in charge of processing SQL requests.
+ */
+ public int getThreadPoolSize() {
+ return threadPoolSize;
+ }
+
+ /**
+ * Sets thread pool that is in charge of processing SQL requests. See {@link #getThreadPoolSize()} for more
+ * information.
+ *
+ * @param threadPoolSize Thread pool that is in charge of processing SQL requests.
+ * @return This instance for chaining.
+ */
+ public SqlConnectorConfiguration setThreadPoolSize(int threadPoolSize) {
+ this.threadPoolSize = threadPoolSize;
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(SqlConnectorConfiguration.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/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 a346ea8..8d7d6b1 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
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.jdbc.thin;
import org.apache.ignite.configuration.OdbcConfiguration;
+import org.apache.ignite.configuration.SqlConnectorConfiguration;
import java.sql.Time;
import java.sql.Timestamp;
@@ -85,7 +86,7 @@ public class JdbcThinUtils {
public static final String PROP_TCP_NO_DELAY = PROP_PREFIX + PARAM_TCP_NO_DELAY;
/** Default port. */
- public static final int DFLT_PORT = OdbcConfiguration.DFLT_TCP_PORT_FROM;
+ public static final int DFLT_PORT = SqlConnectorConfiguration.DFLT_PORT;
/**
* Trim prefix from property.
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTypes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTypes.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTypes.java
deleted file mode 100644
index 70ac92b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcTypes.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.odbc;
-
-/**
- * Data type names that can occur within ODBC escape sequence
- */
-public class OdbcTypes {
- /** Type name for BIGINT */
- static final String SQL_BIGINT = "SQL_BIGINT";
-
- /** Type name for BINARY */
- static final String SQL_BINARY = "SQL_BINARY";
-
- /** Type name for LONGVARBINARY */
- static final String SQL_LONGVARBINARY = "SQL_LONGVARBINARY";
-
- /** Type name for VARBINARY */
- static final String SQL_VARBINARY = "SQL_VARBINARY";
-
- /** Type name for BIT */
- static final String SQL_BIT = "SQL_BIT";
-
- /** Type name for CHAR */
- static final String SQL_CHAR = "SQL_CHAR";
-
- /** Type name for DECIMAL */
- static final String SQL_DECIMAL = "SQL_DECIMAL";
-
- /** Type name for NUMERIC */
- static final String SQL_NUMERIC = "SQL_NUMERIC";
-
- /** Type name for LONGVARCHAR */
- static final String SQL_LONGVARCHAR = "SQL_LONGVARCHAR";
-
- /** Type name for VARCHAR */
- static final String SQL_VARCHAR = "SQL_VARCHAR";
-
- /** Type name for WCHAR */
- static final String SQL_WCHAR = "SQL_WCHAR";
-
- /** Type name for WLONGVARCHAR */
- static final String SQL_WLONGVARCHAR = "SQL_WLONGVARCHAR";
-
- /** Type name for WVARCHAR */
- static final String SQL_WVARCHAR = "SQL_WVARCHAR";
-
- /** Type name for DOUBLE */
- static final String SQL_DOUBLE = "SQL_DOUBLE";
-
- /** Type name for FLOAT */
- static final String SQL_FLOAT = "SQL_FLOAT";
-
- /** Type name for REAL */
- static final String SQL_REAL = "SQL_REAL";
-
- /** Type name for GUID */
- static final String SQL_GUID = "SQL_GUID";
-
- /** Type name for SMALLINT */
- static final String SQL_SMALLINT = "SQL_SMALLINT";
-
- /** Type name for INTEGER */
- static final String SQL_INTEGER = "SQL_INTEGER";
-
- /** Type name for DATE */
- static final String SQL_DATE = "SQL_DATE";
-
- /** Type name for TIME */
- static final String SQL_TIME = "SQL_TIME";
-
- /** Type name for TIMESTAMP */
- static final String SQL_TIMESTAMP = "SQL_TIMESTAMP";
-
- /** Type name for TINYINT */
- static final String SQL_TINYINT = "SQL_TINYINT";
-
- /** Type name for INTERVAL_SECOND */
- static final String SQL_INTERVAL_SECOND = "SQL_INTERVAL_SECOND";
-
- /** Type name for INTERVAL_MINUTE */
- static final String SQL_INTERVAL_MINUTE = "SQL_INTERVAL_MINUTE";
-
- /** Type name for INTERVAL_HOUR */
- static final String SQL_INTERVAL_HOUR = "SQL_INTERVAL_HOUR";
-
- /** Type name for INTERVAL_DAY */
- static final String SQL_INTERVAL_DAY = "SQL_INTERVAL_DAY";
-
- /** Type name for INTERVAL_MONTH */
- static final String SQL_INTERVAL_MONTH = "SQL_INTERVAL_MONTH";
-
- /** Type name for INTERVAL_YEAR */
- static final String SQL_INTERVAL_YEAR = "SQL_INTERVAL_YEAR";
-
- /** Type name for INTERVAL_YEAR_TO_MONTH */
- static final String SQL_INTERVAL_YEAR_TO_MONTH = "SQL_INTERVAL_YEAR_TO_MONTH";
-
- /** Type name for INTERVAL_HOUR_TO_MINUTE */
- static final String SQL_INTERVAL_HOUR_TO_MINUTE = "SQL_INTERVAL_HOUR_TO_MINUTE";
-
- /** Type name for INTERVAL_HOUR_TO_SECOND */
- static final String SQL_INTERVAL_HOUR_TO_SECOND = "SQL_INTERVAL_HOUR_TO_SECOND";
-
- /** Type name for INTERVAL_MINUTE_TO_SECOND */
- static final String SQL_INTERVAL_MINUTE_TO_SECOND = "SQL_INTERVAL_MINUTE_TO_SECOND";
-
- /** Type name for INTERVAL_DAY_TO_HOUR */
- static final String SQL_INTERVAL_DAY_TO_HOUR = "SQL_INTERVAL_DAY_TO_HOUR";
-
- /** Type name for INTERVAL_DAY_TO_MINUTE */
- static final String SQL_INTERVAL_DAY_TO_MINUTE = "SQL_INTERVAL_DAY_TO_MINUTE";
-
- /** Type name for INTERVAL_DAY_TO_SECOND */
- static final String SQL_INTERVAL_DAY_TO_SECOND = "SQL_INTERVAL_DAY_TO_SECOND";
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcUtils.java
deleted file mode 100644
index 4b046e8..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcUtils.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.odbc;
-
-import org.apache.ignite.IgniteException;
-
-/**
- * Various ODBC utility methods.
- */
-public class OdbcUtils {
- /**
- * Add quotation marks at the beginning and end of the string.
- *
- * @param str Input string.
- * @return String surrounded with quotation marks.
- */
- public static String addQuotationMarksIfNeeded(String str) {
- if (str != null && !str.isEmpty() && !(str.startsWith("\"") && str.endsWith("\"")))
- return "\"" + str + "\"";
-
- return str;
- }
-
- /**
- * Remove quotation marks at the beginning and end of the string if present.
- *
- * @param str Input string.
- * @return String without leading and trailing quotation marks.
- */
- public static String removeQuotationMarksIfNeeded(String str) {
- if (str != null && str.startsWith("\"") && str.endsWith("\""))
- return str.substring(1, str.length() - 1);
-
- return str;
- }
-
- /**
- * Private constructor.
- */
- private OdbcUtils() {
- // No-op.
- }
-
- /**
- * Lookup Ignite data type corresponding to specific ODBC data type
- *
- * @param odbcDataType ODBC data type identifier
- * @return Ignite data type name
- */
- public static String getIgniteTypeFromOdbcType(String odbcDataType) {
- assert odbcDataType != null;
- switch (odbcDataType.toUpperCase()) {
- case OdbcTypes.SQL_BIGINT:
- return SqlListenerDataTypes.BIGINT;
-
- case OdbcTypes.SQL_BINARY:
- case OdbcTypes.SQL_LONGVARBINARY:
- case OdbcTypes.SQL_VARBINARY:
- return SqlListenerDataTypes.BINARY;
-
- case OdbcTypes.SQL_BIT:
- return SqlListenerDataTypes.BIT;
-
- case OdbcTypes.SQL_CHAR:
- return SqlListenerDataTypes.CHAR;
-
- case OdbcTypes.SQL_DECIMAL:
- case OdbcTypes.SQL_NUMERIC:
- return SqlListenerDataTypes.DECIMAL;
-
- case OdbcTypes.SQL_LONGVARCHAR:
- case OdbcTypes.SQL_VARCHAR:
- case OdbcTypes.SQL_WCHAR:
- case OdbcTypes.SQL_WLONGVARCHAR:
- case OdbcTypes.SQL_WVARCHAR:
- return SqlListenerDataTypes.VARCHAR;
-
- case OdbcTypes.SQL_DOUBLE:
- case OdbcTypes.SQL_FLOAT:
- return SqlListenerDataTypes.DOUBLE;
-
- case OdbcTypes.SQL_REAL:
- return SqlListenerDataTypes.REAL;
-
- case OdbcTypes.SQL_GUID:
- return SqlListenerDataTypes.UUID;
-
- case OdbcTypes.SQL_SMALLINT:
- return SqlListenerDataTypes.SMALLINT;
-
- case OdbcTypes.SQL_INTEGER:
- return SqlListenerDataTypes.INTEGER;
-
- case OdbcTypes.SQL_DATE:
- return SqlListenerDataTypes.DATE;
-
- case OdbcTypes.SQL_TIME:
- return SqlListenerDataTypes.TIME;
-
- case OdbcTypes.SQL_TIMESTAMP:
- return SqlListenerDataTypes.TIMESTAMP;
-
- case OdbcTypes.SQL_TINYINT:
- return SqlListenerDataTypes.TINYINT;
-
- //No support for interval types
- case OdbcTypes.SQL_INTERVAL_SECOND:
- case OdbcTypes.SQL_INTERVAL_MINUTE:
- case OdbcTypes.SQL_INTERVAL_HOUR:
- case OdbcTypes.SQL_INTERVAL_DAY:
- case OdbcTypes.SQL_INTERVAL_MONTH:
- case OdbcTypes.SQL_INTERVAL_YEAR:
- case OdbcTypes.SQL_INTERVAL_YEAR_TO_MONTH:
- case OdbcTypes.SQL_INTERVAL_HOUR_TO_MINUTE:
- case OdbcTypes.SQL_INTERVAL_HOUR_TO_SECOND:
- case OdbcTypes.SQL_INTERVAL_MINUTE_TO_SECOND:
- case OdbcTypes.SQL_INTERVAL_DAY_TO_HOUR:
- case OdbcTypes.SQL_INTERVAL_DAY_TO_MINUTE:
- case OdbcTypes.SQL_INTERVAL_DAY_TO_SECOND:
- throw new IgniteException("Unsupported ODBC data type '" + odbcDataType + "'");
-
- default:
- throw new IgniteException("Invalid ODBC data type '" + odbcDataType + "'");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerDataTypes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerDataTypes.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerDataTypes.java
index 0f0bfdd..c25b89d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerDataTypes.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerDataTypes.java
@@ -23,47 +23,47 @@ package org.apache.ignite.internal.processors.odbc;
*/
public class SqlListenerDataTypes {
/** Type name for 64-bit integer */
- static final String BIGINT = "BIGINT";
+ public static final String BIGINT = "BIGINT";
/** Type name for byte array */
- static final String BINARY = "BINARY";
+ public static final String BINARY = "BINARY";
/** Type name for boolean flag */
- static final String BIT = "BIT";
+ public static final String BIT = "BIT";
/** Type name for unicode string */
- static final String CHAR = "CHAR";
+ public static final String CHAR = "CHAR";
/** Type name for decimal number */
- static final String DECIMAL = "DECIMAL";
+ public static final String DECIMAL = "DECIMAL";
/** Type name for unicode string */
- static final String VARCHAR = "VARCHAR";
+ public static final String VARCHAR = "VARCHAR";
/** Type name for floating point number */
- static final String DOUBLE = "DOUBLE";
+ public static final String DOUBLE = "DOUBLE";
/** Type name for single precision floating point number */
- static final String REAL = "REAL";
+ public static final String REAL = "REAL";
/** Type name for universally unique identifier */
- static final String UUID = "UUID";
+ public static final String UUID = "UUID";
/** Type name for 16-bit integer */
- static final String SMALLINT = "SMALLINT";
+ public static final String SMALLINT = "SMALLINT";
/** Type name for 32-bit integer */
- static final String INTEGER = "INTEGER";
+ public static final String INTEGER = "INTEGER";
/** Type name for 8-bit integer */
- static final String TINYINT = "TINYINT";
+ public static final String TINYINT = "TINYINT";
/** Type name for date */
- static final String DATE = "DATE";
+ public static final String DATE = "DATE";
/** Type name for time */
- static final String TIME = "TIME";
+ public static final String TIME = "TIME";
/** Type name for timestamp */
- static final String TIMESTAMP = "TIMESTAMP";
+ public static final String TIMESTAMP = "TIMESTAMP";
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/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 e46ee50..f8f595f 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
@@ -39,7 +39,7 @@ import org.apache.ignite.internal.util.nio.GridNioSessionMetaKey;
import org.jetbrains.annotations.Nullable;
/**
- * ODBC message listener.
+ * SQL message listener.
*/
public class SqlListenerNioListener extends GridNioServerListenerAdapter<byte[]> {
/** The value corresponds to ODBC driver of the parser field of the handshake request. */
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
index 7ac0929..9a30d54 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessor.java
@@ -24,6 +24,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.OdbcConfiguration;
+import org.apache.ignite.configuration.SqlConnectorConfiguration;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.processors.GridProcessorAdapter;
import org.apache.ignite.internal.util.GridSpinBusyLock;
@@ -37,28 +38,26 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.spi.IgnitePortProtocol;
import org.apache.ignite.thread.IgniteThreadPoolExecutor;
+import org.jetbrains.annotations.Nullable;
/**
- * ODBC processor.
+ * SQL processor.
*/
public class SqlListenerProcessor extends GridProcessorAdapter {
/** Default number of selectors. */
private static final int DFLT_SELECTOR_CNT = Math.min(4, Runtime.getRuntime().availableProcessors());
- /** Default TCP_NODELAY flag. */
- private static final boolean DFLT_TCP_NODELAY = true;
-
/** Default TCP direct buffer flag. */
private static final boolean DFLT_TCP_DIRECT_BUF = false;
/** Busy lock. */
private final GridSpinBusyLock busyLock = new GridSpinBusyLock();
- /** ODBC TCP Server. */
+ /** TCP Server. */
private GridNioServer<byte[]> srv;
- /** ODBC executor service. */
- private ExecutorService odbcExecSvc;
+ /** Executor service. */
+ private ExecutorService execSvc;
/**
* @param ctx Kernal context.
@@ -71,71 +70,69 @@ public class SqlListenerProcessor extends GridProcessorAdapter {
@Override public void start(boolean activeOnStart) throws IgniteCheckedException {
IgniteConfiguration cfg = ctx.config();
- OdbcConfiguration odbcCfg = cfg.getOdbcConfiguration();
+ SqlConnectorConfiguration sqlCfg = prepareConfiguration(cfg);
- if (odbcCfg != null) {
+ if (sqlCfg != null) {
try {
- HostAndPortRange hostPort;
-
- if (F.isEmpty(odbcCfg.getEndpointAddress())) {
- hostPort = new HostAndPortRange(OdbcConfiguration.DFLT_TCP_HOST,
- OdbcConfiguration.DFLT_TCP_PORT_FROM,
- OdbcConfiguration.DFLT_TCP_PORT_TO
- );
- }
- else {
- hostPort = HostAndPortRange.parse(odbcCfg.getEndpointAddress(),
- OdbcConfiguration.DFLT_TCP_PORT_FROM,
- OdbcConfiguration.DFLT_TCP_PORT_TO,
- "Failed to parse ODBC endpoint address"
- );
- }
+ validateConfiguration(sqlCfg);
- assertParameter(odbcCfg.getThreadPoolSize() > 0, "threadPoolSize > 0");
+ // Resolve host.
+ String host = sqlCfg.getHost();
- odbcExecSvc = new IgniteThreadPoolExecutor(
- "odbc",
- cfg.getIgniteInstanceName(),
- odbcCfg.getThreadPoolSize(),
- odbcCfg.getThreadPoolSize(),
- 0,
- new LinkedBlockingQueue<Runnable>());
+ if (host == null)
+ host = cfg.getLocalHost();
- InetAddress host;
+ InetAddress hostAddr;
try {
- host = InetAddress.getByName(hostPort.host());
+ hostAddr = U.resolveLocalHost(host);
}
catch (Exception e) {
- throw new IgniteCheckedException("Failed to resolve ODBC host: " + hostPort.host(), e);
+ throw new IgniteCheckedException("Failed to resolve SQL connector host: " + host, e);
}
+ execSvc = new IgniteThreadPoolExecutor(
+ "sql-connector",
+ cfg.getIgniteInstanceName(),
+ sqlCfg.getThreadPoolSize(),
+ sqlCfg.getThreadPoolSize(),
+ 0,
+ new LinkedBlockingQueue<Runnable>());
+
Exception lastErr = null;
- for (int port = hostPort.portFrom(); port <= hostPort.portTo(); port++) {
+ int portTo = sqlCfg.getPort() + sqlCfg.getPortRange();
+
+ if (portTo <= 0) // Handle int overflow.
+ portTo = Integer.MAX_VALUE;
+
+ for (int port = sqlCfg.getPort(); port <= portTo && port <= 65535; port++) {
try {
GridNioFilter[] filters = new GridNioFilter[] {
- new GridNioAsyncNotifyFilter(ctx.igniteInstanceName(), odbcExecSvc, log) {
- @Override public void onSessionOpened(GridNioSession ses) throws IgniteCheckedException {
+ new GridNioAsyncNotifyFilter(ctx.igniteInstanceName(), execSvc, log) {
+ @Override public void onSessionOpened(GridNioSession ses)
+ throws IgniteCheckedException {
proceedSessionOpened(ses);
}
},
new GridNioCodecFilter(new SqlListenerBufferedParser(), log, false)
};
+ int maxOpenCursors = sqlCfg.getMaxOpenCursorsPerConnection();
+
GridNioServer<byte[]> srv0 = GridNioServer.<byte[]>builder()
- .address(host)
+ .address(hostAddr)
.port(port)
- .listener(new SqlListenerNioListener(ctx, busyLock, odbcCfg.getMaxOpenCursors()))
+ .listener(new SqlListenerNioListener(ctx, busyLock, maxOpenCursors))
.logger(log)
.selectorCount(DFLT_SELECTOR_CNT)
.igniteInstanceName(ctx.igniteInstanceName())
- .serverName("odbc")
- .tcpNoDelay(DFLT_TCP_NODELAY)
+ .serverName("sql-listener")
+ .tcpNoDelay(sqlCfg.isTcpNoDelay())
.directBuffer(DFLT_TCP_DIRECT_BUF)
.byteOrder(ByteOrder.nativeOrder())
- .socketSendBufferSize(odbcCfg.getSocketSendBufferSize())
- .socketReceiveBufferSize(odbcCfg.getSocketReceiveBufferSize())
+ .socketSendBufferSize(sqlCfg.getSocketSendBufferSize())
+ .socketReceiveBufferSize(sqlCfg.getSocketReceiveBufferSize())
.filters(filters)
.directMode(false)
.idleTimeout(Long.MAX_VALUE)
@@ -147,7 +144,7 @@ public class SqlListenerProcessor extends GridProcessorAdapter {
ctx.ports().registerPort(port, IgnitePortProtocol.TCP, getClass());
- log.info("ODBC processor has started on TCP port " + port);
+ log.info("SQL connector processor has started on TCP port " + port);
lastErr = null;
@@ -162,10 +159,11 @@ public class SqlListenerProcessor extends GridProcessorAdapter {
if (lastErr != null)
throw new IgniteCheckedException("Failed to bind to any [host:port] from the range [" +
- "address=" + hostPort + ", lastErr=" + lastErr + ']');
+ "host=" + host + ", portFrom=" + sqlCfg.getPort() + ", portTo=" + portTo +
+ ", lastErr=" + lastErr + ']');
}
catch (Exception e) {
- throw new IgniteCheckedException("Failed to start ODBC processor.", e);
+ throw new IgniteCheckedException("Failed to start SQL connector processor.", e);
}
}
}
@@ -179,14 +177,101 @@ public class SqlListenerProcessor extends GridProcessorAdapter {
ctx.ports().deregisterPorts(getClass());
- if (odbcExecSvc != null) {
- U.shutdownNow(getClass(), odbcExecSvc, log);
+ if (execSvc != null) {
+ U.shutdownNow(getClass(), execSvc, log);
- odbcExecSvc = null;
+ execSvc = null;
}
if (log.isDebugEnabled())
- log.debug("ODBC processor stopped.");
+ log.debug("SQL connector processor stopped.");
}
}
+
+ /**
+ * Prepare connector configuration.
+ *
+ * @param cfg Ignote configuration.
+ * @return Connector configuration.
+ * @throws IgniteCheckedException If failed.
+ */
+ @SuppressWarnings("deprecation")
+ @Nullable private SqlConnectorConfiguration prepareConfiguration(IgniteConfiguration cfg)
+ throws IgniteCheckedException {
+ SqlConnectorConfiguration res = cfg.getSqlConnectorConfiguration();
+
+ OdbcConfiguration odbcCfg = cfg.getOdbcConfiguration();
+
+ if (odbcCfg != null) {
+ if (res == null) {
+ // SQL connector is either default or null, so we replace it with ODBC stuff.
+ HostAndPortRange hostAndPort = parseOdbcEndpoint(odbcCfg);
+
+ res = new SqlConnectorConfiguration();
+
+ res.setHost(hostAndPort.host());
+ res.setPort(hostAndPort.portFrom());
+ res.setPortRange(hostAndPort.portTo() - hostAndPort.portFrom());
+ res.setThreadPoolSize(odbcCfg.getThreadPoolSize());
+ res.setSocketSendBufferSize(odbcCfg.getSocketSendBufferSize());
+ res.setSocketReceiveBufferSize(odbcCfg.getSocketReceiveBufferSize());
+ res.setMaxOpenCursorsPerConnection(odbcCfg.getMaxOpenCursors());
+
+ U.warn(log, "Automatically converted deprecated ODBC configuration to SQL connector configuration: " +
+ res);
+ }
+ else {
+ // Non-default SQL connector is set, ignore ODBC.
+ U.warn(log, "Deprecated ODBC configuration will be ignored because SQL connector configuration is " +
+ "set (either migrate to new SqlConnectorConfiguration or set " +
+ "IgniteConfiguration.sqlConnectorConfiguration to null explicitly).");
+ }
+ }
+
+ return res;
+ }
+
+ /**
+ * Validate SQL connector configuration.
+ *
+ * @param cfg Configuration.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void validateConfiguration(SqlConnectorConfiguration cfg) throws IgniteCheckedException {
+ assertParameter(cfg.getPort() > 1024, "port > 1024");
+ assertParameter(cfg.getPort() <= 65535, "port <= 65535");
+ assertParameter(cfg.getPortRange() >= 0, "portRange > 0");
+ assertParameter(cfg.getSocketSendBufferSize() >= 0, "socketSendBufferSize > 0");
+ assertParameter(cfg.getSocketReceiveBufferSize() >= 0, "socketReceiveBufferSize > 0");
+ assertParameter(cfg.getMaxOpenCursorsPerConnection() >= 0, "maxOpenCursorsPerConnection() >= 0");
+ assertParameter(cfg.getThreadPoolSize() > 0, "threadPoolSize > 0");
+ }
+
+ /**
+ * Parse ODBC endpoint.
+ *
+ * @param odbcCfg ODBC configuration.
+ * @return ODBC host and port range.
+ * @throws IgniteCheckedException If failed.
+ */
+ @SuppressWarnings("deprecation")
+ private HostAndPortRange parseOdbcEndpoint(OdbcConfiguration odbcCfg) throws IgniteCheckedException {
+ HostAndPortRange res;
+
+ if (F.isEmpty(odbcCfg.getEndpointAddress())) {
+ res = new HostAndPortRange(OdbcConfiguration.DFLT_TCP_HOST,
+ OdbcConfiguration.DFLT_TCP_PORT_FROM,
+ OdbcConfiguration.DFLT_TCP_PORT_TO
+ );
+ }
+ else {
+ res = HostAndPortRange.parse(odbcCfg.getEndpointAddress(),
+ OdbcConfiguration.DFLT_TCP_PORT_FROM,
+ OdbcConfiguration.DFLT_TCP_PORT_TO,
+ "Failed to parse SQL connector endpoint address"
+ );
+ }
+
+ return res;
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcColumnMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcColumnMeta.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcColumnMeta.java
index d9d39de..1d4f1a8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcColumnMeta.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcColumnMeta.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.odbc.odbc;
import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.internal.binary.BinaryUtils;
-import org.apache.ignite.internal.processors.odbc.OdbcUtils;
import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/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 a520d96..dfcd462 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
@@ -33,7 +33,6 @@ import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.binary.GridBinaryMarshaller;
import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
-import org.apache.ignite.internal.processors.odbc.OdbcUtils;
import org.apache.ignite.internal.processors.odbc.SqlListenerRequest;
import org.apache.ignite.internal.processors.odbc.SqlListenerRequestHandler;
import org.apache.ignite.internal.processors.odbc.SqlListenerResponse;
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcTableMeta.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcTableMeta.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcTableMeta.java
index d680435..a6bb178 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcTableMeta.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcTableMeta.java
@@ -20,7 +20,6 @@ package org.apache.ignite.internal.processors.odbc.odbc;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
import java.util.Objects;
-import org.apache.ignite.internal.processors.odbc.OdbcUtils;
/**
* ODBC table-related metadata.
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcTypes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcTypes.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcTypes.java
new file mode 100644
index 0000000..650066f
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcTypes.java
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.odbc.odbc;
+
+/**
+ * Data type names that can occur within ODBC escape sequence
+ */
+public class OdbcTypes {
+ /** Type name for BIGINT */
+ static final String SQL_BIGINT = "SQL_BIGINT";
+
+ /** Type name for BINARY */
+ static final String SQL_BINARY = "SQL_BINARY";
+
+ /** Type name for LONGVARBINARY */
+ static final String SQL_LONGVARBINARY = "SQL_LONGVARBINARY";
+
+ /** Type name for VARBINARY */
+ static final String SQL_VARBINARY = "SQL_VARBINARY";
+
+ /** Type name for BIT */
+ static final String SQL_BIT = "SQL_BIT";
+
+ /** Type name for CHAR */
+ static final String SQL_CHAR = "SQL_CHAR";
+
+ /** Type name for DECIMAL */
+ static final String SQL_DECIMAL = "SQL_DECIMAL";
+
+ /** Type name for NUMERIC */
+ static final String SQL_NUMERIC = "SQL_NUMERIC";
+
+ /** Type name for LONGVARCHAR */
+ static final String SQL_LONGVARCHAR = "SQL_LONGVARCHAR";
+
+ /** Type name for VARCHAR */
+ static final String SQL_VARCHAR = "SQL_VARCHAR";
+
+ /** Type name for WCHAR */
+ static final String SQL_WCHAR = "SQL_WCHAR";
+
+ /** Type name for WLONGVARCHAR */
+ static final String SQL_WLONGVARCHAR = "SQL_WLONGVARCHAR";
+
+ /** Type name for WVARCHAR */
+ static final String SQL_WVARCHAR = "SQL_WVARCHAR";
+
+ /** Type name for DOUBLE */
+ static final String SQL_DOUBLE = "SQL_DOUBLE";
+
+ /** Type name for FLOAT */
+ static final String SQL_FLOAT = "SQL_FLOAT";
+
+ /** Type name for REAL */
+ static final String SQL_REAL = "SQL_REAL";
+
+ /** Type name for GUID */
+ static final String SQL_GUID = "SQL_GUID";
+
+ /** Type name for SMALLINT */
+ static final String SQL_SMALLINT = "SQL_SMALLINT";
+
+ /** Type name for INTEGER */
+ static final String SQL_INTEGER = "SQL_INTEGER";
+
+ /** Type name for DATE */
+ static final String SQL_DATE = "SQL_DATE";
+
+ /** Type name for TIME */
+ static final String SQL_TIME = "SQL_TIME";
+
+ /** Type name for TIMESTAMP */
+ static final String SQL_TIMESTAMP = "SQL_TIMESTAMP";
+
+ /** Type name for TINYINT */
+ static final String SQL_TINYINT = "SQL_TINYINT";
+
+ /** Type name for INTERVAL_SECOND */
+ static final String SQL_INTERVAL_SECOND = "SQL_INTERVAL_SECOND";
+
+ /** Type name for INTERVAL_MINUTE */
+ static final String SQL_INTERVAL_MINUTE = "SQL_INTERVAL_MINUTE";
+
+ /** Type name for INTERVAL_HOUR */
+ static final String SQL_INTERVAL_HOUR = "SQL_INTERVAL_HOUR";
+
+ /** Type name for INTERVAL_DAY */
+ static final String SQL_INTERVAL_DAY = "SQL_INTERVAL_DAY";
+
+ /** Type name for INTERVAL_MONTH */
+ static final String SQL_INTERVAL_MONTH = "SQL_INTERVAL_MONTH";
+
+ /** Type name for INTERVAL_YEAR */
+ static final String SQL_INTERVAL_YEAR = "SQL_INTERVAL_YEAR";
+
+ /** Type name for INTERVAL_YEAR_TO_MONTH */
+ static final String SQL_INTERVAL_YEAR_TO_MONTH = "SQL_INTERVAL_YEAR_TO_MONTH";
+
+ /** Type name for INTERVAL_HOUR_TO_MINUTE */
+ static final String SQL_INTERVAL_HOUR_TO_MINUTE = "SQL_INTERVAL_HOUR_TO_MINUTE";
+
+ /** Type name for INTERVAL_HOUR_TO_SECOND */
+ static final String SQL_INTERVAL_HOUR_TO_SECOND = "SQL_INTERVAL_HOUR_TO_SECOND";
+
+ /** Type name for INTERVAL_MINUTE_TO_SECOND */
+ static final String SQL_INTERVAL_MINUTE_TO_SECOND = "SQL_INTERVAL_MINUTE_TO_SECOND";
+
+ /** Type name for INTERVAL_DAY_TO_HOUR */
+ static final String SQL_INTERVAL_DAY_TO_HOUR = "SQL_INTERVAL_DAY_TO_HOUR";
+
+ /** Type name for INTERVAL_DAY_TO_MINUTE */
+ static final String SQL_INTERVAL_DAY_TO_MINUTE = "SQL_INTERVAL_DAY_TO_MINUTE";
+
+ /** Type name for INTERVAL_DAY_TO_SECOND */
+ static final String SQL_INTERVAL_DAY_TO_SECOND = "SQL_INTERVAL_DAY_TO_SECOND";
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcUtils.java
new file mode 100644
index 0000000..9bdd0c7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/OdbcUtils.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.odbc.odbc;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.processors.odbc.SqlListenerDataTypes;
+
+/**
+ * Various ODBC utility methods.
+ */
+public class OdbcUtils {
+ /**
+ * Add quotation marks at the beginning and end of the string.
+ *
+ * @param str Input string.
+ * @return String surrounded with quotation marks.
+ */
+ public static String addQuotationMarksIfNeeded(String str) {
+ if (str != null && !str.isEmpty() && !(str.startsWith("\"") && str.endsWith("\"")))
+ return "\"" + str + "\"";
+
+ return str;
+ }
+
+ /**
+ * Remove quotation marks at the beginning and end of the string if present.
+ *
+ * @param str Input string.
+ * @return String without leading and trailing quotation marks.
+ */
+ public static String removeQuotationMarksIfNeeded(String str) {
+ if (str != null && str.startsWith("\"") && str.endsWith("\""))
+ return str.substring(1, str.length() - 1);
+
+ return str;
+ }
+
+ /**
+ * Private constructor.
+ */
+ private OdbcUtils() {
+ // No-op.
+ }
+
+ /**
+ * Lookup Ignite data type corresponding to specific ODBC data type
+ *
+ * @param odbcDataType ODBC data type identifier
+ * @return Ignite data type name
+ */
+ public static String getIgniteTypeFromOdbcType(String odbcDataType) {
+ assert odbcDataType != null;
+ switch (odbcDataType.toUpperCase()) {
+ case OdbcTypes.SQL_BIGINT:
+ return SqlListenerDataTypes.BIGINT;
+
+ case OdbcTypes.SQL_BINARY:
+ case OdbcTypes.SQL_LONGVARBINARY:
+ case OdbcTypes.SQL_VARBINARY:
+ return SqlListenerDataTypes.BINARY;
+
+ case OdbcTypes.SQL_BIT:
+ return SqlListenerDataTypes.BIT;
+
+ case OdbcTypes.SQL_CHAR:
+ return SqlListenerDataTypes.CHAR;
+
+ case OdbcTypes.SQL_DECIMAL:
+ case OdbcTypes.SQL_NUMERIC:
+ return SqlListenerDataTypes.DECIMAL;
+
+ case OdbcTypes.SQL_LONGVARCHAR:
+ case OdbcTypes.SQL_VARCHAR:
+ case OdbcTypes.SQL_WCHAR:
+ case OdbcTypes.SQL_WLONGVARCHAR:
+ case OdbcTypes.SQL_WVARCHAR:
+ return SqlListenerDataTypes.VARCHAR;
+
+ case OdbcTypes.SQL_DOUBLE:
+ case OdbcTypes.SQL_FLOAT:
+ return SqlListenerDataTypes.DOUBLE;
+
+ case OdbcTypes.SQL_REAL:
+ return SqlListenerDataTypes.REAL;
+
+ case OdbcTypes.SQL_GUID:
+ return SqlListenerDataTypes.UUID;
+
+ case OdbcTypes.SQL_SMALLINT:
+ return SqlListenerDataTypes.SMALLINT;
+
+ case OdbcTypes.SQL_INTEGER:
+ return SqlListenerDataTypes.INTEGER;
+
+ case OdbcTypes.SQL_DATE:
+ return SqlListenerDataTypes.DATE;
+
+ case OdbcTypes.SQL_TIME:
+ return SqlListenerDataTypes.TIME;
+
+ case OdbcTypes.SQL_TIMESTAMP:
+ return SqlListenerDataTypes.TIMESTAMP;
+
+ case OdbcTypes.SQL_TINYINT:
+ return SqlListenerDataTypes.TINYINT;
+
+ //No support for interval types
+ case OdbcTypes.SQL_INTERVAL_SECOND:
+ case OdbcTypes.SQL_INTERVAL_MINUTE:
+ case OdbcTypes.SQL_INTERVAL_HOUR:
+ case OdbcTypes.SQL_INTERVAL_DAY:
+ case OdbcTypes.SQL_INTERVAL_MONTH:
+ case OdbcTypes.SQL_INTERVAL_YEAR:
+ case OdbcTypes.SQL_INTERVAL_YEAR_TO_MONTH:
+ case OdbcTypes.SQL_INTERVAL_HOUR_TO_MINUTE:
+ case OdbcTypes.SQL_INTERVAL_HOUR_TO_SECOND:
+ case OdbcTypes.SQL_INTERVAL_MINUTE_TO_SECOND:
+ case OdbcTypes.SQL_INTERVAL_DAY_TO_HOUR:
+ case OdbcTypes.SQL_INTERVAL_DAY_TO_MINUTE:
+ case OdbcTypes.SQL_INTERVAL_DAY_TO_SECOND:
+ throw new IgniteException("Unsupported ODBC data type '" + odbcDataType + "'");
+
+ default:
+ throw new IgniteException("Invalid ODBC data type '" + odbcDataType + "'");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/escape/OdbcEscapeUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/escape/OdbcEscapeUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/escape/OdbcEscapeUtils.java
index cd97667..70a284d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/escape/OdbcEscapeUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/odbc/escape/OdbcEscapeUtils.java
@@ -18,7 +18,7 @@
package org.apache.ignite.internal.processors.odbc.odbc.escape;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.internal.processors.odbc.OdbcUtils;
+import org.apache.ignite.internal.processors.odbc.odbc.OdbcUtils;
import java.util.LinkedList;
import java.util.regex.Matcher;
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcConfigurationValidationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcConfigurationValidationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcConfigurationValidationSelfTest.java
new file mode 100644
index 0000000..ae3f592
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcConfigurationValidationSelfTest.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.odbc;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.OdbcConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * ODBC configuration validation tests.
+ */
+@SuppressWarnings("deprecation")
+public class OdbcConfigurationValidationSelfTest extends GridCommonAbstractTest {
+ /** Node index generator. */
+ private static final AtomicInteger NODE_IDX_GEN = new AtomicInteger();
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * Ensure we can start with default configuration.
+ *
+ * @throws Exception If failed.
+ */
+ public void testAddressDefault() throws Exception {
+ check(new OdbcConfiguration(), true);
+ }
+
+ /**
+ * Test address where only host is provided.
+ *
+ * @throws Exception If failed.
+ */
+ public void testAddressHostOnly() throws Exception {
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1"), true);
+ }
+
+ /**
+ * Test address with both host and port.
+ *
+ * @throws Exception If failed.
+ */
+ public void testAddressHostAndPort() throws Exception {
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999"), true);
+
+ // Shouldn't fit into range.
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999"), false);
+ }
+
+ /**
+ * Test address with host and port range.
+ *
+ * @throws Exception If failed.
+ */
+ public void testAddressHostAndPortRange() throws Exception {
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999..10000"), true);
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999..10000"), true);
+
+ // Shouldn't fit into range.
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999..10000"), false);
+ }
+
+ /**
+ * Test start with invalid host.
+ *
+ * @throws Exception If failed.
+ */
+ public void testAddressInvalidHost() throws Exception {
+ check(new OdbcConfiguration().setEndpointAddress("126.0.0.1"), false);
+ }
+
+ /**
+ * Test start with invalid address format.
+ *
+ * @throws Exception If failed.
+ */
+ public void testAddressInvalidFormat() throws Exception {
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:"), false);
+
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:0"), false);
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:-1"), false);
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:111111"), false);
+
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999.."), false);
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999..9998"), false);
+
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:a"), false);
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:a.."), false);
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:a..b"), false);
+
+ check(new OdbcConfiguration().setEndpointAddress(":9999"), false);
+ check(new OdbcConfiguration().setEndpointAddress(":9999..10000"), false);
+ }
+
+ /**
+ * Test connection parameters: sendBufferSize, receiveBufferSize, connectionTimeout.
+ *
+ * @throws Exception If failed.
+ */
+ public void testConnectionParams() throws Exception {
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000")
+ .setSocketSendBufferSize(4 * 1024), true);
+
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000")
+ .setSocketReceiveBufferSize(4 * 1024), true);
+
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000")
+ .setSocketSendBufferSize(-64 * 1024), false);
+
+ check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000")
+ .setSocketReceiveBufferSize(-64 * 1024), false);
+ }
+
+ /**
+ * Test thread pool size.
+ *
+ * @throws Exception If failed.
+ */
+ public void testThreadPoolSize() throws Exception {
+ check(new OdbcConfiguration().setThreadPoolSize(0), false);
+ check(new OdbcConfiguration().setThreadPoolSize(-1), false);
+
+ check(new OdbcConfiguration().setThreadPoolSize(4), true);
+ }
+
+ /**
+ * Perform check.
+ *
+ * @param odbcCfg ODBC configuration.
+ * @param success Success flag. * @throws Exception If failed.
+ */
+ @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+ private void check(OdbcConfiguration odbcCfg, boolean success) throws Exception {
+ final IgniteConfiguration cfg = super.getConfiguration();
+
+ cfg.setIgniteInstanceName(OdbcConfigurationValidationSelfTest.class.getName() + "-" +
+ NODE_IDX_GEN.incrementAndGet());
+
+ cfg.setLocalHost("127.0.0.1");
+ cfg.setSqlConnectorConfiguration(null);
+ cfg.setOdbcConfiguration(odbcCfg);
+ cfg.setMarshaller(new BinaryMarshaller());
+
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+ spi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
+
+ cfg.setDiscoverySpi(spi);
+
+ if (success)
+ startGrid(cfg.getIgniteInstanceName(), cfg);
+ else {
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ startGrid(cfg.getIgniteInstanceName(), cfg);
+
+ return null;
+ }
+ }, IgniteException.class, null);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessorValidationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessorValidationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessorValidationSelfTest.java
deleted file mode 100644
index e433b6c..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessorValidationSelfTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.odbc;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.OdbcConfiguration;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- * ODBC configuration validation tests.
- */
-public class SqlListenerProcessorValidationSelfTest extends GridCommonAbstractTest {
- /** Node index generator. */
- private static final AtomicInteger NODE_IDX_GEN = new AtomicInteger();
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- stopAllGrids();
- }
-
- /**
- * Ensure we can start with default configuration.
- *
- * @throws Exception If failed.
- */
- public void testAddressDefault() throws Exception {
- check(new OdbcConfiguration(), true);
- }
-
- /**
- * Test address where only host is provided.
- *
- * @throws Exception If failed.
- */
- public void testAddressHostOnly() throws Exception {
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1"), true);
- }
-
- /**
- * Test address with both host and port.
- *
- * @throws Exception If failed.
- */
- public void testAddressHostAndPort() throws Exception {
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999"), true);
-
- // Shouldn't fit into range.
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999"), false);
- }
-
- /**
- * Test address with host and port range.
- *
- * @throws Exception If failed.
- */
- public void testAddressHostAndPortRange() throws Exception {
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999..10000"), true);
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999..10000"), true);
-
- // Shouldn't fit into range.
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999..10000"), false);
- }
-
- /**
- * Test start with invalid host.
- *
- * @throws Exception If failed.
- */
- public void testAddressInvalidHost() throws Exception {
- check(new OdbcConfiguration().setEndpointAddress("126.0.0.1"), false);
- }
-
- /**
- * Test start with invalid address format.
- *
- * @throws Exception If failed.
- */
- public void testAddressInvalidFormat() throws Exception {
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:"), false);
-
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:0"), false);
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:-1"), false);
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:111111"), false);
-
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999.."), false);
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9999..9998"), false);
-
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:a"), false);
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:a.."), false);
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:a..b"), false);
-
- check(new OdbcConfiguration().setEndpointAddress(":9999"), false);
- check(new OdbcConfiguration().setEndpointAddress(":9999..10000"), false);
- }
-
- /**
- * Test connection parameters: sendBufferSize, receiveBufferSize, connectionTimeout.
- *
- * @throws Exception If failed.
- */
- public void testConnectionParams() throws Exception {
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000")
- .setSocketSendBufferSize(4 * 1024), true);
-
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000")
- .setSocketReceiveBufferSize(4 * 1024), true);
-
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000")
- .setSocketSendBufferSize(-64 * 1024), false);
-
- check(new OdbcConfiguration().setEndpointAddress("127.0.0.1:9998..10000")
- .setSocketReceiveBufferSize(-64 * 1024), false);
- }
-
- /**
- * Test thread pool size.
- *
- * @throws Exception If failed.
- */
- public void testThreadPoolSize() throws Exception {
- check(new OdbcConfiguration().setThreadPoolSize(0), false);
- check(new OdbcConfiguration().setThreadPoolSize(-1), false);
-
- check(new OdbcConfiguration().setThreadPoolSize(4), true);
- }
-
- /**
- * Perform check.
- *
- * @param odbcCfg ODBC configuration.
- * @param success Success flag. * @throws Exception If failed.
- */
- @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
- private void check(OdbcConfiguration odbcCfg, boolean success) throws Exception {
- final IgniteConfiguration cfg = super.getConfiguration();
-
- cfg.setIgniteInstanceName(SqlListenerProcessorValidationSelfTest.class.getName() + "-" +
- NODE_IDX_GEN.incrementAndGet());
-
- cfg.setLocalHost("127.0.0.1");
- cfg.setOdbcConfiguration(odbcCfg);
- cfg.setMarshaller(new BinaryMarshaller());
-
- TcpDiscoverySpi spi = new TcpDiscoverySpi();
- spi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
-
- cfg.setDiscoverySpi(spi);
-
- if (success)
- startGrid(cfg.getGridName(), cfg);
- else {
- GridTestUtils.assertThrows(log, new Callable<Void>() {
- @Override public Void call() throws Exception {
- startGrid(cfg.getGridName(), cfg);
-
- return null;
- }
- }, IgniteException.class, null);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index 46b1eb5..3305058 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -53,7 +53,7 @@ import org.apache.ignite.internal.processors.database.FreeListImplSelfTest;
import org.apache.ignite.internal.processors.database.MemoryMetricsSelfTest;
import org.apache.ignite.internal.processors.database.MetadataStorageSelfTest;
import org.apache.ignite.internal.processors.odbc.OdbcEscapeSequenceSelfTest;
-import org.apache.ignite.internal.processors.odbc.SqlListenerProcessorValidationSelfTest;
+import org.apache.ignite.internal.processors.odbc.OdbcConfigurationValidationSelfTest;
import org.apache.ignite.internal.processors.service.ClosureServiceClientsNodesTest;
import org.apache.ignite.internal.product.GridProductVersionSelfTest;
import org.apache.ignite.internal.util.nio.IgniteExceptionInNioWorkerSelfTest;
@@ -145,7 +145,7 @@ public class IgniteBasicTestSuite extends TestSuite {
suite.addTestSuite(IgniteExceptionInNioWorkerSelfTest.class);
suite.addTestSuite(IgniteLocalNodeMapBeforeStartTest.class);
- suite.addTestSuite(SqlListenerProcessorValidationSelfTest.class);
+ suite.addTestSuite(OdbcConfigurationValidationSelfTest.class);
suite.addTestSuite(OdbcEscapeSequenceSelfTest.class);
GridTestUtils.addTestIfNeeded(suite, DynamicProxySerializationMultiJvmSelfTest.class, ignoredTests);
http://git-wip-us.apache.org/repos/asf/ignite/blob/776cc6e7/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 53201a7..e7f93c5 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1830,7 +1830,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
dbUrl = "jdbc:h2:mem:" + dbName + DB_OPTIONS;
- org.h2.Driver.load();
+ //org.h2.Driver.load();
try {
if (getString(IGNITE_H2_DEBUG_CONSOLE) != null) {