IGNITE-9002: Fixed C++ thin client crash with dynamic cache without
config

This closes #4361


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5e9d3c25
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5e9d3c25
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5e9d3c25

Branch: refs/heads/ignite-8783
Commit: 5e9d3c25f7c50a59e3a9a0f7e540e344ec00bb4a
Parents: e721619
Author: Igor Sapego <isap...@gridgain.com>
Authored: Tue Jul 17 14:45:01 2018 +0300
Committer: Igor Sapego <isap...@gridgain.com>
Committed: Tue Jul 17 14:49:20 2018 +0300

----------------------------------------------------------------------
 .../client/ClientConnectionContext.java         |  5 +++-
 modules/platforms/cpp/README.txt                |  2 +-
 .../thin-client-test/src/cache_client_test.cpp  | 24 ++++++++++++++++++++
 .../ignite/impl/thin/cache/cache_client_proxy.h |  8 +++++++
 .../include/ignite/thin/cache/cache_client.h    | 16 +++++++++++--
 .../include/ignite/thin/ignite_client.h         |  8 +++++++
 .../src/impl/cache/cache_client_impl.cpp        |  2 +-
 .../cpp/thin-client/src/impl/data_channel.cpp   |  8 +++----
 .../cpp/thin-client/src/impl/data_channel.h     |  4 ++--
 9 files changed, 66 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5e9d3c25/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientConnectionContext.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientConnectionContext.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientConnectionContext.java
index 6be72df..c957901 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientConnectionContext.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientConnectionContext.java
@@ -41,8 +41,11 @@ public class ClientConnectionContext extends 
ClientListenerAbstractConnectionCon
     /** Version 1.1.0. */
     public static final ClientListenerProtocolVersion VER_1_1_0 = 
ClientListenerProtocolVersion.create(1, 1, 0);
 
+    /** Version 1.2.0. */
+    public static final ClientListenerProtocolVersion VER_1_2_0 = 
ClientListenerProtocolVersion.create(1, 2, 0);
+
     /** Supported versions. */
-    private static final Collection<ClientListenerProtocolVersion> 
SUPPORTED_VERS = Arrays.asList(VER_1_1_0, VER_1_0_0);
+    private static final Collection<ClientListenerProtocolVersion> 
SUPPORTED_VERS = Arrays.asList(VER_1_2_0, VER_1_1_0, VER_1_0_0);
 
     /** Message parser. */
     private final ClientMessageParser parser;

http://git-wip-us.apache.org/repos/asf/ignite/blob/5e9d3c25/modules/platforms/cpp/README.txt
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/README.txt b/modules/platforms/cpp/README.txt
index dc740eb..c758343 100644
--- a/modules/platforms/cpp/README.txt
+++ b/modules/platforms/cpp/README.txt
@@ -55,7 +55,7 @@ Files list:
  * ignite.exe - executable to start standalone Ignite C++ node.
  * ignite.core.dll - Ignite C++ API library.
  * ignite.odbc.dll - Ignite ODBC driver.
- * ignite.thin-client.dll - Ignite ODBC driver.
+ * ignite.thin-client.dll - Ignite thin C++ client.
  
 Development:
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5e9d3c25/modules/platforms/cpp/thin-client-test/src/cache_client_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/thin-client-test/src/cache_client_test.cpp 
b/modules/platforms/cpp/thin-client-test/src/cache_client_test.cpp
index 5594134..b7329fb 100644
--- a/modules/platforms/cpp/thin-client-test/src/cache_client_test.cpp
+++ b/modules/platforms/cpp/thin-client-test/src/cache_client_test.cpp
@@ -740,4 +740,28 @@ BOOST_AUTO_TEST_CASE(CacheClientClear)
     }
 }
 
+BOOST_AUTO_TEST_CASE(CacheClientDefaultDynamicCache)
+{
+    IgniteClientConfiguration cfg;
+    cfg.SetEndPoints("127.0.0.1:11110..11120");
+
+    IgniteClient client = IgniteClient::Start(cfg);
+
+    cache::CacheClient<std::string, int64_t> cache =
+        client.CreateCache<std::string, int64_t>("defaultdynamic");
+
+    cache.RefreshAffinityMapping();
+
+    for (int64_t i = 1; i < 1000; ++i)
+        cache.Put(ignite::common::LexicalCast<std::string>(i * 39916801), i * 
5039);
+
+    for (int64_t i = 1; i < 1000; ++i)
+    {
+        int64_t val;
+        LocalPeek(cache, ignite::common::LexicalCast<std::string>(i * 
39916801), val);
+
+        BOOST_CHECK_EQUAL(val, i * 5039);
+    }
+}
+
 BOOST_AUTO_TEST_SUITE_END()

http://git-wip-us.apache.org/repos/asf/ignite/blob/5e9d3c25/modules/platforms/cpp/thin-client/include/ignite/impl/thin/cache/cache_client_proxy.h
----------------------------------------------------------------------
diff --git 
a/modules/platforms/cpp/thin-client/include/ignite/impl/thin/cache/cache_client_proxy.h
 
b/modules/platforms/cpp/thin-client/include/ignite/impl/thin/cache/cache_client_proxy.h
index 00c04f6..349a1dc 100644
--- 
a/modules/platforms/cpp/thin-client/include/ignite/impl/thin/cache/cache_client_proxy.h
+++ 
b/modules/platforms/cpp/thin-client/include/ignite/impl/thin/cache/cache_client_proxy.h
@@ -44,6 +44,14 @@ namespace ignite
                 {
                 public:
                     /**
+                     * Default constructor.
+                     */
+                    CacheClientProxy()
+                    {
+                        // No-op.
+                    }
+
+                    /**
                      * Constructor.
                      */
                     CacheClientProxy(const 
common::concurrent::SharedPointer<void>& impl) :

http://git-wip-us.apache.org/repos/asf/ignite/blob/5e9d3c25/modules/platforms/cpp/thin-client/include/ignite/thin/cache/cache_client.h
----------------------------------------------------------------------
diff --git 
a/modules/platforms/cpp/thin-client/include/ignite/thin/cache/cache_client.h 
b/modules/platforms/cpp/thin-client/include/ignite/thin/cache/cache_client.h
index 1719c07..39e1269 100644
--- a/modules/platforms/cpp/thin-client/include/ignite/thin/cache/cache_client.h
+++ b/modules/platforms/cpp/thin-client/include/ignite/thin/cache/cache_client.h
@@ -76,6 +76,14 @@ namespace ignite
                 }
 
                 /**
+                 * Default constructor.
+                 */
+                CacheClient()
+                {
+                    // No-op.
+                }
+
+                /**
                  * Destructor.
                  */
                 ~CacheClient()
@@ -107,7 +115,7 @@ namespace ignite
                 {
                     impl::thin::WritableKeyImpl<KeyType> wrKey(key);
                     impl::thin::ReadableImpl<ValueType> rdValue(value);
-                    
+
                     proxy.Get(wrKey, rdValue);
                 }
 
@@ -207,7 +215,11 @@ namespace ignite
                 /**
                  * Refresh affinity mapping.
                  *
-                 * TODO
+                 * Retrieves affinity mapping information from remote server. 
This information uses to send data
+                 * requests to the most appropriate nodes. This can lessen 
latency and improve overall performance.
+                 *
+                 * It is recommended to refresh affinity mapping after every 
topology change, i.e. when a node enters or
+                 * leaves cluster.
                  */
                 void RefreshAffinityMapping()
                 {

http://git-wip-us.apache.org/repos/asf/ignite/blob/5e9d3c25/modules/platforms/cpp/thin-client/include/ignite/thin/ignite_client.h
----------------------------------------------------------------------
diff --git 
a/modules/platforms/cpp/thin-client/include/ignite/thin/ignite_client.h 
b/modules/platforms/cpp/thin-client/include/ignite/thin/ignite_client.h
index aa8c14a..245accb 100644
--- a/modules/platforms/cpp/thin-client/include/ignite/thin/ignite_client.h
+++ b/modules/platforms/cpp/thin-client/include/ignite/thin/ignite_client.h
@@ -49,6 +49,14 @@ namespace ignite
             typedef common::concurrent::SharedPointer<void> SP_Void;
         public:
             /**
+             * Default constructor.
+             */
+            IgniteClient()
+            {
+                // No-op.
+            }
+
+            /**
              * Destructor.
              */
             ~IgniteClient();

http://git-wip-us.apache.org/repos/asf/ignite/blob/5e9d3c25/modules/platforms/cpp/thin-client/src/impl/cache/cache_client_impl.cpp
----------------------------------------------------------------------
diff --git 
a/modules/platforms/cpp/thin-client/src/impl/cache/cache_client_impl.cpp 
b/modules/platforms/cpp/thin-client/src/impl/cache/cache_client_impl.cpp
index 607d330..fe37a9c 100644
--- a/modules/platforms/cpp/thin-client/src/impl/cache/cache_client_impl.cpp
+++ b/modules/platforms/cpp/thin-client/src/impl/cache/cache_client_impl.cpp
@@ -51,7 +51,7 @@ namespace ignite
                 {
                     SP_CacheAffinityInfo affinityInfo = 
router.Get()->GetAffinityMapping(id);
 
-                    if (!affinityInfo.IsValid())
+                    if (!affinityInfo.IsValid() || 
affinityInfo.Get()->GetPartitionsNum() == 0)
                     {
                         router.Get()->SyncMessage(req, rsp);
                     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/5e9d3c25/modules/platforms/cpp/thin-client/src/impl/data_channel.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/thin-client/src/impl/data_channel.cpp 
b/modules/platforms/cpp/thin-client/src/impl/data_channel.cpp
index e1fffc5..6b40d81 100644
--- a/modules/platforms/cpp/thin-client/src/impl/data_channel.cpp
+++ b/modules/platforms/cpp/thin-client/src/impl/data_channel.cpp
@@ -36,14 +36,14 @@ namespace ignite
     {
         namespace thin
         {
-            /** Version 1.1.0. */
-            const ProtocolVersion DataChannel::VERSION_1_1_0(1, 1, 0);
+            /** Version 1.2.0. */
+            const ProtocolVersion DataChannel::VERSION_1_2_0(1, 2, 0);
 
             /** Current version. */
-            const ProtocolVersion DataChannel::VERSION_CURRENT(VERSION_1_1_0);
+            const ProtocolVersion DataChannel::VERSION_CURRENT(VERSION_1_2_0);
 
             DataChannel::VersionSet::value_type supportedArray[] = {
-                DataChannel::VERSION_1_1_0,
+                DataChannel::VERSION_1_2_0,
             };
 
             const DataChannel::VersionSet 
DataChannel::supportedVersions(supportedArray,

http://git-wip-us.apache.org/repos/asf/ignite/blob/5e9d3c25/modules/platforms/cpp/thin-client/src/impl/data_channel.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/thin-client/src/impl/data_channel.h 
b/modules/platforms/cpp/thin-client/src/impl/data_channel.h
index 20e7628..951f9f0 100644
--- a/modules/platforms/cpp/thin-client/src/impl/data_channel.h
+++ b/modules/platforms/cpp/thin-client/src/impl/data_channel.h
@@ -57,8 +57,8 @@ namespace ignite
                 /** Version set type. */
                 typedef std::set<ProtocolVersion> VersionSet;
 
-                /** Version 1.1.0. */
-                static const ProtocolVersion VERSION_1_1_0;
+                /** Version 1.2.0. */
+                static const ProtocolVersion VERSION_1_2_0;
 
                 /** Current version. */
                 static const ProtocolVersion VERSION_CURRENT;

Reply via email to