You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2016/09/05 08:11:37 UTC
[1/7] ignite git commit: IGNITE-3811 Fixed query for merge with
complex key on SQL Server.
Repository: ignite
Updated Branches:
refs/heads/master 347429ac6 -> 857a1eac1
IGNITE-3811 Fixed query for merge with complex key on SQL Server.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/dabd86c6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/dabd86c6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/dabd86c6
Branch: refs/heads/master
Commit: dabd86c62e39eb983ef3d198c8b8ee96d2623c84
Parents: 1ef150e
Author: Andrey Novikov <an...@apache.org>
Authored: Wed Aug 31 16:00:19 2016 +0700
Committer: Andrey Novikov <an...@apache.org>
Committed: Wed Aug 31 16:00:19 2016 +0700
----------------------------------------------------------------------
.../apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/dabd86c6/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java
index 0082617..9831aa8 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/dialect/SQLServerDialect.java
@@ -44,7 +44,7 @@ public class SQLServerDialect extends BasicJdbcDialect {
@Override public String apply(String col) {
return String.format("t.%s=v.%s", col, col);
}
- }, "", ", ", "");
+ }, "", " AND ", "");
String setCols = mkString(uniqCols, new C1<String, String>() {
@Override public String apply(String col) {
[2/7] ignite git commit: IGNITE-3390: Added DSN configuration window.
Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/protocol_version.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/protocol_version.cpp b/modules/platforms/cpp/odbc/src/protocol_version.cpp
new file mode 100644
index 0000000..818df88
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/protocol_version.cpp
@@ -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.
+ */
+#include <ignite/common/concurrent.h>
+#include <ignite/common/utils.h>
+#include <ignite/ignite_error.h>
+
+#include "ignite/odbc/protocol_version.h"
+#include "ignite/odbc/utility.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ const ProtocolVersion ProtocolVersion::VERSION_1_6_0(1);
+ const ProtocolVersion ProtocolVersion::VERSION_UNKNOWN(INT64_MIN);
+
+ ProtocolVersion::StringToVersionMap::value_type s2vInitVals[] = {
+ std::make_pair("1.6.0", ProtocolVersion::VERSION_1_6_0)
+ };
+
+ const ProtocolVersion::StringToVersionMap ProtocolVersion::stringToVersionMap(s2vInitVals,
+ s2vInitVals + (sizeof(s2vInitVals) / sizeof(s2vInitVals[0])));
+
+ ProtocolVersion::VersionToStringMap::value_type v2sInitVals[] = {
+ std::make_pair(ProtocolVersion::VERSION_1_6_0, "1.6.0")
+ };
+
+ const ProtocolVersion::VersionToStringMap ProtocolVersion::versionToStringMap(v2sInitVals,
+ v2sInitVals + (sizeof(v2sInitVals) / sizeof(v2sInitVals[0])));
+
+ ProtocolVersion::ProtocolVersion(int64_t val) :
+ val(val)
+ {
+ // No-op.
+ }
+
+ const ProtocolVersion::StringToVersionMap& ProtocolVersion::GetMap()
+ {
+ return stringToVersionMap;
+ }
+
+ const ProtocolVersion& ProtocolVersion::GetCurrent()
+ {
+ return VERSION_1_6_0;
+ }
+
+ ProtocolVersion ProtocolVersion::FromString(const std::string& version)
+ {
+ StringToVersionMap::const_iterator it = stringToVersionMap.find(common::ToLower(version));
+
+ if (it == stringToVersionMap.end())
+ {
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+ "Invalid version format. Valid format is X.Y.Z, where X, Y and Z are major "
+ "and minor versions and revision of Ignite since which protocol is introduced.");
+ }
+
+ return it->second;
+ }
+
+ const std::string& ProtocolVersion::ToString() const
+ {
+ VersionToStringMap::const_iterator it = versionToStringMap.find(*this);
+
+ if (it == versionToStringMap.end())
+ {
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+ "Unknown protocol version can not be converted to string.");
+ }
+
+ return it->second;
+ }
+
+ int64_t ProtocolVersion::GetIntValue() const
+ {
+ assert(!IsUnknown());
+
+ return val;
+ }
+
+ bool ProtocolVersion::IsUnknown() const
+ {
+ return *this == VERSION_UNKNOWN;
+ }
+
+ bool operator==(const ProtocolVersion& val1, const ProtocolVersion& val2)
+ {
+ return val1.val == val2.val;
+ }
+
+ bool operator!=(const ProtocolVersion& val1, const ProtocolVersion& val2)
+ {
+ return val1.val != val2.val;
+ }
+
+ bool operator<(const ProtocolVersion& val1, const ProtocolVersion& val2)
+ {
+ return val1.val < val2.val;
+ }
+
+ bool operator<=(const ProtocolVersion& val1, const ProtocolVersion& val2)
+ {
+ return val1.val <= val2.val;
+ }
+
+ bool operator>(const ProtocolVersion& val1, const ProtocolVersion& val2)
+ {
+ return val1.val > val2.val;
+ }
+
+ bool operator>=(const ProtocolVersion& val1, const ProtocolVersion& val2)
+ {
+ return val1.val >= val2.val;
+ }
+ }
+}
+
[7/7] ignite git commit: Merge branches 'ignite-1.7.2' to 'master'.
Posted by ak...@apache.org.
Merge branches 'ignite-1.7.2' to 'master'.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/857a1eac
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/857a1eac
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/857a1eac
Branch: refs/heads/master
Commit: 857a1eac12a39ea8d269ac35be7267d8cf16818b
Parents: 347429a afac3fa
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Sep 5 15:11:00 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Sep 5 15:11:00 2016 +0700
----------------------------------------------------------------------
.../store/jdbc/dialect/SQLServerDialect.java | 2 +-
.../cpp/odbc/include/ignite/odbc/connection.h | 7 -
.../ignite/visor/commands/VisorConsole.scala | 1 +
.../commands/cache/VisorCacheCommand.scala | 33 ++++-
.../commands/cache/VisorCacheResetCommand.scala | 129 +++++++++++++++++++
.../cache/VisorCacheResetCommandSpec.scala | 114 ++++++++++++++++
6 files changed, 272 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
[6/7] ignite git commit: IGNITE-1952 Visorcmd: add a command for
reset (clear) of metrics. Fixes #1029.
Posted by ak...@apache.org.
IGNITE-1952 Visorcmd: add a command for reset (clear) of metrics. Fixes #1029.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/afac3fab
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/afac3fab
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/afac3fab
Branch: refs/heads/master
Commit: afac3fab5f22250b830383a9f10336d396c83ad9
Parents: bdbc5a3
Author: Saikat Maitra <sa...@gmail.com>
Authored: Mon Sep 5 15:06:39 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Sep 5 15:06:39 2016 +0700
----------------------------------------------------------------------
.../ignite/visor/commands/VisorConsole.scala | 1 +
.../commands/cache/VisorCacheCommand.scala | 33 ++++-
.../commands/cache/VisorCacheResetCommand.scala | 129 +++++++++++++++++++
.../cache/VisorCacheResetCommandSpec.scala | 114 ++++++++++++++++
4 files changed, 271 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/afac3fab/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
index b4d78b5..ad8c2ed 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/VisorConsole.scala
@@ -62,6 +62,7 @@ class VisorConsole {
org.apache.ignite.visor.commands.ack.VisorAckCommand
org.apache.ignite.visor.commands.alert.VisorAlertCommand
org.apache.ignite.visor.commands.cache.VisorCacheClearCommand
+ org.apache.ignite.visor.commands.cache.VisorCacheResetCommand
org.apache.ignite.visor.commands.cache.VisorCacheCommand
org.apache.ignite.visor.commands.cache.VisorCacheSwapCommand
org.apache.ignite.visor.commands.config.VisorConfigurationCommand
http://git-wip-us.apache.org/repos/asf/ignite/blob/afac3fab/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
index 68465de..1fa185f 100755
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
@@ -58,6 +58,9 @@ import scala.language.{implicitConversions, reflectiveCalls}
* +-----------------------------------------------------------------------------------------+
* | cache -stop | Stop cache with specified name. |
* +-----------------------------------------------------------------------------------------+
+ * | cache -reset | Reset metrics for cache with specified name. |
+ * +-----------------------------------------------------------------------------------------+
+ *
* }}}
*
* ====Specification====
@@ -69,6 +72,7 @@ import scala.language.{implicitConversions, reflectiveCalls}
* cache -scan -c=<cache-name> {-id=<node-id>|id8=<node-id8>} {-p=<page size>} {-system}
* cache -swap {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>}
* cache -stop -c=<cache-name>
+ * cache -reset -c=<cache-name>
* }}}
*
* ====Arguments====
@@ -113,6 +117,8 @@ import scala.language.{implicitConversions, reflectiveCalls}
* Swaps backup entries in cache.
* -stop
* Stop cache with specified name.
+ * -reset
+ * Reset metrics for cache with specified name.
* -p=<page size>
* Number of object to fetch from cache at once.
* Valid range from 1 to 100.
@@ -153,6 +159,9 @@ import scala.language.{implicitConversions, reflectiveCalls}
* Swaps entries in cache with name taken from 'c0' memory variable.
* cache -stop -c=cache
* Stops cache with name 'cache'.
+ * cache -reset -c=cache
+ * Reset metrics for cache with name 'cache'.
+ *
* }}}
*/
class VisorCacheCommand {
@@ -210,6 +219,9 @@ class VisorCacheCommand {
* <br>
* <ex>cache -stop -c=@c0</ex>
* Stop cache with name taken from 'c0' memory variable.
+ * <br>
+ * <ex>cache -reset -c=@c0</ex>
+ * Reset metrics for cache with name taken from 'c0' memory variable.
*
* @param args Command arguments.
*/
@@ -260,9 +272,9 @@ class VisorCacheCommand {
// Get cache stats data from all nodes.
val aggrData = cacheData(node, cacheName, showSystem)
- if (hasArgFlagIn("clear", "swap", "scan", "stop")) {
+ if (hasArgFlagIn("clear", "swap", "scan", "stop", "reset")) {
if (cacheName.isEmpty)
- askForCache("Select cache from:", node, showSystem && !hasArgFlagIn("clear", "swap", "stop"), aggrData) match {
+ askForCache("Select cache from:", node, showSystem && !hasArgFlagIn("clear", "swap", "stop", "reset"), aggrData) match {
case Some(name) =>
argLst = argLst ++ Seq("c" -> name)
@@ -282,6 +294,8 @@ class VisorCacheCommand {
VisorCacheSwapCommand().swap(argLst, node)
else if (hasArgFlag("stop", argLst))
VisorCacheStopCommand().stop(argLst, node)
+ else if (hasArgFlag("reset", argLst))
+ VisorCacheResetCommand().reset(argLst, node)
}
else {
if (hasArgFlag("clear", argLst))
@@ -290,6 +304,8 @@ class VisorCacheCommand {
warn("Backup swapping of system cache is not allowed: " + name)
else if (hasArgFlag("stop", argLst))
warn("Stopping of system cache is not allowed: " + name)
+ else if (hasArgFlag("reset", argLst))
+ warn("Reset metrics of system cache is not allowed: " + name)
}
}
})
@@ -716,8 +732,9 @@ object VisorCacheCommand {
"cache -clear {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>}",
"cache -scan -c=<cache-name> {-id=<node-id>|id8=<node-id8>} {-p=<page size>}",
"cache -swap {-c=<cache-name>} {-id=<node-id>|id8=<node-id8>}",
- "cache -stop -c=<cache-name>"
- ),
+ "cache -stop -c=<cache-name>",
+ "cache -reset -c=<cache-name>"
+ ),
args = Seq(
"-id8=<node-id>" -> Seq(
"ID8 of the node to get cache statistics from.",
@@ -749,7 +766,10 @@ object VisorCacheCommand {
"Swaps backup entries in cache."
),
"-stop" -> Seq(
- "Stop cache with specified name"
+ "Stop cache with specified name."
+ ),
+ "-reset" -> Seq(
+ "Reset metrics of cache with specified name."
),
"-s=hi|mi|rd|wr|cn" -> Seq(
"Defines sorting type. Sorted by:",
@@ -809,7 +829,8 @@ object VisorCacheCommand {
"cache -swap" -> "Swaps entries in interactively selected cache.",
"cache -swap -c=cache" -> "Swaps entries in cache with name 'cache'.",
"cache -swap -c=@c0" -> "Swaps entries in cache with name taken from 'c0' memory variable.",
- "cache -stop -c=@c0" -> "Stop cache with name taken from 'c0' memory variable."
+ "cache -stop -c=@c0" -> "Stop cache with name taken from 'c0' memory variable.",
+ "cache -reset -c=@c0" -> "Reset metrics for cache with name taken from 'c0' memory variable."
),
emptyArgs = cmd.cache,
withArgs = cmd.cache
http://git-wip-us.apache.org/repos/asf/ignite/blob/afac3fab/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommand.scala
new file mode 100644
index 0000000..b59155b
--- /dev/null
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommand.scala
@@ -0,0 +1,129 @@
+/*
+ * 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.visor.commands.cache
+
+import org.apache.ignite.cluster.{ClusterGroupEmptyException, ClusterNode}
+import org.apache.ignite.internal.visor.cache.VisorCacheResetMetricsTask
+import org.apache.ignite.internal.visor.util.VisorTaskUtils._
+import org.apache.ignite.visor.visor._
+
+import scala.language.reflectiveCalls
+
+/**
+ * ==Overview==
+ * Visor 'reset' command implementation.
+ *
+ * ====Specification====
+ * {{{
+ * cache -reset -c=<cache name>
+ * }}}
+ *
+ * ====Arguments====
+ * {{{
+ * <cache-name>
+ * Name of the cache.
+ * }}}
+ *
+ * ====Examples====
+ * {{{
+ * cache -reset -c=@c0
+ * Reset metrics for cache with name taken from 'c0' memory variable.
+ * }}}
+ */
+class VisorCacheResetCommand {
+ /**
+ * Prints error message and advise.
+ *
+ * @param errMsgs Error messages.
+ */
+ private def scold(errMsgs: Any*) {
+ assert(errMsgs != null)
+
+ warn(errMsgs: _*)
+ warn("Type 'help cache' to see how to use this command.")
+ }
+
+ private def error(e: Exception) {
+ var cause: Throwable = e
+
+ while (cause.getCause != null)
+ cause = cause.getCause
+
+ scold(cause.getMessage)
+ }
+
+ /**
+ * ===Command===
+ * Reset metrics for cache with specified name.
+ *
+ * ===Examples===
+ * <ex>cache -c=cache -reset</ex>
+ * Reset metrics for cache with name 'cache'.
+ *
+ * @param argLst Command arguments.
+ */
+ def reset(argLst: ArgList, node: Option[ClusterNode]) {
+ val cacheArg = argValue("c", argLst)
+
+ val cacheName = cacheArg match {
+ case None => null // default cache.
+
+ case Some(s) if s.startsWith("@") =>
+ warn("Can't find cache variable with specified name: " + s,
+ "Type 'cache' to see available cache variables."
+ )
+
+ return
+
+ case Some(name) => name
+ }
+
+ val grp = try {
+ groupForDataNode(node, cacheName)
+ }
+ catch {
+ case _: ClusterGroupEmptyException =>
+ scold(messageNodeNotFound(node, cacheName))
+
+ return
+ }
+
+ try {
+ executeRandom(grp, classOf[VisorCacheResetMetricsTask], cacheName)
+
+ println("Visor successfully reset metrics for cache: " + escapeName(cacheName))
+ }
+ catch {
+ case _: ClusterGroupEmptyException => scold(messageNodeNotFound(node, cacheName))
+ case e: Exception => error(e)
+ }
+ }
+}
+
+/**
+ * Companion object that does initialization of the command.
+ */
+object VisorCacheResetCommand {
+ /** Singleton command. */
+ private val cmd = new VisorCacheResetCommand
+
+ /**
+ * Singleton.
+ */
+ def apply() = cmd
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/afac3fab/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommandSpec.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommandSpec.scala b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommandSpec.scala
new file mode 100644
index 0000000..18f728c
--- /dev/null
+++ b/modules/visor-console/src/test/scala/org/apache/ignite/visor/commands/cache/VisorCacheResetCommandSpec.scala
@@ -0,0 +1,114 @@
+/*
+ * 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.visor.commands.cache
+
+import org.apache.ignite.Ignition
+import org.apache.ignite.cache.CacheAtomicityMode._
+import org.apache.ignite.cache.CacheMode._
+import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration}
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder
+import org.apache.ignite.visor.commands.cache.VisorCacheCommand._
+import org.apache.ignite.visor.{VisorRuntimeBaseSpec, visor}
+import org.jetbrains.annotations.Nullable
+
+import scala.collection.JavaConversions._
+
+/**
+ * Unit test for 'reset' command.
+ */
+class VisorCacheResetCommandSpec extends VisorRuntimeBaseSpec(2) {
+ /** IP finder. */
+ val ipFinder = new TcpDiscoveryVmIpFinder(true)
+
+ /**
+ * Creates grid configuration for provided grid host.
+ *
+ * @param name Grid name.
+ * @return Grid configuration.
+ */
+ override def config(name: String): IgniteConfiguration = {
+ val cfg = new IgniteConfiguration
+
+ cfg.setGridName(name)
+ cfg.setLocalHost("127.0.0.1")
+ cfg.setCacheConfiguration(cacheConfig(null), cacheConfig("cache"))
+
+ val discoSpi = new TcpDiscoverySpi()
+
+ discoSpi.setIpFinder(ipFinder)
+
+ cfg.setDiscoverySpi(discoSpi)
+
+ cfg
+ }
+
+ /**
+ * @param name Cache name.
+ * @return Cache Configuration.
+ */
+ def cacheConfig(@Nullable name: String): CacheConfiguration[Object, Object] = {
+ val cfg = new CacheConfiguration[Object, Object]
+
+ cfg.setCacheMode(REPLICATED)
+ cfg.setAtomicityMode(TRANSACTIONAL)
+ cfg.setName(name)
+
+ cfg
+ }
+
+ describe("A 'reset' visor command") {
+ it("should show correct result for default cache") {
+ Ignition.ignite("node-1").cache[Int, Int](null).putAll(Map(1 -> 1, 2 -> 2, 3 -> 3))
+
+ val lock = Ignition.ignite("node-1").cache[Int, Int](null).lock(1)
+
+ lock.lock()
+
+ VisorCacheResetCommand().reset(Nil, None)
+
+ lock.unlock()
+
+ VisorCacheResetCommand().reset(Nil, None)
+ }
+
+ it("should show correct result for named cache") {
+ Ignition.ignite("node-1").cache[Int, Int]("cache").putAll(Map(1 -> 1, 2 -> 2, 3 -> 3))
+
+ val lock = Ignition.ignite("node-1").cache[Int, Int]("cache").lock(1)
+
+ lock.lock()
+
+ visor.cache("-reset -c=cache")
+
+ lock.unlock()
+
+ visor.cache("-reset -c=cache")
+ }
+
+ it("should show correct help") {
+ VisorCacheCommand
+
+ visor.help("cache")
+ }
+
+ it("should show empty projection error message") {
+ visor.cache("-reset -c=wrong")
+ }
+ }
+}
[5/7] ignite git commit: Merge branch 'ignite-1.6.7' into ignite-1.7.2
Posted by ak...@apache.org.
Merge branch 'ignite-1.6.7' into ignite-1.7.2
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bdbc5a37
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bdbc5a37
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bdbc5a37
Branch: refs/heads/master
Commit: bdbc5a37c1924ba4427221ee6cdf506c7f3ba248
Parents: 31dbc5d 70e69cb
Author: isapego <is...@gridgain.com>
Authored: Wed Aug 31 17:13:34 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Wed Aug 31 17:13:34 2016 +0300
----------------------------------------------------------------------
.../ignite/cache/store/jdbc/dialect/SQLServerDialect.java | 2 +-
modules/platforms/cpp/odbc/include/ignite/odbc/connection.h | 7 -------
2 files changed, 1 insertion(+), 8 deletions(-)
----------------------------------------------------------------------
[3/7] ignite git commit: IGNITE-3390: Added DSN configuration window.
Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/custom_window.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/custom_window.h b/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/custom_window.h
new file mode 100644
index 0000000..1502c07
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/custom_window.h
@@ -0,0 +1,189 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_SYSTEM_UI_CUSTOM_WINDOW
+#define _IGNITE_ODBC_SYSTEM_UI_CUSTOM_WINDOW
+
+#include "ignite/odbc/system/ui/window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ /**
+ * Application execution result.
+ */
+ enum Result
+ {
+ RESULT_OK,
+ RESULT_CANCEL
+ };
+
+ /**
+ * Process UI messages in current thread.
+ * Blocks until quit message has been received.
+ *
+ * @param window Main window.
+ * @return Application execution result.
+ */
+ Result ProcessMessages(Window& window);
+
+ /**
+ * Window class.
+ */
+ class CustomWindow : public Window
+ {
+ public:
+ /**
+ * Constructor.
+ *
+ * @param parent Parent window.
+ * @param className Window class name.
+ * @param title Window title.
+ * @param callback Event processing function.
+ */
+ CustomWindow(Window* parent, const char* className, const char* title);
+
+ /**
+ * Destructor.
+ */
+ virtual ~CustomWindow();
+
+ /**
+ * Callback which is called upon receiving new message.
+ * Pure virtual. Should be defined by user.
+ *
+ * @param msg Message.
+ * @param wParam Word-sized parameter.
+ * @param lParam Long parameter.
+ * @return Should return true if the message has been
+ * processed by the handler and false otherwise.
+ */
+ virtual bool OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) = 0;
+
+ /**
+ * Callback that is called upon window creation.
+ */
+ virtual void OnCreate() = 0;
+
+ /**
+ * Create child group box window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateGroupBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id);
+
+ /**
+ * Create child label window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateLabel(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id);
+
+ /**
+ * Create child Edit window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateEdit(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id, int style = 0);
+
+ /**
+ * Create child button window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateButton(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id);
+
+ /**
+ * Create child CheckBox window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateCheckBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id, bool state);
+
+ /**
+ * Create child ComboBox window.
+ *
+ * @param posX Position by X coordinate.
+ * @param posY Position by Y coordinate.
+ * @param sizeX Size by X coordinate.
+ * @param sizeY Size by Y coordinate.
+ * @param title Title.
+ * @param id ID to be assigned to the created window.
+ * @return Auto pointer containing new window.
+ */
+ std::auto_ptr<Window> CreateComboBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id);
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(CustomWindow)
+
+ /**
+ * Static callback.
+ *
+ * @param hwnd Window handle.
+ * @param msg Message.
+ * @param wParam Word-sized parameter.
+ * @param lParam Long parameter.
+ * @return Operation result.
+ */
+ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+ };
+ }
+ }
+ }
+}
+
+#endif //_IGNITE_ODBC_SYSTEM_UI_CUSTOM_WINDOW
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/window.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/window.h b/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/window.h
new file mode 100644
index 0000000..32a54b2
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/include/ignite/odbc/system/ui/window.h
@@ -0,0 +1,201 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_SYSTEM_UI_WINDOW
+#define _IGNITE_ODBC_SYSTEM_UI_WINDOW
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/system/odbc_constants.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ /**
+ * Get handle for the current module.
+ *
+ * @return Handle for the current module.
+ */
+ HINSTANCE GetHInstance();
+
+ /**
+ * Window class.
+ */
+ class Window
+ {
+ public:
+ /**
+ * Constructor for a new window that is going to be created.
+ *
+ * @param parent Parent window handle.
+ * @param className Window class name.
+ * @param title Window title.
+ * @param callback Event processing function.
+ */
+ Window(Window* parent, const char* className, const char* title);
+
+ /**
+ * Constructor for the existing window.
+ *
+ * @param handle Window handle.
+ */
+ Window(HWND handle);
+
+ /**
+ * Destructor.
+ */
+ virtual ~Window();
+
+ /**
+ * Create window.
+ *
+ * @param style Window style.
+ * @param posX Window x position.
+ * @param posY Window y position.
+ * @param width Window width.
+ * @param height Window height.
+ * @param id ID for child window.
+ */
+ void Create(DWORD style, int posX, int posY, int width, int height, int id);
+
+ /**
+ * Show window.
+ */
+ void Show();
+
+ /**
+ * Update window.
+ */
+ void Update();
+
+ /**
+ * Destroy window.
+ */
+ void Destroy();
+
+ /**
+ * Get window handle.
+ *
+ * @return Window handle.
+ */
+ HWND GetHandle() const
+ {
+ return handle;
+ }
+
+ /**
+ * Get window text.
+ *
+ * @param text Text.
+ */
+ void GetText(std::string& text) const;
+
+ /**
+ * Set window text.
+ *
+ * @param text Text.
+ */
+ void SetText(const std::string& text) const;
+
+ /**
+ * Get CheckBox state.
+ *
+ * @param True if checked.
+ */
+ bool IsChecked() const;
+
+ /**
+ * Set CheckBox state.
+ *
+ * @param state True if checked.
+ */
+ void SetChecked(bool state);
+
+ /**
+ * Add string.
+ *
+ * @param str String.
+ */
+ void AddString(const std::string& str);
+
+ /**
+ * Set current ComboBox selection.
+ *
+ * @param idx List index.
+ */
+ void SetSelection(int idx);
+
+ /**
+ * Get current ComboBox selection.
+ *
+ * @return idx List index.
+ */
+ int GetSelection() const;
+
+ /**
+ * Set enabled.
+ *
+ * @param enabled Enable flag.
+ */
+ void SetEnabled(bool enabled);
+
+ /**
+ * Check if the window is enabled.
+ *
+ * @return True if enabled.
+ */
+ bool IsEnabled() const;
+
+ protected:
+ /**
+ * Set window handle.
+ *
+ * @param value Window handle.
+ */
+ void SetHandle(HWND value)
+ {
+ handle = value;
+ }
+
+ /** Window class name. */
+ std::string className;
+
+ /** Window title. */
+ std::string title;
+
+ /** Window handle. */
+ HWND handle;
+
+ /** Specifies whether window has been created by the thread and needs destruction. */
+ bool created;
+
+ /** Window parent. */
+ Window* parent;
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(Window)
+ };
+ }
+ }
+ }
+}
+
+#endif //_IGNITE_ODBC_SYSTEM_UI_WINDOW
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/os/win/src/system/ui/custom_window.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/src/system/ui/custom_window.cpp b/modules/platforms/cpp/odbc/os/win/src/system/ui/custom_window.cpp
new file mode 100644
index 0000000..1e855a1
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/src/system/ui/custom_window.cpp
@@ -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.
+ */
+
+#include <Windowsx.h>
+
+#include "ignite/odbc/system/ui/custom_window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ Result ProcessMessages(Window& window)
+ {
+ MSG msg;
+
+ while (GetMessage(&msg, NULL, 0, 0) > 0)
+ {
+ if (!IsDialogMessage(window.GetHandle(), &msg))
+ {
+ TranslateMessage(&msg);
+
+ DispatchMessage(&msg);
+ }
+ }
+
+ return static_cast<Result>(msg.wParam);
+ }
+
+ LRESULT CALLBACK CustomWindow::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+ {
+ CustomWindow* window = reinterpret_cast<CustomWindow*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
+
+ switch (msg)
+ {
+ case WM_NCCREATE:
+ {
+ _ASSERT(lParam != NULL);
+
+ CREATESTRUCT* createStruct = reinterpret_cast<CREATESTRUCT*>(lParam);
+
+ LONG_PTR longSelfPtr = reinterpret_cast<LONG_PTR>(createStruct->lpCreateParams);
+
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, longSelfPtr);
+
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+ }
+
+ case WM_CREATE:
+ {
+ _ASSERT(window != NULL);
+
+ window->SetHandle(hwnd);
+
+ window->OnCreate();
+
+ return 0;
+ }
+
+ default:
+ break;
+ }
+
+ if (window && window->OnMessage(msg, wParam, lParam))
+ return 0;
+
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+ }
+
+ CustomWindow::CustomWindow(Window* parent, const char* className, const char* title) :
+ Window(parent, className, title)
+ {
+ WNDCLASS wcx;
+
+ wcx.style = CS_HREDRAW | CS_VREDRAW;
+ wcx.lpfnWndProc = WndProc;
+ wcx.cbClsExtra = 0;
+ wcx.cbWndExtra = 0;
+ wcx.hInstance = GetHInstance();
+ wcx.hIcon = NULL;
+ wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcx.hbrBackground = (HBRUSH)COLOR_WINDOW;
+ wcx.lpszMenuName = NULL;
+ wcx.lpszClassName = className;
+
+
+ if (!RegisterClass(&wcx))
+ {
+ std::stringstream buf;
+
+ buf << "Can not register window class, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+ }
+
+ CustomWindow::~CustomWindow()
+ {
+ UnregisterClass(className.c_str(), GetHInstance());
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateGroupBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Button", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | BS_GROUPBOX, posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateLabel(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Static", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE, posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateEdit(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id, int style)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Edit", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL | WS_TABSTOP | style,
+ posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateButton(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Button", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP, posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateCheckBox(int posX, int posY,
+ int sizeX, int sizeY, const char* title, int id, bool state)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Button", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | BS_CHECKBOX, posX, posY, sizeX, sizeY, id);
+
+ child->SetChecked(state);
+
+ return child;
+ }
+
+ std::auto_ptr<Window> CustomWindow::CreateComboBox(int posX, int posY,
+ int sizeX, int sizeY, const char * title, int id)
+ {
+ std::auto_ptr<Window> child(new Window(this, "Combobox", title));
+
+ child->Create(WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST, posX, posY, sizeX, sizeY, id);
+
+ return child;
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp b/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp
new file mode 100644
index 0000000..76132bd
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/src/system/ui/dsn_configuration_window.cpp
@@ -0,0 +1,212 @@
+/*
+ * 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.
+ */
+
+#include <Windowsx.h>
+
+#include "ignite/odbc/system/ui/dsn_configuration_window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ DsnConfigurationWindow::DsnConfigurationWindow(Window* parent, config::Configuration& config):
+ CustomWindow(parent, "IgniteConfigureDsn", "Configure Apache Ignite DSN"),
+ width(360),
+ height(160),
+ connectionSettingsGroupBox(),
+ nameLabel(),
+ nameEdit(),
+ addressLabel(),
+ addressEdit(),
+ cacheLabel(),
+ cacheEdit(),
+ okButton(),
+ cancelButton(),
+ config(config),
+ accepted(false)
+ {
+ // No-op.
+ }
+
+ DsnConfigurationWindow::~DsnConfigurationWindow()
+ {
+ // No-op.
+ }
+
+ void DsnConfigurationWindow::Create()
+ {
+ // Finding out parent position.
+ RECT parentRect;
+ GetWindowRect(parent->GetHandle(), &parentRect);
+
+ // Positioning window to the center of parent window.
+ const int posX = parentRect.left + (parentRect.right - parentRect.left - width) / 2;
+ const int posY = parentRect.top + (parentRect.bottom - parentRect.top - height) / 2;
+
+ RECT desiredRect = {posX, posY, posX + width, posY + height};
+ AdjustWindowRect(&desiredRect, WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, FALSE);
+
+ Window::Create(WS_OVERLAPPED | WS_SYSMENU, desiredRect.left, desiredRect.top,
+ desiredRect.right - desiredRect.left, desiredRect.bottom - desiredRect.top, 0);
+
+ if (!handle)
+ {
+ std::stringstream buf;
+
+ buf << "Can not create window, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+ }
+
+ void DsnConfigurationWindow::OnCreate()
+ {
+ int margin = 10;
+ int interval = 10;
+
+ int labelSizeX = 80;
+ int labelPosX = margin + interval;
+
+ int editSizeX = width - labelSizeX - 2 * margin - 3 * interval;
+ int editPosX = margin + labelSizeX + 2 * interval;
+
+ int rowSize = 20;
+ int rowPos = margin + 2 * interval;
+
+ int checkBoxSize = (editSizeX - interval) / 2;
+
+ int sectionBegin = margin;
+
+ const char* val = config.GetDsn().c_str();
+ nameLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize, "DSN name:", ID_NAME_LABEL);
+ nameEdit = CreateEdit(editPosX, rowPos, editSizeX, rowSize, val, ID_NAME_EDIT);
+
+ rowPos += interval + rowSize;
+
+ val = config.GetAddress().c_str();
+ addressLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize, "Address:", ID_ADDRESS_LABEL);
+ addressEdit = CreateEdit(editPosX, rowPos, editSizeX, rowSize, val, ID_ADDRESS_EDIT);
+
+ rowPos += interval + rowSize;
+
+ val = config.GetCache().c_str();
+ cacheLabel = CreateLabel(labelPosX, rowPos, labelSizeX, rowSize, "Cache name:", ID_CACHE_LABEL);
+ cacheEdit = CreateEdit(editPosX, rowPos, editSizeX, rowSize, val, ID_CACHE_EDIT);
+
+ rowPos += interval * 2 + rowSize;
+
+ connectionSettingsGroupBox = CreateGroupBox(margin, sectionBegin, width - 2 * margin,
+ rowPos - interval - sectionBegin, "Connection settings", ID_CONNECTION_SETTINGS_GROUP_BOX);
+
+ int buttonSizeX = 80;
+ int cancelPosX = width - margin - buttonSizeX;
+ int okPosX = cancelPosX - interval - buttonSizeX;
+
+ rowSize = 25;
+
+ okButton = CreateButton(okPosX, rowPos, buttonSizeX, rowSize, "Ok", ID_OK_BUTTON);
+ cancelButton = CreateButton(cancelPosX, rowPos, buttonSizeX, rowSize, "Cancel", ID_CANCEL_BUTTON);
+ }
+
+ bool DsnConfigurationWindow::OnMessage(UINT msg, WPARAM wParam, LPARAM lParam)
+ {
+ switch (msg)
+ {
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case ID_OK_BUTTON:
+ {
+ try
+ {
+ RetrieveParameters(config);
+
+ accepted = true;
+
+ PostMessage(GetHandle(), WM_CLOSE, 0, 0);
+ }
+ catch (IgniteError& err)
+ {
+ MessageBox(NULL, err.GetText(), "Error!", MB_ICONEXCLAMATION | MB_OK);
+ }
+
+ break;
+ }
+
+ case IDCANCEL:
+ case ID_CANCEL_BUTTON:
+ {
+ PostMessage(GetHandle(), WM_CLOSE, 0, 0);
+
+ break;
+ }
+
+ default:
+ return false;
+ }
+
+ break;
+ }
+
+ case WM_DESTROY:
+ {
+ PostQuitMessage(accepted ? RESULT_OK : RESULT_CANCEL);
+
+ break;
+ }
+
+ default:
+ return false;
+ }
+
+ return true;
+ }
+
+ void DsnConfigurationWindow::RetrieveParameters(config::Configuration& cfg) const
+ {
+ std::string dsn;
+ std::string address;
+ std::string cache;
+
+ nameEdit->GetText(dsn);
+ addressEdit->GetText(address);
+ cacheEdit->GetText(cache);
+
+ common::StripSurroundingWhitespaces(address);
+ common::StripSurroundingWhitespaces(dsn);
+
+ LOG_MSG("Retriving arguments:\n");
+ LOG_MSG("DSN: %s\n", dsn.c_str());
+ LOG_MSG("Address: %s\n", address.c_str());
+ LOG_MSG("Cache: %s\n", cache.c_str());
+
+ if (dsn.empty())
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, "DSN name can not be empty.");
+
+ cfg.SetDsn(dsn);
+ cfg.SetAddress(address);
+ cfg.SetCache(cache);
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp b/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp
new file mode 100644
index 0000000..1143f01
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/src/system/ui/window.cpp
@@ -0,0 +1,192 @@
+/*
+ * 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.
+ */
+
+#include <Windowsx.h>
+
+#include "ignite/odbc/system/ui/window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ HINSTANCE GetHInstance()
+ {
+ HINSTANCE hInstance = GetModuleHandle(TARGET_MODULE_FULL_NAME);
+
+ if (hInstance == NULL)
+ {
+ std::stringstream buf;
+
+ buf << "Can not get hInstance for the module, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+
+ return hInstance;
+ }
+
+ Window::Window(Window* parent, const char* className, const char* title) :
+ className(className),
+ title(title),
+ handle(NULL),
+ created(false),
+ parent(parent)
+ {
+ // No-op.
+ }
+
+ Window::Window(HWND handle) :
+ className(),
+ title(),
+ handle(handle),
+ created(false),
+ parent(0)
+ {
+ // No-op.
+ }
+
+ Window::~Window()
+ {
+ if (created)
+ Destroy();
+ }
+
+ void Window::Create(DWORD style, int posX, int posY, int width, int height, int id)
+ {
+ if (handle)
+ {
+ std::stringstream buf;
+
+ buf << "Window already created, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+
+ handle = CreateWindow(
+ className.c_str(),
+ title.c_str(),
+ style,
+ posX,
+ posY,
+ width,
+ height,
+ parent ? parent->GetHandle() : NULL,
+ reinterpret_cast<HMENU>(id),
+ GetHInstance(),
+ this
+ );
+
+ if (!handle)
+ {
+ std::stringstream buf;
+
+ buf << "Can not create window, error code: " << GetLastError();
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+
+ created = true;
+
+ HGDIOBJ hfDefault = GetStockObject(DEFAULT_GUI_FONT);
+
+ SendMessage(GetHandle(), WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
+ }
+
+ void Window::Show()
+ {
+ ShowWindow(handle, SW_SHOW);
+ }
+
+ void Window::Update()
+ {
+ UpdateWindow(handle);
+ }
+
+ void Window::Destroy()
+ {
+ if (handle)
+ DestroyWindow(handle);
+
+ handle = NULL;
+ }
+
+ void Window::GetText(std::string& text) const
+ {
+ int len = GetWindowTextLength(handle);
+
+ if (len <= 0)
+ {
+ text.clear();
+
+ return;
+ }
+
+ text.resize(len + 1);
+
+ if (!GetWindowText(handle, &text[0], len + 1))
+ text.clear();
+
+ text.resize(len);
+ }
+
+ void Window::SetText(const std::string& text) const
+ {
+ SNDMSG(handle, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(text.c_str()));
+ }
+
+ bool Window::IsChecked() const
+ {
+ return Button_GetCheck(handle) == BST_CHECKED;
+ }
+
+ void Window::SetChecked(bool state)
+ {
+ Button_SetCheck(handle, state ? BST_CHECKED : BST_UNCHECKED);
+ }
+
+ void Window::AddString(const std::string & str)
+ {
+ SNDMSG(handle, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(str.c_str()));
+ }
+
+ void Window::SetSelection(int idx)
+ {
+ SNDMSG(handle, CB_SETCURSEL, static_cast<WPARAM>(idx), 0);
+ }
+
+ int Window::GetSelection() const
+ {
+ return static_cast<int>(SNDMSG(handle, CB_GETCURSEL, 0, 0));
+ }
+
+ void Window::SetEnabled(bool enabled)
+ {
+ EnableWindow(GetHandle(), enabled);
+ }
+
+ bool Window::IsEnabled() const
+ {
+ return IsWindowEnabled(GetHandle()) != 0;
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/os/win/src/system_dsn.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/os/win/src/system_dsn.cpp b/modules/platforms/cpp/odbc/os/win/src/system_dsn.cpp
new file mode 100644
index 0000000..f432a40
--- /dev/null
+++ b/modules/platforms/cpp/odbc/os/win/src/system_dsn.cpp
@@ -0,0 +1,218 @@
+/*
+ * 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.
+ */
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/system/odbc_constants.h"
+
+#include "ignite/odbc/dsn_config.h"
+#include "ignite/odbc/system/ui/window.h"
+#include "ignite/odbc/system/ui/dsn_configuration_window.h"
+
+using ignite::odbc::config::Configuration;
+
+/**
+ * Display configuration window for user to configure DSN.
+ *
+ * @param hwndParent Parent window handle.
+ * @param config Output configuration.
+ * @return True on success and false on fail.
+ */
+bool DisplayConfigureDsnWindow(HWND hwndParent, Configuration& config)
+{
+ using namespace ignite::odbc::system::ui;
+
+ if (!hwndParent)
+ return false;
+
+ try
+ {
+ Window parent(hwndParent);
+
+ DsnConfigurationWindow window(&parent, config);
+
+ window.Create();
+
+ window.Show();
+ window.Update();
+
+ return ProcessMessages(window) == RESULT_OK;
+ }
+ catch (const ignite::IgniteError& err)
+ {
+ std::stringstream buf;
+
+ buf << "Message: " << err.GetText() << ", Code: " << err.GetCode();
+
+ std::string message = buf.str();
+
+ MessageBox(NULL, message.c_str(), "Error!", MB_ICONEXCLAMATION | MB_OK);
+
+ SQLPostInstallerError(err.GetCode(), err.GetText());
+ }
+
+ return false;
+}
+
+/**
+ * Register DSN with specified configuration.
+ *
+ * @param config Configuration.
+ * @param driver Driver.
+ * @return True on success and false on fail.
+ */
+bool RegisterDsn(const Configuration& config, LPCSTR driver)
+{
+ using namespace ignite::odbc::config;
+ using ignite::common::LexicalCast;
+
+ typedef Configuration::ArgumentMap ArgMap;
+
+ const char* dsn = config.GetDsn().c_str();
+
+ try
+ {
+ if (!SQLWriteDSNToIni(dsn, driver))
+ ignite::odbc::ThrowLastSetupError();
+
+ const ArgMap& map = config.GetMap();
+
+ std::set<std::string> ignore;
+
+ ignore.insert(Configuration::Key::dsn);
+ ignore.insert(Configuration::Key::driver);
+
+ for (ArgMap::const_iterator it = map.begin(); it != map.end(); ++it)
+ {
+ const std::string& key = it->first;
+ const std::string& value = it->second;
+
+ if (ignore.find(key) != ignore.end())
+ continue;
+
+ ignite::odbc::WriteDsnString(dsn, key.c_str(), value.c_str());
+ }
+
+ return true;
+ }
+ catch (ignite::IgniteError& err)
+ {
+ MessageBox(NULL, err.GetText(), "Error!", MB_ICONEXCLAMATION | MB_OK);
+
+ SQLPostInstallerError(err.GetCode(), err.GetText());
+ }
+
+ return false;
+}
+
+/**
+ * Unregister specified DSN.
+ *
+ * @param dsn DSN name.
+ * @return True on success and false on fail.
+ */
+bool UnregisterDsn(const char* dsn)
+{
+ try
+ {
+ if (!SQLRemoveDSNFromIni(dsn))
+ ignite::odbc::ThrowLastSetupError();
+
+ return true;
+ }
+ catch (ignite::IgniteError& err)
+ {
+ MessageBox(NULL, err.GetText(), "Error!", MB_ICONEXCLAMATION | MB_OK);
+
+ SQLPostInstallerError(err.GetCode(), err.GetText());
+ }
+
+ return false;
+}
+
+BOOL INSTAPI ConfigDSN(HWND hwndParent, WORD req, LPCSTR driver, LPCSTR attributes)
+{
+ using namespace ignite::odbc;
+
+ LOG_MSG("ConfigDSN called\n");
+
+ Configuration config;
+
+ LOG_MSG("Attributes: %s\n", attributes);
+
+ config.FillFromConfigAttributes(attributes);
+
+ if (!SQLValidDSN(config.GetDsn().c_str()))
+ return FALSE;
+
+ LOG_MSG("Driver: %s\n", driver);
+ LOG_MSG("Attributes: %s\n", attributes);
+
+ LOG_MSG("DSN: %s\n", config.GetDsn().c_str());
+
+ switch (req)
+ {
+ case ODBC_ADD_DSN:
+ {
+ LOG_MSG("ODBC_ADD_DSN\n");
+
+ if (!DisplayConfigureDsnWindow(hwndParent, config))
+ return FALSE;
+
+ if (!RegisterDsn(config, driver))
+ return FALSE;
+
+ break;
+ }
+
+ case ODBC_CONFIG_DSN:
+ {
+ LOG_MSG("ODBC_CONFIG_DSN\n");
+
+ std::string dsn = config.GetDsn();
+
+ Configuration loaded(config);
+
+ ReadDsnConfiguration(dsn.c_str(), loaded);
+
+ if (!DisplayConfigureDsnWindow(hwndParent, loaded))
+ return FALSE;
+
+ if (!RegisterDsn(loaded, driver))
+ return FALSE;
+
+ if (loaded.GetDsn() != dsn && !UnregisterDsn(dsn.c_str()))
+ return FALSE;
+
+ break;
+ }
+
+ case ODBC_REMOVE_DSN:
+ {
+ LOG_MSG("ODBC_REMOVE_DSN\n");
+
+ if (!UnregisterDsn(config.GetDsn().c_str()))
+ return FALSE;
+
+ break;
+ }
+
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
index 5820030..348a11a 100644
--- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
+++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj
@@ -93,8 +93,8 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -107,8 +107,8 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -123,8 +123,8 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -141,8 +141,8 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
- <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\binary\include;$(ProjectDir)\..\..\..\binary\os\win\include;$(ProjectDir)\..\..\include;$(ProjectDir)\..\..\os\win\include;$(ProjectDir)\..\..\src</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;IGNITE_IMPL;IGNITE_FRIEND;TARGET_MODULE_FULL_NAME="$(TargetFileName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -153,7 +153,11 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClCompile Include="..\..\os\win\src\system_dsn.cpp" />
<ClCompile Include="..\..\os\win\src\system\socket_client.cpp" />
+ <ClCompile Include="..\..\os\win\src\system\ui\custom_window.cpp" />
+ <ClCompile Include="..\..\os\win\src\system\ui\dsn_configuration_window.cpp" />
+ <ClCompile Include="..\..\os\win\src\system\ui\window.cpp" />
<ClCompile Include="..\..\src\app\application_data_buffer.cpp" />
<ClCompile Include="..\..\src\app\parameter.cpp" />
<ClCompile Include="..\..\src\column.cpp" />
@@ -165,11 +169,13 @@
<ClCompile Include="..\..\src\diagnostic\diagnosable_adapter.cpp" />
<ClCompile Include="..\..\src\diagnostic\diagnostic_record.cpp" />
<ClCompile Include="..\..\src\diagnostic\diagnostic_record_storage.cpp" />
+ <ClCompile Include="..\..\src\dsn_config.cpp" />
<ClCompile Include="..\..\src\entry_points.cpp" />
<ClCompile Include="..\..\src\environment.cpp" />
<ClCompile Include="..\..\src\meta\column_meta.cpp" />
<ClCompile Include="..\..\src\meta\table_meta.cpp" />
<ClCompile Include="..\..\src\odbc.cpp" />
+ <ClCompile Include="..\..\src\protocol_version.cpp" />
<ClCompile Include="..\..\src\query\data_query.cpp" />
<ClCompile Include="..\..\src\query\column_metadata_query.cpp" />
<ClCompile Include="..\..\src\query\foreign_keys_query.cpp" />
@@ -200,12 +206,14 @@
<ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnosable_adapter.h" />
<ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnostic_record.h" />
<ClInclude Include="..\..\include\ignite\odbc\diagnostic\diagnostic_record_storage.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\dsn_config.h" />
<ClInclude Include="..\..\include\ignite\odbc\environment.h" />
<ClInclude Include="..\..\include\ignite\odbc\message.h" />
<ClInclude Include="..\..\include\ignite\odbc\meta\column_meta.h" />
<ClInclude Include="..\..\include\ignite\odbc\meta\primary_key_meta.h" />
<ClInclude Include="..\..\include\ignite\odbc\meta\table_meta.h" />
<ClInclude Include="..\..\include\ignite\odbc\parser.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\protocol_version.h" />
<ClInclude Include="..\..\include\ignite\odbc\query\data_query.h" />
<ClInclude Include="..\..\include\ignite\odbc\query\column_metadata_query.h" />
<ClInclude Include="..\..\include\ignite\odbc\query\foreign_keys_query.h" />
@@ -219,8 +227,11 @@
<ClInclude Include="..\..\include\ignite\odbc\statement.h" />
<ClInclude Include="..\..\include\ignite\odbc\system\odbc_constants.h" />
<ClInclude Include="..\..\include\ignite\odbc\system\socket_client.h" />
+ <ClInclude Include="..\..\include\ignite\odbc\system\ui\dsn_configuration_window.h" />
<ClInclude Include="..\..\include\ignite\odbc\type_traits.h" />
<ClInclude Include="..\..\include\ignite\odbc\utility.h" />
+ <ClInclude Include="..\..\os\win\include\ignite\odbc\system\ui\custom_window.h" />
+ <ClInclude Include="..\..\os\win\include\ignite\odbc\system\ui\window.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\binary\project\vs\binary.vcxproj">
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
index 6ca58e2..58764e4 100644
--- a/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
+++ b/modules/platforms/cpp/odbc/project/vs/odbc.vcxproj.filters
@@ -26,6 +26,9 @@
<Filter Include="Code\diagnostic">
<UniqueIdentifier>{df33e506-b5d8-423f-bcc5-1825242a3e28}</UniqueIdentifier>
</Filter>
+ <Filter Include="Code\system\ui">
+ <UniqueIdentifier>{ff144e89-0a10-42c3-97dd-d22bfdbc7abb}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\odbc.cpp">
@@ -115,6 +118,24 @@
<ClCompile Include="..\..\src\entry_points.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\os\win\src\system\ui\window.cpp">
+ <Filter>Code\system\ui</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\os\win\src\system\ui\custom_window.cpp">
+ <Filter>Code\system\ui</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\os\win\src\system\ui\dsn_configuration_window.cpp">
+ <Filter>Code\system\ui</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\os\win\src\system_dsn.cpp">
+ <Filter>Code\system</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\dsn_config.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\protocol_version.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="module.def">
@@ -224,5 +245,20 @@
<ClInclude Include="..\..\include\ignite\odbc.h">
<Filter>Code</Filter>
</ClInclude>
+ <ClInclude Include="..\..\os\win\include\ignite\odbc\system\ui\window.h">
+ <Filter>Code\system\ui</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\os\win\include\ignite\odbc\system\ui\custom_window.h">
+ <Filter>Code\system\ui</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\system\ui\dsn_configuration_window.h">
+ <Filter>Code\system\ui</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\dsn_config.h">
+ <Filter>Code</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\include\ignite\odbc\protocol_version.h">
+ <Filter>Code</Filter>
+ </ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/config/configuration.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/config/configuration.cpp b/modules/platforms/cpp/odbc/src/config/configuration.cpp
index 8d57dee..f40c74f 100644
--- a/modules/platforms/cpp/odbc/src/config/configuration.cpp
+++ b/modules/platforms/cpp/odbc/src/config/configuration.cpp
@@ -15,13 +15,14 @@
* limitations under the License.
*/
-#include <cstring>
-
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
+#include "ignite/common/common.h"
+#include "ignite/common/utils.h"
+
#include "ignite/odbc/utility.h"
#include "ignite/odbc/config/configuration.h"
@@ -31,50 +32,29 @@ namespace ignite
{
namespace config
{
- /** Default values for configuration. */
- namespace dflt
- {
- /** Default value for DSN attribute. */
- const std::string dsn = "Default Apache Ignite DSN";
+ const std::string Configuration::Key::dsn = "dsn";
+ const std::string Configuration::Key::driver = "driver";
+ const std::string Configuration::Key::cache = "cache";
+ const std::string Configuration::Key::address = "address";
+ const std::string Configuration::Key::server = "server";
+ const std::string Configuration::Key::port = "port";
+ const std::string Configuration::Key::protocolVersion = "protocol_version";
- /** Default value for Driver attribute. */
- const std::string driver = "Apache Ignite";
+ const std::string Configuration::DefaultValue::dsn = "Apache Ignite DSN";
+ const std::string Configuration::DefaultValue::driver = "Apache Ignite";
+ const std::string Configuration::DefaultValue::cache = "";
+ const std::string Configuration::DefaultValue::address = "";
+ const std::string Configuration::DefaultValue::server = "";
- /** Default value for host attribute. */
- const std::string host = "localhost";
+ const uint16_t Configuration::DefaultValue::port = 10800;
- /** Default value for port attribute. */
- const uint16_t port = 10800;
+ const ProtocolVersion& Configuration::DefaultValue::protocolVersion = ProtocolVersion::GetCurrent();
- /** Default value for cache attribute. */
- const std::string cache = "";
- }
-
- /** Connection attribute keywords. */
- namespace attrkey
- {
- /** Connection attribute keyword for DSN attribute. */
- const std::string dsn = "dsn";
-
- /** Connection attribute keyword for Driver attribute. */
- const std::string driver = "driver";
-
- /** Connection attribute keyword for server host attribute. */
- const std::string host = "server";
-
- /** Connection attribute keyword for server port attribute. */
- const std::string port = "port";
-
- /** Connection attribute keyword for cache attribute. */
- const std::string cache = "cache";
- }
Configuration::Configuration() :
- dsn(dflt::dsn), driver(dflt::driver),
- host(dflt::host), port(dflt::port),
- cache(dflt::cache)
+ arguments()
{
- // No-op.
+ ParseAddress(DefaultValue::address, endPoint);
}
Configuration::~Configuration()
@@ -84,7 +64,11 @@ namespace ignite
void Configuration::FillFromConnectString(const char* str, size_t len)
{
- ArgumentMap connect_attributes;
+ // Initializing map.
+ arguments.clear();
+
+ // Initializing DSN to empty string.
+ arguments[Key::dsn].clear();
// Ignoring terminating zero byte if present.
// Some Driver Managers pass zero-terminated connection string
@@ -92,39 +76,19 @@ namespace ignite
if (len && !str[len - 1])
--len;
- ParseAttributeList(str, len, ';', connect_attributes);
-
- ArgumentMap::const_iterator it;
-
- it = connect_attributes.find(attrkey::dsn);
- if (it != connect_attributes.end())
- dsn = it->second;
- else
- dsn.clear();
-
- it = connect_attributes.find(attrkey::driver);
- if (it != connect_attributes.end())
- driver = it->second;
- else
- driver = dflt::driver;
-
- it = connect_attributes.find(attrkey::host);
- if (it != connect_attributes.end())
- host = it->second;
- else
- host = dflt::host;
-
- it = connect_attributes.find(attrkey::port);
- if (it != connect_attributes.end())
- port = atoi(it->second.c_str());
- else
- port = dflt::port;
+ ParseAttributeList(str, len, ';', arguments);
- it = connect_attributes.find(attrkey::cache);
- if (it != connect_attributes.end())
- cache = it->second;
+ ArgumentMap::const_iterator it = arguments.find(Key::address);
+ if (it != arguments.end())
+ {
+ // Parsing address.
+ ParseAddress(it->second, endPoint);
+ }
else
- cache = dflt::cache;
+ {
+ endPoint.host = GetStringValue(Key::server, DefaultValue::server);
+ endPoint.port = static_cast<uint16_t>(GetIntValue(Key::port, DefaultValue::port));
+ }
}
void Configuration::FillFromConnectString(const std::string& str)
@@ -136,27 +100,27 @@ namespace ignite
{
std::stringstream connect_string_buffer;
- if (!driver.empty())
- connect_string_buffer << attrkey::driver << "={" << driver << "};";
-
- if (!host.empty())
- connect_string_buffer << attrkey::host << '=' << host << ';';
-
- if (port)
- connect_string_buffer << attrkey::port << '=' << port << ';';
+ for (ArgumentMap::const_iterator it = arguments.begin(); it != arguments.end(); ++it)
+ {
+ const std::string& key = it->first;
+ const std::string& value = it->second;
- if (!dsn.empty())
- connect_string_buffer << attrkey::dsn << '=' << dsn << ';';
+ if (value.empty())
+ continue;
- if (!cache.empty())
- connect_string_buffer << attrkey::cache << '=' << cache << ';';
+ if (value.find(' ') == std::string::npos)
+ connect_string_buffer << key << '=' << value << ';';
+ else
+ connect_string_buffer << key << "={" << value << "};";
+ }
return connect_string_buffer.str();
}
- void Configuration::FillFromConfigAttributes(const char * attributes)
+ void Configuration::FillFromConfigAttributes(const char* attributes)
{
- ArgumentMap config_attributes;
+ // Initializing map.
+ arguments.clear();
size_t len = 0;
@@ -166,45 +130,74 @@ namespace ignite
++len;
- ParseAttributeList(attributes, len, '\0', config_attributes);
-
- ArgumentMap::const_iterator it;
+ ParseAttributeList(attributes, len, '\0', arguments);
- it = config_attributes.find(attrkey::dsn);
- if (it != config_attributes.end())
- dsn = it->second;
+ ArgumentMap::const_iterator it = arguments.find(Key::address);
+ if (it != arguments.end())
+ {
+ // Parsing address.
+ ParseAddress(it->second, endPoint);
+ }
else
- dsn = dflt::dsn;
+ {
+ endPoint.host = GetStringValue(Key::server, DefaultValue::server);
+ endPoint.port = static_cast<uint16_t>(GetIntValue(Key::port, DefaultValue::port));
+ }
+ }
- it = config_attributes.find(attrkey::driver);
- if (it != config_attributes.end())
- driver = it->second;
- else
- driver.clear();
+ void Configuration::SetTcpPort(uint16_t port)
+ {
+ arguments[Key::port] = common::LexicalCast<std::string>(port);
+ }
- it = config_attributes.find(attrkey::host);
- if (it != config_attributes.end())
- host = it->second;
- else
- host.clear();
+ ProtocolVersion Configuration::GetProtocolVersion() const
+ {
+ ArgumentMap::const_iterator it = arguments.find(Key::protocolVersion);
- it = config_attributes.find(attrkey::port);
- if (it != config_attributes.end())
- port = atoi(it->second.c_str());
- else
- port = 0;
+ if (it != arguments.end())
+ return ProtocolVersion::FromString(it->second);
- it = config_attributes.find(attrkey::cache);
- if (it != config_attributes.end())
- cache = it->second;
- else
- cache.clear();
+ return DefaultValue::protocolVersion;
+ }
+
+ void Configuration::SetProtocolVersion(const std::string& version)
+ {
+ arguments[Key::protocolVersion] = version;
+ }
+
+ const std::string& Configuration::GetStringValue(const std::string& key, const std::string& dflt) const
+ {
+ ArgumentMap::const_iterator it = arguments.find(common::ToLower(key));
+
+ if (it != arguments.end())
+ return it->second;
+
+ return dflt;
}
- void Configuration::ParseAttributeList(const char * str, size_t len, char delimeter, ArgumentMap & args) const
+ int64_t Configuration::GetIntValue(const std::string& key, int64_t dflt) const
+ {
+ ArgumentMap::const_iterator it = arguments.find(common::ToLower(key));
+
+ if (it != arguments.end())
+ {
+ const std::string& val = it->second;
+
+ if (!common::AllOf(val.begin(), val.end(), isdigit))
+ IGNITE_ERROR_FORMATTED_1(IgniteError::IGNITE_ERR_GENERIC,
+ "Invalid argument value: Integer value is expected.", "key", key);
+
+ return common::LexicalCast<int64_t>(val);
+ }
+
+ return dflt;
+ }
+
+
+
+ void Configuration::ParseAttributeList(const char * str, size_t len, char delimeter, ArgumentMap & args)
{
std::string connect_str(str, len);
- args.clear();
while (!connect_str.empty())
{
@@ -245,6 +238,51 @@ namespace ignite
connect_str.erase(attr_begin - 1);
}
}
+
+ void Configuration::ParseAddress(const std::string& address, EndPoint& res)
+ {
+ int64_t colonNum = std::count(address.begin(), address.end(), ':');
+
+ if (colonNum == 0)
+ {
+ res.host = address;
+ res.port = DefaultValue::port;
+ }
+ else if (colonNum == 1)
+ {
+ size_t pos = address.find(':');
+
+ if (pos == address.size() - 1)
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+ "Invalid address format: no port after colon");
+
+ res.host = address.substr(0, pos);
+
+ std::string port = address.substr(pos + 1);
+
+ if (!common::AllOf(port.begin(), port.end(), isdigit))
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+ "Invalid address format: port can only contain digits");
+
+ int32_t intPort = common::LexicalCast<int32_t>(port);
+
+ if (port.size() > sizeof("65535") - 1 || intPort > UINT16_MAX)
+ {
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+ "Invalid address format: Port value is too large,"
+ " valid value should be in range from 1 to 65535");
+ }
+
+ if (intPort == 0)
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+ "Invalid address format: Port value can not be zero");
+
+ res.port = static_cast<uint16_t>(intPort);
+ }
+ else
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC,
+ "Invalid address format: too many colons");
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/connection.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/connection.cpp b/modules/platforms/cpp/odbc/src/connection.cpp
index 2441759..cffecdf 100644
--- a/modules/platforms/cpp/odbc/src/connection.cpp
+++ b/modules/platforms/cpp/odbc/src/connection.cpp
@@ -39,9 +39,11 @@ namespace ignite
{
namespace odbc
{
- const std::string Connection::PROTOCOL_VERSION_SINCE = "1.6.0";
-
- Connection::Connection() : socket(), connected(false), cache(), parser()
+ Connection::Connection() :
+ socket(),
+ connected(false),
+ parser(),
+ config()
{
// No-op.
}
@@ -53,8 +55,8 @@ namespace ignite
const config::ConnectionInfo& Connection::GetInfo() const
{
- // Connection info is the same for all connections now.
- static config::ConnectionInfo info;
+ // Connection info is constant and the same for all connections now.
+ const static config::ConnectionInfo info;
return info;
}
@@ -76,32 +78,38 @@ namespace ignite
return res;
}
- void Connection::Establish(const std::string& server)
+ void Connection::Establish(const std::string& connectStr)
{
- IGNITE_ODBC_API_CALL(InternalEstablish(server));
+ IGNITE_ODBC_API_CALL(InternalEstablish(connectStr));
}
- SqlResult Connection::InternalEstablish(const std::string& server)
+ SqlResult Connection::InternalEstablish(const std::string& connectStr)
{
config::Configuration config;
- if (server != config.GetDsn())
+ try
{
- AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, "Unknown server.");
+ config.FillFromConnectString(connectStr);
+ }
+ catch (IgniteError& e)
+ {
+ AddStatusRecord(SQL_STATE_HY000_GENERAL_ERROR, e.GetText());
return SQL_RESULT_ERROR;
}
- return InternalEstablish(config.GetHost(), config.GetPort(), config.GetCache());
+ return InternalEstablish(config);
}
- void Connection::Establish(const std::string& host, uint16_t port, const std::string& cache)
+ void Connection::Establish(const config::Configuration cfg)
{
- IGNITE_ODBC_API_CALL(InternalEstablish(host, port, cache));
+ IGNITE_ODBC_API_CALL(InternalEstablish(cfg));
}
- SqlResult Connection::InternalEstablish(const std::string & host, uint16_t port, const std::string & cache)
+ SqlResult Connection::InternalEstablish(const config::Configuration cfg)
{
+ config = cfg;
+
if (connected)
{
AddStatusRecord(SQL_STATE_08002_ALREADY_CONNECTED, "Already connected.");
@@ -109,9 +117,7 @@ namespace ignite
return SQL_RESULT_ERROR;
}
- this->cache = cache;
-
- connected = socket.Connect(host.c_str(), port);
+ connected = socket.Connect(cfg.GetHost().c_str(), cfg.GetTcpPort());
if (!connected)
{
@@ -262,11 +268,16 @@ namespace ignite
const std::string& Connection::GetCache() const
{
- return cache;
+ return config.GetCache();
+ }
+
+ const config::Configuration& Connection::GetConfiguration() const
+ {
+ return config;
}
diagnostic::DiagnosticRecord Connection::CreateStatusRecord(SqlState sqlState,
- const std::string& message, int32_t rowNum, int32_t columnNum) const
+ const std::string& message, int32_t rowNum, int32_t columnNum)
{
return diagnostic::DiagnosticRecord(sqlState, message, "", "", rowNum, columnNum);
}
@@ -296,7 +307,20 @@ namespace ignite
SqlResult Connection::MakeRequestHandshake()
{
- HandshakeRequest req(PROTOCOL_VERSION);
+ int64_t protocolVersion = 0;
+
+ try
+ {
+ protocolVersion = config.GetProtocolVersion().GetIntValue();
+ }
+ catch (const IgniteError& err)
+ {
+ AddStatusRecord(SQL_STATE_01S00_INVALID_CONNECTION_STRING_ATTRIBUTE, err.GetText());
+
+ return SQL_RESULT_ERROR;
+ }
+
+ HandshakeRequest req(protocolVersion);
HandshakeResponse rsp;
try
@@ -330,7 +354,7 @@ namespace ignite
constructor << "Node rejected handshake message. "
<< "Current node Apache Ignite version: " << rsp.CurrentVer() << ", "
<< "node protocol version introduced in version: " << rsp.ProtoVerSince() << ", "
- << "driver protocol version introduced in version: " << PROTOCOL_VERSION_SINCE << ".";
+ << "driver protocol version introduced in version: " << config.GetProtocolVersion().ToString() << ".";
AddStatusRecord(SQL_STATE_08001_CANNOT_CONNECT, constructor.str());
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
index 568c125..8553ee4 100644
--- a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
+++ b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record.cpp
@@ -34,6 +34,9 @@ namespace
/** SQL state 01004 constant. */
const std::string STATE_01004 = "01004";
+ /** SQL state 01S00 constant. */
+ const std::string STATE_01S00 = "01S00";
+
/** SQL state 01S01 constant. */
const std::string STATE_01S01 = "01S01";
@@ -168,7 +171,7 @@ namespace ignite
return ORIGIN_ISO_9075;
}
- const std::string& DiagnosticRecord::GetMessage() const
+ const std::string& DiagnosticRecord::GetMessageText() const
{
return message;
}
@@ -190,6 +193,9 @@ namespace ignite
case SQL_STATE_01004_DATA_TRUNCATED:
return STATE_01004;
+ case SQL_STATE_01S00_INVALID_CONNECTION_STRING_ATTRIBUTE:
+ return STATE_01S00;
+
case SQL_STATE_01S01_ERROR_IN_ROW:
return STATE_01S01;
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
index 90c0a4f..99ef292 100644
--- a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
+++ b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
@@ -190,7 +190,7 @@ namespace ignite
case IGNITE_SQL_DIAG_STATUS_MESSAGE_TEXT:
{
- buffer.PutString(record.GetMessage());
+ buffer.PutString(record.GetMessageText());
return SQL_RESULT_SUCCESS;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/dsn_config.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/dsn_config.cpp b/modules/platforms/cpp/odbc/src/dsn_config.cpp
new file mode 100644
index 0000000..99635dc
--- /dev/null
+++ b/modules/platforms/cpp/odbc/src/dsn_config.cpp
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+#include <set>
+
+#include "ignite/odbc/utility.h"
+#include "ignite/odbc/system/odbc_constants.h"
+
+#include "ignite/odbc/dsn_config.h"
+
+using ignite::odbc::config::Configuration;
+
+#define BUFFER_SIZE 1024
+#define CONFIG_FILE "ODBC.INI"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ void ThrowLastSetupError()
+ {
+ DWORD code;
+ char msg[BUFFER_SIZE];
+
+ SQLInstallerError(1, &code, msg, sizeof(msg), NULL);
+
+ std::stringstream buf;
+
+ buf << "Message: \"" << msg << "\", Code: " << code;
+
+ throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
+ }
+
+ void WriteDsnString(const char* dsn, const char* key, const char* value)
+ {
+ if (!SQLWritePrivateProfileString(dsn, key, value, CONFIG_FILE))
+ ThrowLastSetupError();
+ }
+
+ std::string ReadDsnString(const char* dsn, const std::string& key, const char* dflt)
+ {
+ char buf[BUFFER_SIZE];
+
+ memset(buf, 0, sizeof(buf));
+
+ SQLGetPrivateProfileString(dsn, key.c_str(), dflt, buf, sizeof(buf), CONFIG_FILE);
+
+ return std::string(buf);
+ }
+
+ int ReadDsnInt(const char* dsn, const std::string& key, int dflt)
+ {
+ char buf[BUFFER_SIZE];
+
+ memset(buf, 0, sizeof(buf));
+
+ std::string dflt0 = common::LexicalCast<std::string>(dflt);
+
+ SQLGetPrivateProfileString(dsn, key.c_str(), dflt0.c_str(), buf, sizeof(buf), CONFIG_FILE);
+
+ return common::LexicalCast<int, std::string>(buf);
+ }
+
+ bool ReadDsnBool(const char* dsn, const std::string& key, bool dflt)
+ {
+ char buf[BUFFER_SIZE];
+
+ memset(buf, 0, sizeof(buf));
+
+ std::string dflt0 = dflt ? "true" : "false";
+
+ SQLGetPrivateProfileString(dsn, key.c_str(), dflt0.c_str(), buf, sizeof(buf), CONFIG_FILE);
+
+ return std::string(buf) == "true";
+ }
+
+ void ReadDsnConfiguration(const char* dsn, Configuration& config)
+ {
+ std::string address = ReadDsnString(dsn, Configuration::Key::address, config.GetAddress().c_str());
+ std::string server = ReadDsnString(dsn, Configuration::Key::server, config.GetHost().c_str());
+ uint16_t port = ReadDsnInt(dsn, Configuration::Key::port, config.GetTcpPort());
+ std::string cache = ReadDsnString(dsn, Configuration::Key::cache, config.GetCache().c_str());
+ std::string version = ReadDsnString(dsn, Configuration::Key::protocolVersion,
+ config.GetProtocolVersion().ToString().c_str());
+
+ LOG_MSG("%d\n", __LINE__);
+
+ config.SetAddress(address);
+ config.SetHost(server);
+ config.SetTcpPort(port);
+ config.SetCache(cache);
+ config.SetProtocolVersion(version);
+
+ LOG_MSG("%d\n", __LINE__);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/entry_points.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/entry_points.cpp b/modules/platforms/cpp/odbc/src/entry_points.cpp
index c8e78a5..f6195e1 100644
--- a/modules/platforms/cpp/odbc/src/entry_points.cpp
+++ b/modules/platforms/cpp/odbc/src/entry_points.cpp
@@ -19,14 +19,6 @@
#include "ignite/odbc/utility.h"
-BOOL INSTAPI ConfigDSN(HWND hwndParent,
- WORD req,
- LPCSTR driver,
- LPCSTR attributes)
-{
- return ignite::ConfigDSN(hwndParent, req, driver, attributes);
-}
-
SQLRETURN SQL_API SQLGetInfo(SQLHDBC conn,
SQLUSMALLINT infoType,
SQLPOINTER infoValue,
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/src/odbc.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/odbc.cpp b/modules/platforms/cpp/odbc/src/odbc.cpp
index 3b31f1d..fd35cba 100644
--- a/modules/platforms/cpp/odbc/src/odbc.cpp
+++ b/modules/platforms/cpp/odbc/src/odbc.cpp
@@ -28,61 +28,11 @@
#include "ignite/odbc/environment.h"
#include "ignite/odbc/connection.h"
#include "ignite/odbc/statement.h"
+#include "ignite/odbc/dsn_config.h"
#include "ignite/odbc.h"
namespace ignite
{
-
- BOOL ConfigDSN(HWND hwndParent,
- WORD req,
- LPCSTR driver,
- LPCSTR attributes)
- {
- LOG_MSG("ConfigDSN called\n");
-
- ignite::odbc::config::Configuration config;
-
- config.FillFromConfigAttributes(attributes);
-
- if (!SQLValidDSN(config.GetDsn().c_str()))
- return SQL_FALSE;
-
- LOG_MSG("Driver: %s\n", driver);
- LOG_MSG("Attributes: %s\n", attributes);
-
- LOG_MSG("DSN: %s\n", config.GetDsn().c_str());
-
- switch (req)
- {
- case ODBC_ADD_DSN:
- {
- LOG_MSG("ODBC_ADD_DSN\n");
-
- return SQLWriteDSNToIni(config.GetDsn().c_str(), driver);
- }
-
- case ODBC_CONFIG_DSN:
- {
- LOG_MSG("ODBC_CONFIG_DSN\n");
- break;
- }
-
- case ODBC_REMOVE_DSN:
- {
- LOG_MSG("ODBC_REMOVE_DSN\n");
-
- return SQLRemoveDSNFromIni(config.GetDsn().c_str());
- }
-
- default:
- {
- return SQL_FALSE;
- }
- }
-
- return SQL_TRUE;
- }
-
SQLRETURN SQLGetInfo(SQLHDBC conn,
SQLUSMALLINT infoType,
SQLPOINTER infoValue,
@@ -306,10 +256,10 @@ namespace ignite
SQLSMALLINT* outConnectionStringLen,
SQLUSMALLINT driverCompletion)
{
- using ignite::odbc::Connection;
- using ignite::odbc::diagnostic::DiagnosticRecordStorage;
- using ignite::utility::SqlStringToString;
- using ignite::utility::CopyStringToBuffer;
+ using odbc::Connection;
+ using odbc::diagnostic::DiagnosticRecordStorage;
+ using utility::SqlStringToString;
+ using utility::CopyStringToBuffer;
UNREFERENCED_PARAMETER(windowHandle);
@@ -323,18 +273,23 @@ namespace ignite
std::string connectStr = SqlStringToString(inConnectionString, inConnectionStringLen);
- ignite::odbc::config::Configuration config;
+ odbc::config::Configuration config;
config.FillFromConnectString(connectStr);
- connection->Establish(config.GetHost(), config.GetPort(), config.GetCache());
+ std::string dsn = config.GetDsn();
+
+ if (!dsn.empty())
+ odbc::ReadDsnConfiguration(dsn.c_str(), config);
+
+ connection->Establish(config);
const DiagnosticRecordStorage& diag = connection->GetDiagnosticRecords();
if (!diag.IsSuccessful())
return diag.GetReturnCode();
- std::string outConnectStr = config.ToConnectString();
+ std::string outConnectStr = connection->GetConfiguration().ToConnectString();
size_t reslen = CopyStringToBuffer(outConnectStr,
reinterpret_cast<char*>(outConnectionString),
@@ -357,7 +312,7 @@ namespace ignite
SQLSMALLINT authLen)
{
using ignite::odbc::Connection;
- using ignite::odbc::diagnostic::DiagnosticRecordStorage;
+ using ignite::odbc::config::Configuration;
using ignite::utility::SqlStringToString;
LOG_MSG("SQLConnect called\n");
@@ -367,9 +322,13 @@ namespace ignite
if (!connection)
return SQL_INVALID_HANDLE;
- std::string server = SqlStringToString(serverName, serverNameLen);
+ odbc::config::Configuration config;
+
+ std::string dsn = SqlStringToString(serverName, serverNameLen);
+
+ odbc::ReadDsnConfiguration(dsn.c_str(), config);
- connection->Establish(server);
+ connection->Establish(config);
return connection->GetDiagnosticRecords().GetReturnCode();
}
@@ -1168,7 +1127,7 @@ namespace ignite
SqlLen outResLen;
ApplicationDataBuffer outBuffer(IGNITE_ODBC_C_TYPE_CHAR, msgBuffer, msgBufferLen, &outResLen);
- outBuffer.PutString(record.GetMessage());
+ outBuffer.PutString(record.GetMessageText());
*msgLen = static_cast<SQLSMALLINT>(outResLen);
[4/7] ignite git commit: IGNITE-3390: Added DSN configuration window.
Posted by ak...@apache.org.
IGNITE-3390: Added DSN configuration window.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/70e69cb7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/70e69cb7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/70e69cb7
Branch: refs/heads/master
Commit: 70e69cb7aa08c268b07920838add4a40e28fe25d
Parents: dabd86c
Author: isapego <is...@gridgain.com>
Authored: Wed Aug 31 16:47:11 2016 +0300
Committer: isapego <is...@gridgain.com>
Committed: Wed Aug 31 16:47:11 2016 +0300
----------------------------------------------------------------------
.../processors/odbc/OdbcHandshakeRequest.java | 8 +-
.../processors/odbc/OdbcHandshakeResult.java | 17 +-
.../processors/odbc/OdbcMessageParser.java | 22 +-
.../processors/odbc/OdbcProtocolVersion.java | 106 ++++++++
.../processors/odbc/OdbcRequestHandler.java | 17 +-
.../cpp/common/include/ignite/common/utils.h | 25 ++
.../cpp/common/os/win/src/common/utils.cpp | 20 ++
modules/platforms/cpp/odbc-test/Makefile.am | 1 +
.../odbc-test/config/queries-test-noodbc.xml | 103 +++++++
.../cpp/odbc-test/config/queries-test.xml | 31 ++-
.../cpp/odbc-test/project/vs/odbc-test.vcxproj | 2 +
.../project/vs/odbc-test.vcxproj.filters | 6 +
.../cpp/odbc-test/src/configuration_test.cpp | 156 ++++++++---
.../cpp/odbc-test/src/queries_test.cpp | 122 ++++++---
.../odbc-test/src/sql_test_suite_fixture.cpp | 14 +-
modules/platforms/cpp/odbc/Makefile.am | 2 +
modules/platforms/cpp/odbc/include/Makefile.am | 2 +
.../cpp/odbc/include/ignite/odbc/common_types.h | 3 +
.../include/ignite/odbc/config/configuration.h | 207 +++++++++++++--
.../cpp/odbc/include/ignite/odbc/connection.h | 47 ++--
.../ignite/odbc/diagnostic/diagnostic_record.h | 2 +-
.../cpp/odbc/include/ignite/odbc/dsn_config.h | 61 +++++
.../cpp/odbc/include/ignite/odbc/parser.h | 3 -
.../odbc/include/ignite/odbc/protocol_version.h | 168 ++++++++++++
.../include/ignite/odbc/system/odbc_constants.h | 4 -
.../odbc/system/ui/dsn_configuration_window.h | 136 ++++++++++
.../ignite/odbc/system/ui/custom_window.h | 189 +++++++++++++
.../win/include/ignite/odbc/system/ui/window.h | 201 ++++++++++++++
.../odbc/os/win/src/system/ui/custom_window.cpp | 184 +++++++++++++
.../src/system/ui/dsn_configuration_window.cpp | 212 +++++++++++++++
.../cpp/odbc/os/win/src/system/ui/window.cpp | 192 +++++++++++++
.../cpp/odbc/os/win/src/system_dsn.cpp | 218 +++++++++++++++
.../platforms/cpp/odbc/project/vs/odbc.vcxproj | 27 +-
.../cpp/odbc/project/vs/odbc.vcxproj.filters | 36 +++
.../cpp/odbc/src/config/configuration.cpp | 266 +++++++++++--------
modules/platforms/cpp/odbc/src/connection.cpp | 66 +++--
.../odbc/src/diagnostic/diagnostic_record.cpp | 8 +-
.../diagnostic/diagnostic_record_storage.cpp | 2 +-
modules/platforms/cpp/odbc/src/dsn_config.cpp | 111 ++++++++
modules/platforms/cpp/odbc/src/entry_points.cpp | 8 -
modules/platforms/cpp/odbc/src/odbc.cpp | 83 ++----
.../platforms/cpp/odbc/src/protocol_version.cpp | 131 +++++++++
42 files changed, 2822 insertions(+), 397 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java
index 5e09041..2ffd8cd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeRequest.java
@@ -24,21 +24,21 @@ import org.apache.ignite.internal.util.typedef.internal.S;
*/
public class OdbcHandshakeRequest extends OdbcRequest {
/** Protocol version. */
- private final long ver;
+ private final OdbcProtocolVersion ver;
/**
- * @param ver Protocol version.
+ * @param ver Long value for protocol version.
*/
public OdbcHandshakeRequest(long ver) {
super(HANDSHAKE);
- this.ver = ver;
+ this.ver = OdbcProtocolVersion.fromLong(ver);
}
/**
* @return Protocol version.
*/
- public long version() {
+ public OdbcProtocolVersion version() {
return ver;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeResult.java
index bf1c61e..74c5bd4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcHandshakeResult.java
@@ -17,7 +17,7 @@
package org.apache.ignite.internal.processors.odbc;
-import org.jetbrains.annotations.Nullable;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* ODBC handshake result.
@@ -33,11 +33,13 @@ public class OdbcHandshakeResult {
private final String curVer;
/**
- * @param accepted Handshake accepted.
+ * Constructor.
+ *
+ * @param accepted Indicates whether handshake accepted or not.
* @param protoVerSince Apache Ignite version when protocol version has been introduced.
* @param curVer Current Apache Ignite version.
*/
- public OdbcHandshakeResult(boolean accepted, @Nullable String protoVerSince, @Nullable String curVer) {
+ public OdbcHandshakeResult(boolean accepted, String protoVerSince, String curVer) {
this.accepted = accepted;
this.protoVerSince = protoVerSince;
this.curVer = curVer;
@@ -53,14 +55,19 @@ public class OdbcHandshakeResult {
/**
* @return Apache Ignite version when protocol version has been introduced.
*/
- @Nullable public String protoVerSince() {
+ public String protocolVersionSince() {
return protoVerSince;
}
/**
* @return Current Apache Ignite version.
*/
- @Nullable public String currentVer() {
+ public String currentVersion() {
return curVer;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(OdbcHandshakeResult.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
index fce8b1b..a751eb2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcMessageParser.java
@@ -34,12 +34,6 @@ import java.util.Collection;
* ODBC message parser.
*/
public class OdbcMessageParser {
- /** Current ODBC communication protocol version. */
- public static final long PROTO_VER = 1;
-
- /** Apache Ignite version when ODBC communication protocol version has been introduced. */
- public static final String PROTO_VER_SINCE = "1.6.0";
-
/** Initial output stream capacity. */
private static final int INIT_CAP = 1024;
@@ -82,10 +76,14 @@ public class OdbcMessageParser {
// we has not confirmed that the remote client uses the same protocol version.
if (!verConfirmed) {
if (cmd == OdbcRequest.HANDSHAKE)
- return new OdbcHandshakeRequest(reader.readLong());
+ {
+ long longVersion = reader.readLong();
+
+ return new OdbcHandshakeRequest(longVersion);
+ }
else
- throw new IgniteException("Unexpected ODBC command (first message is not a handshake request): [cmd=" +
- cmd + ']');
+ throw new IgniteException("Unexpected ODBC command " +
+ "(first message is not a handshake request): [cmd=" + cmd + ']');
}
OdbcRequest res;
@@ -174,6 +172,8 @@ public class OdbcMessageParser {
Object res0 = msg.response();
+ if (res0 == null)
+ return writer.array();
if (res0 instanceof OdbcHandshakeResult) {
OdbcHandshakeResult res = (OdbcHandshakeResult) res0;
@@ -189,8 +189,8 @@ public class OdbcMessageParser {
}
else {
writer.writeBoolean(false);
- writer.writeString(res.protoVerSince());
- writer.writeString(res.currentVer());
+ writer.writeString(res.protocolVersionSince());
+ writer.writeString(res.currentVersion());
}
}
else if (res0 instanceof OdbcQueryExecuteResult) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java
new file mode 100644
index 0000000..97a1306
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcProtocolVersion.java
@@ -0,0 +1,106 @@
+/*
+ * 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.HashMap;
+import java.util.Map;
+
+/**
+ * ODBC protocol version.
+ */
+public enum OdbcProtocolVersion {
+ /** First version of the ODBC. Released with Ignite 1.6 */
+ VERSION_1_6_0(1),
+
+ /** Unknown version. */
+ VERSION_UNKNOWN(Long.MIN_VALUE);
+
+ /** Long value to enum map. */
+ private static final Map<Long, OdbcProtocolVersion> versions = new HashMap<>();
+
+ /** Enum value to Ignite version map */
+ private static final Map<OdbcProtocolVersion, String> since = new HashMap<>();
+
+ /**
+ * Map long values to version.
+ */
+ static {
+ for (OdbcProtocolVersion version : values())
+ versions.put(version.longValue(), version);
+
+ since.put(VERSION_1_6_0, "1.6.0");
+ }
+
+ /** Long value for version. */
+ private final long longVal;
+
+ /**
+ * @param longVal Long value.
+ */
+ OdbcProtocolVersion(long longVal) {
+ this.longVal = longVal;
+ }
+
+ /**
+ * @param longVal Long value.
+ * @return Protocol version.
+ */
+ public static OdbcProtocolVersion fromLong(long longVal) {
+ OdbcProtocolVersion res = versions.get(longVal);
+
+ return res == null ? VERSION_UNKNOWN : res;
+ }
+
+ /**
+ * @return Current version.
+ */
+ public static OdbcProtocolVersion current() {
+ return VERSION_1_6_0;
+ }
+
+ /**
+ * @return Long value.
+ */
+ public long longValue() {
+ return longVal;
+ }
+
+ /**
+ * @return {@code true} if this version is unknown.
+ */
+ public boolean isUnknown() {
+ return longVal == VERSION_UNKNOWN.longVal;
+ }
+
+ /**
+ * @return {@code true} if this version supports distributed joins.
+ */
+ public boolean isDistributedJoinsSupported() {
+ assert !isUnknown();
+
+ return longVal >= VERSION_1_6_0.longVal;
+ }
+
+ /**
+ * @return Ignite version when introduced.
+ */
+ public String since() {
+ assert !isUnknown();
+
+ return since.get(this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
index ce98720..3f7d505 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/odbc/OdbcRequestHandler.java
@@ -91,7 +91,7 @@ public class OdbcRequestHandler {
try {
switch (req.command()) {
case HANDSHAKE:
- return performHandshake(reqId, (OdbcHandshakeRequest)req);
+ return performHandshake((OdbcHandshakeRequest)req);
case EXECUTE_SQL_QUERY:
return executeQuery(reqId, (OdbcQueryExecuteRequest)req);
@@ -119,23 +119,24 @@ public class OdbcRequestHandler {
/**
* {@link OdbcHandshakeRequest} command handler.
*
- * @param reqId Request ID.
* @param req Handshake request.
* @return Response.
*/
- private OdbcResponse performHandshake(long reqId, OdbcHandshakeRequest req) {
- OdbcHandshakeResult res;
+ private OdbcResponse performHandshake(OdbcHandshakeRequest req) {
+ OdbcProtocolVersion version = req.version();
- if (req.version() == OdbcMessageParser.PROTO_VER)
- res = new OdbcHandshakeResult(true, null, null);
- else {
+ if (version.isUnknown()) {
IgniteProductVersion ver = ctx.grid().version();
String verStr = Byte.toString(ver.major()) + '.' + ver.minor() + '.' + ver.maintenance();
- res = new OdbcHandshakeResult(false, OdbcMessageParser.PROTO_VER_SINCE, verStr);
+ OdbcHandshakeResult res = new OdbcHandshakeResult(false, OdbcProtocolVersion.current().since(), verStr);
+
+ return new OdbcResponse(res);
}
+ OdbcHandshakeResult res = new OdbcHandshakeResult(true, null, null);
+
return new OdbcResponse(res);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/common/include/ignite/common/utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/utils.h b/modules/platforms/cpp/common/include/ignite/common/utils.h
index c1046e2..f4d2a9f 100644
--- a/modules/platforms/cpp/common/include/ignite/common/utils.h
+++ b/modules/platforms/cpp/common/include/ignite/common/utils.h
@@ -60,6 +60,13 @@ namespace ignite
}
/**
+ * Strips leading and trailing whitespaces from string.
+ *
+ * @param str String to be transformed.
+ */
+ IGNITE_IMPORT_EXPORT void StripSurroundingWhitespaces(std::string& str);
+
+ /**
* Get string representation of long in decimal form.
*
* @param val Long value to be converted to string.
@@ -179,6 +186,24 @@ namespace ignite
return res;
}
+
+ /**
+ * Check if the predicate returns true for all the elements of the
+ * sequence.
+ *
+ * @return True if the predicate returns true for all the elements
+ * of the sequence and false otherwise.
+ */
+ template<typename Iter, typename Pred>
+ bool AllOf(Iter begin, Iter end, Pred pred)
+ {
+ Iter i = begin;
+
+ while (i != end && pred(*i))
+ ++i;
+
+ return i == end;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/common/os/win/src/common/utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/os/win/src/common/utils.cpp b/modules/platforms/cpp/common/os/win/src/common/utils.cpp
index 47d7f43..77c90b8 100644
--- a/modules/platforms/cpp/common/os/win/src/common/utils.cpp
+++ b/modules/platforms/cpp/common/os/win/src/common/utils.cpp
@@ -40,6 +40,26 @@ namespace ignite
return false;
}
+ void StripSurroundingWhitespaces(std::string& str)
+ {
+ std::string::size_type newBegin = 0;
+ while (newBegin < str.size() && ::isspace(str[newBegin]))
+ ++newBegin;
+
+ if (newBegin == str.size())
+ {
+ str.clear();
+
+ return;
+ }
+
+ std::string::size_type newEnd = str.size() - 1;
+ while (::isspace(str[newEnd]))
+ --newEnd;
+
+ str.assign(str, newBegin, (newEnd - newBegin) + 1);
+ }
+
time_t IgniteTimeGm(const tm& time)
{
tm tmc = time;
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/Makefile.am b/modules/platforms/cpp/odbc-test/Makefile.am
index de8fb5d..1ca85a7 100644
--- a/modules/platforms/cpp/odbc-test/Makefile.am
+++ b/modules/platforms/cpp/odbc-test/Makefile.am
@@ -75,6 +75,7 @@ ignite_odbc_tests_SOURCES = \
../odbc/src/app/application_data_buffer.cpp \
../odbc/src/config/configuration.cpp \
../odbc/src/row.cpp \
+ ../odbc/src/protocol_version.cpp \
../odbc/src/column.cpp \
../odbc/src/utility.cpp \
../odbc/src/result_page.cpp
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml b/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml
new file mode 100644
index 0000000..db19669
--- /dev/null
+++ b/modules/platforms/cpp/odbc-test/config/queries-test-noodbc.xml
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="localHost" value="127.0.0.1"/>
+ <property name="connectorConfiguration"><null/></property>
+ <property name="odbcConfiguration"><null/></property>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="cache"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+
+ <!-- Configure type metadata to enable queries. -->
+ <property name="queryEntities">
+ <list>
+ <bean class="org.apache.ignite.cache.QueryEntity">
+ <property name="keyType" value="java.lang.Long"/>
+ <property name="valueType" value="TestType"/>
+
+ <property name="fields">
+ <map>
+ <entry key="i8Field" value="java.lang.Byte"/>
+ <entry key="i16Field" value="java.lang.Short"/>
+ <entry key="i32Field" value="java.lang.Integer"/>
+ <entry key="i64Field" value="java.lang.Long"/>
+ <entry key="strField" value="java.lang.String"/>
+ <entry key="floatField" value="java.lang.Float"/>
+ <entry key="doubleField" value="java.lang.Double"/>
+ <entry key="boolField" value="java.lang.Boolean"/>
+ <entry key="guidField" value="java.util.UUID"/>
+ <entry key="dateField" value="java.util.Date"/>
+ <entry key="timestampField" value="java.sql.Timestamp"/>
+ </map>
+ </property>
+
+ <property name="indexes">
+ <list>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <constructor-arg value="i32Field"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <constructor-arg value="i64Field"/>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <!--
+ Ignite provides several options for automatic discovery that can be used
+ instead os static IP based discovery.
+ -->
+ <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <!-- In distributed environment, replace with actual host IP address. -->
+ <value>127.0.0.1:47500</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ <property name="socketTimeout" value="300" />
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/config/queries-test.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/config/queries-test.xml b/modules/platforms/cpp/odbc-test/config/queries-test.xml
index 67415fb..26e6341 100644
--- a/modules/platforms/cpp/odbc-test/config/queries-test.xml
+++ b/modules/platforms/cpp/odbc-test/config/queries-test.xml
@@ -31,7 +31,9 @@
<!-- Enabling ODBC. -->
<property name="odbcConfiguration">
- <bean class="org.apache.ignite.configuration.OdbcConfiguration"></bean>
+ <bean class="org.apache.ignite.configuration.OdbcConfiguration">
+ <property name="endpointAddress" value="127.0.0.1:11110"/>
+ </bean>
</property>
<property name="cacheConfiguration">
@@ -39,16 +41,17 @@
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache"/>
<property name="cacheMode" value="PARTITIONED"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="writeSynchronizationMode" value="PRIMARY_SYNC"/>
-
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+
<!-- Configure type metadata to enable queries. -->
- <property name="typeMetadata">
+ <property name="queryEntities">
<list>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <bean class="org.apache.ignite.cache.QueryEntity">
<property name="keyType" value="java.lang.Long"/>
<property name="valueType" value="TestType"/>
- <property name="queryFields">
+
+ <property name="fields">
<map>
<entry key="i8Field" value="java.lang.Byte"/>
<entry key="i16Field" value="java.lang.Short"/>
@@ -63,6 +66,17 @@
<entry key="timestampField" value="java.sql.Timestamp"/>
</map>
</property>
+
+ <property name="indexes">
+ <list>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <constructor-arg value="i32Field"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.QueryIndex">
+ <constructor-arg value="i64Field"/>
+ </bean>
+ </list>
+ </property>
</bean>
</list>
</property>
@@ -79,8 +93,7 @@
instead os static IP based discovery.
-->
<!-- Uncomment static IP finder to enable static-based discovery of initial nodes. -->
- <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">-->
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
<property name="addresses">
<list>
<!-- In distributed environment, replace with actual host IP address. -->
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
index a9423ca..cb5735f 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj
@@ -157,6 +157,7 @@
<ClCompile Include="..\..\..\odbc\src\config\configuration.cpp" />
<ClCompile Include="..\..\..\odbc\src\config\connection_info.cpp" />
<ClCompile Include="..\..\..\odbc\src\cursor.cpp" />
+ <ClCompile Include="..\..\..\odbc\src\protocol_version.cpp" />
<ClCompile Include="..\..\..\odbc\src\result_page.cpp" />
<ClCompile Include="..\..\..\odbc\src\row.cpp" />
<ClCompile Include="..\..\..\odbc\src\utility.cpp" />
@@ -202,6 +203,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <None Include="..\..\config\queries-test-noodbc.xml" />
<None Include="..\..\config\queries-test.xml" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
index 84f5a29..270bdd6 100644
--- a/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
+++ b/modules/platforms/cpp/odbc-test/project/vs/odbc-test.vcxproj.filters
@@ -76,6 +76,9 @@
<ClCompile Include="..\..\src\queries_test.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\odbc\src\protocol_version.cpp">
+ <Filter>Externals</Filter>
+ </ClCompile>
<ClCompile Include="..\..\src\sql_string_functions_test.cpp">
<Filter>Code</Filter>
</ClCompile>
@@ -122,5 +125,8 @@
<None Include="..\..\config\queries-test.xml">
<Filter>Configs</Filter>
</None>
+ <None Include="..\..\config\queries-test-noodbc.xml">
+ <Filter>Configs</Filter>
+ </None>
</ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/configuration_test.cpp b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
index 85aa3ff..0fd3277 100644
--- a/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/configuration_test.cpp
@@ -20,51 +20,93 @@
#endif
#include <iostream>
+#include <set>
#include <boost/test/unit_test.hpp>
#include <ignite/odbc/config/configuration.h>
+#include <ignite/ignite_error.h>
+#include <ignite/common/utils.h>
using namespace ignite::odbc::config;
namespace
{
- const char* testDriverName = "Ignite";
- const char* testServerHost = "testhost.com";
+ const std::string testDriverName = "Ignite Driver";
+ const std::string testServerHost = "testhost.com";
const uint16_t testServerPort = 4242;
- const char* testCacheName = "TestCache";
- const char* testDsn = "Ignite DSN";
+ const std::string testCacheName = "TestCache";
+ const std::string testDsn = "Ignite DSN";
+
+ const std::string testAddress = testServerHost + ':' + ignite::common::LexicalCast<std::string>(testServerPort);
}
-BOOST_AUTO_TEST_SUITE(ConfigurationTestSuite)
+void CheckValidAddress(const char* connectStr, uint16_t port)
+{
+ Configuration cfg;
+
+ BOOST_CHECK_NO_THROW(cfg.FillFromConnectString(connectStr));
+
+ BOOST_CHECK_EQUAL(cfg.GetTcpPort(), port);
+}
+
+void CheckValidProtocolVersion(const char* connectStr, ignite::odbc::ProtocolVersion version)
+{
+ Configuration cfg;
+
+ BOOST_CHECK_NO_THROW(cfg.FillFromConnectString(connectStr));
+
+ BOOST_CHECK(cfg.GetProtocolVersion() == version);
+}
+
+void CheckInvalidProtocolVersion(const char* connectStr)
+{
+ Configuration cfg;
+
+ cfg.FillFromConnectString(connectStr);
+
+ BOOST_CHECK_THROW(cfg.GetProtocolVersion(), ignite::IgniteError);
+}
void CheckConnectionConfig(const Configuration& cfg)
{
- BOOST_REQUIRE(cfg.GetDriver() == testDriverName);
- BOOST_REQUIRE(cfg.GetHost() == testServerHost);
- BOOST_REQUIRE(cfg.GetPort() == testServerPort);
- BOOST_REQUIRE(cfg.GetCache() == testCacheName);
- BOOST_REQUIRE(cfg.GetDsn().empty());
+ BOOST_CHECK_EQUAL(cfg.GetDriver(), testDriverName);
+ BOOST_CHECK_EQUAL(cfg.GetHost(), testServerHost);
+ BOOST_CHECK_EQUAL(cfg.GetTcpPort(), testServerPort);
+ BOOST_CHECK_EQUAL(cfg.GetAddress(), testAddress);
+ BOOST_CHECK_EQUAL(cfg.GetCache(), testCacheName);
+ BOOST_CHECK_EQUAL(cfg.GetDsn(), std::string());
std::stringstream constructor;
- constructor << "driver={" << testDriverName << "};"
- << "server=" << testServerHost << ";"
- << "port=" << testServerPort << ";"
- << "cache=" << testCacheName << ";";
+ constructor << "address=" << testAddress << ';'
+ << "cache=" << testCacheName << ';'
+ << "driver={" << testDriverName << "};";
const std::string& expectedStr = constructor.str();
- BOOST_REQUIRE(cfg.ToConnectString() == expectedStr);
+ BOOST_CHECK_EQUAL(ignite::common::ToLower(cfg.ToConnectString()), ignite::common::ToLower(expectedStr));
}
void CheckDsnConfig(const Configuration& cfg)
{
- BOOST_REQUIRE(cfg.GetDriver() == testDriverName);
- BOOST_REQUIRE(cfg.GetDsn() == testDsn);
- BOOST_REQUIRE(cfg.GetHost().empty());
- BOOST_REQUIRE(cfg.GetCache().empty());
- BOOST_REQUIRE(cfg.GetPort() == 0);
+ BOOST_CHECK_EQUAL(cfg.GetDriver(), testDriverName);
+ BOOST_CHECK_EQUAL(cfg.GetDsn(), testDsn);
+ BOOST_CHECK_EQUAL(cfg.GetCache(), Configuration::DefaultValue::cache);
+ BOOST_CHECK_EQUAL(cfg.GetAddress(), Configuration::DefaultValue::address);
+ BOOST_CHECK_EQUAL(cfg.GetHost(), std::string());
+ BOOST_CHECK_EQUAL(cfg.GetTcpPort(), Configuration::DefaultValue::port);
+}
+
+BOOST_AUTO_TEST_SUITE(ConfigurationTestSuite)
+
+BOOST_AUTO_TEST_CASE(CheckTestValuesNotEquealDefault)
+{
+ BOOST_CHECK_NE(testDriverName, Configuration::DefaultValue::driver);
+ BOOST_CHECK_NE(testAddress, Configuration::DefaultValue::address);
+ BOOST_CHECK_NE(testServerPort, Configuration::DefaultValue::port);
+ BOOST_CHECK_NE(testCacheName, Configuration::DefaultValue::cache);
+ BOOST_CHECK_NE(testDsn, Configuration::DefaultValue::dsn);
}
BOOST_AUTO_TEST_CASE(TestConnectStringUppercase)
@@ -74,13 +116,12 @@ BOOST_AUTO_TEST_CASE(TestConnectStringUppercase)
std::stringstream constructor;
constructor << "DRIVER={" << testDriverName << "};"
- << "SERVER=" << testServerHost <<";"
- << "PORT=" << testServerPort << ";"
+ << "ADDRESS=" << testAddress << ';'
<< "CACHE=" << testCacheName;
const std::string& connectStr = constructor.str();
- cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
+ cfg.FillFromConnectString(connectStr);
CheckConnectionConfig(cfg);
}
@@ -92,13 +133,12 @@ BOOST_AUTO_TEST_CASE(TestConnectStringLowercase)
std::stringstream constructor;
constructor << "driver={" << testDriverName << "};"
- << "server=" << testServerHost << ";"
- << "port=" << testServerPort << ";"
- << "cache=" << testCacheName;
+ << "address=" << testAddress << ';'
+ << "cache=" << testCacheName << ';';
const std::string& connectStr = constructor.str();
- cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
+ cfg.FillFromConnectString(connectStr);
CheckConnectionConfig(cfg);
}
@@ -110,9 +150,8 @@ BOOST_AUTO_TEST_CASE(TestConnectStringZeroTerminated)
std::stringstream constructor;
constructor << "driver={" << testDriverName << "};"
- << "server=" << testServerHost << ";"
- << "port=" << testServerPort << ";"
- << "cache=" << testCacheName;
+ << "address=" << testAddress << ';'
+ << "cache=" << testCacheName << ';';
const std::string& connectStr = constructor.str();
@@ -128,13 +167,12 @@ BOOST_AUTO_TEST_CASE(TestConnectStringMixed)
std::stringstream constructor;
constructor << "Driver={" << testDriverName << "};"
- << "Server=" << testServerHost << ";"
- << "Port=" << testServerPort << ";"
- << "Cache=" << testCacheName;
+ << "Address=" << testAddress << ';'
+ << "Cache=" << testCacheName << ';';
const std::string& connectStr = constructor.str();
- cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
+ cfg.FillFromConnectString(connectStr);
CheckConnectionConfig(cfg);
}
@@ -146,17 +184,53 @@ BOOST_AUTO_TEST_CASE(TestConnectStringWhitepaces)
std::stringstream constructor;
constructor << "DRIVER = {" << testDriverName << "} ;\n"
- << " SERVER =" << testServerHost << " ; \n"
- << "PORT= " << testServerPort << "; "
- << "CACHE = \n\r" << testCacheName;
+ << " ADDRESS =" << testAddress << "; "
+ << "CACHE = \n\r" << testCacheName << ';';
const std::string& connectStr = constructor.str();
- cfg.FillFromConnectString(connectStr.c_str(), connectStr.size());
+ cfg.FillFromConnectString(connectStr);
CheckConnectionConfig(cfg);
}
+BOOST_AUTO_TEST_CASE(TestConnectStringInvalidAddress)
+{
+ Configuration cfg;
+
+ BOOST_CHECK_THROW(cfg.FillFromConnectString("Address=example.com:0;"), ignite::IgniteError);
+ BOOST_CHECK_THROW(cfg.FillFromConnectString("Address=example.com:00000;"), ignite::IgniteError);
+ BOOST_CHECK_THROW(cfg.FillFromConnectString("Address=example.com:fdsf;"), ignite::IgniteError);
+ BOOST_CHECK_THROW(cfg.FillFromConnectString("Address=example.com:123:1;"), ignite::IgniteError);
+ BOOST_CHECK_THROW(cfg.FillFromConnectString("Address=example.com:12322221;"), ignite::IgniteError);
+ BOOST_CHECK_THROW(cfg.FillFromConnectString("Address=example.com:12322a;"), ignite::IgniteError);
+ BOOST_CHECK_THROW(cfg.FillFromConnectString("Address=example.com:;"), ignite::IgniteError);
+}
+
+BOOST_AUTO_TEST_CASE(TestConnectStringValidAddress)
+{
+ CheckValidAddress("Address=example.com:1;", 1);
+ CheckValidAddress("Address=example.com:31242;", 31242);
+ CheckValidAddress("Address=example.com:55555;", 55555);
+ CheckValidAddress("Address=example.com:110;", 110);
+ CheckValidAddress("Address=example.com;", Configuration::DefaultValue::port);
+}
+
+BOOST_AUTO_TEST_CASE(TestConnectStringInvalidVersion)
+{
+ CheckInvalidProtocolVersion("Protocol_Version=0;");
+ CheckInvalidProtocolVersion("Protocol_Version=1;");
+ CheckInvalidProtocolVersion("Protocol_Version=2;");
+ CheckInvalidProtocolVersion("Protocol_Version=1.6.1;");
+ CheckInvalidProtocolVersion("Protocol_Version=1.7.0;");
+ CheckInvalidProtocolVersion("Protocol_Version=1.8.1;");
+}
+
+BOOST_AUTO_TEST_CASE(TestConnectStringValidVersion)
+{
+ CheckValidProtocolVersion("Protocol_Version=1.6.0;", ignite::odbc::ProtocolVersion::VERSION_1_6_0);
+}
+
BOOST_AUTO_TEST_CASE(TestDsnStringUppercase)
{
Configuration cfg;
@@ -173,7 +247,7 @@ BOOST_AUTO_TEST_CASE(TestDsnStringUppercase)
CheckDsnConfig(cfg);
}
-BOOST_AUTO_TEST_CASE(TestDsnStrinLowercase)
+BOOST_AUTO_TEST_CASE(TestDsnStringLowercase)
{
Configuration cfg;
@@ -189,7 +263,7 @@ BOOST_AUTO_TEST_CASE(TestDsnStrinLowercase)
CheckDsnConfig(cfg);
}
-BOOST_AUTO_TEST_CASE(TestDsnStrinMixed)
+BOOST_AUTO_TEST_CASE(TestDsnStringMixed)
{
Configuration cfg;
@@ -205,7 +279,7 @@ BOOST_AUTO_TEST_CASE(TestDsnStrinMixed)
CheckDsnConfig(cfg);
}
-BOOST_AUTO_TEST_CASE(TestDsnStrinWhitespaces)
+BOOST_AUTO_TEST_CASE(TestDsnStringWhitespaces)
{
Configuration cfg;
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/src/queries_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/queries_test.cpp b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
index 2d9bd58..4ba3a63 100644
--- a/modules/platforms/cpp/odbc-test/src/queries_test.cpp
+++ b/modules/platforms/cpp/odbc-test/src/queries_test.cpp
@@ -24,6 +24,7 @@
#include <vector>
#include <string>
+#include <algorithm>
#ifndef _MSC_VER
# define BOOST_TEST_DYN_LINK
@@ -53,41 +54,12 @@ using ignite::impl::binary::BinaryUtils;
struct QueriesTestSuiteFixture
{
/**
- * Constructor.
+ * Establish connection to node.
+ *
+ * @param connectStr Connection string.
*/
- QueriesTestSuiteFixture() : testCache(0), env(NULL), dbc(NULL), stmt(NULL)
+ void Connect(const std::string& connectStr)
{
- IgniteConfiguration cfg;
-
- cfg.jvmOpts.push_back("-Xdebug");
- cfg.jvmOpts.push_back("-Xnoagent");
- cfg.jvmOpts.push_back("-Djava.compiler=NONE");
- cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
- cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
-
-#ifdef IGNITE_TESTS_32
- cfg.jvmInitMem = 256;
- cfg.jvmMaxMem = 768;
-#else
- cfg.jvmInitMem = 1024;
- cfg.jvmMaxMem = 4096;
-#endif
-
- char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
-
- BOOST_REQUIRE(cfgPath != 0);
-
- cfg.springCfgPath.assign(cfgPath).append("/queries-test.xml");
-
- IgniteError err;
-
- grid = Ignition::Start(cfg, &err);
-
- if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
- BOOST_FAIL(err.GetText());
-
- testCache = grid.GetCache<int64_t, TestType>("cache");
-
// Allocate an environment handle
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
@@ -102,13 +74,16 @@ struct QueriesTestSuiteFixture
BOOST_REQUIRE(dbc != NULL);
// Connect string
- SQLCHAR connectStr[] = "DRIVER={Apache Ignite};SERVER=localhost;PORT=10800;CACHE=cache";
+ std::vector<SQLCHAR> connectStr0;
+
+ connectStr0.reserve(connectStr.size() + 1);
+ std::copy(connectStr.begin(), connectStr.end(), std::back_inserter(connectStr0));
SQLCHAR outstr[ODBC_BUFFER_SIZE];
SQLSMALLINT outstrlen;
// Connecting to ODBC server.
- SQLRETURN ret = SQLDriverConnect(dbc, NULL, connectStr, static_cast<SQLSMALLINT>(sizeof(connectStr)),
+ SQLRETURN ret = SQLDriverConnect(dbc, NULL, &connectStr0[0], static_cast<SQLSMALLINT>(connectStr0.size()),
outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_COMPLETE);
if (!SQL_SUCCEEDED(ret))
@@ -124,10 +99,7 @@ struct QueriesTestSuiteFixture
BOOST_REQUIRE(stmt != NULL);
}
- /**
- * Destructor.
- */
- ~QueriesTestSuiteFixture()
+ void Disconnect()
{
// Releasing statement handle.
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
@@ -138,13 +110,67 @@ struct QueriesTestSuiteFixture
// Releasing allocated handles.
SQLFreeHandle(SQL_HANDLE_DBC, dbc);
SQLFreeHandle(SQL_HANDLE_ENV, env);
+ }
+
+ static Ignite StartNode(const char* name, const char* config)
+ {
+ IgniteConfiguration cfg;
- Ignition::Stop(grid.GetName(), true);
+ cfg.jvmOpts.push_back("-Xdebug");
+ cfg.jvmOpts.push_back("-Xnoagent");
+ cfg.jvmOpts.push_back("-Djava.compiler=NONE");
+ cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+ cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
+
+#ifdef IGNITE_TESTS_32
+ cfg.jvmInitMem = 256;
+ cfg.jvmMaxMem = 768;
+#else
+ cfg.jvmInitMem = 1024;
+ cfg.jvmMaxMem = 4096;
+#endif
+
+ char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
+
+ BOOST_REQUIRE(cfgPath != 0);
+
+ cfg.springCfgPath.assign(cfgPath).append("/").append(config);
+
+ IgniteError err;
+
+ return Ignition::Start(cfg, name);
+ }
+
+ static Ignite StartAdditionalNode(const char* name)
+ {
+ return StartNode(name, "queries-test-noodbc.xml");
+ }
+
+ /**
+ * Constructor.
+ */
+ QueriesTestSuiteFixture() : testCache(0), env(NULL), dbc(NULL), stmt(NULL)
+ {
+ grid = StartNode("NodeMain", "queries-test.xml");
+
+ testCache = grid.GetCache<int64_t, TestType>("cache");
+ }
+
+ /**
+ * Destructor.
+ */
+ ~QueriesTestSuiteFixture()
+ {
+ Disconnect();
+
+ Ignition::StopAll(true);
}
template<typename T>
void CheckTwoRowsInt(SQLSMALLINT type)
{
+ Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;CACHE=cache");
+
SQLRETURN ret;
TestType in1(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), BinaryUtils::MakeDateGmt(1987, 6, 5), BinaryUtils::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
@@ -252,6 +278,16 @@ struct QueriesTestSuiteFixture
BOOST_FIXTURE_TEST_SUITE(QueriesTestSuite, QueriesTestSuiteFixture)
+BOOST_AUTO_TEST_CASE(TestLegacyConnection)
+{
+ Connect("DRIVER={Apache Ignite};SERVER=127.0.0.1;PORT=11110;CACHE=cache");
+}
+
+BOOST_AUTO_TEST_CASE(TestConnectionProtocolVersion_1_6_0)
+{
+ Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;CACHE=cache;PROTOCOL_VERSION=1.6.0");
+}
+
BOOST_AUTO_TEST_CASE(TestTwoRowsInt8)
{
CheckTwoRowsInt<int8_t>(SQL_C_STINYINT);
@@ -294,6 +330,8 @@ BOOST_AUTO_TEST_CASE(TestTwoRowsUint64)
BOOST_AUTO_TEST_CASE(TestTwoRowsString)
{
+ Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;CACHE=cache");
+
SQLRETURN ret;
TestType in1(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), BinaryUtils::MakeDateGmt(1987, 6, 5), BinaryUtils::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
@@ -387,6 +425,8 @@ BOOST_AUTO_TEST_CASE(TestTwoRowsString)
BOOST_AUTO_TEST_CASE(TestOneRowString)
{
+ Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;CACHE=cache");
+
SQLRETURN ret;
TestType in(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), BinaryUtils::MakeDateGmt(1987, 6, 5), BinaryUtils::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
@@ -448,6 +488,8 @@ BOOST_AUTO_TEST_CASE(TestOneRowString)
BOOST_AUTO_TEST_CASE(TestOneRowStringLen)
{
+ Connect("DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;CACHE=cache");
+
SQLRETURN ret;
TestType in(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9), BinaryUtils::MakeDateGmt(1987, 6, 5), BinaryUtils::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456));
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp b/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
index 16e5ea0..69b4bfa 100644
--- a/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
+++ b/modules/platforms/cpp/odbc-test/src/sql_test_suite_fixture.cpp
@@ -45,7 +45,7 @@ namespace ignite
char* cfgPath = getenv("IGNITE_NATIVE_TEST_ODBC_CONFIG_PATH");
- BOOST_REQUIRE(cfgPath != 0) ;
+ BOOST_REQUIRE(cfgPath != 0);
cfg.springCfgPath.assign(cfgPath).append("/queries-test.xml");
@@ -54,14 +54,14 @@ namespace ignite
grid = Ignition::Start(cfg, &err);
if (err.GetCode() != IgniteError::IGNITE_SUCCESS)
- BOOST_FAIL(err.GetText()) ;
+ BOOST_FAIL(err.GetText()) ;
testCache = grid.GetCache<int64_t, TestType>("cache");
// Allocate an environment handle
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
- BOOST_REQUIRE(env != NULL) ;
+ BOOST_REQUIRE(env != NULL);
// We want ODBC 3 support
SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, reinterpret_cast<void*>(SQL_OV_ODBC3), 0);
@@ -69,10 +69,10 @@ namespace ignite
// Allocate a connection handle
SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
- BOOST_REQUIRE(dbc != NULL) ;
+ BOOST_REQUIRE(dbc != NULL);
// Connect string
- SQLCHAR connectStr[] = "DRIVER={Apache Ignite};SERVER=localhost;PORT=10800;CACHE=cache";
+ SQLCHAR connectStr[] = "DRIVER={Apache Ignite};ADDRESS=127.0.0.1:11110;CACHE=cache";
SQLCHAR outstr[ODBC_BUFFER_SIZE];
SQLSMALLINT outstrlen;
@@ -85,13 +85,13 @@ namespace ignite
{
Ignition::Stop(grid.GetName(), true);
- BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_DBC, dbc)) ;
+ BOOST_FAIL(GetOdbcErrorMessage(SQL_HANDLE_DBC, dbc));
}
// Allocate a statement handle
SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
- BOOST_REQUIRE(stmt != NULL) ;
+ BOOST_REQUIRE(stmt != NULL);
}
SqlTestSuiteFixture::~SqlTestSuiteFixture()
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/Makefile.am b/modules/platforms/cpp/odbc/Makefile.am
index 29f0ef4..1781bc0 100644
--- a/modules/platforms/cpp/odbc/Makefile.am
+++ b/modules/platforms/cpp/odbc/Makefile.am
@@ -62,6 +62,7 @@ libignite_odbc_la_SOURCES = \
src/meta/table_meta.cpp \
src/odbc.cpp \
src/entry_points.cpp \
+ src/dsn_config.cpp \
src/query/column_metadata_query.cpp \
src/query/data_query.cpp \
src/query/foreign_keys_query.cpp \
@@ -69,6 +70,7 @@ libignite_odbc_la_SOURCES = \
src/query/table_metadata_query.cpp \
src/query/type_info_query.cpp \
src/query/special_columns_query.cpp \
+ src/protocol_version.cpp \
src/result_page.cpp \
src/row.cpp \
src/column.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/Makefile.am b/modules/platforms/cpp/odbc/include/Makefile.am
index 192021d..073dcaa 100644
--- a/modules/platforms/cpp/odbc/include/Makefile.am
+++ b/modules/platforms/cpp/odbc/include/Makefile.am
@@ -27,6 +27,7 @@ noinst_HEADERS = \
ignite/odbc/query/column_metadata_query.h \
ignite/odbc/query/query.h \
ignite/odbc/query/primary_keys_query.h \
+ ignite/odbc/protocol_version.h \
ignite/odbc/statement.h \
ignite/odbc/config/configuration.h \
ignite/odbc/config/connection_info.h \
@@ -37,6 +38,7 @@ noinst_HEADERS = \
ignite/odbc/row.h \
ignite/odbc/utility.h \
ignite/odbc/environment.h \
+ ignite/odbc/dsn_config.h \
ignite/odbc/system/odbc_constants.h \
ignite/odbc/system/socket_client.h \
ignite/odbc/meta/primary_key_meta.h \
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h b/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h
index 6636ca4..250eaf2 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/common_types.h
@@ -60,6 +60,9 @@ namespace ignite
/** Output data has been truncated. */
SQL_STATE_01004_DATA_TRUNCATED,
+ /** Invalid connection string attribute. */
+ SQL_STATE_01S00_INVALID_CONNECTION_STRING_ATTRIBUTE,
+
/** Error in row. */
SQL_STATE_01S01_ERROR_IN_ROW,
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h b/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
index d6d7944..f90fa2d 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/config/configuration.h
@@ -23,6 +23,8 @@
#include <map>
#include <ignite/common/common.h>
+#include <ignite/common/utils.h>
+#include "ignite/odbc/protocol_version.h"
namespace ignite
{
@@ -36,6 +38,71 @@ namespace ignite
class Configuration
{
public:
+ /** Map containing connect arguments. */
+ typedef std::map<std::string, std::string> ArgumentMap;
+
+ /** Connection attribute keywords. */
+ struct Key
+ {
+ /** Connection attribute keyword for DSN attribute. */
+ static const std::string dsn;
+
+ /** Connection attribute keyword for Driver attribute. */
+ static const std::string driver;
+
+ /** Connection attribute keyword for cache attribute. */
+ static const std::string cache;
+
+ /** Connection attribute keyword for address attribute. */
+ static const std::string address;
+
+ /** Connection attribute keyword for server attribute. */
+ static const std::string server;
+
+ /** Connection attribute keyword for port attribute. */
+ static const std::string port;
+
+ /** Connection attribute keyword for protocol version attribute. */
+ static const std::string protocolVersion;
+ };
+
+ /** Default values for configuration. */
+ struct DefaultValue
+ {
+ /** Default value for DSN attribute. */
+ static const std::string dsn;
+
+ /** Default value for Driver attribute. */
+ static const std::string driver;
+
+ /** Default value for cache attribute. */
+ static const std::string cache;
+
+ /** Default value for address attribute. */
+ static const std::string address;
+
+ /** Default value for server attribute. */
+ static const std::string server;
+
+ /** Default value for protocol version. */
+ static const ProtocolVersion& protocolVersion;
+
+ /** Default value for port attribute. */
+ static const uint16_t port;
+ };
+
+ /**
+ * Connection end point structure.
+ */
+ struct EndPoint
+ {
+ /** Remote host. */
+ std::string host;
+
+ /** TCP port. */
+ uint16_t port;
+ };
+
/**
* Default constructor.
*/
@@ -81,19 +148,36 @@ namespace ignite
*
* @return Server port.
*/
- uint16_t GetPort() const
+ uint16_t GetTcpPort() const
{
- return port;
+ return endPoint.port;
}
/**
+ * Set server port.
+ *
+ * @param port Server port.
+ */
+ void SetTcpPort(uint16_t port);
+
+ /**
* Get DSN.
*
* @return Data Source Name.
*/
const std::string& GetDsn() const
{
- return dsn;
+ return GetStringValue(Key::dsn, DefaultValue::dsn);
+ }
+
+ /**
+ * Set DSN.
+ *
+ * @param dsn Data Source Name.
+ */
+ void SetDsn(const std::string& dsn)
+ {
+ arguments[Key::dsn] = dsn;
}
/**
@@ -103,7 +187,7 @@ namespace ignite
*/
const std::string& GetDriver() const
{
- return driver;
+ return GetStringValue(Key::driver, DefaultValue::driver);
}
/**
@@ -113,7 +197,17 @@ namespace ignite
*/
const std::string& GetHost() const
{
- return host;
+ return endPoint.host;
+ }
+
+ /**
+ * Set server host.
+ *
+ * @param server Server host.
+ */
+ void SetHost(const std::string& server)
+ {
+ arguments[Key::server] = server;
}
/**
@@ -123,38 +217,105 @@ namespace ignite
*/
const std::string& GetCache() const
{
- return cache;
+ return GetStringValue(Key::cache, DefaultValue::cache);
}
- private:
- IGNITE_NO_COPY_ASSIGNMENT(Configuration);
+ /**
+ * Set cache.
+ *
+ * @param cache Cache name.
+ */
+ void SetCache(const std::string& cache)
+ {
+ arguments[Key::cache] = cache;
+ }
- /** Map containing connect arguments. */
- typedef std::map<std::string, std::string> ArgumentMap;
+ /**
+ * Get address.
+ *
+ * @return Address.
+ */
+ const std::string& GetAddress() const
+ {
+ return GetStringValue(Key::address, DefaultValue::address);
+ }
+
+ /**
+ * Set address.
+ *
+ * @param address Address.
+ */
+ void SetAddress(const std::string& address)
+ {
+ arguments[Key::address] = address;
+ }
/**
+ * Get argument map.
+ *
+ * @return Argument map.
+ */
+ const ArgumentMap& GetMap() const
+ {
+ return arguments;
+ }
+
+ /**
+ * Get protocol version.
+ *
+ * @return Protocol version.
+ */
+ ProtocolVersion GetProtocolVersion() const;
+
+ /**
+ * Set protocol version.
+ *
+ * @param version Version to set.
+ */
+ void SetProtocolVersion(const std::string& version);
+
+ /**
+ * Get string value from the config.
+ *
+ * @param key Configuration key.
+ * @param dflt Default value to be returned if there is no value stored.
+ * @return Found or default value.
+ */
+ const std::string& GetStringValue(const std::string& key, const std::string& dflt) const;
+
+ /**
+ * Get int value from the config.
+ *
+ * @param key Configuration key.
+ * @param dflt Default value to be returned if there is no value stored.
+ * @return Found or default value.
+ */
+ int64_t GetIntValue(const std::string& key, int64_t dflt) const;
+
+ private:
+ /**
* Parse connect string into key-value storage.
*
* @param str String to parse.
* @param len String length.
* @param params Parsing result.
*/
- void ParseAttributeList(const char* str, size_t len, char delimeter, ArgumentMap& args) const;
+ static void ParseAttributeList(const char* str, size_t len, char delimeter, ArgumentMap& args);
- /** Data Source Name. */
- std::string dsn;
-
- /** Driver name. */
- std::string driver;
-
- /** Server hostname. */
- std::string host;
+ /**
+ * Parse address and extract connection end-point.
+ *
+ * @throw IgniteException if address can not be parsed.
+ * @param address Address string to parse.
+ * @param res Result is placed here.
+ */
+ static void ParseAddress(const std::string& address, EndPoint& res);
- /** Port of the server. */
- uint16_t port;
+ /** Arguments. */
+ ArgumentMap arguments;
- /** Cache name. */
- std::string cache;
+ /** Connection end-point. */
+ EndPoint endPoint;
};
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h b/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
index 10ceb19..acf82ba 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/connection.h
@@ -25,6 +25,7 @@
#include "ignite/odbc/parser.h"
#include "ignite/odbc/system/socket_client.h"
#include "ignite/odbc/config/connection_info.h"
+#include "ignite/odbc/config/configuration.h"
#include "ignite/odbc/diagnostic/diagnosable_adapter.h"
namespace ignite
@@ -40,15 +41,6 @@ namespace ignite
{
friend class Environment;
public:
- /** ODBC communication protocol version. */
- enum { PROTOCOL_VERSION = 1 };
-
- /**
- * Apache Ignite version when the current ODBC communication
- * protocol version has been introduced.
- */
- static const std::string PROTOCOL_VERSION_SINCE;
-
/**
* Destructor.
*/
@@ -74,18 +66,16 @@ namespace ignite
/**
* Establish connection to ODBC server.
*
- * @param server Server (DSN).
+ * @param connectStr Connection string.
*/
- void Establish(const std::string& server);
+ void Establish(const std::string& connectStr);
/**
* Establish connection to ODBC server.
*
- * @param host Host.
- * @param port Port.
- * @param cache Cache name to connect to.
+ * @param cfg Configuration.
*/
- void Establish(const std::string& host, uint16_t port, const std::string& cache);
+ void Establish(const config::Configuration cfg);
/**
* Release established connection.
@@ -124,6 +114,13 @@ namespace ignite
const std::string& GetCache() const;
/**
+ * Get configuration.
+ *
+ * @return Connection configuration.
+ */
+ const config::Configuration& GetConfiguration() const;
+
+ /**
* Create diagnostic record associated with the Connection instance.
*
* @param sqlState SQL state.
@@ -132,8 +129,8 @@ namespace ignite
* @param columnNum Associated column number.
* @return DiagnosticRecord associated with the instance.
*/
- diagnostic::DiagnosticRecord CreateStatusRecord(SqlState sqlState,
- const std::string& message, int32_t rowNum = 0, int32_t columnNum = 0) const;
+ static diagnostic::DiagnosticRecord CreateStatusRecord(SqlState sqlState,
+ const std::string& message, int32_t rowNum = 0, int32_t columnNum = 0);
/**
* Synchronously send request message and receive response.
@@ -172,21 +169,19 @@ namespace ignite
* Establish connection to ODBC server.
* Internal call.
*
- * @param server Server (DNS).
+ * @param connectStr Connection string.
* @return Operation result.
*/
- SqlResult InternalEstablish(const std::string& server);
+ SqlResult InternalEstablish(const std::string& connectStr);
/**
* Establish connection to ODBC server.
* Internal call.
*
- * @param host Host.
- * @param port Port.
- * @param cache Cache name to connect to.
+ * @param cfg Configuration.
* @return Operation result.
*/
- SqlResult InternalEstablish(const std::string& host, uint16_t port, const std::string& cache);
+ SqlResult InternalEstablish(const config::Configuration cfg);
/**
* Release established connection.
@@ -269,11 +264,11 @@ namespace ignite
/** State flag. */
bool connected;
- /** Cache name. */
- std::string cache;
-
/** Message parser. */
Parser parser;
+
+ /** Configuration. */
+ config::Configuration config;
};
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
index bfb4f4c..670e0aa 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/diagnostic/diagnostic_record.h
@@ -84,7 +84,7 @@ namespace ignite
*
* @return An informational message on the error or warning.
*/
- const std::string& GetMessage() const;
+ const std::string& GetMessageText() const;
/**
* Get connection name.
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/dsn_config.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/dsn_config.h b/modules/platforms/cpp/odbc/include/ignite/odbc/dsn_config.h
new file mode 100644
index 0000000..dbad9b5
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/dsn_config.h
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_DSN_CONFIG
+#define _IGNITE_ODBC_DSN_CONFIG
+
+#include "ignite/odbc/config/configuration.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /**
+ * Extract last setup error and throw it like IgniteError.
+ */
+ void ThrowLastSetupError();
+
+ /**
+ * Add new string to the DSN file.
+ *
+ * @param dsn DSN name.
+ * @param key Key.
+ * @param value Value.
+ */
+ void WriteDsnString(const char* dsn, const char* key, const char* value);
+
+ /**
+ * Get string from the DSN file.
+ *
+ * @param dsn DSN name.
+ * @param key Key.
+ * @param dflt Default value.
+ * @return Value.
+ */
+ std::string ReadDsnString(const char* dsn, const char* key, const char* dflt);
+
+ /**
+ * Read DSN to fill the configuration.
+ *
+ * @param dsn DSN name.
+ * @param config Configuration.
+ */
+ void ReadDsnConfiguration(const char* dsn, config::Configuration& config);
+ }
+}
+
+#endif //_IGNITE_ODBC_DSN_CONFIG
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h b/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
index c19e08c..a91af22 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/parser.h
@@ -42,9 +42,6 @@ namespace ignite
/** Default initial size of operational memory. */
enum { DEFAULT_MEM_ALLOCATION = 4096 };
- /** ODBC communication protocol version. */
- enum { PROTOCOL_VERSION = 1 };
-
/**
* Constructor.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h b/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h
new file mode 100644
index 0000000..8682119
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/protocol_version.h
@@ -0,0 +1,168 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_PROTOCOL_VERSION
+#define _IGNITE_ODBC_PROTOCOL_VERSION
+
+#include <stdint.h>
+
+#include <string>
+#include <map>
+
+namespace ignite
+{
+ namespace odbc
+ {
+ /** Protocol version. */
+ class ProtocolVersion
+ {
+ public:
+ /** String to version map type alias. */
+ typedef std::map<std::string, ProtocolVersion> StringToVersionMap;
+
+ /** Version to string map type alias. */
+ typedef std::map<ProtocolVersion, std::string> VersionToStringMap;
+
+ /** First version of the protocol that was introduced in Ignite 1.6.0. */
+ static const ProtocolVersion VERSION_1_6_0;
+
+ /** Unknown version of the protocol. */
+ static const ProtocolVersion VERSION_UNKNOWN;
+
+ /**
+ * Get string to version map.
+ *
+ * @return String to version map.
+ */
+ static const StringToVersionMap& GetMap();
+
+ /**
+ * Get current version.
+ *
+ * @return Current version.
+ */
+ static const ProtocolVersion& GetCurrent();
+
+ /**
+ * Parse string and extract protocol version.
+ *
+ * @throw IgniteException if version can not be parsed.
+ * @param version Version string to parse.
+ * @return Protocol version.
+ */
+ static ProtocolVersion FromString(const std::string& version);
+
+ /**
+ * Convert to string value.
+ *
+ * @throw IgniteException if version is unknow parsed.
+ * @param version Version string to parse.
+ * @return Protocol version.
+ */
+ const std::string& ToString() const;
+
+ /**
+ * Get int value.
+ *
+ * @return Integer value.
+ */
+ int64_t GetIntValue() const;
+
+ /**
+ * Check if the version is unknown.
+ *
+ * @return True if the version is unknown.
+ */
+ bool IsUnknown() const;
+
+ /**
+ * Comparison operator.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if equal.
+ */
+ friend bool operator==(const ProtocolVersion& val1, const ProtocolVersion& val2);
+
+ /**
+ * Comparison operator.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if not equal.
+ */
+ friend bool operator!=(const ProtocolVersion& val1, const ProtocolVersion& val2);
+
+ /**
+ * Comparison operator.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if less.
+ */
+ friend bool operator<(const ProtocolVersion& val1, const ProtocolVersion& val2);
+
+ /**
+ * Comparison operator.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if less or equal.
+ */
+ friend bool operator<=(const ProtocolVersion& val1, const ProtocolVersion& val2);
+
+ /**
+ * Comparison operator.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if gretter.
+ */
+ friend bool operator>(const ProtocolVersion& val1, const ProtocolVersion& val2);
+
+ /**
+ * Comparison operator.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if gretter or equal.
+ */
+ friend bool operator>=(const ProtocolVersion& val1, const ProtocolVersion& val2);
+
+ private:
+ /**
+ * Constructor.
+ *
+ * @param val Underlying value.
+ */
+ explicit ProtocolVersion(int64_t val);
+
+ ProtocolVersion();
+
+ /** String to version map. */
+ static const StringToVersionMap stringToVersionMap;
+
+ /** Version to string map. */
+ static const VersionToStringMap versionToStringMap;
+
+ /** Underlying int value. */
+ int64_t val;
+ };
+ }
+}
+
+#endif //_IGNITE_ODBC_PROTOCOL_VERSION
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h b/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
index 60a6552..ecd1a55 100644
--- a/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/system/odbc_constants.h
@@ -27,10 +27,6 @@
# undef min
#endif // min
-#ifdef GetMessage
-# undef GetMessage
-#endif // GetMessage
-
#endif //_WIN32
#define ODBCVER 0x0380
http://git-wip-us.apache.org/repos/asf/ignite/blob/70e69cb7/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h b/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h
new file mode 100644
index 0000000..034de82
--- /dev/null
+++ b/modules/platforms/cpp/odbc/include/ignite/odbc/system/ui/dsn_configuration_window.h
@@ -0,0 +1,136 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_ODBC_SYSTEM_UI_DSN_CONFIGURATION_WINDOW
+#define _IGNITE_ODBC_SYSTEM_UI_DSN_CONFIGURATION_WINDOW
+
+#include "ignite/odbc/config/configuration.h"
+#include "ignite/odbc/system/ui/custom_window.h"
+
+namespace ignite
+{
+ namespace odbc
+ {
+ namespace system
+ {
+ namespace ui
+ {
+ /**
+ * DSN configuration window class.
+ */
+ class DsnConfigurationWindow : public CustomWindow
+ {
+ /**
+ * Children windows ids.
+ */
+ enum ChildId
+ {
+ ID_CONNECTION_SETTINGS_GROUP_BOX,
+ ID_NAME_EDIT,
+ ID_NAME_LABEL,
+ ID_ADDRESS_EDIT,
+ ID_ADDRESS_LABEL,
+ ID_CACHE_EDIT,
+ ID_CACHE_LABEL,
+ ID_OK_BUTTON,
+ ID_CANCEL_BUTTON
+ };
+
+ public:
+ /**
+ * Constructor.
+ *
+ * @param parent Parent window handle.
+ */
+ explicit DsnConfigurationWindow(Window* parent, config::Configuration& config);
+
+ /**
+ * Destructor.
+ */
+ virtual ~DsnConfigurationWindow();
+
+ /**
+ * Create window in the center of the parent window.
+ */
+ void Create();
+
+ /**
+ * @copedoc ignite::odbc::system::ui::CustomWindow::OnCreate
+ */
+ virtual void OnCreate();
+
+ /**
+ * @copedoc ignite::odbc::system::ui::CustomWindow::OnMessage
+ */
+ virtual bool OnMessage(UINT msg, WPARAM wParam, LPARAM lParam);
+
+ private:
+ IGNITE_NO_COPY_ASSIGNMENT(DsnConfigurationWindow)
+
+ /**
+ * Retrieves current values from the children and stores
+ * them to the specified configuration.
+ *
+ * @param cfg Configuration.
+ */
+ void RetrieveParameters(config::Configuration& cfg) const;
+
+ /** Window width. */
+ int width;
+
+ /** Window height. */
+ int height;
+
+ /** Connection settings group box. */
+ std::auto_ptr<Window> connectionSettingsGroupBox;
+
+ /** DSN name edit field label. */
+ std::auto_ptr<Window> nameLabel;
+
+ /** DSN name edit field. */
+ std::auto_ptr<Window> nameEdit;
+
+ /** DSN address edit field label. */
+ std::auto_ptr<Window> addressLabel;
+
+ /** DSN address edit field. */
+ std::auto_ptr<Window> addressEdit;
+
+ /** DSN cache edit field label. */
+ std::auto_ptr<Window> cacheLabel;
+
+ /** DSN cache edit field. */
+ std::auto_ptr<Window> cacheEdit;
+
+ /** Ok button. */
+ std::auto_ptr<Window> okButton;
+
+ /** Cancel button. */
+ std::auto_ptr<Window> cancelButton;
+
+ /** Configuration. */
+ config::Configuration& config;
+
+ /** Flag indicating whether OK option was selected. */
+ bool accepted;
+ };
+ }
+ }
+ }
+}
+
+#endif //_IGNITE_ODBC_SYSTEM_UI_DSN_CONFIGURATION_WINDOW
\ No newline at end of file