ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptupit...@apache.org
Subject [2/2] ignite git commit: IGNITE-7109 .NET: Thin client: Async cache operations
Date Fri, 22 Dec 2017 12:48:03 GMT
IGNITE-7109 .NET: Thin client: Async cache operations

This closes #3187


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

Branch: refs/heads/master
Commit: 1c09a923d90987da111f8ac9722e5870bb9f7627
Parents: d7987e6
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Fri Dec 22 15:47:49 2017 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Fri Dec 22 15:47:49 2017 +0300

----------------------------------------------------------------------
 .../client/cache/ClientCachePutRequest.java     |   1 +
 .../Apache.Ignite.Benchmarks.csproj             |   2 +
 .../Apache.Ignite.Benchmarks/BenchmarkRunner.cs |   5 +-
 .../ThinClient/ThinClientGetAsyncBenchmark.cs   |  63 ++
 .../ThinClient/ThinClientPutAsyncBenchmark.cs   |  59 ++
 .../Apache.Ignite.Core.Tests.DotNetCore.csproj  |   3 +
 .../Apache.Ignite.Core.Tests.csproj             |   3 +
 .../Cache/CacheTestAsyncWrapper.cs              |  83 +--
 .../Client/Cache/CacheClientAsyncWrapper.cs     | 353 ++++++++++
 .../Client/Cache/CacheTest.cs                   | 687 ++++++++++---------
 .../Client/Cache/CacheTestAsync.cs              |  35 +
 .../Client/ClientConnectionTest.cs              | 119 +++-
 .../Client/ClientTestBase.cs                    |  17 +-
 .../Client/IgniteClientConfigurationTest.cs     |   2 +
 .../Config/Client/IgniteClientConfiguration.xml | Bin 2436 -> 2482 bytes
 .../Apache.Ignite.Core.Tests/TaskExtensions.cs  |  59 ++
 .../Client/Cache/ICacheClient.cs                | 173 ++++-
 .../Apache.Ignite.Core/Client/IIgniteClient.cs  |   2 +
 .../Client/IgniteClientConfiguration.cs         |  14 +
 .../IgniteClientConfigurationSection.xsd        |   5 +
 .../Impl/Binary/Io/BinaryHeapStream.cs          |   2 +-
 .../Impl/Client/Cache/CacheClient.cs            | 324 +++++++--
 .../Impl/Client/ClientSocket.cs                 | 501 ++++++++++++--
 23 files changed, 1996 insertions(+), 516 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java
index 94c2b25..2c396b7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java
@@ -42,3 +42,4 @@ public class ClientCachePutRequest extends ClientCacheKeyValueRequest {
         return super.process(ctx);
     }
 }
+

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj
index b5c2074..e712337 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj
@@ -69,7 +69,9 @@
     <Compile Include="Result\BenchmarkConsoleResultWriter.cs" />
     <Compile Include="Result\BenchmarkFileResultWriter.cs" />
     <Compile Include="Result\IBenchmarkResultWriter.cs" />
+    <Compile Include="ThinClient\ThinClientGetAsyncBenchmark.cs" />
     <Compile Include="ThinClient\ThinClientGetBenchmark.cs" />
+    <Compile Include="ThinClient\ThinClientPutAsyncBenchmark.cs" />
     <Compile Include="ThinClient\ThinClientPutBenchmark.cs" />
   </ItemGroup>
   <ItemGroup>

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
index 2571c14..9d86da2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/BenchmarkRunner.cs
@@ -21,6 +21,7 @@ namespace Apache.Ignite.Benchmarks
     using System.Diagnostics;
     using System.Text;
     using Apache.Ignite.Benchmarks.Interop;
+    using Apache.Ignite.Benchmarks.ThinClient;
 
     /// <summary>
     /// Benchmark runner.
@@ -35,8 +36,8 @@ namespace Apache.Ignite.Benchmarks
         public static void Main(string[] args)
         {
             args = new[] { 
-                typeof(GetBenchmark).FullName,
-                "-ConfigPath", @"C:\W\incubator-ignite\modules\platforms\dotnet\Apache.Ignite.Benchmarks\Config\benchmark.xml",
+                typeof(ThinClientGetBenchmark).FullName,
+                "-ConfigPath", @"S:\W\incubator-ignite\modules\platforms\dotnet\Apache.Ignite.Benchmarks\Config\benchmark.xml",
                 "-Threads", "1",
                 "-Warmup", "0",
                 "-Duration", "60",

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Benchmarks/ThinClient/ThinClientGetAsyncBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/ThinClient/ThinClientGetAsyncBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/ThinClient/ThinClientGetAsyncBenchmark.cs
new file mode 100644
index 0000000..a9fca1f
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/ThinClient/ThinClientGetAsyncBenchmark.cs
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Benchmarks.ThinClient
+{
+    using System.Collections.Generic;
+    using Apache.Ignite.Benchmarks.Interop;
+    using Apache.Ignite.Benchmarks.Model;
+    using Apache.Ignite.Core.Client.Cache;
+
+    /// <summary>
+    /// Cache get async benchmark.
+    /// </summary>
+    internal class ThinClientGetAsyncBenchmark : PlatformBenchmarkBase
+    {
+        /** Cache name. */
+        private const string CacheName = "cache";
+
+        /** Native cache wrapper. */
+        private ICacheClient<int, Employee> _cache;
+
+        /** <inheritDoc /> */
+        protected override void OnStarted()
+        {
+            base.OnStarted();
+
+            _cache = GetClient().GetCache<int, Employee>(CacheName);
+
+            for (int i = 0; i < Emps.Length; i++)
+                _cache.Put(i, Emps[i]);
+        }
+
+        /** <inheritDoc /> */
+        protected override void GetDescriptors(ICollection<BenchmarkOperationDescriptor> descs)
+        {
+            descs.Add(BenchmarkOperationDescriptor.Create("ThinClientGetAsync", GetAsync, 1));
+        }
+
+        /// <summary>
+        /// Cache get.
+        /// </summary>
+        private void GetAsync(BenchmarkState state)
+        {
+            var idx = BenchmarkUtils.GetRandomInt(Dataset);
+
+            _cache.GetAsync(idx).Wait();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Benchmarks/ThinClient/ThinClientPutAsyncBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/ThinClient/ThinClientPutAsyncBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/ThinClient/ThinClientPutAsyncBenchmark.cs
new file mode 100644
index 0000000..92a2150
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/ThinClient/ThinClientPutAsyncBenchmark.cs
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Benchmarks.ThinClient
+{
+    using System.Collections.Generic;
+    using Apache.Ignite.Benchmarks.Interop;
+    using Apache.Ignite.Core.Client.Cache;
+
+    /// <summary>
+    /// Cache put async benchmark.
+    /// </summary>
+    internal class ThinClientPutAsyncBenchmark : PlatformBenchmarkBase
+    {
+        /** Cache name. */
+        private const string CacheName = "cache";
+
+        /** Native cache wrapper. */
+        private ICacheClient<object, object> _cache;
+
+        /** <inheritDoc /> */
+        protected override void OnStarted()
+        {
+            base.OnStarted();
+
+            _cache = GetClient().GetCache<object, object>(CacheName);
+        }
+
+        /** <inheritDoc /> */
+        protected override void GetDescriptors(ICollection<BenchmarkOperationDescriptor> descs)
+        {
+            descs.Add(BenchmarkOperationDescriptor.Create("ThinClientPutAsync", PutAsync, 1));
+        }
+        
+        /// <summary>
+        /// Cache put.
+        /// </summary>
+        private void PutAsync(BenchmarkState state)
+        {
+            int idx = BenchmarkUtils.GetRandomInt(Dataset);
+
+            _cache.PutAsync(idx, Emps[idx]).Wait();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Apache.Ignite.Core.Tests.DotNetCore.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Apache.Ignite.Core.Tests.DotNetCore.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Apache.Ignite.Core.Tests.DotNetCore.csproj
index 5947685..f1ccb06 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Apache.Ignite.Core.Tests.DotNetCore.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.DotNetCore/Apache.Ignite.Core.Tests.DotNetCore.csproj
@@ -83,6 +83,8 @@
     <Compile Include="..\Apache.Ignite.Core.Tests\Cache\TestReferenceObject.cs" Link="Cache\TestReferenceObject.cs" />
     <Compile Include="..\Apache.Ignite.Core.Tests\Client\Cache\BinaryBuilderTest.cs" Link="ThinClient\Cache\BinaryBuilderTest.cs" />
     <Compile Include="..\Apache.Ignite.Core.Tests\Client\Cache\CacheTest.cs" Link="ThinClient\Cache\CacheTest.cs" />
+    <Compile Include="..\Apache.Ignite.Core.Tests\Client\Cache\CacheTestAsync.cs" Link="ThinClient\Cache\CacheTestAsync.cs" />
+    <Compile Include="..\Apache.Ignite.Core.Tests\Client\Cache\CacheClientAsyncWrapper.cs" Link="ThinClient\Cache\CacheClientAsyncWrapper.cs" />
     <Compile Include="..\Apache.Ignite.Core.Tests\Client\Cache\CacheTestKeepBinary.cs" Link="ThinClient\Cache\CacheTestKeepBinary.cs" />
     <Compile Include="..\Apache.Ignite.Core.Tests\Client\Cache\EmptyObject.cs" Link="ThinClient\Cache\EmptyObject.cs" />
     <Compile Include="..\Apache.Ignite.Core.Tests\Client\Cache\Person.cs" Link="ThinClient\Cache\Person.cs" />
@@ -108,6 +110,7 @@
     <Compile Include="..\Apache.Ignite.Core.Tests\Plugin\TestIgnitePluginException.cs" Link="Plugin\TestIgnitePluginException.cs" />
     <Compile Include="..\Apache.Ignite.Core.Tests\Plugin\TestIgnitePluginProvider.cs" Link="Plugin\TestIgnitePluginProvider.cs" />
     <Compile Include="..\Apache.Ignite.Core.Tests\Query\BinarizablePerson.cs" Link="Cache\Query\BinarizablePerson.cs" />
+    <Compile Include="..\Apache.Ignite.Core.Tests\TaskExtensions.cs" Link="Common\TaskExtensions.cs" />
     <Compile Include="..\Apache.Ignite.Core.Tests\TestUtils.Common.cs" Link="Common\TestUtils.Common.cs" />
   </ItemGroup>
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 059a6e0..d3b9fa2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -123,7 +123,9 @@
     <Compile Include="Cache\Store\CacheStoreSessionTestCodeConfig.cs" />
     <Compile Include="Cache\Store\CacheStoreSessionTestSharedFactory.cs" />
     <Compile Include="Client\Cache\BinaryBuilderTest.cs" />
+    <Compile Include="Client\Cache\CacheClientAsyncWrapper.cs" />
     <Compile Include="Client\Cache\CacheTest.cs" />
+    <Compile Include="Client\Cache\CacheTestAsync.cs" />
     <Compile Include="Client\Cache\CacheTestKeepBinary.cs" />
     <Compile Include="Client\Cache\CacheTestNoMeta.cs" />
     <Compile Include="Client\Cache\ClientCacheConfigurationTest.cs" />
@@ -199,6 +201,7 @@
     <Compile Include="Plugin\TestIgnitePluginConfiguration.cs" />
     <Compile Include="Plugin\TestIgnitePluginException.cs" />
     <Compile Include="Plugin\TestIgnitePluginProvider.cs" />
+    <Compile Include="TaskExtensions.cs" />
     <Compile Include="TestAppConfig.cs" />
     <Compile Include="Binary\BinaryBuilderSelfTestFullFooter.cs" />
     <Compile Include="Binary\BinaryCompactFooterInteropTest.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
index 0b1af41..c4e50d1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
@@ -98,7 +98,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public void LoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
         {
-            WaitResult(_cache.LoadCacheAsync(p, args));
+            _cache.LoadCacheAsync(p, args).WaitResult();
         }
 
         /** <inheritDoc /> */
@@ -110,7 +110,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public void LocalLoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
         {
-            WaitResult(_cache.LocalLoadCacheAsync(p, args));
+            _cache.LocalLoadCacheAsync(p, args).WaitResult();
         }
 
         /** <inheritDoc /> */
@@ -134,7 +134,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public bool ContainsKey(TK key)
         {
-            return GetResult(_cache.ContainsKeyAsync(key));
+            return _cache.ContainsKeyAsync(key).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -146,7 +146,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public bool ContainsKeys(IEnumerable<TK> keys)
         {
-            return GetResult(_cache.ContainsKeysAsync(keys));
+            return _cache.ContainsKeysAsync(keys).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -177,7 +177,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public TV Get(TK key)
         {
-            return GetResult(_cache.GetAsync(key));
+            return _cache.GetAsync(key).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -201,7 +201,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public ICollection<ICacheEntry<TK, TV>> GetAll(IEnumerable<TK> keys)
         {
-            return GetResult(_cache.GetAllAsync(keys));
+            return _cache.GetAllAsync(keys).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -213,7 +213,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public void Put(TK key, TV val)
         {
-            WaitResult(_cache.PutAsync(key, val));
+            _cache.PutAsync(key, val).WaitResult();
         }
 
         /** <inheritDoc /> */
@@ -225,7 +225,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public CacheResult<TV> GetAndPut(TK key, TV val)
         {
-            return GetResult(_cache.GetAndPutAsync(key, val));
+            return _cache.GetAndPutAsync(key, val).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -237,7 +237,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public CacheResult<TV> GetAndReplace(TK key, TV val)
         {
-            return GetResult(_cache.GetAndReplaceAsync(key, val));
+            return _cache.GetAndReplaceAsync(key, val).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -249,7 +249,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public CacheResult<TV> GetAndRemove(TK key)
         {
-            return GetResult(_cache.GetAndRemoveAsync(key));
+            return _cache.GetAndRemoveAsync(key).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -261,7 +261,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public bool PutIfAbsent(TK key, TV val)
         {
-            return GetResult(_cache.PutIfAbsentAsync(key, val));
+            return _cache.PutIfAbsentAsync(key, val).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -273,7 +273,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public CacheResult<TV> GetAndPutIfAbsent(TK key, TV val)
         {
-            return GetResult(_cache.GetAndPutIfAbsentAsync(key, val));
+            return _cache.GetAndPutIfAbsentAsync(key, val).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -285,7 +285,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public bool Replace(TK key, TV val)
         {
-            return GetResult(_cache.ReplaceAsync(key, val));
+            return _cache.ReplaceAsync(key, val).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -297,7 +297,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public bool Replace(TK key, TV oldVal, TV newVal)
         {
-            return GetResult(_cache.ReplaceAsync(key, oldVal, newVal));
+            return _cache.ReplaceAsync(key, oldVal, newVal).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -309,7 +309,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public void PutAll(IEnumerable<KeyValuePair<TK, TV>> vals)
         {
-            WaitResult(_cache.PutAllAsync(vals));
+            _cache.PutAllAsync(vals).WaitResult();
         }
 
         /** <inheritDoc /> */
@@ -327,7 +327,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public void Clear()
         {
-            WaitResult(_cache.ClearAsync());
+            _cache.ClearAsync().WaitResult();
         }
 
         /** <inheritDoc /> */
@@ -339,7 +339,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public void Clear(TK key)
         {
-            WaitResult(_cache.ClearAsync(key));
+            _cache.ClearAsync(key).WaitResult();
         }
 
         /** <inheritDoc /> */
@@ -351,7 +351,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public void ClearAll(IEnumerable<TK> keys)
         {
-            WaitResult(_cache.ClearAllAsync(keys));
+            _cache.ClearAllAsync(keys).WaitResult();
         }
 
         /** <inheritDoc /> */
@@ -375,7 +375,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public bool Remove(TK key)
         {
-            return GetResult(_cache.RemoveAsync(key));
+            return _cache.RemoveAsync(key).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -387,7 +387,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public bool Remove(TK key, TV val)
         {
-            return GetResult(_cache.RemoveAsync(key, val));
+            return _cache.RemoveAsync(key, val).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -399,7 +399,8 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public void RemoveAll(IEnumerable<TK> keys)
         {
-            WaitResult(_cache.RemoveAllAsync(keys));
+            Task task = _cache.RemoveAllAsync(keys);
+            task.WaitResult();
         }
 
         /** <inheritDoc /> */
@@ -411,7 +412,8 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public void RemoveAll()
         {
-            WaitResult(_cache.RemoveAllAsync());
+            Task task = _cache.RemoveAllAsync();
+            task.WaitResult();
         }
 
         /** <inheritDoc /> */
@@ -429,7 +431,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public int GetSize(params CachePeekMode[] modes)
         {
-            return GetResult(_cache.GetSizeAsync(modes));
+            return _cache.GetSizeAsync(modes).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -478,7 +480,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         /** <inheritDoc /> */
         public TRes Invoke<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
         {
-            return GetResult(_cache.InvokeAsync(key, processor, arg));
+            return _cache.InvokeAsync(key, processor, arg).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -491,7 +493,7 @@ namespace Apache.Ignite.Core.Tests.Cache
         public ICollection<ICacheEntryProcessorResult<TK, TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys, 
             ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
         {
-            return GetResult(_cache.InvokeAllAsync(keys, processor, arg));
+            return _cache.InvokeAllAsync(keys, processor, arg).GetResult();
         }
 
         /** <inheritDoc /> */
@@ -571,37 +573,6 @@ namespace Apache.Ignite.Core.Tests.Cache
         {
             return GetEnumerator();
         }
-
-        /// <summary>
-        /// Waits the result of a task, unwraps exceptions.
-        /// </summary>
-        /// <param name="task">The task.</param>
-        private static void WaitResult(Task task)
-        {
-            try
-            {
-                task.Wait();
-            }
-            catch (AggregateException ex)
-            {
-                throw ex.InnerException ?? ex;
-            }
-        }
-
-        /// <summary>
-        /// Gets the result of a task, unwraps exceptions.
-        /// </summary>
-        private static T GetResult<T>(Task<T> task)
-        {
-            try
-            {
-                return task.Result;
-            }
-            catch (Exception ex)
-            {
-                throw ex.InnerException ?? ex;
-            }
-        }
     }
 
     /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheClientAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheClientAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheClientAsyncWrapper.cs
new file mode 100644
index 0000000..1075ddf
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheClientAsyncWrapper.cs
@@ -0,0 +1,353 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Client.Cache
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Threading.Tasks;
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Query;
+    using Apache.Ignite.Core.Client.Cache;
+
+    /// <summary>
+    /// Cache client async wrapper.
+    /// </summary>
+    public class CacheClientAsyncWrapper<TK, TV> : ICacheClient<TK, TV>
+    {
+        /** */
+        private readonly ICacheClient<TK, TV> _cache;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="CacheClientAsyncWrapper{TK, TV}"/> class.
+        /// </summary>
+        /// <param name="cache">The cache.</param>
+        public CacheClientAsyncWrapper(ICacheClient<TK, TV> cache)
+        {
+            _cache = cache;
+        }
+
+        /** <inheritDoc /> */
+        public string Name
+        {
+            get { return _cache.Name; }
+        }
+
+        /** <inheritDoc /> */
+        public void Put(TK key, TV val)
+        {
+            _cache.PutAsync(key, val).WaitResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task PutAsync(TK key, TV val)
+        {
+            return _cache.PutAsync(key, val);
+        }
+
+        /** <inheritDoc /> */
+        public TV Get(TK key)
+        {
+            return _cache.GetAsync(key).GetResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task<TV> GetAsync(TK key)
+        {
+            return _cache.GetAsync(key);
+        }
+
+        /** <inheritDoc /> */
+        public bool TryGet(TK key, out TV value)
+        {
+            var res = _cache.TryGetAsync(key).GetResult();
+            value = res.Value;
+            return res.Success;
+        }
+
+        /** <inheritDoc /> */
+        public Task<CacheResult<TV>> TryGetAsync(TK key)
+        {
+            return _cache.TryGetAsync(key);
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<ICacheEntry<TK, TV>> GetAll(IEnumerable<TK> keys)
+        {
+            return _cache.GetAllAsync(keys).GetResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task<ICollection<ICacheEntry<TK, TV>>> GetAllAsync(IEnumerable<TK> keys)
+        {
+            return _cache.GetAllAsync(keys);
+        }
+
+        /** <inheritDoc /> */
+        public TV this[TK key]
+        {
+            get { return _cache[key]; }
+            set { _cache[key] = value; }
+        }
+
+        /** <inheritDoc /> */
+        public bool ContainsKey(TK key)
+        {
+            return _cache.ContainsKeyAsync(key).GetResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task<bool> ContainsKeyAsync(TK key)
+        {
+            return _cache.ContainsKeyAsync(key);
+        }
+
+        /** <inheritDoc /> */
+        public bool ContainsKeys(IEnumerable<TK> keys)
+        {
+            return _cache.ContainsKeysAsync(keys).GetResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task<bool> ContainsKeysAsync(IEnumerable<TK> keys)
+        {
+            return _cache.ContainsKeysAsync(keys);
+        }
+
+        /** <inheritDoc /> */
+        public IQueryCursor<ICacheEntry<TK, TV>> Query(ScanQuery<TK, TV> scanQuery)
+        {
+            return _cache.Query(scanQuery);
+        }
+
+        /** <inheritDoc /> */
+        public IQueryCursor<ICacheEntry<TK, TV>> Query(SqlQuery sqlQuery)
+        {
+            return _cache.Query(sqlQuery);
+        }
+
+        /** <inheritDoc /> */
+        public IFieldsQueryCursor Query(SqlFieldsQuery sqlFieldsQuery)
+        {
+            return _cache.Query(sqlFieldsQuery);
+        }
+
+        /** <inheritDoc /> */
+        public CacheResult<TV> GetAndPut(TK key, TV val)
+        {
+            return _cache.GetAndPutAsync(key, val).GetResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task<CacheResult<TV>> GetAndPutAsync(TK key, TV val)
+        {
+            return _cache.GetAndPutAsync(key, val);
+        }
+
+        /** <inheritDoc /> */
+        public CacheResult<TV> GetAndReplace(TK key, TV val)
+        {
+            return _cache.GetAndReplaceAsync(key, val).GetResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task<CacheResult<TV>> GetAndReplaceAsync(TK key, TV val)
+        {
+            return _cache.GetAndReplaceAsync(key, val);
+        }
+
+        /** <inheritDoc /> */
+        public CacheResult<TV> GetAndRemove(TK key)
+        {
+            return _cache.GetAndRemoveAsync(key).GetResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task<CacheResult<TV>> GetAndRemoveAsync(TK key)
+        {
+            return _cache.GetAndRemoveAsync(key);
+        }
+
+        /** <inheritDoc /> */
+        public bool PutIfAbsent(TK key, TV val)
+        {
+            return _cache.PutIfAbsentAsync(key, val).GetResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task<bool> PutIfAbsentAsync(TK key, TV val)
+        {
+            return _cache.PutIfAbsentAsync(key, val);
+        }
+
+        /** <inheritDoc /> */
+        public CacheResult<TV> GetAndPutIfAbsent(TK key, TV val)
+        {
+            return _cache.GetAndPutIfAbsentAsync(key, val).GetResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task<CacheResult<TV>> GetAndPutIfAbsentAsync(TK key, TV val)
+        {
+            return _cache.GetAndPutIfAbsentAsync(key, val);
+        }
+
+        /** <inheritDoc /> */
+        public bool Replace(TK key, TV val)
+        {
+            return _cache.ReplaceAsync(key, val).GetResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task<bool> ReplaceAsync(TK key, TV val)
+        {
+            return _cache.ReplaceAsync(key, val);
+        }
+
+        /** <inheritDoc /> */
+        public bool Replace(TK key, TV oldVal, TV newVal)
+        {
+            return _cache.ReplaceAsync(key, oldVal, newVal).GetResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task<bool> ReplaceAsync(TK key, TV oldVal, TV newVal)
+        {
+            return _cache.ReplaceAsync(key, oldVal, newVal);
+        }
+
+        /** <inheritDoc /> */
+        public void PutAll(IEnumerable<KeyValuePair<TK, TV>> vals)
+        {
+            _cache.PutAllAsync(vals).WaitResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task PutAllAsync(IEnumerable<KeyValuePair<TK, TV>> vals)
+        {
+            return _cache.PutAllAsync(vals);
+        }
+
+        /** <inheritDoc /> */
+        public void Clear()
+        {
+            _cache.ClearAsync().WaitResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task ClearAsync()
+        {
+            return _cache.ClearAsync();
+        }
+
+        /** <inheritDoc /> */
+        public void Clear(TK key)
+        {
+            _cache.ClearAsync(key).WaitResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task ClearAsync(TK key)
+        {
+            return _cache.ClearAsync(key);
+        }
+
+        /** <inheritDoc /> */
+        public void ClearAll(IEnumerable<TK> keys)
+        {
+            _cache.ClearAllAsync(keys).WaitResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task ClearAllAsync(IEnumerable<TK> keys)
+        {
+            return _cache.ClearAllAsync(keys);
+        }
+
+        /** <inheritDoc /> */
+        public bool Remove(TK key)
+        {
+            return _cache.RemoveAsync(key).GetResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task<bool> RemoveAsync(TK key)
+        {
+            return _cache.RemoveAsync(key);
+        }
+
+        /** <inheritDoc /> */
+        public bool Remove(TK key, TV val)
+        {
+            return _cache.RemoveAsync(key, val).GetResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task<bool> RemoveAsync(TK key, TV val)
+        {
+            return _cache.RemoveAsync(key, val);
+        }
+
+        /** <inheritDoc /> */
+        public void RemoveAll(IEnumerable<TK> keys)
+        {
+            _cache.RemoveAllAsync(keys).WaitResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task RemoveAllAsync(IEnumerable<TK> keys)
+        {
+            return _cache.RemoveAllAsync(keys);
+        }
+
+        /** <inheritDoc /> */
+        public void RemoveAll()
+        {
+            _cache.RemoveAllAsync().WaitResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task RemoveAllAsync()
+        {
+            return _cache.RemoveAllAsync();
+        }
+
+        /** <inheritDoc /> */
+        public long GetSize(params CachePeekMode[] modes)
+        {
+            return _cache.GetSizeAsync(modes).GetResult();
+        }
+
+        /** <inheritDoc /> */
+        public Task<long> GetSizeAsync(params CachePeekMode[] modes)
+        {
+            return _cache.GetSizeAsync(modes);
+        }
+
+        /** <inheritDoc /> */
+        public CacheClientConfiguration GetConfiguration()
+        {
+            return _cache.GetConfiguration();
+        }
+
+        /** <inheritDoc /> */
+        public ICacheClient<TK1, TV1> WithKeepBinary<TK1, TV1>()
+        {
+            return _cache.WithKeepBinary<TK1, TV1>();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs
index f54efae..4c51d72 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs
@@ -30,7 +30,7 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
     /// <summary>
     /// Thin client cache test.
     /// </summary>
-    public sealed class CacheTest : ClientTestBase
+    public class CacheTest : ClientTestBase
     {
         /// <summary>
         /// Tests the cache put / get with primitive data types.
@@ -38,32 +38,29 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestPutGetPrimitives()
         {
-            using (var client = GetClient())
-            {
-                GetCache<string>().Put(1, "foo");
+            GetCache<string>().Put(1, "foo");
 
-                var clientCache = client.GetCache<int?, string>(CacheName);
+            var clientCache = GetClientCache<int?, string>();
 
-                clientCache.Put(2, "bar");
-                clientCache[3] = "baz";
+            clientCache.Put(2, "bar");
+            clientCache[3] = "baz";
 
-                // Existing key.
-                Assert.AreEqual("foo", clientCache.Get(1));
-                Assert.AreEqual("foo", clientCache[1]);
-                Assert.AreEqual("bar", clientCache[2]);
-                Assert.AreEqual("baz", clientCache[3]);
+            // Existing key.
+            Assert.AreEqual("foo", clientCache.Get(1));
+            Assert.AreEqual("foo", clientCache[1]);
+            Assert.AreEqual("bar", clientCache[2]);
+            Assert.AreEqual("baz", clientCache[3]);
 
-                // Missing key.
-                Assert.Throws<KeyNotFoundException>(() => clientCache.Get(-1));
+            // Missing key.
+            Assert.Throws<KeyNotFoundException>(() => clientCache.Get(-1));
 
-                // Null key.
-                Assert.Throws<ArgumentNullException>(() => clientCache.Get(null));
+            // Null key.
+            Assert.Throws<ArgumentNullException>(() => clientCache.Get(null));
 
-                // Null vs 0.
-                var intCache = client.GetCache<int?, int?>(CacheName);
-                intCache.Put(1, 0);
-                Assert.AreEqual(0, intCache.Get(1));
-            }
+            // Null vs 0.
+            var intCache = GetClientCache<int?, int?>();
+            intCache.Put(1, 0);
+            Assert.AreEqual(0, intCache.Get(1));
         }
 
         /// <summary>
@@ -72,14 +69,11 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestPutGetEmptyObject()
         {
-            using (var client = GetClient())
-            {
-                var serverCache = GetCache<EmptyObject>();
-                var clientCache = client.GetCache<int, EmptyObject>(CacheName);
+            var serverCache = GetCache<EmptyObject>();
+            var clientCache = GetClientCache<EmptyObject>();
 
-                serverCache.Put(1, new EmptyObject());
-                Assert.IsNotNull(clientCache.Get(1));
-            }
+            serverCache.Put(1, new EmptyObject());
+            Assert.IsNotNull(clientCache.Get(1));
         }
 
         /// <summary>
@@ -185,40 +179,60 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         }
 
         /// <summary>
+        /// Tests the GetAsync method.
+        /// </summary>
+        [Test]
+        public void TestGetAsync()
+        {
+            var cache = GetClientCache<int>();
+            cache[1] = 1;
+
+            // Existing key.
+            Assert.AreEqual(1, cache.GetAsync(1).Result);
+
+            // Missing key.
+            cache.Remove(1);
+            var aex = Assert.Throws<AggregateException>(() => cache.GetAsync(1).Wait());
+            Assert.IsInstanceOf<KeyNotFoundException>(aex.InnerException);
+
+            // Incorrect data type.
+            GetClientCache<Person>().PutAsync(1, new Person(1)).Wait();
+            aex = Assert.Throws<AggregateException>(() => cache.GetAsync(1).Wait());
+            Assert.IsInstanceOf<InvalidCastException>(aex.InnerException);
+        }
+
+        /// <summary>
         /// Tests the TryGet method.
         /// </summary>
         [Test]
         public void TestTryGet()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int>(CacheName);
+            var cache = GetClientCache<int?, int>();
 
-                cache[1] = 0;
-                cache[2] = 2;
+            cache[1] = 0;
+            cache[2] = 2;
 
-                // Non-existent key.
-                int res;
-                var success = cache.TryGet(0, out res);
+            // Non-existent key.
+            int res;
+            var success = cache.TryGet(0, out res);
 
-                Assert.AreEqual(0, res);
-                Assert.IsFalse(success);
+            Assert.AreEqual(0, res);
+            Assert.IsFalse(success);
 
-                // Key with default value.
-                success = cache.TryGet(1, out res);
+            // Key with default value.
+            success = cache.TryGet(1, out res);
 
-                Assert.AreEqual(0, res);
-                Assert.IsTrue(success);
+            Assert.AreEqual(0, res);
+            Assert.IsTrue(success);
 
-                // Key with custom value.
-                success = cache.TryGet(2, out res);
+            // Key with custom value.
+            success = cache.TryGet(2, out res);
 
-                Assert.AreEqual(2, res);
-                Assert.IsTrue(success);
+            Assert.AreEqual(2, res);
+            Assert.IsTrue(success);
 
-                // Null key.
-                Assert.Throws<ArgumentNullException>(() => cache.TryGet(null, out res));
-            }
+            // Null key.
+            Assert.Throws<ArgumentNullException>(() => cache.TryGet(null, out res));
         }
 
         /// <summary>
@@ -227,30 +241,27 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestGetAll()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int>(CacheName);
+            var cache = GetClientCache<int?, int>();
 
-                cache[1] = 1;
-                cache[2] = 2;
-                cache[3] = 3;
+            cache[1] = 1;
+            cache[2] = 2;
+            cache[3] = 3;
 
-                var res = cache.GetAll(new int?[] {1}).Single();
-                Assert.AreEqual(1, res.Key);
-                Assert.AreEqual(1, res.Value);
+            var res = cache.GetAll(new int?[] {1}).Single();
+            Assert.AreEqual(1, res.Key);
+            Assert.AreEqual(1, res.Value);
 
-                res = cache.GetAll(new int?[] {1, -1}).Single();
-                Assert.AreEqual(1, res.Key);
-                Assert.AreEqual(1, res.Value);
+            res = cache.GetAll(new int?[] {1, -1}).Single();
+            Assert.AreEqual(1, res.Key);
+            Assert.AreEqual(1, res.Value);
 
-                CollectionAssert.AreEquivalent(new[] {1, 2, 3},
-                    cache.GetAll(new int?[] {1, 2, 3}).Select(x => x.Value));
+            CollectionAssert.AreEquivalent(new[] {1, 2, 3},
+                cache.GetAll(new int?[] {1, 2, 3}).Select(x => x.Value));
 
-                Assert.Throws<ArgumentNullException>(() => cache.GetAll(null));
+            Assert.Throws<ArgumentNullException>(() => cache.GetAll(null));
 
-                Assert.Throws<IgniteClientException>(() => cache.GetAll(new int?[] {1, null}));
-                Assert.Throws<IgniteClientException>(() => cache.GetAll(new int?[] {null}));
-            }
+            Assert.Throws<IgniteClientException>(() => cache.GetAll(new int?[] {1, null}));
+            Assert.Throws<IgniteClientException>(() => cache.GetAll(new int?[] {null}));
         }
 
         /// <summary>
@@ -259,27 +270,24 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestGetAndPut()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int?>(CacheName);
+            var cache = GetClientCache<int?, int?>();
 
-                Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsFalse(cache.ContainsKey(1));
 
-                var res = cache.GetAndPut(1, 1);
-                Assert.IsFalse(res.Success);
-                Assert.IsNull(res.Value);
+            var res = cache.GetAndPut(1, 1);
+            Assert.IsFalse(res.Success);
+            Assert.IsNull(res.Value);
 
-                Assert.IsTrue(cache.ContainsKey(1));
+            Assert.IsTrue(cache.ContainsKey(1));
 
-                res = cache.GetAndPut(1, 2);
-                Assert.IsTrue(res.Success);
-                Assert.AreEqual(1, res.Value);
+            res = cache.GetAndPut(1, 2);
+            Assert.IsTrue(res.Success);
+            Assert.AreEqual(1, res.Value);
 
-                Assert.AreEqual(2, cache[1]);
+            Assert.AreEqual(2, cache[1]);
 
-                Assert.Throws<ArgumentNullException>(() => cache.GetAndPut(1, null));
-                Assert.Throws<ArgumentNullException>(() => cache.GetAndPut(null, 1));
-            }
+            Assert.Throws<ArgumentNullException>(() => cache.GetAndPut(1, null));
+            Assert.Throws<ArgumentNullException>(() => cache.GetAndPut(null, 1));
         }
 
         /// <summary>
@@ -288,28 +296,25 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestGetAndReplace()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int?>(CacheName);
+            var cache = GetClientCache<int?, int?>();
 
-                Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsFalse(cache.ContainsKey(1));
 
-                var res = cache.GetAndReplace(1, 1);
-                Assert.IsFalse(res.Success);
-                Assert.IsNull(res.Value);
+            var res = cache.GetAndReplace(1, 1);
+            Assert.IsFalse(res.Success);
+            Assert.IsNull(res.Value);
 
-                Assert.IsFalse(cache.ContainsKey(1));
-                cache[1] = 1;
+            Assert.IsFalse(cache.ContainsKey(1));
+            cache[1] = 1;
 
-                res = cache.GetAndReplace(1, 2);
-                Assert.IsTrue(res.Success);
-                Assert.AreEqual(1, res.Value);
+            res = cache.GetAndReplace(1, 2);
+            Assert.IsTrue(res.Success);
+            Assert.AreEqual(1, res.Value);
 
-                Assert.AreEqual(2, cache[1]);
+            Assert.AreEqual(2, cache[1]);
 
-                Assert.Throws<ArgumentNullException>(() => cache.GetAndReplace(1, null));
-                Assert.Throws<ArgumentNullException>(() => cache.GetAndReplace(null, 1));
-            }
+            Assert.Throws<ArgumentNullException>(() => cache.GetAndReplace(1, null));
+            Assert.Throws<ArgumentNullException>(() => cache.GetAndReplace(null, 1));
         }
 
         /// <summary>
@@ -318,27 +323,24 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestGetAndRemove()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int?>(CacheName);
+            var cache = GetClientCache<int?, int?>();
 
-                Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsFalse(cache.ContainsKey(1));
 
-                var res = cache.GetAndRemove(1);
-                Assert.IsFalse(res.Success);
-                Assert.IsNull(res.Value);
+            var res = cache.GetAndRemove(1);
+            Assert.IsFalse(res.Success);
+            Assert.IsNull(res.Value);
 
-                Assert.IsFalse(cache.ContainsKey(1));
-                cache[1] = 1;
+            Assert.IsFalse(cache.ContainsKey(1));
+            cache[1] = 1;
 
-                res = cache.GetAndRemove(1);
-                Assert.IsTrue(res.Success);
-                Assert.AreEqual(1, res.Value);
+            res = cache.GetAndRemove(1);
+            Assert.IsTrue(res.Success);
+            Assert.AreEqual(1, res.Value);
 
-                Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsFalse(cache.ContainsKey(1));
 
-                Assert.Throws<ArgumentNullException>(() => cache.GetAndRemove(null));
-            }
+            Assert.Throws<ArgumentNullException>(() => cache.GetAndRemove(null));
         }
 
         /// <summary>
@@ -347,17 +349,14 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestContainsKey()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int>(CacheName);
+            var cache = GetClientCache<int?, int>();
 
-                cache[1] = 1;
+            cache[1] = 1;
 
-                Assert.IsTrue(cache.ContainsKey(1));
-                Assert.IsFalse(cache.ContainsKey(2));
+            Assert.IsTrue(cache.ContainsKey(1));
+            Assert.IsFalse(cache.ContainsKey(2));
 
-                Assert.Throws<ArgumentNullException>(() => cache.ContainsKey(null));
-            }
+            Assert.Throws<ArgumentNullException>(() => cache.ContainsKey(null));
         }
 
         /// <summary>
@@ -366,27 +365,24 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestContainsKeys()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int, int>(CacheName);
+            var cache = GetClientCache<int, int>();
 
-                cache[1] = 1;
-                cache[2] = 2;
-                cache[3] = 3;
+            cache[1] = 1;
+            cache[2] = 2;
+            cache[3] = 3;
 
-                Assert.IsTrue(cache.ContainsKeys(new[] {1}));
-                Assert.IsTrue(cache.ContainsKeys(new[] {1, 2}));
-                Assert.IsTrue(cache.ContainsKeys(new[] {2, 1}));
-                Assert.IsTrue(cache.ContainsKeys(new[] {1, 2, 3}));
-                Assert.IsTrue(cache.ContainsKeys(new[] {1, 3, 2}));
+            Assert.IsTrue(cache.ContainsKeys(new[] {1}));
+            Assert.IsTrue(cache.ContainsKeys(new[] {1, 2}));
+            Assert.IsTrue(cache.ContainsKeys(new[] {2, 1}));
+            Assert.IsTrue(cache.ContainsKeys(new[] {1, 2, 3}));
+            Assert.IsTrue(cache.ContainsKeys(new[] {1, 3, 2}));
 
-                Assert.IsFalse(cache.ContainsKeys(new[] {0}));
-                Assert.IsFalse(cache.ContainsKeys(new[] {0, 1}));
-                Assert.IsFalse(cache.ContainsKeys(new[] {1, 0}));
-                Assert.IsFalse(cache.ContainsKeys(new[] {1, 2, 3, 0}));
+            Assert.IsFalse(cache.ContainsKeys(new[] {0}));
+            Assert.IsFalse(cache.ContainsKeys(new[] {0, 1}));
+            Assert.IsFalse(cache.ContainsKeys(new[] {1, 0}));
+            Assert.IsFalse(cache.ContainsKeys(new[] {1, 2, 3, 0}));
 
-                Assert.Throws<ArgumentNullException>(() => cache.ContainsKeys(null));
-            }
+            Assert.Throws<ArgumentNullException>(() => cache.ContainsKeys(null));
         }
 
         /// <summary>
@@ -395,23 +391,20 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestPutIfAbsent()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int?>(CacheName);
+            var cache = GetClientCache<int?, int?>();
 
-                Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsFalse(cache.ContainsKey(1));
 
-                var res = cache.PutIfAbsent(1, 1);
-                Assert.IsTrue(res);
-                Assert.AreEqual(1, cache[1]);
+            var res = cache.PutIfAbsent(1, 1);
+            Assert.IsTrue(res);
+            Assert.AreEqual(1, cache[1]);
 
-                res = cache.PutIfAbsent(1, 2);
-                Assert.IsFalse(res);
-                Assert.AreEqual(1, cache[1]);
+            res = cache.PutIfAbsent(1, 2);
+            Assert.IsFalse(res);
+            Assert.AreEqual(1, cache[1]);
 
-                Assert.Throws<ArgumentNullException>(() => cache.PutIfAbsent(null, 1));
-                Assert.Throws<ArgumentNullException>(() => cache.PutIfAbsent(1, null));
-            }
+            Assert.Throws<ArgumentNullException>(() => cache.PutIfAbsent(null, 1));
+            Assert.Throws<ArgumentNullException>(() => cache.PutIfAbsent(1, null));
         }
 
         /// <summary>
@@ -420,25 +413,22 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestGetAndPutIfAbsent()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int?>(CacheName);
+            var cache = GetClientCache<int?, int?>();
 
-                Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsFalse(cache.ContainsKey(1));
 
-                var res = cache.GetAndPutIfAbsent(1, 1);
-                Assert.IsFalse(res.Success);
-                Assert.IsNull(res.Value);
-                Assert.AreEqual(1, cache[1]);
+            var res = cache.GetAndPutIfAbsent(1, 1);
+            Assert.IsFalse(res.Success);
+            Assert.IsNull(res.Value);
+            Assert.AreEqual(1, cache[1]);
 
-                res = cache.GetAndPutIfAbsent(1, 2);
-                Assert.IsTrue(res.Success);
-                Assert.AreEqual(1, res.Value);
-                Assert.AreEqual(1, cache[1]);
+            res = cache.GetAndPutIfAbsent(1, 2);
+            Assert.IsTrue(res.Success);
+            Assert.AreEqual(1, res.Value);
+            Assert.AreEqual(1, cache[1]);
 
-                Assert.Throws<ArgumentNullException>(() => cache.GetAndPutIfAbsent(null, 1));
-                Assert.Throws<ArgumentNullException>(() => cache.GetAndPutIfAbsent(1, null));
-            }
+            Assert.Throws<ArgumentNullException>(() => cache.GetAndPutIfAbsent(null, 1));
+            Assert.Throws<ArgumentNullException>(() => cache.GetAndPutIfAbsent(1, null));
         }
 
         /// <summary>
@@ -447,25 +437,22 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestReplace()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int?>(CacheName);
+            var cache = GetClientCache<int?, int?>();
 
-                Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsFalse(cache.ContainsKey(1));
 
-                var res = cache.Replace(1, 1);
-                Assert.IsFalse(res);
-                Assert.IsFalse(cache.ContainsKey(1));
+            var res = cache.Replace(1, 1);
+            Assert.IsFalse(res);
+            Assert.IsFalse(cache.ContainsKey(1));
 
-                cache[1] = 1;
+            cache[1] = 1;
 
-                res = cache.Replace(1, 2);
-                Assert.IsTrue(res);
-                Assert.AreEqual(2, cache[1]);
+            res = cache.Replace(1, 2);
+            Assert.IsTrue(res);
+            Assert.AreEqual(2, cache[1]);
 
-                Assert.Throws<ArgumentNullException>(() => cache.Replace(null, 1));
-                Assert.Throws<ArgumentNullException>(() => cache.Replace(1, null));
-            }
+            Assert.Throws<ArgumentNullException>(() => cache.Replace(null, 1));
+            Assert.Throws<ArgumentNullException>(() => cache.Replace(1, null));
         }
 
         /// <summary>
@@ -474,30 +461,27 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestReplaceIfEquals()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int?>(CacheName);
+            var cache = GetClientCache<int?, int?>();
 
-                Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsFalse(cache.ContainsKey(1));
 
-                var res = cache.Replace(1, 1, 2);
-                Assert.IsFalse(res);
-                Assert.IsFalse(cache.ContainsKey(1));
+            var res = cache.Replace(1, 1, 2);
+            Assert.IsFalse(res);
+            Assert.IsFalse(cache.ContainsKey(1));
 
-                cache[1] = 1;
+            cache[1] = 1;
 
-                res = cache.Replace(1, -1, 2);
-                Assert.IsFalse(res);
-                Assert.AreEqual(1, cache[1]);
+            res = cache.Replace(1, -1, 2);
+            Assert.IsFalse(res);
+            Assert.AreEqual(1, cache[1]);
 
-                res = cache.Replace(1, 1, 2);
-                Assert.IsTrue(res);
-                Assert.AreEqual(2, cache[1]);
+            res = cache.Replace(1, 1, 2);
+            Assert.IsTrue(res);
+            Assert.AreEqual(2, cache[1]);
 
-                Assert.Throws<ArgumentNullException>(() => cache.Replace(null, 1, 1));
-                Assert.Throws<ArgumentNullException>(() => cache.Replace(1, null, 1));
-                Assert.Throws<ArgumentNullException>(() => cache.Replace(1, 1, null));
-            }
+            Assert.Throws<ArgumentNullException>(() => cache.Replace(null, 1, 1));
+            Assert.Throws<ArgumentNullException>(() => cache.Replace(1, null, 1));
+            Assert.Throws<ArgumentNullException>(() => cache.Replace(1, 1, null));
         }
 
         /// <summary>
@@ -509,7 +493,7 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
             using (var client = GetClient())
             {
                 // Primitives.
-                var cache = client.GetCache<int?, int?>(CacheName);
+                var cache = GetClientCache<int?, int?>();
 
                 cache.PutAll(Enumerable.Range(1, 3).ToDictionary(x => (int?) x, x => (int?) x + 1));
 
@@ -543,6 +527,13 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
                 Assert.AreEqual(res2, res2.Inner.Inner);
                 Assert.IsNotNull(res3.Inner.Inner.Inner);
 
+                // Huge data set.
+                var cache3 = client.GetCache<int, Person>(CacheName);
+                const int count = 30000;
+
+                cache3.PutAll(Enumerable.Range(1, count).ToDictionary(x => x, x => new Person(x)));
+                Assert.AreEqual(count, cache3.GetSize());
+
                 // Nulls.
                 Assert.Throws<ArgumentNullException>(() => cache.PutAll(null));
 
@@ -564,18 +555,15 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestClear()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int?>(CacheName);
+            var cache = GetClientCache<int?, int?>();
 
-                cache[1] = 1;
-                cache[2] = 2;
+            cache[1] = 1;
+            cache[2] = 2;
 
-                cache.Clear();
+            cache.Clear();
 
-                Assert.IsFalse(cache.ContainsKey(1));
-                Assert.IsFalse(cache.ContainsKey(2));
-            }
+            Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsFalse(cache.ContainsKey(2));
         }
 
         /// <summary>
@@ -584,23 +572,20 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestClearKey()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int?>(CacheName);
+            var cache = GetClientCache<int?, int?>();
 
-                cache[1] = 1;
-                cache[2] = 2;
+            cache[1] = 1;
+            cache[2] = 2;
 
-                cache.Clear(1);
-                Assert.IsFalse(cache.ContainsKey(1));
-                Assert.IsTrue(cache.ContainsKey(2));
+            cache.Clear(1);
+            Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsTrue(cache.ContainsKey(2));
 
-                cache.Clear(2);
-                Assert.IsFalse(cache.ContainsKey(1));
-                Assert.IsFalse(cache.ContainsKey(2));
+            cache.Clear(2);
+            Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsFalse(cache.ContainsKey(2));
 
-                Assert.Throws<ArgumentNullException>(() => cache.Clear(null));
-            }
+            Assert.Throws<ArgumentNullException>(() => cache.Clear(null));
         }
 
         /// <summary>
@@ -609,22 +594,19 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestClearAll()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int?>(CacheName);
+            var cache = GetClientCache<int?, int?>();
 
-                cache[1] = 1;
-                cache[2] = 2;
-                cache[3] = 3;
+            cache[1] = 1;
+            cache[2] = 2;
+            cache[3] = 3;
 
-                cache.ClearAll(new int?[] {1, 3});
-                Assert.IsFalse(cache.ContainsKey(1));
-                Assert.IsTrue(cache.ContainsKey(2));
-                Assert.IsFalse(cache.ContainsKey(3));
+            cache.ClearAll(new int?[] {1, 3});
+            Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsTrue(cache.ContainsKey(2));
+            Assert.IsFalse(cache.ContainsKey(3));
 
-                Assert.Throws<ArgumentNullException>(() => cache.ClearAll(null));
-                Assert.Throws<IgniteClientException>(() => cache.ClearAll(new int?[] {null, 1}));
-            }
+            Assert.Throws<ArgumentNullException>(() => cache.ClearAll(null));
+            Assert.Throws<IgniteClientException>(() => cache.ClearAll(new int?[] {null, 1}));
         }
 
         /// <summary>
@@ -633,28 +615,25 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestRemove()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int?>(CacheName);
+            var cache = GetClientCache<int?, int?>();
 
-                cache[1] = 1;
-                cache[2] = 2;
+            cache[1] = 1;
+            cache[2] = 2;
 
-                var res = cache.Remove(1);
-                Assert.IsTrue(res);
-                Assert.IsFalse(cache.ContainsKey(1));
-                Assert.IsTrue(cache.ContainsKey(2));
+            var res = cache.Remove(1);
+            Assert.IsTrue(res);
+            Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsTrue(cache.ContainsKey(2));
 
-                res = cache.Remove(2);
-                Assert.IsTrue(res);
-                Assert.IsFalse(cache.ContainsKey(1));
-                Assert.IsFalse(cache.ContainsKey(2));
+            res = cache.Remove(2);
+            Assert.IsTrue(res);
+            Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsFalse(cache.ContainsKey(2));
 
-                res = cache.Remove(-1);
-                Assert.IsFalse(res);
+            res = cache.Remove(-1);
+            Assert.IsFalse(res);
 
-                Assert.Throws<ArgumentNullException>(() => cache.Remove(null));
-            }
+            Assert.Throws<ArgumentNullException>(() => cache.Remove(null));
         }
 
         /// <summary>
@@ -663,35 +642,32 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestRemoveKeyVal()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int?>(CacheName);
+            var cache = GetClientCache<int?, int?>();
 
-                cache[1] = 1;
-                cache[2] = 2;
+            cache[1] = 1;
+            cache[2] = 2;
 
-                var res = cache.Remove(1, 0);
-                Assert.IsFalse(res);
+            var res = cache.Remove(1, 0);
+            Assert.IsFalse(res);
 
-                res = cache.Remove(0, 0);
-                Assert.IsFalse(res);
+            res = cache.Remove(0, 0);
+            Assert.IsFalse(res);
 
-                res = cache.Remove(1, 1);
-                Assert.IsTrue(res);
-                Assert.IsFalse(cache.ContainsKey(1));
-                Assert.IsTrue(cache.ContainsKey(2));
+            res = cache.Remove(1, 1);
+            Assert.IsTrue(res);
+            Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsTrue(cache.ContainsKey(2));
 
-                res = cache.Remove(2, 2);
-                Assert.IsTrue(res);
-                Assert.IsFalse(cache.ContainsKey(1));
-                Assert.IsFalse(cache.ContainsKey(2));
+            res = cache.Remove(2, 2);
+            Assert.IsTrue(res);
+            Assert.IsFalse(cache.ContainsKey(1));
+            Assert.IsFalse(cache.ContainsKey(2));
 
-                res = cache.Remove(2, 2);
-                Assert.IsFalse(res);
+            res = cache.Remove(2, 2);
+            Assert.IsFalse(res);
 
-                Assert.Throws<ArgumentNullException>(() => cache.Remove(1, null));
-                Assert.Throws<ArgumentNullException>(() => cache.Remove(null, 1));
-            }
+            Assert.Throws<ArgumentNullException>(() => cache.Remove(1, null));
+            Assert.Throws<ArgumentNullException>(() => cache.Remove(null, 1));
         }
 
         /// <summary>
@@ -700,27 +676,24 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestRemoveReys()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int?, int?>(CacheName);
-                var keys = Enumerable.Range(1, 10).Cast<int?>().ToArray();
+            var cache = GetClientCache<int?, int?>();
+            var keys = Enumerable.Range(1, 10).Cast<int?>().ToArray();
 
-                cache.PutAll(keys.ToDictionary(x => x, x => x));
+            cache.PutAll(keys.ToDictionary(x => x, x => x));
 
-                cache.RemoveAll(keys.Skip(2));
-                CollectionAssert.AreEquivalent(keys.Take(2), cache.GetAll(keys).Select(x => x.Key));
+            cache.RemoveAll(keys.Skip(2));
+            CollectionAssert.AreEquivalent(keys.Take(2), cache.GetAll(keys).Select(x => x.Key));
 
-                cache.RemoveAll(new int?[] {1});
-                Assert.AreEqual(2, cache.GetAll(keys).Single().Value);
+            cache.RemoveAll(new int?[] {1});
+            Assert.AreEqual(2, cache.GetAll(keys).Single().Value);
 
-                cache.RemoveAll(keys);
-                cache.RemoveAll(keys);
+            cache.RemoveAll(keys);
+            cache.RemoveAll(keys);
 
-                Assert.AreEqual(0, cache.GetSize());
+            Assert.AreEqual(0, cache.GetSize());
 
-                Assert.Throws<ArgumentNullException>(() => cache.RemoveAll(null));
-                Assert.Throws<IgniteClientException>(() => cache.RemoveAll(new int?[] {1, null}));
-            }
+            Assert.Throws<ArgumentNullException>(() => cache.RemoveAll(null));
+            Assert.Throws<IgniteClientException>(() => cache.RemoveAll(new int?[] {1, null}));
         }
 
         /// <summary>
@@ -748,38 +721,35 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         [Test]
         public void TestGetSize()
         {
-            using (var client = GetClient())
-            {
-                var cache = client.GetCache<int, int>(CacheName);
-
-                Assert.AreEqual(0, cache.GetSize());
-                Assert.AreEqual(0, cache.GetSize(CachePeekMode.All));
-                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Backup));
-                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Near));
-                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Offheap));
-                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Onheap));
-                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Primary));
-
-                cache[1] = 1;
-                
-                Assert.AreEqual(1, cache.GetSize());
-                Assert.AreEqual(1, cache.GetSize(CachePeekMode.All));
-                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Backup));
-                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Near));
-                Assert.AreEqual(1, cache.GetSize(CachePeekMode.Offheap));
-                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Onheap));
-                Assert.AreEqual(1, cache.GetSize(CachePeekMode.Primary));
-
-                cache.PutAll(Enumerable.Range(1, 100).ToDictionary(x => x, x => x));
-                
-                Assert.AreEqual(100, cache.GetSize());
-                Assert.AreEqual(100, cache.GetSize(CachePeekMode.All));
-                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Backup));
-                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Near));
-                Assert.AreEqual(100, cache.GetSize(CachePeekMode.Offheap));
-                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Onheap));
-                Assert.AreEqual(100, cache.GetSize(CachePeekMode.Primary));
-            }
+            var cache = GetClientCache<int>();
+
+            Assert.AreEqual(0, cache.GetSize());
+            Assert.AreEqual(0, cache.GetSize(CachePeekMode.All));
+            Assert.AreEqual(0, cache.GetSize(CachePeekMode.Backup));
+            Assert.AreEqual(0, cache.GetSize(CachePeekMode.Near));
+            Assert.AreEqual(0, cache.GetSize(CachePeekMode.Offheap));
+            Assert.AreEqual(0, cache.GetSize(CachePeekMode.Onheap));
+            Assert.AreEqual(0, cache.GetSize(CachePeekMode.Primary));
+
+            cache[1] = 1;
+
+            Assert.AreEqual(1, cache.GetSize());
+            Assert.AreEqual(1, cache.GetSize(CachePeekMode.All));
+            Assert.AreEqual(0, cache.GetSize(CachePeekMode.Backup));
+            Assert.AreEqual(0, cache.GetSize(CachePeekMode.Near));
+            Assert.AreEqual(1, cache.GetSize(CachePeekMode.Offheap));
+            Assert.AreEqual(0, cache.GetSize(CachePeekMode.Onheap));
+            Assert.AreEqual(1, cache.GetSize(CachePeekMode.Primary));
+
+            cache.PutAll(Enumerable.Range(1, 100).ToDictionary(x => x, x => x));
+
+            Assert.AreEqual(100, cache.GetSize());
+            Assert.AreEqual(100, cache.GetSize(CachePeekMode.All));
+            Assert.AreEqual(0, cache.GetSize(CachePeekMode.Backup));
+            Assert.AreEqual(0, cache.GetSize(CachePeekMode.Near));
+            Assert.AreEqual(100, cache.GetSize(CachePeekMode.Offheap));
+            Assert.AreEqual(0, cache.GetSize(CachePeekMode.Onheap));
+            Assert.AreEqual(100, cache.GetSize(CachePeekMode.Primary));
         }
 
         /// <summary>
@@ -826,22 +796,81 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         }
 
         /// <summary>
+        /// Tests interleaved put/get operations.
+        /// </summary>
+        [Test]
+        [Category(TestUtils.CategoryIntensive)]
+        public void TestPutGetAsyncMultithreaded()
+        {
+            const int count = 5000;
+
+            var cache = GetClientCache<string>();
+            var key = 0;
+
+            TestUtils.RunMultiThreaded(() =>
+            {
+                for (var i = 0; i < count; i++)
+                {
+                    // ReSharper disable once AccessToModifiedClosure
+                    var k = Interlocked.Increment(ref key);
+                    var v = k + "_" + Guid.NewGuid();
+
+                    if (k % 3 == 0)
+                    {
+                        cache.Put(k, v);
+                    }
+                    else
+                    {
+                        cache.PutAsync(k, v);
+                    }
+                }
+            }, Environment.ProcessorCount * 2);
+
+            key = 0;
+
+            TestUtils.RunMultiThreaded(() =>
+            {
+                for (var i = 0; i < count; i++)
+                {
+                    var k = Interlocked.Increment(ref key);
+                    var val = k % 3 == 0 ? cache.Get(k) : cache.GetAsync(k).Result;
+
+                    Assert.IsTrue(val.Split('_').First() == k.ToString());
+                }
+            }, Environment.ProcessorCount * 2);
+        }
+
+        /// <summary>
+        /// Tests that long operation completes later than short operation.
+        /// </summary>
+        [Test]
+        public void TestAsyncCompletionOrder()
+        {
+            var cache = GetClientCache<int>();
+
+            var t1 = cache.PutAllAsync(Enumerable.Range(1, 100000).ToDictionary(x => x, x => x));
+            var t2 = cache.PutAsync(-1, -1);
+
+            t2.Wait();
+            Assert.IsFalse(t1.IsCompleted);
+
+            t1.Wait();
+        }
+
+        /// <summary>
         /// Tests the cache exceptions.
         /// </summary>
         [Test]
         public void TestExceptions()
         {
-            using (var client = GetClient())
-            {
-                // Getting the cache instance does not throw.
-                var cache = client.GetCache<int, int>("foobar");
+            // Getting the cache instance does not throw.
+            var cache = GetClientCache<int, int>("foobar");
 
-                // Accessing non-existent cache throws.
-                var ex = Assert.Throws<IgniteClientException>(() => cache.Put(1, 1));
+            // Accessing non-existent cache throws.
+            var ex = Assert.Throws<IgniteClientException>(() => cache.Put(1, 1));
 
-                Assert.AreEqual("Cache doesn't exist: foobar", ex.Message);
-                Assert.AreEqual(ClientStatusCode.CacheDoesNotExist, ex.StatusCode);
-            }
+            Assert.AreEqual("Cache doesn't exist: foobar", ex.Message);
+            Assert.AreEqual(ClientStatusCode.CacheDoesNotExist, ex.StatusCode);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestAsync.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestAsync.cs
new file mode 100644
index 0000000..2081167
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestAsync.cs
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests.Client.Cache
+{
+    using Apache.Ignite.Core.Client.Cache;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Async cache test.
+    /// </summary>
+    [TestFixture]
+    public sealed class CacheTestAsync : CacheTest
+    {
+        /** <inheritdoc /> */
+        protected override ICacheClient<TK, TV> GetClientCache<TK, TV>(string cacheName = CacheName)
+        {
+            return new CacheClientAsyncWrapper<TK, TV>(base.GetClientCache<TK, TV>(cacheName));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
index 145762a..2b92eb7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
@@ -18,9 +18,12 @@
 namespace Apache.Ignite.Core.Tests.Client
 {
     using System;
+    using System.Collections.Generic;
     using System.Linq;
     using System.Net;
     using System.Net.Sockets;
+    using System.Threading;
+    using System.Threading.Tasks;
     using Apache.Ignite.Core.Client;
     using Apache.Ignite.Core.Configuration;
     using NUnit.Framework;
@@ -33,8 +36,8 @@ namespace Apache.Ignite.Core.Tests.Client
         /// <summary>
         /// Fixture tear down.
         /// </summary>
-        [TestFixtureTearDown]
-        public void FixtureTearDown()
+        [TearDown]
+        public void TearDown()
         {
             Ignition.StopAll(true);
         }
@@ -128,7 +131,7 @@ namespace Apache.Ignite.Core.Tests.Client
 
                 Assert.AreEqual(ClientStatusCode.Fail, ex.StatusCode);
 
-                Assert.AreEqual("Client handhsake failed: 'Unsupported version.'. " +
+                Assert.AreEqual("Client handshake failed: 'Unsupported version.'. " +
                                 "Client version: -1.-1.-1. Server version: 1.0.0", ex.Message);
             }
         }
@@ -159,6 +162,116 @@ namespace Apache.Ignite.Core.Tests.Client
         }
 
         /// <summary>
+        /// Tests that we get a proper exception when server disconnects (node shutdown, network issues, etc).
+        /// </summary>
+        [Test]
+        public void TestServerConnectionAborted()
+        {
+            var evt = new ManualResetEventSlim();
+            var ignite = Ignition.Start(TestUtils.GetTestConfiguration());
+
+            var putGetTask = Task.Factory.StartNew(() =>
+            {
+                using (var client = StartClient())
+                {
+                    var cache = client.GetOrCreateCache<int, int>("foo");
+                    evt.Set();
+
+                    for (var i = 0; i < 100000; i++)
+                    {
+                        cache[i] = i;
+                        Assert.AreEqual(i, cache.GetAsync(i).Result);
+                    }
+                }
+            });
+
+            evt.Wait();
+            ignite.Dispose();
+
+            var ex = Assert.Throws<AggregateException>(() => putGetTask.Wait());
+            var baseEx = ex.GetBaseException();
+            var socketEx = baseEx as SocketException;
+
+            if (socketEx != null)
+            {
+                Assert.AreEqual(SocketError.ConnectionAborted, socketEx.SocketErrorCode);
+            }
+            else
+            {
+                Assert.Fail("Unexpected exception: " + ex);
+            }
+        }
+
+        /// <summary>
+        /// Tests the operation timeout.
+        /// </summary>
+        [Test]
+        [Category(TestUtils.CategoryIntensive)]
+        public void TestOperationTimeout()
+        {
+            var data = Enumerable.Range(1, 500000).ToDictionary(x => x, x => x.ToString());
+
+            Ignition.Start(TestUtils.GetTestConfiguration());
+
+            var cfg = GetClientConfiguration();
+            cfg.SocketTimeout = TimeSpan.FromMilliseconds(500);
+            var client = Ignition.StartClient(cfg);
+            var cache = client.CreateCache<int, string>("s");
+            Assert.AreEqual(cfg.SocketTimeout, client.GetConfiguration().SocketTimeout);
+
+            // Async.
+            var task = cache.PutAllAsync(data);
+            Assert.IsFalse(task.IsCompleted);
+            var aex = Assert.Throws<AggregateException>(() => task.Wait());
+            Assert.AreEqual(SocketError.TimedOut, ((SocketException) aex.GetBaseException()).SocketErrorCode);
+
+            // Sync (reconnect for clean state).
+            Ignition.StopAll(true);
+            Ignition.Start(TestUtils.GetTestConfiguration());
+            client = Ignition.StartClient(cfg);
+            cache = client.CreateCache<int, string>("s");
+            var ex = Assert.Throws<SocketException>(() => cache.PutAll(data));
+            Assert.AreEqual(SocketError.TimedOut, ex.SocketErrorCode);
+        }
+
+        /// <summary>
+        /// Tests the client dispose while operations are in progress.
+        /// </summary>
+        [Test]
+        [Category(TestUtils.CategoryIntensive)]
+        public void TestClientDisposeWhileOperationsAreInProgress()
+        {
+            Ignition.Start(TestUtils.GetTestConfiguration());
+
+            var ops = new List<Task>();
+
+            using (var client = StartClient())
+            {
+                var cache = client.GetOrCreateCache<int, int>("foo");
+                for (var i = 0; i < 100000; i++)
+                {
+                    ops.Add(cache.PutAsync(i, i));
+                }
+                ops.First().Wait();
+            }
+
+            var completed = ops.Count(x => x.Status == TaskStatus.RanToCompletion);
+            Assert.Greater(completed, 0, "Some tasks should have completed.");
+
+            var failed = ops.Where(x => x.Status == TaskStatus.Faulted).ToArray();
+            Assert.IsTrue(failed.Any(), "Some tasks should have failed.");
+
+            foreach (var task in failed)
+            {
+                var ex = task.Exception;
+                Assert.IsNotNull(ex);
+                var baseEx = ex.GetBaseException();
+                Assert.IsNotNull((object) (baseEx as SocketException) ?? baseEx as ObjectDisposedException, 
+                    ex.ToString());
+            }
+        }
+
+        /// <summary>
         /// Starts the client.
         /// </summary>
         private static IIgniteClient StartClient()

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
index 6177f34..78d571b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
@@ -87,7 +87,12 @@ namespace Apache.Ignite.Core.Tests.Client
         [SetUp]
         public virtual void TestSetUp()
         {
-            GetCache<int>().RemoveAll();
+            var cache = GetCache<int>();
+            cache.RemoveAll();
+            cache.Clear();
+            
+            Assert.AreEqual(0, cache.GetSize(CachePeekMode.All));
+            Assert.AreEqual(0, GetClientCache<int>().GetSize(CachePeekMode.All));
         }
 
         /// <summary>
@@ -108,7 +113,15 @@ namespace Apache.Ignite.Core.Tests.Client
         /// </summary>
         protected ICacheClient<int, T> GetClientCache<T>()
         {
-            return Client.GetCache<int, T>(CacheName);
+            return GetClientCache<int, T>();
+        }
+
+        /// <summary>
+        /// Gets the client cache.
+        /// </summary>
+        protected virtual ICacheClient<TK, TV> GetClientCache<TK, TV>(string cacheName = CacheName)
+        {
+            return Client.GetCache<TK, TV>(cacheName ?? CacheName);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/IgniteClientConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/IgniteClientConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/IgniteClientConfigurationTest.cs
index 0b28cfd..1857520 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/IgniteClientConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/IgniteClientConfigurationTest.cs
@@ -43,6 +43,7 @@ namespace Apache.Ignite.Core.Tests.Client
             Assert.AreEqual(IgniteClientConfiguration.DefaultSocketBufferSize, cfg.SocketReceiveBufferSize);
             Assert.AreEqual(IgniteClientConfiguration.DefaultSocketBufferSize, cfg.SocketSendBufferSize);
             Assert.AreEqual(IgniteClientConfiguration.DefaultTcpNoDelay, cfg.TcpNoDelay);
+            Assert.AreEqual(IgniteClientConfiguration.DefaultSocketTimeout, cfg.SocketTimeout);
         }
 
         /// <summary>
@@ -68,6 +69,7 @@ namespace Apache.Ignite.Core.Tests.Client
                 SocketReceiveBufferSize = 222,
                 SocketSendBufferSize = 333,
                 TcpNoDelay = false,
+                SocketTimeout = TimeSpan.FromSeconds(15),
                 BinaryConfiguration = new BinaryConfiguration
                 {
                     CompactFooter = false,

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/IgniteClientConfiguration.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/IgniteClientConfiguration.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/IgniteClientConfiguration.xml
index 9a19e32..18026b4 100644
Binary files a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/IgniteClientConfiguration.xml and b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Client/IgniteClientConfiguration.xml differ

http://git-wip-us.apache.org/repos/asf/ignite/blob/1c09a923/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TaskExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TaskExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TaskExtensions.cs
new file mode 100644
index 0000000..6e8489e
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TaskExtensions.cs
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Core.Tests
+{
+    using System;
+    using System.Threading.Tasks;
+
+    /// <summary>
+    /// Task extensions.
+    /// </summary>
+    public static class TaskExtensions
+    {
+        /// <summary>
+        /// Waits the result of a task, unwraps exceptions.
+        /// </summary>
+        /// <param name="task">The task.</param>
+        public static void WaitResult(this Task task)
+        {
+            try
+            {
+                task.Wait();
+            }
+            catch (AggregateException ex)
+            {
+                throw ex.GetBaseException();
+            }
+        }
+
+        /// <summary>
+        /// Gets the result of a task, unwraps exceptions.
+        /// </summary>
+        public static T GetResult<T>(this Task<T> task)
+        {
+            try
+            {
+                return task.Result;
+            }
+            catch (AggregateException ex)
+            {
+                throw ex.GetBaseException();
+            }
+        }
+    }
+}


Mime
View raw message