ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [2/7] ignite git commit: IGNITE-7811: Implemented connection failover for ODBC
Date Mon, 19 Mar 2018 19:26:56 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ddc6d70/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 11105b6..7b06ea7 100644
--- a/modules/platforms/cpp/odbc/src/connection.cpp
+++ b/modules/platforms/cpp/odbc/src/connection.cpp
@@ -19,6 +19,7 @@
 #include <cstddef>
 
 #include <sstream>
+#include <algorithm>
 
 #include <ignite/common/fixed_size_array.h>
 
@@ -27,11 +28,13 @@
 #include "ignite/odbc/statement.h"
 #include "ignite/odbc/connection.h"
 #include "ignite/odbc/message.h"
-#include "ignite/odbc/config/configuration.h"
 #include "ignite/odbc/ssl/ssl_mode.h"
 #include "ignite/odbc/ssl/ssl_gateway.h"
 #include "ignite/odbc/ssl/secure_socket_client.h"
 #include "ignite/odbc/system/tcp_socket_client.h"
+#include "ignite/odbc/dsn_config.h"
+#include "ignite/odbc/config/configuration.h"
+#include "ignite/odbc/config/connection_string_parser.h"
 
 // Uncomment for per-byte debug.
 //#define PER_BYTE_DEBUG
@@ -104,16 +107,14 @@ namespace ignite
         {
             config::Configuration config;
 
-            try
-            {
-                config.FillFromConnectString(connectStr);
-            }
-            catch (IgniteError& e)
-            {
-                AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, e.GetText());
+            config::ConnectionStringParser parser(config);
 
-                return SqlResult::AI_ERROR;
-            }
+            parser.ParseConnectionString(connectStr, &GetDiagnosticRecords());
+
+            std::string dsn = config.GetDsn();
+
+            if (!dsn.empty())
+                ReadDsnConfiguration(dsn.c_str(), config);
 
             return InternalEstablish(config);
         }
@@ -123,7 +124,7 @@ namespace ignite
             IGNITE_ODBC_API_CALL(InternalEstablish(cfg));
         }
 
-        SqlResult::Type Connection::InternalEstablish(const config::Configuration cfg)
+        SqlResult::Type Connection::InternalEstablish(const config::Configuration& cfg)
         {
             using ssl::SslMode;
 
@@ -136,7 +137,14 @@ namespace ignite
                 return SqlResult::AI_ERROR;
             }
 
-            SslMode::T sslMode = SslMode::FromString(cfg.GetSslMode(), SslMode::DISABLE);
+            if (!config.IsHostSet() && config.IsAddressesSet() && config.GetAddresses().empty())
+            {
+                AddStatusRecord(SqlState::SHY000_GENERAL_ERROR, "No valid address to connect.");
+
+                return SqlResult::AI_ERROR;
+            }
+
+            SslMode::Type sslMode = config.GetSslMode();
 
             if (sslMode != SslMode::DISABLE)
             {
@@ -150,30 +158,24 @@ namespace ignite
                     return SqlResult::AI_ERROR;
                 }
 
-                socket.reset(new ssl::SecureSocketClient(cfg.GetSslCertFile(), cfg.GetSslKeyFile(),
cfg.GetSslCaFile()));
+                socket.reset(new ssl::SecureSocketClient(config.GetSslCertFile(),
+                    config.GetSslKeyFile(), config.GetSslCaFile()));
             }
             else
                 socket.reset(new system::TcpSocketClient());
 
-            bool connected = socket->Connect(cfg.GetHost().c_str(), cfg.GetTcpPort(),
*this);
+            bool connected = TryRestoreConnection();
 
             if (!connected)
             {
                 AddStatusRecord(SqlState::S08001_CANNOT_CONNECT, "Failed to establish connection
with the host.");
 
-                Close();
-
                 return SqlResult::AI_ERROR;
             }
 
-            SqlResult::Type res = MakeRequestHandshake();
-
-            if (res == SqlResult::AI_ERROR)
-                Close();
-            else
-                parser.SetProtocolVersion(config.GetProtocolVersion());
+            bool errors = GetDiagnosticRecords().GetStatusRecordsNumber() > 0;
 
-            return res;
+            return errors ? SqlResult::AI_SUCCESS_WITH_INFO : SqlResult::AI_SUCCESS;
         }
 
         void Connection::Release()
@@ -513,30 +515,7 @@ namespace ignite
 
         SqlResult::Type Connection::MakeRequestHandshake()
         {
-            bool distributedJoins = false;
-            bool enforceJoinOrder = false;
-            bool replicatedOnly = false;
-            bool collocated = false;
-            bool lazy = false;
-            bool skipReducerOnUpdate = false;
-            ProtocolVersion protocolVersion;
-
-            try
-            {
-                protocolVersion = config.GetProtocolVersion();
-                distributedJoins = config.IsDistributedJoins();
-                enforceJoinOrder = config.IsEnforceJoinOrder();
-                replicatedOnly = config.IsReplicatedOnly();
-                collocated = config.IsCollocated();
-                lazy = config.IsLazy();
-                skipReducerOnUpdate = config.IsSkipReducerOnUpdate();
-            }
-            catch (const IgniteError& err)
-            {
-                AddStatusRecord(SqlState::S01S00_INVALID_CONNECTION_STRING_ATTRIBUTE, err.GetText());
-
-                return SqlResult::AI_ERROR;
-            }
+            ProtocolVersion protocolVersion = config.GetProtocolVersion();
 
             if (!protocolVersion.IsSupported())
             {
@@ -546,6 +525,13 @@ namespace ignite
                 return SqlResult::AI_ERROR;
             }
 
+            bool distributedJoins = config.IsDistributedJoins();
+            bool enforceJoinOrder = config.IsEnforceJoinOrder();
+            bool replicatedOnly = config.IsReplicatedOnly();
+            bool collocated = config.IsCollocated();
+            bool lazy = config.IsLazy();
+            bool skipReducerOnUpdate = config.IsSkipReducerOnUpdate();
+
             HandshakeRequest req(protocolVersion, distributedJoins, enforceJoinOrder, replicatedOnly,
collocated, lazy,
                 skipReducerOnUpdate);
             HandshakeResponse rsp;
@@ -554,7 +540,7 @@ namespace ignite
             {
                 // Workaround for some Linux systems that report connection on non-blocking
                 // sockets as successful but fail to establish real connection.
-                bool sent = SyncMessage(req, rsp, SocketClient::CONNECT_TIMEOUT);
+                bool sent = InternalSyncMessage(req, rsp, SocketClient::CONNECT_TIMEOUT);
 
                 if (!sent)
                 {
@@ -599,6 +585,74 @@ namespace ignite
 
             return SqlResult::AI_SUCCESS;
         }
+
+        void Connection::EnsureConnected()
+        {
+            if (socket.get() != 0)
+                return;
+
+            bool success = TryRestoreConnection();
+
+            if (!success)
+                throw OdbcError(SqlState::S08001_CANNOT_CONNECT,
+                    "Failed to establish connection with any provided hosts");
+        }
+
+        bool Connection::TryRestoreConnection()
+        {
+            std::vector<EndPoint> addrs;
+
+            CollectAddresses(config, addrs);
+
+            bool connected = false;
+
+            while (!addrs.empty() && !connected)
+            {
+                const EndPoint& addr = addrs.back();
+
+                for (uint16_t port = addr.port; port <= addr.port + addr.range; ++port)
+                {
+                    connected = socket->Connect(addr.host.c_str(), port, *this);
+
+                    if (connected)
+                    {
+                        SqlResult::Type res = MakeRequestHandshake();
+
+                        connected = res != SqlResult::AI_ERROR;
+
+                        if (connected)
+                            break;
+                    }
+                }
+
+                addrs.pop_back();
+            }
+
+            if (!connected)
+                Close();
+            else
+                parser.SetProtocolVersion(config.GetProtocolVersion());
+
+            return connected;
+        }
+
+        void Connection::CollectAddresses(const config::Configuration& cfg, std::vector<EndPoint>&
endPoints)
+        {
+            endPoints.clear();
+
+            if (!cfg.IsAddressesSet())
+            {
+                LOG_MSG("'Address' is not set. Using legacy connection method.");
+
+                endPoints.push_back(EndPoint(cfg.GetHost(), cfg.GetTcpPort()));
+
+                return;
+            }
+
+            endPoints = cfg.GetAddresses();
+
+            std::random_shuffle(endPoints.begin(), endPoints.end());
+        }
     }
 }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ddc6d70/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 4b90e44..dde1a94 100644
--- a/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
+++ b/modules/platforms/cpp/odbc/src/diagnostic/diagnostic_record_storage.cpp
@@ -50,6 +50,11 @@ namespace ignite
                 rowsAffected = 0;
             }
 
+            void DiagnosticRecordStorage::AddStatusRecord(SqlState::Type sqlState, const
std::string& message)
+            {
+                statusRecords.push_back(DiagnosticRecord(sqlState, message, "", "", 0, 0));
+            }
+
             void DiagnosticRecordStorage::AddStatusRecord(const DiagnosticRecord& record)
             {
                 statusRecords.push_back(record);

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ddc6d70/modules/platforms/cpp/odbc/src/dsn_config.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/dsn_config.cpp b/modules/platforms/cpp/odbc/src/dsn_config.cpp
index 845c8bd..da9d61f 100644
--- a/modules/platforms/cpp/odbc/src/dsn_config.cpp
+++ b/modules/platforms/cpp/odbc/src/dsn_config.cpp
@@ -15,16 +15,18 @@
  * limitations under the License.
  */
 
-#include <set>
+#include <ignite/common/fixed_size_array.h>
 
 #include "ignite/odbc/utility.h"
+#include "ignite/odbc/config/connection_string_parser.h"
 #include "ignite/odbc/system/odbc_constants.h"
-
 #include "ignite/odbc/dsn_config.h"
+#include "ignite/odbc/config/config_tools.h"
+
 
-using ignite::odbc::config::Configuration;
+using namespace ignite::odbc::config;
 
-#define BUFFER_SIZE 1024
+#define BUFFER_SIZE (1024 * 1024)
 #define CONFIG_FILE "ODBC.INI"
 
 namespace ignite
@@ -34,13 +36,13 @@ namespace ignite
         void ThrowLastSetupError()
         {
             DWORD code;
-            char msg[BUFFER_SIZE];
+            common::FixedSizeArray<char> msg(BUFFER_SIZE);
 
-            SQLInstallerError(1, &code, msg, sizeof(msg), NULL);
+            SQLInstallerError(1, &code, msg.GetData(), msg.GetSize(), NULL);
 
             std::stringstream buf;
 
-            buf << "Message: \"" << msg << "\", Code: " << code;
+            buf << "Message: \"" << msg.GetData() << "\", Code: " <<
code;
 
             throw IgniteError(IgniteError::IGNITE_ERR_GENERIC, buf.str().c_str());
         }
@@ -51,98 +53,155 @@ namespace ignite
                 ThrowLastSetupError();
         }
 
-        std::string ReadDsnString(const char* dsn, const std::string& key, const std::string&
dflt)
+        SettableValue<std::string> ReadDsnString(const char* dsn, const std::string&
key, const std::string& dflt = "")
         {
-            char buf[BUFFER_SIZE];
+            static const char* unique = "35a920dd-8837-43d2-a846-e01a2e7b5f84";
 
-            memset(buf, 0, sizeof(buf));
+            SettableValue<std::string> val(dflt);
 
-            SQLGetPrivateProfileString(dsn, key.c_str(), dflt.c_str(), buf, sizeof(buf),
CONFIG_FILE);
+            common::FixedSizeArray<char> buf(BUFFER_SIZE);
 
-            return std::string(buf);
-        }
+            int ret = SQLGetPrivateProfileString(dsn, key.c_str(), unique, buf.GetData(),
buf.GetSize(), CONFIG_FILE);
 
-        int ReadDsnInt(const char* dsn, const std::string& key, int dflt)
-        {
-            char buf[BUFFER_SIZE];
+            if (ret > BUFFER_SIZE)
+            {
+                buf.Reset(ret + 1);
 
-            memset(buf, 0, sizeof(buf));
+                ret = SQLGetPrivateProfileString(dsn, key.c_str(), unique, buf.GetData(),
buf.GetSize(), CONFIG_FILE);
+            }
 
-            std::string dflt0 = common::LexicalCast<std::string>(dflt);
+            std::string res(buf.GetData());
 
-            SQLGetPrivateProfileString(dsn, key.c_str(), dflt0.c_str(), buf, sizeof(buf),
CONFIG_FILE);
+            if (res == unique)
+                return val;
 
-            return common::LexicalCast<int, std::string>(buf);
+            val.SetValue(res);
+
+            return val;
         }
 
-        bool ReadDsnBool(const char* dsn, const std::string& key, bool dflt)
+        SettableValue<int32_t> ReadDsnInt(const char* dsn, const std::string& key,
int32_t dflt = 0)
         {
-            char buf[BUFFER_SIZE];
+            SettableValue<std::string> str = ReadDsnString(dsn, key, "");
+
+            SettableValue<int32_t> res(dflt);
 
-            memset(buf, 0, sizeof(buf));
+            if (str.IsSet())
+                res.SetValue(common::LexicalCast<int, std::string>(str.GetValue()));
 
-            std::string dflt0 = dflt ? "true" : "false";
+            return res;
+        }
 
-            SQLGetPrivateProfileString(dsn, key.c_str(), dflt0.c_str(), buf, sizeof(buf),
CONFIG_FILE);
+        SettableValue<bool> ReadDsnBool(const char* dsn, const std::string& key,
bool dflt = false)
+        {
+            SettableValue<std::string> str = ReadDsnString(dsn, key, "");
 
-            return std::string(buf) == "true";
+            SettableValue<bool> res(dflt);
+
+            if (str.IsSet())
+                res.SetValue(str.GetValue() == "true");
+
+            return res;
         }
 
         void ReadDsnConfiguration(const char* dsn, Configuration& config)
         {
-            std::string address = ReadDsnString(dsn, Configuration::Key::address, config.GetAddress());
+            SettableValue<std::string> address = ReadDsnString(dsn, ConnectionStringParser::Key::address);
+
+            if (address.IsSet() && !config.IsAddressesSet())
+            {
+                std::vector<EndPoint> endPoints;
+
+                ParseAddress(address.GetValue(), endPoints, 0);
+
+                config.SetAddresses(endPoints);
+            }
+
+            SettableValue<std::string> server = ReadDsnString(dsn, ConnectionStringParser::Key::server);
+
+            if (server.IsSet() && !config.IsHostSet())
+                config.SetHost(server.GetValue());
+
+            SettableValue<int32_t> port = ReadDsnInt(dsn, ConnectionStringParser::Key::port);
+
+            if (port.IsSet() && !config.IsTcpPortSet())
+                config.SetTcpPort(static_cast<uint16_t>(port.GetValue()));
+
+            SettableValue<std::string> schema = ReadDsnString(dsn, ConnectionStringParser::Key::schema);
+
+            if (schema.IsSet() && !config.IsSchemaSet())
+                config.SetSchema(schema.GetValue());
+
+            SettableValue<bool> distributedJoins = ReadDsnBool(dsn, ConnectionStringParser::Key::distributedJoins);
+
+            if (distributedJoins.IsSet() && !config.IsDistributedJoinsSet())
+                config.SetDistributedJoins(distributedJoins.GetValue());
+
+            SettableValue<bool> enforceJoinOrder = ReadDsnBool(dsn, ConnectionStringParser::Key::enforceJoinOrder);
+
+            if (enforceJoinOrder.IsSet() && !config.IsEnforceJoinOrderSet())
+                config.SetEnforceJoinOrder(enforceJoinOrder.GetValue());
+
+            SettableValue<bool> replicatedOnly = ReadDsnBool(dsn, ConnectionStringParser::Key::replicatedOnly);
+
+            if (replicatedOnly.IsSet() && !config.IsReplicatedOnlySet())
+                config.SetReplicatedOnly(replicatedOnly.GetValue());
+
+            SettableValue<bool> collocated = ReadDsnBool(dsn, ConnectionStringParser::Key::collocated);
+
+            if (collocated.IsSet() && !config.IsCollocatedSet())
+                config.SetCollocated(collocated.GetValue());
+
+            SettableValue<bool> lazy = ReadDsnBool(dsn, ConnectionStringParser::Key::lazy);
+
+            if (lazy.IsSet() && !config.IsLazySet())
+                config.SetLazy(lazy.GetValue());
 
-            std::string server = ReadDsnString(dsn, Configuration::Key::server, config.GetHost());
+            SettableValue<bool> skipReducerOnUpdate = ReadDsnBool(dsn, ConnectionStringParser::Key::skipReducerOnUpdate);
 
-            uint16_t port = ReadDsnInt(dsn, Configuration::Key::port, config.GetTcpPort());
+            if (skipReducerOnUpdate.IsSet() && !config.IsSkipReducerOnUpdateSet())
+                config.SetSkipReducerOnUpdate(skipReducerOnUpdate.GetValue());
 
-            std::string schema = ReadDsnString(dsn, Configuration::Key::schema, config.GetSchema());
+            SettableValue<std::string> versionStr = ReadDsnString(dsn, ConnectionStringParser::Key::protocolVersion);
 
-            bool distributedJoins = ReadDsnBool(dsn, Configuration::Key::distributedJoins,
config.IsDistributedJoins());
+            if (versionStr.IsSet() && !config.IsProtocolVersionSet())
+            {
+                ProtocolVersion version = ProtocolVersion::FromString(versionStr.GetValue());
 
-            bool enforceJoinOrder = ReadDsnBool(dsn, Configuration::Key::enforceJoinOrder,
config.IsEnforceJoinOrder());
+                if (!version.IsSupported())
+                    version = Configuration::DefaultValue::protocolVersion;
 
-            bool replicatedOnly = ReadDsnBool(dsn, Configuration::Key::replicatedOnly, config.IsReplicatedOnly());
+                config.SetProtocolVersion(version);
+            }
 
-            bool collocated = ReadDsnBool(dsn, Configuration::Key::collocated, config.IsCollocated());
+            SettableValue<int32_t> pageSize = ReadDsnInt(dsn, ConnectionStringParser::Key::pageSize);
 
-            bool lazy = ReadDsnBool(dsn, Configuration::Key::lazy, config.IsLazy());
+            if (pageSize.IsSet() && !config.IsPageSizeSet() && pageSize.GetValue()
> 0)
+                config.SetPageSize(pageSize.GetValue());
 
-            bool skipReducerOnUpdate =
-                ReadDsnBool(dsn, Configuration::Key::skipReducerOnUpdate, config.IsSkipReducerOnUpdate());
+            SettableValue<std::string> sslModeStr = ReadDsnString(dsn, ConnectionStringParser::Key::sslMode);
 
-            std::string version = ReadDsnString(dsn, Configuration::Key::protocolVersion,
-                config.GetProtocolVersion().ToString());
+            if (sslModeStr.IsSet() && !config.IsSslModeSet())
+            {
+                ssl::SslMode::Type sslMode = ssl::SslMode::FromString(sslModeStr.GetValue(),
ssl::SslMode::DISABLE);
 
-            int32_t pageSize = ReadDsnInt(dsn, Configuration::Key::pageSize, config.GetPageSize());
+                config.SetSslMode(sslMode);
+            }
 
-            if (pageSize <= 0)
-                pageSize = config.GetPageSize();
+            SettableValue<std::string> sslKeyFile = ReadDsnString(dsn, ConnectionStringParser::Key::sslKeyFile);
 
-            std::string sslMode = ReadDsnString(dsn, Configuration::Key::sslMode, config.GetSslMode());
+            if (sslKeyFile.IsSet() && !config.IsSslKeyFileSet())
+                config.SetSslKeyFile(sslKeyFile.GetValue());
 
-            std::string sslKeyFile = ReadDsnString(dsn, Configuration::Key::sslKeyFile, config.GetSslKeyFile());
+            SettableValue<std::string> sslCertFile = ReadDsnString(dsn, ConnectionStringParser::Key::sslCertFile);
 
-            std::string sslCertFile = ReadDsnString(dsn, Configuration::Key::sslCertFile,
config.GetSslCertFile());
+            if (sslCertFile.IsSet() && !config.IsSslCertFileSet())
+                config.SetSslCertFile(sslCertFile.GetValue());
 
-            std::string sslCaFile = ReadDsnString(dsn, Configuration::Key::sslCaFile, config.GetSslCaFile());
+            SettableValue<std::string> sslCaFile = ReadDsnString(dsn, ConnectionStringParser::Key::sslCaFile);
 
-            config.SetAddress(address);
-            config.SetHost(server);
-            config.SetTcpPort(port);
-            config.SetSchema(schema);
-            config.SetDistributedJoins(distributedJoins);
-            config.SetEnforceJoinOrder(enforceJoinOrder);
-            config.SetReplicatedOnly(replicatedOnly);
-            config.SetCollocated(collocated);
-            config.SetLazy(lazy);
-            config.SetSkipReducerOnUpdate(skipReducerOnUpdate);
-            config.SetProtocolVersion(version);
-            config.SetPageSize(pageSize);
-            config.SetSslMode(sslMode);
-            config.SetSslKeyFile(sslKeyFile);
-            config.SetSslCertFile(sslCertFile);
-            config.SetSslCaFile(sslCaFile);
+            if (sslCaFile.IsSet() && !config.IsSslCaFileSet())
+                config.SetSslCaFile(sslCaFile.GetValue());
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ddc6d70/modules/platforms/cpp/odbc/src/environment.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/environment.cpp b/modules/platforms/cpp/odbc/src/environment.cpp
index 6182fa2..417fedc 100644
--- a/modules/platforms/cpp/odbc/src/environment.cpp
+++ b/modules/platforms/cpp/odbc/src/environment.cpp
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+#include <cstdlib>
+
 #include "ignite/odbc/system/odbc_constants.h"
 #include "ignite/odbc/connection.h"
 #include "ignite/odbc/environment.h"
@@ -24,9 +26,10 @@ namespace ignite
     namespace odbc
     {
         Environment::Environment() : 
-            odbcVersion(SQL_OV_ODBC3), odbcNts(SQL_TRUE)
+            odbcVersion(SQL_OV_ODBC3),
+            odbcNts(SQL_TRUE)
         {
-            // No-op.
+            srand(common::GetRandSeed());
         }
 
         Environment::~Environment()

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ddc6d70/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 dfa2dec..3aad52f 100644
--- a/modules/platforms/cpp/odbc/src/odbc.cpp
+++ b/modules/platforms/cpp/odbc/src/odbc.cpp
@@ -24,6 +24,7 @@
 #include "ignite/odbc/utility.h"
 #include "ignite/odbc/system/odbc_constants.h"
 
+#include "ignite/odbc/config/connection_string_parser.h"
 #include "ignite/odbc/config/configuration.h"
 #include "ignite/odbc/type_traits.h"
 #include "ignite/odbc/environment.h"
@@ -270,16 +271,7 @@ namespace ignite
 
         std::string connectStr = SqlStringToString(inConnectionString, inConnectionStringLen);
 
-        odbc::config::Configuration config;
-
-        config.FillFromConnectString(connectStr);
-
-        std::string dsn = config.GetDsn();
-
-        if (!dsn.empty())
-            odbc::ReadDsnConfiguration(dsn.c_str(), config);
-
-        connection->Establish(config);
+        connection->Establish(connectStr);
 
         const DiagnosticRecordStorage& diag = connection->GetDiagnosticRecords();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/6ddc6d70/modules/platforms/cpp/odbc/src/ssl/ssl_mode.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc/src/ssl/ssl_mode.cpp b/modules/platforms/cpp/odbc/src/ssl/ssl_mode.cpp
index 0bdbc60..3a8e923 100644
--- a/modules/platforms/cpp/odbc/src/ssl/ssl_mode.cpp
+++ b/modules/platforms/cpp/odbc/src/ssl/ssl_mode.cpp
@@ -24,7 +24,7 @@ namespace ignite
     {
         namespace ssl
         {
-            SslMode::T SslMode::FromString(const std::string& val, T dflt)
+            SslMode::Type SslMode::FromString(const std::string& val, Type dflt)
             {
                 std::string lowerVal = common::ToLower(val);
 
@@ -38,6 +38,22 @@ namespace ignite
 
                 return dflt;
             }
+
+            std::string SslMode::ToString(Type val)
+            {
+                switch (val)
+                {
+                    case SslMode::DISABLE:
+                        return "disable";
+
+                    case SslMode::REQUIRE:
+                        return "require";
+
+                    case SslMode::UNKNOWN:
+                    default:
+                        return "unknown";
+                }
+            }
         }
     }
 }


Mime
View raw message