You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2017/05/24 17:27:03 UTC
[19/41] ignite git commit: IGNITE-5163: Implemented infrastructure
for the new JDBC driver. This closes #1912.
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<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/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<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/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);