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 B1B83200CB6 for ; Wed, 24 May 2017 20:05:27 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B09B1160BD0; Wed, 24 May 2017 18:05:27 +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 947EF160BE2 for ; Wed, 24 May 2017 20:05:25 +0200 (CEST) Received: (qmail 35061 invoked by uid 500); 24 May 2017 18:05:24 -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 34714 invoked by uid 99); 24 May 2017 18:05:24 -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, 24 May 2017 18:05:24 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4AB1DF0DBE; Wed, 24 May 2017 18:05:24 +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, 24 May 2017 18:05:36 -0000 Message-Id: <0dd89a8bb2324756b1566353a04b7fe3@git.apache.org> In-Reply-To: <70bd05f26a064bf9987ad9d78809c8ec@git.apache.org> References: <70bd05f26a064bf9987ad9d78809c8ec@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [13/32] ignite git commit: IGNITE-5163: Implemented infrastructure for the new JDBC driver. This closes #1912. archived-at: Wed, 24 May 2017 18:05:27 -0000 http://git-wip-us.apache.org/repos/asf/ignite/blob/6f1dc3ac/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcProcessorValidationSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcProcessorValidationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcProcessorValidationSelfTest.java deleted file mode 100644 index 3d21948..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/OdbcProcessorValidationSelfTest.java +++ /dev/null @@ -1,182 +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 OdbcProcessorValidationSelfTest 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(OdbcProcessorValidationSelfTest.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() { - @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/6f1dc3ac/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 new file mode 100644 index 0000000..e433b6c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/odbc/SqlListenerProcessorValidationSelfTest.java @@ -0,0 +1,184 @@ +/* + * 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() { + @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/6f1dc3ac/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java index 1a821a1..8559b97 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java @@ -344,7 +344,7 @@ public final class GridTestUtils { Throwable t = e; while (t != null) { - if (cls == t.getClass() && (msg == null || (t.getMessage() != null || t.getMessage().contains(msg)))) { + if (cls == t.getClass() && (msg == null || (t.getMessage() != null && t.getMessage().contains(msg)))) { log.info("Caught expected exception: " + t.getMessage()); return t; http://git-wip-us.apache.org/repos/asf/ignite/blob/6f1dc3ac/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 0ec0f0d..ee69f24 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 @@ -52,7 +52,7 @@ import org.apache.ignite.internal.processors.database.BPlusTreeSelfTest; import org.apache.ignite.internal.processors.database.FreeListImplSelfTest; import org.apache.ignite.internal.processors.database.MetadataStorageSelfTest; import org.apache.ignite.internal.processors.odbc.OdbcEscapeSequenceSelfTest; -import org.apache.ignite.internal.processors.odbc.OdbcProcessorValidationSelfTest; +import org.apache.ignite.internal.processors.odbc.SqlListenerProcessorValidationSelfTest; import org.apache.ignite.internal.processors.service.ClosureServiceClientsNodesTest; import org.apache.ignite.internal.product.GridProductVersionSelfTest; import org.apache.ignite.internal.util.nio.IgniteExceptionInNioWorkerSelfTest; @@ -142,7 +142,7 @@ public class IgniteBasicTestSuite extends TestSuite { suite.addTestSuite(IgniteExceptionInNioWorkerSelfTest.class); suite.addTestSuite(IgniteLocalNodeMapBeforeStartTest.class); - suite.addTestSuite(OdbcProcessorValidationSelfTest.class); + suite.addTestSuite(SqlListenerProcessorValidationSelfTest.class); suite.addTestSuite(OdbcEscapeSequenceSelfTest.class); GridTestUtils.addTestIfNeeded(suite, DynamicProxySerializationMultiJvmSelfTest.class, ignoredTests); http://git-wip-us.apache.org/repos/asf/ignite/blob/6f1dc3ac/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 aca214a..54c00fd 100644 --- a/modules/platforms/cpp/odbc/include/ignite/odbc/message.h +++ b/modules/platforms/cpp/odbc/include/ignite/odbc/message.h @@ -34,6 +34,14 @@ namespace ignite { namespace odbc { + struct ClientType + { + enum Type + { + ODBC = 0 + }; + }; + struct RequestType { enum Type @@ -104,6 +112,8 @@ namespace ignite writer.WriteInt16(version.GetMajor()); writer.WriteInt16(version.GetMinor()); writer.WriteInt16(version.GetMaintenance()); + + writer.WriteInt8(ClientType::ODBC); writer.WriteBool(distributedJoins); writer.WriteBool(enforceJoinOrder);