You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2015/10/28 09:42:36 UTC
[01/17] ignite git commit: .NET: Make IgniteManager public for usage
in benchmarks and exe runner
Repository: ignite
Updated Branches:
refs/heads/ignite-950-new 52ac93b24 -> bc976b434
.NET: Make IgniteManager public for usage in benchmarks and exe runner
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b1b5428e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b1b5428e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b1b5428e
Branch: refs/heads/ignite-950-new
Commit: b1b5428e2edba42c7412d2216dffd221c13f87be
Parents: f85c6a3
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Thu Oct 22 18:00:54 2015 +0300
Committer: Pavel Tupitsyn <pt...@gridgain.com>
Committed: Thu Oct 22 18:00:54 2015 +0300
----------------------------------------------------------------------
.../platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs | 4 ++--
.../dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs | 1 -
2 files changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b1b5428e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
index 67af684..6803772 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
@@ -32,7 +32,7 @@ namespace Apache.Ignite.Core.Impl
/// <summary>
/// Native interface manager.
/// </summary>
- internal static unsafe class IgniteManager
+ public static unsafe class IgniteManager
{
/** Java Command line argument: Xms. Case sensitive. */
private const string CmdJvmMinMemJava = "-Xms";
@@ -100,7 +100,7 @@ namespace Apache.Ignite.Core.Impl
}
/// <summary>
- /// Destroy JVM.
+ /// Blocks until JVM stops.
/// </summary>
public static void DestroyJvm()
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/b1b5428e/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
index 127bd5a..6dd5706 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
@@ -40,7 +40,6 @@ using System.Runtime.InteropServices;
#if !EXCLUDE_INTERNALS_VISIBLE_TO
-[assembly: InternalsVisibleTo("Apache.Ignite")]
[assembly: InternalsVisibleTo("Apache.Ignite.Core.Tests")]
[assembly: InternalsVisibleTo("Apache.Ignite.Benchmarks")]
[13/17] ignite git commit: IGNITE-1652: .Net async API reworked.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
index 204c56c..48bc695 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
@@ -21,11 +21,11 @@ namespace Apache.Ignite.Core.Cache
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Cache.Expiry;
using Apache.Ignite.Core.Cache.Query;
using Apache.Ignite.Core.Cache.Query.Continuous;
using Apache.Ignite.Core.Cache.Store;
- using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Transactions;
/// <summary>
@@ -53,7 +53,7 @@ namespace Apache.Ignite.Core.Cache
/// <typeparam name="TK">Key type.</typeparam>
/// <typeparam name="TV">Value type.</typeparam>
[SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
- public interface ICache<TK, TV> : IAsyncSupport<ICache<TK, TV>>, IEnumerable<ICacheEntry<TK, TV>>
+ public interface ICache<TK, TV> : IEnumerable<ICacheEntry<TK, TV>>
{
/// <summary>
/// Name of this cache (<c>null</c> for default cache).
@@ -113,13 +113,23 @@ namespace Apache.Ignite.Core.Cache
/// <param name="args">
/// Optional user arguments to be passed into <see cref="ICacheStore.LoadCache" />.
/// </param>
- [AsyncSupported]
void LoadCache(ICacheEntryFilter<TK, TV> p, params object[] args);
/// <summary>
- /// Delegates to <see cref="ICacheStore.LoadCache" /> method to load state
- /// from the underlying persistent storage. The loaded values will then be given
- /// to the optionally passed in predicate, and, if the predicate returns true,
+ /// Executes <see cref="LocalLoadCache"/> on all cache nodes.
+ /// </summary>
+ /// <param name="p">
+ /// Optional predicate. If provided, will be used to filter values to be put into cache.
+ /// </param>
+ /// <param name="args">
+ /// Optional user arguments to be passed into <see cref="ICacheStore.LoadCache" />.
+ /// </param>
+ Task LoadCacheAsync(ICacheEntryFilter<TK, TV> p, params object[] args);
+
+ /// <summary>
+ /// Delegates to <see cref="ICacheStore.LoadCache" /> method to load state
+ /// from the underlying persistent storage. The loaded values will then be given
+ /// to the optionally passed in predicate, and, if the predicate returns true,
/// will be stored in cache. If predicate is null, then all loaded values will be stored in cache.
/// </summary>
/// <param name="p">
@@ -128,26 +138,51 @@ namespace Apache.Ignite.Core.Cache
/// <param name="args">
/// Optional user arguments to be passed into <see cref="ICacheStore.LoadCache" />.
/// </param>
- [AsyncSupported]
void LocalLoadCache(ICacheEntryFilter<TK, TV> p, params object[] args);
/// <summary>
+ /// Delegates to <see cref="ICacheStore.LoadCache" /> method to load state
+ /// from the underlying persistent storage. The loaded values will then be given
+ /// to the optionally passed in predicate, and, if the predicate returns true,
+ /// will be stored in cache. If predicate is null, then all loaded values will be stored in cache.
+ /// </summary>
+ /// <param name="p">
+ /// Optional predicate. If provided, will be used to filter values to be put into cache.
+ /// </param>
+ /// <param name="args">
+ /// Optional user arguments to be passed into <see cref="ICacheStore.LoadCache" />.
+ /// </param>
+ Task LocalLoadCacheAsync(ICacheEntryFilter<TK, TV> p, params object[] args);
+
+ /// <summary>
/// Check if cache contains mapping for this key.
/// </summary>
/// <param name="key">Key.</param>
/// <returns>True if cache contains mapping for this key.</returns>
- [AsyncSupported]
bool ContainsKey(TK key);
/// <summary>
+ /// Check if cache contains mapping for this key.
+ /// </summary>
+ /// <param name="key">Key.</param>
+ /// <returns>True if cache contains mapping for this key.</returns>
+ Task<bool> ContainsKeyAsync(TK key);
+
+ /// <summary>
/// Check if cache contains mapping for these keys.
/// </summary>
/// <param name="keys">Keys.</param>
/// <returns>True if cache contains mapping for all these keys.</returns>
- [AsyncSupported]
bool ContainsKeys(IEnumerable<TK> keys);
/// <summary>
+ /// Check if cache contains mapping for these keys.
+ /// </summary>
+ /// <param name="keys">Keys.</param>
+ /// <returns>True if cache contains mapping for all these keys.</returns>
+ Task<bool> ContainsKeysAsync(IEnumerable<TK> keys);
+
+ /// <summary>
/// Peeks at cached value using optional set of peek modes. This method will sequentially
/// iterate over given peek modes, and try to peek at value using each peek mode. Once a
/// non-null value is found, it will be immediately returned.
@@ -168,8 +203,8 @@ namespace Apache.Ignite.Core.Cache
/// value depending on the peek modes used.
/// </summary>
/// <param name="key">Key.</param>
- /// <param name="value">When this method returns, the value associated with the specified key,
- /// if the key is found; otherwise, the default value for the type of the value parameter.
+ /// <param name="value">When this method returns, the value associated with the specified key,
+ /// if the key is found; otherwise, the default value for the type of the value parameter.
/// This parameter is passed uninitialized.</param>
/// <param name="modes">Peek modes.</param>
/// <returns>
@@ -187,7 +222,7 @@ namespace Apache.Ignite.Core.Cache
/// <summary>
/// Retrieves value mapped to the specified key from cache. Throws an exception if t
- ///
+ ///
/// If the value is not present in cache, then it will be looked up from swap storage. If
/// it's not present in swap, or if swap is disable, and if read-through is allowed, value
/// will be loaded from persistent store.
@@ -196,10 +231,22 @@ namespace Apache.Ignite.Core.Cache
/// </summary>
/// <param name="key">Key.</param>
/// <returns>Value.</returns>
- [AsyncSupported]
TV Get(TK key);
/// <summary>
+ /// Retrieves value mapped to the specified key from cache. Throws an exception if t
+ ///
+ /// If the value is not present in cache, then it will be looked up from swap storage. If
+ /// it's not present in swap, or if swap is disable, and if read-through is allowed, value
+ /// will be loaded from persistent store.
+ /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+ /// If key is not present in cache, KeyNotFoundException will be thrown.
+ /// </summary>
+ /// <param name="key">Key.</param>
+ /// <returns>Value.</returns>
+ Task<TV> GetAsync(TK key);
+
+ /// <summary>
/// Retrieves value mapped to the specified key from cache.
/// If the value is not present in cache, then it will be looked up from swap storage. If
/// it's not present in swap, or if swap is disable, and if read-through is allowed, value
@@ -207,8 +254,8 @@ namespace Apache.Ignite.Core.Cache
/// This method is transactional and will enlist the entry into ongoing transaction if there is one.
/// </summary>
/// <param name="key">Key.</param>
- /// <param name="value">When this method returns, the value associated with the specified key,
- /// if the key is found; otherwise, the default value for the type of the value parameter.
+ /// <param name="value">When this method returns, the value associated with the specified key,
+ /// if the key is found; otherwise, the default value for the type of the value parameter.
/// This parameter is passed uninitialized.</param>
/// <returns>
/// true if the cache contains an element with the specified key; otherwise, false.
@@ -216,6 +263,19 @@ namespace Apache.Ignite.Core.Cache
bool TryGet(TK key, out TV value);
/// <summary>
+ /// Retrieves value mapped to the specified key from cache.
+ /// If the value is not present in cache, then it will be looked up from swap storage. If
+ /// it's not present in swap, or if swap is disable, and if read-through is allowed, value
+ /// will be loaded from persistent store.
+ /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+ /// </summary>
+ /// <param name="key">Key.</param>
+ /// <returns>
+ /// <see cref="CacheResult{T}"/> containing a bool success flag and a value.
+ /// </returns>
+ Task<CacheResult<TV>> TryGetAsync(TK key);
+
+ /// <summary>
/// Retrieves values mapped to the specified keys from cache.
/// If some value is not present in cache, then it will be looked up from swap storage. If
/// it's not present in swap, or if swap is disabled, and if read-through is allowed, value
@@ -224,21 +284,40 @@ namespace Apache.Ignite.Core.Cache
/// </summary>
/// <param name="keys">Keys.</param>
/// <returns>Map of key-value pairs.</returns>
- [AsyncSupported]
IDictionary<TK, TV> GetAll(IEnumerable<TK> keys);
/// <summary>
+ /// Retrieves values mapped to the specified keys from cache.
+ /// If some value is not present in cache, then it will be looked up from swap storage. If
+ /// it's not present in swap, or if swap is disabled, and if read-through is allowed, value
+ /// will be loaded from persistent store.
+ /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+ /// </summary>
+ /// <param name="keys">Keys.</param>
+ /// <returns>Map of key-value pairs.</returns>
+ Task<IDictionary<TK, TV>> GetAllAsync(IEnumerable<TK> keys);
+
+ /// <summary>
/// Associates the specified value with the specified key in the cache.
/// <para />
- /// If the cache previously contained a mapping for the key,
+ /// If the cache previously contained a mapping for the key,
/// the old value is replaced by the specified value.
/// </summary>
/// <param name="key">Key with which the specified value is to be associated.</param>
/// <param name="val">Value to be associated with the specified key.</param>
- [AsyncSupported]
void Put(TK key, TV val);
/// <summary>
+ /// Associates the specified value with the specified key in the cache.
+ /// <para />
+ /// If the cache previously contained a mapping for the key,
+ /// the old value is replaced by the specified value.
+ /// </summary>
+ /// <param name="key">Key with which the specified value is to be associated.</param>
+ /// <param name="val">Value to be associated with the specified key.</param>
+ Task PutAsync(TK key, TV val);
+
+ /// <summary>
/// Associates the specified value with the specified key in this cache,
/// returning an existing value if one existed.
/// </summary>
@@ -247,9 +326,19 @@ namespace Apache.Ignite.Core.Cache
/// <returns>
/// The value associated with the key at the start of the operation.
/// </returns>
- [AsyncSupported]
CacheResult<TV> GetAndPut(TK key, TV val);
-
+
+ /// <summary>
+ /// Associates the specified value with the specified key in this cache,
+ /// returning an existing value if one existed.
+ /// </summary>
+ /// <param name="key">Key with which the specified value is to be associated.</param>
+ /// <param name="val">Value to be associated with the specified key.</param>
+ /// <returns>
+ /// The value associated with the key at the start of the operation.
+ /// </returns>
+ Task<CacheResult<TV>> GetAndPutAsync(TK key, TV val);
+
/// <summary>
/// Atomically replaces the value for a given key if and only if there is a value currently mapped by the key.
/// </summary>
@@ -258,27 +347,49 @@ namespace Apache.Ignite.Core.Cache
/// <returns>
/// The previous value associated with the specified key.
/// </returns>
- [AsyncSupported]
CacheResult<TV> GetAndReplace(TK key, TV val);
/// <summary>
+ /// Atomically replaces the value for a given key if and only if there is a value currently mapped by the key.
+ /// </summary>
+ /// <param name="key">Key with which the specified value is to be associated.</param>
+ /// <param name="val">Value to be associated with the specified key.</param>
+ /// <returns>
+ /// The previous value associated with the specified key.
+ /// </returns>
+ Task<CacheResult<TV>> GetAndReplaceAsync(TK key, TV val);
+
+ /// <summary>
/// Atomically removes the entry for a key only if currently mapped to some value.
/// </summary>
/// <param name="key">Key with which the specified value is associated.</param>
/// <returns>The value if one existed.</returns>
- [AsyncSupported]
CacheResult<TV> GetAndRemove(TK key);
/// <summary>
+ /// Atomically removes the entry for a key only if currently mapped to some value.
+ /// </summary>
+ /// <param name="key">Key with which the specified value is associated.</param>
+ /// <returns>The value if one existed.</returns>
+ Task<CacheResult<TV>> GetAndRemoveAsync(TK key);
+
+ /// <summary>
/// Atomically associates the specified key with the given value if it is not already associated with a value.
/// </summary>
/// <param name="key">Key with which the specified value is to be associated.</param>
/// <param name="val">Value to be associated with the specified key.</param>
/// <returns>True if a value was set.</returns>
- [AsyncSupported]
bool PutIfAbsent(TK key, TV val);
/// <summary>
+ /// Atomically associates the specified key with the given value if it is not already associated with a value.
+ /// </summary>
+ /// <param name="key">Key with which the specified value is to be associated.</param>
+ /// <param name="val">Value to be associated with the specified key.</param>
+ /// <returns>True if a value was set.</returns>
+ Task<bool> PutIfAbsentAsync(TK key, TV val);
+
+ /// <summary>
/// Stores given key-value pair in cache only if cache had no previous mapping for it.
/// If cache previously contained value for the given key, then this value is returned.
/// In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
@@ -294,10 +405,27 @@ namespace Apache.Ignite.Core.Cache
/// <returns>
/// Previously contained value regardless of whether put happened or not.
/// </returns>
- [AsyncSupported]
CacheResult<TV> GetAndPutIfAbsent(TK key, TV val);
/// <summary>
+ /// Stores given key-value pair in cache only if cache had no previous mapping for it.
+ /// If cache previously contained value for the given key, then this value is returned.
+ /// In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
+ /// which in its turn may load the value from the swap storage, and consecutively, if it's not
+ /// in swap, from the underlying persistent storage.
+ /// If the returned value is not needed, method putxIfAbsent() should be used instead of this one to
+ /// avoid the overhead associated with returning of the previous value.
+ /// If write-through is enabled, the stored value will be persisted to store.
+ /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+ /// </summary>
+ /// <param name="key">Key to store in cache.</param>
+ /// <param name="val">Value to be associated with the given key.</param>
+ /// <returns>
+ /// Previously contained value regardless of whether put happened or not.
+ /// </returns>
+ Task<CacheResult<TV>> GetAndPutIfAbsentAsync(TK key, TV val);
+
+ /// <summary>
/// Stores given key-value pair in cache only if there is a previous mapping for it.
/// If cache previously contained value for the given key, then this value is returned.
/// In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
@@ -309,10 +437,23 @@ namespace Apache.Ignite.Core.Cache
/// <param name="key">Key to store in cache.</param>
/// <param name="val">Value to be associated with the given key.</param>
/// <returns>True if the value was replaced.</returns>
- [AsyncSupported]
bool Replace(TK key, TV val);
/// <summary>
+ /// Stores given key-value pair in cache only if there is a previous mapping for it.
+ /// If cache previously contained value for the given key, then this value is returned.
+ /// In case of PARTITIONED or REPLICATED caches, the value will be loaded from the primary node,
+ /// which in its turn may load the value from the swap storage, and consecutively, if it's not
+ /// in swap, rom the underlying persistent storage.
+ /// If write-through is enabled, the stored value will be persisted to store.
+ /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+ /// </summary>
+ /// <param name="key">Key to store in cache.</param>
+ /// <param name="val">Value to be associated with the given key.</param>
+ /// <returns>True if the value was replaced.</returns>
+ Task<bool> ReplaceAsync(TK key, TV val);
+
+ /// <summary>
/// Stores given key-value pair in cache only if only if the previous value is equal to the
/// old value passed as argument.
/// This method is transactional and will enlist the entry into ongoing transaction if there is one.
@@ -321,20 +462,37 @@ namespace Apache.Ignite.Core.Cache
/// <param name="oldVal">Old value to match.</param>
/// <param name="newVal">Value to be associated with the given key.</param>
/// <returns>True if replace happened, false otherwise.</returns>
- [AsyncSupported]
bool Replace(TK key, TV oldVal, TV newVal);
/// <summary>
+ /// Stores given key-value pair in cache only if only if the previous value is equal to the
+ /// old value passed as argument.
+ /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+ /// </summary>
+ /// <param name="key">Key to store in cache.</param>
+ /// <param name="oldVal">Old value to match.</param>
+ /// <param name="newVal">Value to be associated with the given key.</param>
+ /// <returns>True if replace happened, false otherwise.</returns>
+ Task<bool> ReplaceAsync(TK key, TV oldVal, TV newVal);
+
+ /// <summary>
/// Stores given key-value pairs in cache.
/// If write-through is enabled, the stored values will be persisted to store.
/// This method is transactional and will enlist the entry into ongoing transaction if there is one.
/// </summary>
/// <param name="vals">Key-value pairs to store in cache.</param>
- [AsyncSupported]
void PutAll(IDictionary<TK, TV> vals);
/// <summary>
- /// Attempts to evict all entries associated with keys. Note, that entry will be evicted only
+ /// Stores given key-value pairs in cache.
+ /// If write-through is enabled, the stored values will be persisted to store.
+ /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+ /// </summary>
+ /// <param name="vals">Key-value pairs to store in cache.</param>
+ Task PutAllAsync(IDictionary<TK, TV> vals);
+
+ /// <summary>
+ /// Attempts to evict all entries associated with keys. Note, that entry will be evicted only
/// if it's not used (not participating in any locks or transactions).
/// </summary>
/// <param name="keys">Keys to evict from cache.</param>
@@ -343,26 +501,42 @@ namespace Apache.Ignite.Core.Cache
/// <summary>
/// Clears the contents of the cache, without notifying listeners or CacheWriters.
/// </summary>
- [AsyncSupported]
void Clear();
/// <summary>
+ /// Clears the contents of the cache, without notifying listeners or CacheWriters.
+ /// </summary>
+ Task ClearAsync();
+
+ /// <summary>
/// Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
/// Entry is cleared only if it is not currently locked, and is not participating in a transaction.
/// </summary>
/// <param name="key">Key to clear.</param>
- [AsyncSupported]
void Clear(TK key);
/// <summary>
+ /// Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
+ /// Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+ /// </summary>
+ /// <param name="key">Key to clear.</param>
+ Task ClearAsync(TK key);
+
+ /// <summary>
/// Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
/// Entry is cleared only if it is not currently locked, and is not participating in a transaction.
/// </summary>
/// <param name="keys">Keys to clear.</param>
- [AsyncSupported]
void ClearAll(IEnumerable<TK> keys);
/// <summary>
+ /// Clear entries from the cache and swap storage, without notifying listeners or CacheWriters.
+ /// Entry is cleared only if it is not currently locked, and is not participating in a transaction.
+ /// </summary>
+ /// <param name="keys">Keys to clear.</param>
+ Task ClearAllAsync(IEnumerable<TK> keys);
+
+ /// <summary>
/// Clear entry from the cache and swap storage, without notifying listeners or CacheWriters.
/// Entry is cleared only if it is not currently locked, and is not participating in a transaction.
/// <para />
@@ -394,10 +568,23 @@ namespace Apache.Ignite.Core.Cache
/// </summary>
/// <param name="key">Key whose mapping is to be removed from cache.</param>
/// <returns>False if there was no matching key.</returns>
- [AsyncSupported]
bool Remove(TK key);
/// <summary>
+ /// Removes given key mapping from cache. If cache previously contained value for the given key,
+ /// then this value is returned. In case of PARTITIONED or REPLICATED caches, the value will be
+ /// loaded from the primary node, which in its turn may load the value from the disk-based swap
+ /// storage, and consecutively, if it's not in swap, from the underlying persistent storage.
+ /// If the returned value is not needed, method removex() should always be used instead of this
+ /// one to avoid the overhead associated with returning of the previous value.
+ /// If write-through is enabled, the value will be removed from store.
+ /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+ /// </summary>
+ /// <param name="key">Key whose mapping is to be removed from cache.</param>
+ /// <returns>False if there was no matching key.</returns>
+ Task<bool> RemoveAsync(TK key);
+
+ /// <summary>
/// Removes given key mapping from cache if one exists and value is equal to the passed in value.
/// If write-through is enabled, the value will be removed from store.
/// This method is transactional and will enlist the entry into ongoing transaction if there is one.
@@ -405,27 +592,49 @@ namespace Apache.Ignite.Core.Cache
/// <param name="key">Key whose mapping is to be removed from cache.</param>
/// <param name="val">Value to match against currently cached value.</param>
/// <returns>True if entry was removed, false otherwise.</returns>
- [AsyncSupported]
bool Remove(TK key, TV val);
/// <summary>
+ /// Removes given key mapping from cache if one exists and value is equal to the passed in value.
+ /// If write-through is enabled, the value will be removed from store.
+ /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+ /// </summary>
+ /// <param name="key">Key whose mapping is to be removed from cache.</param>
+ /// <param name="val">Value to match against currently cached value.</param>
+ /// <returns>True if entry was removed, false otherwise.</returns>
+ Task<bool> RemoveAsync(TK key, TV val);
+
+ /// <summary>
/// Removes given key mappings from cache.
/// If write-through is enabled, the value will be removed from store.
/// This method is transactional and will enlist the entry into ongoing transaction if there is one.
/// </summary>
/// <param name="keys">Keys whose mappings are to be removed from cache.</param>
- [AsyncSupported]
void RemoveAll(IEnumerable<TK> keys);
/// <summary>
+ /// Removes given key mappings from cache.
+ /// If write-through is enabled, the value will be removed from store.
+ /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+ /// </summary>
+ /// <param name="keys">Keys whose mappings are to be removed from cache.</param>
+ Task RemoveAllAsync(IEnumerable<TK> keys);
+
+ /// <summary>
/// Removes all mappings from cache.
/// If write-through is enabled, the value will be removed from store.
/// This method is transactional and will enlist the entry into ongoing transaction if there is one.
/// </summary>
- [AsyncSupported]
void RemoveAll();
/// <summary>
+ /// Removes all mappings from cache.
+ /// If write-through is enabled, the value will be removed from store.
+ /// This method is transactional and will enlist the entry into ongoing transaction if there is one.
+ /// </summary>
+ Task RemoveAllAsync();
+
+ /// <summary>
/// Gets the number of all entries cached on this node.
/// </summary>
/// <param name="modes">Optional peek modes. If not provided, then total cache size is returned.</param>
@@ -439,15 +648,23 @@ namespace Apache.Ignite.Core.Cache
/// </summary>
/// <param name="modes">Optional peek modes. If not provided, then total cache size is returned.</param>
/// <returns>Cache size across all nodes.</returns>
- [AsyncSupported]
int GetSize(params CachePeekMode[] modes);
/// <summary>
+ /// Gets the number of all entries cached across all nodes.
+ /// <para />
+ /// NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
+ /// </summary>
+ /// <param name="modes">Optional peek modes. If not provided, then total cache size is returned.</param>
+ /// <returns>Cache size across all nodes.</returns>
+ Task<int> GetSizeAsync(params CachePeekMode[] modes);
+
+ /// <summary>
/// This method unswaps cache entries by given keys, if any, from swap storage into memory.
/// </summary>
/// <param name="keys">Keys to promote entries for.</param>
void LocalPromote(IEnumerable<TK> keys);
-
+
/// <summary>
/// Queries cache.
/// </summary>
@@ -474,14 +691,14 @@ namespace Apache.Ignite.Core.Cache
/// </summary>
/// <param name="qry">Continuous query.</param>
/// <param name="initialQry">
- /// The initial query. This query will be executed before continuous listener is registered which allows
+ /// The initial query. This query will be executed before continuous listener is registered which allows
/// to iterate through entries which have already existed at the time continuous query is executed.
/// </param>
/// <returns>
/// Handle to get initial query cursor or stop query execution.
/// </returns>
IContinuousQueryHandle<ICacheEntry<TK, TV>> QueryContinuous(ContinuousQuery<TK, TV> qry, QueryBase initialQry);
-
+
/// <summary>
/// Get local cache entries.
/// </summary>
@@ -490,9 +707,9 @@ namespace Apache.Ignite.Core.Cache
IEnumerable<ICacheEntry<TK, TV>> GetLocalEntries(params CachePeekMode[] peekModes);
/// <summary>
- /// Invokes an <see cref="ICacheEntryProcessor{K, V, A, R}"/> against the
- /// <see cref="IMutableCacheEntry{K, V}"/> specified by the provided key.
- /// If an entry does not exist for the specified key, an attempt is made to load it (if a loader is configured)
+ /// Invokes an <see cref="ICacheEntryProcessor{K, V, A, R}"/> against the
+ /// <see cref="IMutableCacheEntry{K, V}"/> specified by the provided key.
+ /// If an entry does not exist for the specified key, an attempt is made to load it (if a loader is configured)
/// or a surrogate entry, consisting of the key with a null value is used instead.
/// </summary>
/// <typeparam name="TArg">The type of the argument.</typeparam>
@@ -502,17 +719,55 @@ namespace Apache.Ignite.Core.Cache
/// <param name="arg">The argument.</param>
/// <returns>Result of the processing.</returns>
/// <exception cref="CacheEntryProcessorException">If an exception has occured during processing.</exception>
- [AsyncSupported]
TRes Invoke<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg);
/// <summary>
+ /// Invokes an <see cref="ICacheEntryProcessor{K, V, A, R}"/> against the
+ /// <see cref="IMutableCacheEntry{K, V}"/> specified by the provided key.
+ /// If an entry does not exist for the specified key, an attempt is made to load it (if a loader is configured)
+ /// or a surrogate entry, consisting of the key with a null value is used instead.
+ /// </summary>
+ /// <typeparam name="TArg">The type of the argument.</typeparam>
+ /// <typeparam name="TRes">The type of the result.</typeparam>
+ /// <param name="key">The key.</param>
+ /// <param name="processor">The processor.</param>
+ /// <param name="arg">The argument.</param>
+ /// <returns>Result of the processing.</returns>
+ /// <exception cref="CacheEntryProcessorException">If an exception has occured during processing.</exception>
+ Task<TRes> InvokeAsync<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg);
+
+ /// <summary>
+ /// Invokes an <see cref="ICacheEntryProcessor{K, V, A, R}"/> against a set of keys.
+ /// If an entry does not exist for the specified key, an attempt is made to load it (if a loader is configured)
+ /// or a surrogate entry, consisting of the key with a null value is used instead.
+ ///
+ /// The order that the entries for the keys are processed is undefined.
+ /// Implementations may choose to process the entries in any order, including concurrently.
+ /// Furthermore there is no guarantee implementations will use the same processor instance
+ /// to process each entry, as the case may be in a non-local cache topology.
+ /// </summary>
+ /// <typeparam name="TArg">The type of the argument.</typeparam>
+ /// <typeparam name="TRes">The type of the result.</typeparam>
+ /// <param name="keys">The keys.</param>
+ /// <param name="processor">The processor.</param>
+ /// <param name="arg">The argument.</param>
+ /// <returns>
+ /// Map of <see cref="ICacheEntryProcessorResult{R}" /> of the processing per key, if any,
+ /// defined by the <see cref="ICacheEntryProcessor{K,V,A,R}"/> implementation.
+ /// No mappings will be returned for processors that return a null value for a key.
+ /// </returns>
+ /// <exception cref="CacheEntryProcessorException">If an exception has occured during processing.</exception>
+ IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
+ ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg);
+
+ /// <summary>
/// Invokes an <see cref="ICacheEntryProcessor{K, V, A, R}"/> against a set of keys.
- /// If an entry does not exist for the specified key, an attempt is made to load it (if a loader is configured)
+ /// If an entry does not exist for the specified key, an attempt is made to load it (if a loader is configured)
/// or a surrogate entry, consisting of the key with a null value is used instead.
- ///
- /// The order that the entries for the keys are processed is undefined.
+ ///
+ /// The order that the entries for the keys are processed is undefined.
/// Implementations may choose to process the entries in any order, including concurrently.
- /// Furthermore there is no guarantee implementations will use the same processor instance
+ /// Furthermore there is no guarantee implementations will use the same processor instance
/// to process each entry, as the case may be in a non-local cache topology.
/// </summary>
/// <typeparam name="TArg">The type of the argument.</typeparam>
@@ -521,13 +776,12 @@ namespace Apache.Ignite.Core.Cache
/// <param name="processor">The processor.</param>
/// <param name="arg">The argument.</param>
/// <returns>
- /// Map of <see cref="ICacheEntryProcessorResult{R}" /> of the processing per key, if any,
- /// defined by the <see cref="ICacheEntryProcessor{K,V,A,R}"/> implementation.
+ /// Map of <see cref="ICacheEntryProcessorResult{R}" /> of the processing per key, if any,
+ /// defined by the <see cref="ICacheEntryProcessor{K,V,A,R}"/> implementation.
/// No mappings will be returned for processors that return a null value for a key.
/// </returns>
/// <exception cref="CacheEntryProcessorException">If an exception has occured during processing.</exception>
- [AsyncSupported]
- IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
+ Task<IDictionary<TK, ICacheEntryProcessorResult<TRes>>> InvokeAllAsync<TArg, TRes>(IEnumerable<TK> keys,
ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg);
/// <summary>
@@ -554,7 +808,7 @@ namespace Apache.Ignite.Core.Cache
/// </summary>
/// <param name="key">Key to check.</param>
/// <param name="byCurrentThread">
- /// If true, checks that current thread owns a lock on this key;
+ /// If true, checks that current thread owns a lock on this key;
/// otherwise, checks that any thread on any node owns a lock on this key.
/// </param>
/// <returns>True if specified key is locked; otherwise, false.</returns>
@@ -569,17 +823,17 @@ namespace Apache.Ignite.Core.Cache
ICacheMetrics GetMetrics();
/// <summary>
- /// Rebalances cache partitions. This method is usually used when rebalanceDelay configuration parameter
- /// has non-zero value. When many nodes are started or stopped almost concurrently,
- /// it is more efficient to delay rebalancing until the node topology is stable to make sure that no redundant
+ /// Rebalances cache partitions. This method is usually used when rebalanceDelay configuration parameter
+ /// has non-zero value. When many nodes are started or stopped almost concurrently,
+ /// it is more efficient to delay rebalancing until the node topology is stable to make sure that no redundant
/// re-partitioning happens.
/// <para />
- /// In case of partitioned caches, for better efficiency user should usually make sure that new nodes get
+ /// In case of partitioned caches, for better efficiency user should usually make sure that new nodes get
/// placed on the same place of consistent hash ring as the left nodes, and that nodes are restarted before
/// rebalanceDelay expires.
/// </summary>
- /// <returns>Future that will be completed when rebalancing is finished.</returns>
- IFuture Rebalance();
+ /// <returns>Task that will be completed when rebalancing is finished.</returns>
+ Task Rebalance();
/// <summary>
/// Get another cache instance with no-retries behavior enabled.
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs
deleted file mode 100644
index 094a93c..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Common/AsyncSupportedAttribute.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Common
-{
- using System;
-
- /// <summary>
- /// Attribute to indicate that method can be executed asynchronously if async mode is enabled.
- /// To enable async mode, invoke <see cref="IAsyncSupport{TWithAsync}.WithAsync"/> method on the API.
- /// The future for the async method can be retrieved via
- /// <see cref="IFuture{T}"/> right after the execution of an asynchronous method.
- /// </summary>
- [AttributeUsage(AttributeTargets.Method)]
- public sealed class AsyncSupportedAttribute : Attribute
- {
- // No-op.
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.cs
deleted file mode 100644
index ee98c5a..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IAsyncSupport.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Common
-{
- /// <summary>
- /// Allows to enable asynchronous mode on Ignite APIs.
- /// </summary>
- /// <typeparam name="TWithAsync">Type of WithAsync method result.</typeparam>
- public interface IAsyncSupport<out TWithAsync> where TWithAsync : IAsyncSupport<TWithAsync>
- {
- /// <summary>
- /// Gets component with asynchronous mode enabled.
- /// </summary>
- /// <returns>Component with asynchronous mode enabled.</returns>
- TWithAsync WithAsync();
-
- /// <summary>
- /// Gets a value indicating whether this instance is in asynchronous mode.
- /// </summary>
- /// <value>
- /// <c>true</c> if asynchronous mode is enabled.
- /// </value>
- bool IsAsync { get; }
-
- /// <summary>
- /// Gets and resets future for previous asynchronous operation.
- /// </summary>
- /// <returns>Future for previous asynchronous operation.</returns>
- IFuture GetFuture();
-
- /// <summary>
- /// Gets and resets future for previous asynchronous operation.
- /// </summary>
- /// <returns>Future for previous asynchronous operation.</returns>
- IFuture<TResult> GetFuture<TResult>();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFuture.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFuture.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFuture.cs
deleted file mode 100644
index 2e94cd4..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFuture.cs
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Common
-{
- using System;
- using System.Threading.Tasks;
-
- /// <summary>
- /// Non-generic Future. Represents an asynchronous operation that can return a value.
- /// <para/>
- /// All members are thread-safe and may be used concurrently from multiple threads.
- /// </summary>
- public interface IFuture
- {
- /// <summary>
- /// Gets a value indicating whether this instance is done.
- /// </summary>
- bool IsDone
- {
- get;
- }
-
- /// <summary>
- /// Gets the future result.
- /// </summary>
- /// <returns>Future result.</returns>
- object Get();
-
- /// <summary>
- /// Gets the future result with a timeout.
- /// </summary>
- /// <param name="timeout">The timeout.</param>
- /// <returns>
- /// Future result, if it is obtained within specified timeout; otherwise, throws <see cref="TimeoutException"/>
- /// </returns>
- /// <exception cref="TimeoutException">Thrown if Get operation exceeded specified timeout.</exception>
- object Get(TimeSpan timeout);
-
- /// <summary>
- /// Listens this instance and invokes callback upon future completion.
- /// </summary>
- /// <param name="callback">The callback to execute upon future completion.</param>
- void Listen(Action callback);
-
- /// <summary>
- /// Listens this instance and invokes callback upon future completion.
- /// </summary>
- /// <param name="callback">The callback to execute upon future completion.</param>
- void Listen(Action<IFuture> callback);
-
- /// <summary>
- /// Gets an IAsyncResult indicating the state of this Future.
- /// </summary>
- /// <returns>Future state representation in form of IAsyncResult.</returns>
- IAsyncResult ToAsyncResult();
-
- /// <summary>
- /// Gets a Task that returns the result of this Future.
- /// </summary>
- /// <returns>Task that completes when this future gets done and returns the result.</returns>
- Task<object> ToTask();
- }
-
- /// <summary>
- /// Generic Future. Represents an asynchronous operation that can return a value.
- /// <para/>
- /// All members are thread-safe and may be used concurrently from multiple threads.
- /// </summary>
- /// <typeparam name="T">Future result type.</typeparam>
- public interface IFuture<T> : IFuture
- {
- /// <summary>
- /// Gets the future result.
- /// </summary>
- /// <returns>Future result.</returns>
- new T Get();
-
- /// <summary>
- /// Gets the future result with a timeout.
- /// </summary>
- /// <param name="timeout">The timeout.</param>
- /// <returns>
- /// Future result, if it is obtained within specified timeout; otherwise, throws <see cref="TimeoutException"/>
- /// </returns>
- /// <exception cref="TimeoutException">Thrown if Get operation exceeded specified timeout.</exception>
- new T Get(TimeSpan timeout);
-
- /// <summary>
- /// Gets a Task that returns the result of this Future.
- /// </summary>
- /// <returns>Task that completes when this future gets done and returns the result.</returns>
- new Task<T> ToTask();
-
- /// <summary>
- /// Listens this instance and invokes callback upon future completion.
- /// </summary>
- /// <param name="callback">The callback to execute upon future completion.</param>
- void Listen(Action<IFuture<T>> callback);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
index 367947a..db2ab51 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
@@ -79,7 +79,7 @@ namespace Apache.Ignite.Core.Compute
/// <summary>
/// Reduces (or aggregates) results received so far into one compound result to be returned to
- /// caller via future.
+ /// caller via task.
/// <para />
/// Note, that if some jobs did not succeed and could not be failed over then the list of
/// results passed into this method will include the failed results. Otherwise, failed
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
index 28471aa..ad7bbb5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ICompute.cs
@@ -19,8 +19,8 @@ namespace Apache.Ignite.Core.Compute
{
using System;
using System.Collections.Generic;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
/// <summary>
/// Defines Ignite functionality for executing tasks and closures over nodes
@@ -28,7 +28,7 @@ namespace Apache.Ignite.Core.Compute
/// is obtained from grid projection using <see cref="IClusterGroup.GetCompute"/> method.
/// <para />
/// Note that if attempt is made to execute a computation over an empty projection (i.e. projection that does
- /// not have any alive nodes), <c>ClusterGroupEmptyException</c> will be thrown out of result future.
+ /// not have any alive nodes), <c>ClusterGroupEmptyException</c> will be thrown out of result task.
/// <para />
/// Ignite must select a node for a computation to be executed. The node will be selected based on the
/// underlying <c>GridLoadBalancingSpi</c>, which by default sequentially picks next available node from
@@ -45,7 +45,7 @@ namespace Apache.Ignite.Core.Compute
/// <para/>
/// All members are thread-safe and may be used concurrently from multiple threads.
/// </summary>
- public interface ICompute : IAsyncSupport<ICompute>
+ public interface ICompute
{
/// <summary>
/// Grid projection to which this compute instance belongs.
@@ -88,6 +88,16 @@ namespace Apache.Ignite.Core.Compute
TRes ExecuteJavaTask<TRes>(string taskName, object taskArg);
/// <summary>
+ /// Executes given Java task on the grid projection. If task for given name has not been deployed yet,
+ /// then 'taskName' will be used as task class name to auto-deploy the task.
+ /// </summary>
+ /// <param name="taskName">Java task name</param>
+ /// <param name="taskArg">Optional argument of task execution, can be null.</param>
+ /// <returns>Task result.</returns>
+ /// <typeparam name="TRes">Type of task result.</typeparam>
+ Task<TRes> ExecuteJavaTaskAsync<TRes>(string taskName, object taskArg);
+
+ /// <summary>
/// Executes given task on the grid projection. For step-by-step explanation of task execution process
/// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
/// </summary>
@@ -97,9 +107,20 @@ namespace Apache.Ignite.Core.Compute
/// <typeparam name="TArg">Argument type.</typeparam>
/// <typeparam name="TJobRes">Type of job result.</typeparam>
/// <typeparam name="TRes">Type of final task result.</typeparam>
- [AsyncSupported]
TRes Execute<TArg, TJobRes, TRes>(IComputeTask<TArg, TJobRes, TRes> task, TArg taskArg);
-
+
+ /// <summary>
+ /// Executes given task on the grid projection. For step-by-step explanation of task execution process
+ /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
+ /// </summary>
+ /// <param name="task">Task to execute.</param>
+ /// <param name="taskArg">Optional task argument.</param>
+ /// <returns>Task result.</returns>
+ /// <typeparam name="TArg">Argument type.</typeparam>
+ /// <typeparam name="TJobRes">Type of job result.</typeparam>
+ /// <typeparam name="TRes">Type of final task result.</typeparam>
+ Task<TRes> ExecuteAsync<TArg, TJobRes, TRes>(IComputeTask<TArg, TJobRes, TRes> task, TArg taskArg);
+
/// <summary>
/// Executes given task on the grid projection. For step-by-step explanation of task execution process
/// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
@@ -108,22 +129,42 @@ namespace Apache.Ignite.Core.Compute
/// <returns>Task result.</returns>
/// <typeparam name="TJobRes">Type of job result.</typeparam>
/// <typeparam name="TRes">Type of reduce result.</typeparam>
- [AsyncSupported]
TRes Execute<TJobRes, TRes>(IComputeTask<TJobRes, TRes> task);
/// <summary>
/// Executes given task on the grid projection. For step-by-step explanation of task execution process
/// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
/// </summary>
+ /// <param name="task">Task to execute.</param>
+ /// <returns>Task result.</returns>
+ /// <typeparam name="TJobRes">Type of job result.</typeparam>
+ /// <typeparam name="TRes">Type of reduce result.</typeparam>
+ Task<TRes> ExecuteAsync<TJobRes, TRes>(IComputeTask<TJobRes, TRes> task);
+
+ /// <summary>
+ /// Executes given task on the grid projection. For step-by-step explanation of task execution process
+ /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
+ /// </summary>
/// <param name="taskType">Task type.</param>
/// <param name="taskArg">Optional task argument.</param>
/// <returns>Task result.</returns>
/// <typeparam name="TArg">Argument type.</typeparam>
/// <typeparam name="TJobRes">Type of job result.</typeparam>
/// <typeparam name="TRes">Type of reduce result.</typeparam>
- [AsyncSupported]
TRes Execute<TArg, TJobRes, TRes>(Type taskType, TArg taskArg);
-
+
+ /// <summary>
+ /// Executes given task on the grid projection. For step-by-step explanation of task execution process
+ /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
+ /// </summary>
+ /// <param name="taskType">Task type.</param>
+ /// <param name="taskArg">Optional task argument.</param>
+ /// <returns>Task result.</returns>
+ /// <typeparam name="TArg">Argument type.</typeparam>
+ /// <typeparam name="TJobRes">Type of job result.</typeparam>
+ /// <typeparam name="TRes">Type of reduce result.</typeparam>
+ Task<TRes> ExecuteAsync<TArg, TJobRes, TRes>(Type taskType, TArg taskArg);
+
/// <summary>
/// Executes given task on the grid projection. For step-by-step explanation of task execution process
/// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
@@ -132,21 +173,38 @@ namespace Apache.Ignite.Core.Compute
/// <returns>Task result.</returns>
/// <typeparam name="TJobRes">Type of job result.</typeparam>
/// <typeparam name="TRes">Type of reduce result.</typeparam>
- [AsyncSupported]
TRes Execute<TJobRes, TRes>(Type taskType);
/// <summary>
+ /// Executes given task on the grid projection. For step-by-step explanation of task execution process
+ /// refer to <see cref="IComputeTask{A,T,R}"/> documentation.
+ /// </summary>
+ /// <param name="taskType">Task type.</param>
+ /// <returns>Task result.</returns>
+ /// <typeparam name="TJobRes">Type of job result.</typeparam>
+ /// <typeparam name="TRes">Type of reduce result.</typeparam>
+ Task<TRes> ExecuteAsync<TJobRes, TRes>(Type taskType);
+
+ /// <summary>
/// Executes provided job on a node in this grid projection. The result of the
/// job execution is returned from the result closure.
/// </summary>
/// <param name="clo">Job to execute.</param>
/// <returns>Job result for this execution.</returns>
/// <typeparam name="TRes">Type of job result.</typeparam>
- [AsyncSupported]
TRes Call<TRes>(IComputeFunc<TRes> clo);
/// <summary>
- /// Executes given job on the node where data for provided affinity key is located
+ /// Executes provided job on a node in this grid projection. The result of the
+ /// job execution is returned from the result closure.
+ /// </summary>
+ /// <param name="clo">Job to execute.</param>
+ /// <returns>Job result for this execution.</returns>
+ /// <typeparam name="TRes">Type of job result.</typeparam>
+ Task<TRes> CallAsync<TRes>(IComputeFunc<TRes> clo);
+
+ /// <summary>
+ /// Executes given job on the node where data for provided affinity key is located
/// (a.k.a. affinity co-location).
/// </summary>
/// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
@@ -154,10 +212,20 @@ namespace Apache.Ignite.Core.Compute
/// <param name="clo">Job to execute.</param>
/// <returns>Job result for this execution.</returns>
/// <typeparam name="TRes">Type of job result.</typeparam>
- [AsyncSupported]
TRes AffinityCall<TRes>(string cacheName, object affinityKey, IComputeFunc<TRes> clo);
/// <summary>
+ /// Executes given job on the node where data for provided affinity key is located
+ /// (a.k.a. affinity co-location).
+ /// </summary>
+ /// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
+ /// <param name="affinityKey">Affinity key.</param>
+ /// <param name="clo">Job to execute.</param>
+ /// <returns>Job result for this execution.</returns>
+ /// <typeparam name="TRes">Type of job result.</typeparam>
+ Task<TRes> AffinityCallAsync<TRes>(string cacheName, object affinityKey, IComputeFunc<TRes> clo);
+
+ /// <summary>
/// Executes collection of jobs on nodes within this grid projection.
/// </summary>
/// <param name="clos">Collection of jobs to execute.</param>
@@ -165,28 +233,50 @@ namespace Apache.Ignite.Core.Compute
/// <returns>Reduced job result for this execution.</returns>
/// <typeparam name="TFuncRes">Type of function result.</typeparam>
/// <typeparam name="TRes">Type of result after reduce.</typeparam>
- [AsyncSupported]
- TRes Call<TFuncRes, TRes>(IEnumerable<IComputeFunc<TFuncRes>> clos,
+ TRes Call<TFuncRes, TRes>(IEnumerable<IComputeFunc<TFuncRes>> clos, IComputeReducer<TFuncRes, TRes> reducer);
+
+ /// <summary>
+ /// Executes collection of jobs on nodes within this grid projection.
+ /// </summary>
+ /// <param name="clos">Collection of jobs to execute.</param>
+ /// <param name="reducer">Reducer to reduce all job results into one individual return value.</param>
+ /// <returns>Reduced job result for this execution.</returns>
+ /// <typeparam name="TFuncRes">Type of function result.</typeparam>
+ /// <typeparam name="TRes">Type of result after reduce.</typeparam>
+ Task<TRes> CallAsync<TFuncRes, TRes>(IEnumerable<IComputeFunc<TFuncRes>> clos,
IComputeReducer<TFuncRes, TRes> reducer);
-
+
/// <summary>
/// Executes collection of jobs on nodes within this grid projection.
/// </summary>
/// <param name="clos">Collection of jobs to execute.</param>
/// <returns>Collection of job results for this execution.</returns>
/// <typeparam name="TRes">Type of job result.</typeparam>
- [AsyncSupported]
ICollection<TRes> Call<TRes>(IEnumerable<IComputeFunc<TRes>> clos);
/// <summary>
- /// Broadcasts given job to all nodes in grid projection. Every participating node will return a job result.
+ /// Executes collection of jobs on nodes within this grid projection.
+ /// </summary>
+ /// <param name="clos">Collection of jobs to execute.</param>
+ /// <returns>Collection of job results for this execution.</returns>
+ /// <typeparam name="TRes">Type of job result.</typeparam>
+ Task<ICollection<TRes>> CallAsync<TRes>(IEnumerable<IComputeFunc<TRes>> clos);
+
+ /// <summary>
+ /// Broadcasts given job to all nodes in grid projection. Every participating node will return a job result.
/// </summary>
/// <param name="clo">Job to broadcast to all projection nodes.</param>
/// <returns>Collection of results for this execution.</returns>
- [AsyncSupported]
ICollection<TRes> Broadcast<TRes>(IComputeFunc<TRes> clo);
/// <summary>
+ /// Broadcasts given job to all nodes in grid projection. Every participating node will return a job result.
+ /// </summary>
+ /// <param name="clo">Job to broadcast to all projection nodes.</param>
+ /// <returns>Collection of results for this execution.</returns>
+ Task<ICollection<TRes>> BroadcastAsync<TRes>(IComputeFunc<TRes> clo);
+
+ /// <summary>
/// Broadcasts given closure job with passed in argument to all nodes in grid projection.
/// Every participating node will return a job result.
/// </summary>
@@ -195,41 +285,74 @@ namespace Apache.Ignite.Core.Compute
/// <returns>Collection of results for this execution.</returns>
/// <typeparam name="TArg">Type of argument.</typeparam>
/// <typeparam name="TRes">Type of job result.</typeparam>
- [AsyncSupported]
ICollection<TRes> Broadcast<TArg, TRes>(IComputeFunc<TArg, TRes> clo, TArg arg);
/// <summary>
+ /// Broadcasts given closure job with passed in argument to all nodes in grid projection.
+ /// Every participating node will return a job result.
+ /// </summary>
+ /// <param name="clo">Job to broadcast to all projection nodes.</param>
+ /// <param name="arg">Job closure argument.</param>
+ /// <returns>Collection of results for this execution.</returns>
+ /// <typeparam name="TArg">Type of argument.</typeparam>
+ /// <typeparam name="TRes">Type of job result.</typeparam>
+ Task<ICollection<TRes>> BroadcastAsync<TArg, TRes>(IComputeFunc<TArg, TRes> clo, TArg arg);
+
+ /// <summary>
/// Broadcasts given job to all nodes in grid projection.
/// </summary>
/// <param name="action">Job to broadcast to all projection nodes.</param>
- [AsyncSupported]
void Broadcast(IComputeAction action);
/// <summary>
+ /// Broadcasts given job to all nodes in grid projection.
+ /// </summary>
+ /// <param name="action">Job to broadcast to all projection nodes.</param>
+ Task BroadcastAsync(IComputeAction action);
+
+ /// <summary>
/// Executes provided job on a node in this grid projection.
/// </summary>
/// <param name="action">Job to execute.</param>
- [AsyncSupported]
void Run(IComputeAction action);
/// <summary>
+ /// Executes provided job on a node in this grid projection.
+ /// </summary>
+ /// <param name="action">Job to execute.</param>
+ Task RunAsync(IComputeAction action);
+
+ /// <summary>
/// Executes given job on the node where data for provided affinity key is located
/// (a.k.a. affinity co-location).
/// </summary>
/// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
/// <param name="affinityKey">Affinity key.</param>
/// <param name="action">Job to execute.</param>
- [AsyncSupported]
void AffinityRun(string cacheName, object affinityKey, IComputeAction action);
/// <summary>
+ /// Executes given job on the node where data for provided affinity key is located
+ /// (a.k.a. affinity co-location).
+ /// </summary>
+ /// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
+ /// <param name="affinityKey">Affinity key.</param>
+ /// <param name="action">Job to execute.</param>
+ Task AffinityRunAsync(string cacheName, object affinityKey, IComputeAction action);
+
+ /// <summary>
/// Executes collection of jobs on Ignite nodes within this grid projection.
/// </summary>
/// <param name="actions">Jobs to execute.</param>
- [AsyncSupported]
void Run(IEnumerable<IComputeAction> actions);
/// <summary>
+ /// Executes collection of jobs on Ignite nodes within this grid projection.
+ /// </summary>
+ /// <param name="actions">Jobs to execute.</param>
+ Task RunAsync(IEnumerable<IComputeAction> actions);
+
+ /// <summary>
/// Executes provided closure job on a node in this grid projection.
/// </summary>
/// <param name="clo">Job to run.</param>
@@ -237,10 +360,19 @@ namespace Apache.Ignite.Core.Compute
/// <returns>Job result for this execution.</returns>
/// <typeparam name="TArg">Type of argument.</typeparam>
/// <typeparam name="TRes">Type of job result.</typeparam>
- [AsyncSupported]
TRes Apply<TArg, TRes>(IComputeFunc<TArg, TRes> clo, TArg arg);
/// <summary>
+ /// Executes provided closure job on a node in this grid projection.
+ /// </summary>
+ /// <param name="clo">Job to run.</param>
+ /// <param name="arg">Job argument.</param>
+ /// <returns>Job result for this execution.</returns>
+ /// <typeparam name="TArg">Type of argument.</typeparam>
+ /// <typeparam name="TRes">Type of job result.</typeparam>
+ Task<TRes> ApplyAsync<TArg, TRes>(IComputeFunc<TArg, TRes> clo, TArg arg);
+
+ /// <summary>
/// Executes provided closure job on nodes within this grid projection. A new job is executed for
/// every argument in the passed in collection. The number of actual job executions will be
/// equal to size of the job arguments collection.
@@ -250,12 +382,23 @@ namespace Apache.Ignite.Core.Compute
/// <returns>Сollection of job results.</returns>
/// <typeparam name="TArg">Type of argument.</typeparam>
/// <typeparam name="TRes">Type of job result.</typeparam>
- [AsyncSupported]
ICollection<TRes> Apply<TArg, TRes>(IComputeFunc<TArg, TRes> clo, IEnumerable<TArg> args);
/// <summary>
/// Executes provided closure job on nodes within this grid projection. A new job is executed for
/// every argument in the passed in collection. The number of actual job executions will be
+ /// equal to size of the job arguments collection.
+ /// </summary>
+ /// <param name="clo">Job to run.</param>
+ /// <param name="args">Job arguments.</param>
+ /// <returns>Сollection of job results.</returns>
+ /// <typeparam name="TArg">Type of argument.</typeparam>
+ /// <typeparam name="TRes">Type of job result.</typeparam>
+ Task<ICollection<TRes>> ApplyAsync<TArg, TRes>(IComputeFunc<TArg, TRes> clo, IEnumerable<TArg> args);
+
+ /// <summary>
+ /// Executes provided closure job on nodes within this grid projection. A new job is executed for
+ /// every argument in the passed in collection. The number of actual job executions will be
/// equal to size of the job arguments collection. The returned job results will be reduced
/// into an individual result by provided reducer.
/// </summary>
@@ -266,8 +409,23 @@ namespace Apache.Ignite.Core.Compute
/// <typeparam name="TArg">Type of argument.</typeparam>
/// <typeparam name="TFuncRes">Type of function result.</typeparam>
/// <typeparam name="TRes">Type of result after reduce.</typeparam>
- [AsyncSupported]
TRes Apply<TArg, TFuncRes, TRes>(IComputeFunc<TArg, TFuncRes> clo, IEnumerable<TArg> args,
IComputeReducer<TFuncRes, TRes> rdc);
+
+ /// <summary>
+ /// Executes provided closure job on nodes within this grid projection. A new job is executed for
+ /// every argument in the passed in collection. The number of actual job executions will be
+ /// equal to size of the job arguments collection. The returned job results will be reduced
+ /// into an individual result by provided reducer.
+ /// </summary>
+ /// <param name="clo">Job to run.</param>
+ /// <param name="args">Job arguments.</param>
+ /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
+ /// <returns>Reduced job result for this execution.</returns>
+ /// <typeparam name="TArg">Type of argument.</typeparam>
+ /// <typeparam name="TFuncRes">Type of function result.</typeparam>
+ /// <typeparam name="TRes">Type of result after reduce.</typeparam>
+ Task<TRes> ApplyAsync<TArg, TFuncRes, TRes>(IComputeFunc<TArg, TFuncRes> clo, IEnumerable<TArg> args,
+ IComputeReducer<TFuncRes, TRes> rdc);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
index 7677653..8c3136b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
@@ -66,7 +66,7 @@ namespace Apache.Ignite.Core.Compute
/// </item>
/// <item>
/// <description>Once all results are received or
- /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{TJobRes}, IList{IComputeJobResult{TJobRes}})"/>
+ /// <see cref="IComputeTask{A,T,R}.OnResult(IComputeJobResult{TJobRes}, IList{IComputeJobResult{TJobRes}})"/>
/// method returned <see cref="ComputeJobResultPolicy.Reduce"/> policy, method
/// <see cref="IComputeTask{A,T,R}.Reduce(IList{IComputeJobResult{TJobRes}})"/>
/// is called to aggregate received results into one final result. Once this method is finished the
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs
index 2713040..8c83b74 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/IDataStreamer.cs
@@ -19,8 +19,8 @@ namespace Apache.Ignite.Core.Datastream
{
using System;
using System.Collections.Generic;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Cache.Store;
- using Apache.Ignite.Core.Common;
/// <summary>
/// Data streamer is responsible for loading external data into cache. It achieves it by
@@ -130,10 +130,10 @@ namespace Apache.Ignite.Core.Datastream
long AutoFlushFrequency { get; set; }
/// <summary>
- /// Gets future for this loading process. This future completes whenever method
+ /// Gets the task for this loading process. This task completes whenever method
/// <see cref="IDataStreamer{K,V}.Close(bool)"/> completes.
/// </summary>
- IFuture Future { get; }
+ Task Task { get; }
/// <summary>
/// Gets or sets custom stream receiver.
@@ -146,30 +146,30 @@ namespace Apache.Ignite.Core.Datastream
/// </summary>
/// <param name="key">Key.</param>
/// <param name="val">Value.</param>
- /// <returns>Future for this operation.</returns>
- IFuture AddData(TK key, TV val);
+ /// <returns>Task for this operation.</returns>
+ Task AddData(TK key, TV val);
/// <summary>
/// Adds single key-value pair for loading. Passing <c>null</c> as pair's value will
/// be interpreted as removal.
/// </summary>
/// <param name="pair">Key-value pair.</param>
- /// <returns>Future for this operation.</returns>
- IFuture AddData(KeyValuePair<TK, TV> pair);
+ /// <returns>Task for this operation.</returns>
+ Task AddData(KeyValuePair<TK, TV> pair);
/// <summary>
/// Adds collection of key-value pairs for loading.
/// </summary>
/// <param name="entries">Entries.</param>
- /// <returns>Future for this operation.</returns>
- IFuture AddData(ICollection<KeyValuePair<TK, TV>> entries);
+ /// <returns>Task for this operation.</returns>
+ Task AddData(ICollection<KeyValuePair<TK, TV>> entries);
/// <summary>
/// Adds key for removal.
/// </summary>
/// <param name="key">Key.</param>
- /// <returns>Future for this operation.</returns>
- IFuture RemoveData(TK key);
+ /// <returns>Task for this operation.</returns>
+ Task RemoveData(TK key);
/// <summary>
/// Makes an attempt to load remaining data. This method is mostly similar to
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
index e8459c6..abaa9e7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/IEvents.cs
@@ -19,15 +19,15 @@ namespace Apache.Ignite.Core.Events
{
using System;
using System.Collections.Generic;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
/// <summary>
/// Provides functionality for event notifications on nodes defined by <see cref="ClusterGroup"/>.
/// <para/>
/// All members are thread-safe and may be used concurrently from multiple threads.
/// </summary>
- public interface IEvents : IAsyncSupport<IEvents>
+ public interface IEvents
{
/// <summary>
/// Gets the cluster group to which this instance belongs.
@@ -42,7 +42,6 @@ namespace Apache.Ignite.Core.Events
/// <param name="timeout">Maximum time to wait for result, null or 0 to wait forever.</param>
/// <param name="types">Event types to be queried.</param>
/// <returns>Collection of Ignite events returned from specified nodes.</returns>
- [AsyncSupported]
ICollection<T> RemoteQuery<T>(IEventFilter<T> filter, TimeSpan? timeout = null, params int[] types)
where T : IEvent;
@@ -54,17 +53,37 @@ namespace Apache.Ignite.Core.Events
/// <param name="timeout">Maximum time to wait for result, null or 0 to wait forever.</param>
/// <param name="types">Event types to be queried.</param>
/// <returns>Collection of Ignite events returned from specified nodes.</returns>
- [AsyncSupported]
+ Task<ICollection<T>> RemoteQueryAsync<T>(IEventFilter<T> filter, TimeSpan? timeout = null, params int[] types)
+ where T : IEvent;
+
+ /// <summary>
+ /// Queries nodes in this cluster group for events using passed in predicate filter for event selection.
+ /// </summary>
+ /// <typeparam name="T">Type of events.</typeparam>
+ /// <param name="filter">Predicate filter used to query events on remote nodes.</param>
+ /// <param name="timeout">Maximum time to wait for result, null or 0 to wait forever.</param>
+ /// <param name="types">Event types to be queried.</param>
+ /// <returns>Collection of Ignite events returned from specified nodes.</returns>
ICollection<T> RemoteQuery<T>(IEventFilter<T> filter, TimeSpan? timeout = null, IEnumerable<int> types = null)
where T : IEvent;
/// <summary>
+ /// Queries nodes in this cluster group for events using passed in predicate filter for event selection.
+ /// </summary>
+ /// <typeparam name="T">Type of events.</typeparam>
+ /// <param name="filter">Predicate filter used to query events on remote nodes.</param>
+ /// <param name="timeout">Maximum time to wait for result, null or 0 to wait forever.</param>
+ /// <param name="types">Event types to be queried.</param>
+ /// <returns>Collection of Ignite events returned from specified nodes.</returns>
+ Task<ICollection<T>> RemoteQueryAsync<T>(IEventFilter<T> filter, TimeSpan? timeout = null, IEnumerable<int> types = null)
+ where T : IEvent;
+
+ /// <summary>
/// Waits for the specified events.
/// </summary>
/// <param name="types">Types of the events to wait for.
/// If not provided, all events will be passed to the filter.</param>
/// <returns>Ignite event.</returns>
- [AsyncSupported]
IEvent WaitForLocal(params int[] types);
/// <summary>
@@ -73,18 +92,32 @@ namespace Apache.Ignite.Core.Events
/// <param name="types">Types of the events to wait for.
/// If not provided, all events will be passed to the filter.</param>
/// <returns>Ignite event.</returns>
- [AsyncSupported]
+ Task<IEvent> WaitForLocalAsync(params int[] types);
+
+ /// <summary>
+ /// Waits for the specified events.
+ /// </summary>
+ /// <param name="types">Types of the events to wait for.
+ /// If not provided, all events will be passed to the filter.</param>
+ /// <returns>Ignite event.</returns>
IEvent WaitForLocal(IEnumerable<int> types);
/// <summary>
/// Waits for the specified events.
/// </summary>
+ /// <param name="types">Types of the events to wait for.
+ /// If not provided, all events will be passed to the filter.</param>
+ /// <returns>Ignite event.</returns>
+ Task<IEvent> WaitForLocalAsync(IEnumerable<int> types);
+
+ /// <summary>
+ /// Waits for the specified events.
+ /// </summary>
/// <typeparam name="T">Type of events.</typeparam>
/// <param name="filter">Optional filtering predicate. Event wait will end as soon as it returns false.</param>
/// <param name="types">Types of the events to wait for.
/// If not provided, all events will be passed to the filter.</param>
/// <returns>Ignite event.</returns>
- [AsyncSupported]
T WaitForLocal<T>(IEventFilter<T> filter, params int[] types) where T : IEvent;
/// <summary>
@@ -95,10 +128,29 @@ namespace Apache.Ignite.Core.Events
/// <param name="types">Types of the events to wait for.
/// If not provided, all events will be passed to the filter.</param>
/// <returns>Ignite event.</returns>
- [AsyncSupported]
+ Task<T> WaitForLocalAsync<T>(IEventFilter<T> filter, params int[] types) where T : IEvent;
+
+ /// <summary>
+ /// Waits for the specified events.
+ /// </summary>
+ /// <typeparam name="T">Type of events.</typeparam>
+ /// <param name="filter">Optional filtering predicate. Event wait will end as soon as it returns false.</param>
+ /// <param name="types">Types of the events to wait for.
+ /// If not provided, all events will be passed to the filter.</param>
+ /// <returns>Ignite event.</returns>
T WaitForLocal<T>(IEventFilter<T> filter, IEnumerable<int> types) where T : IEvent;
/// <summary>
+ /// Waits for the specified events.
+ /// </summary>
+ /// <typeparam name="T">Type of events.</typeparam>
+ /// <param name="filter">Optional filtering predicate. Event wait will end as soon as it returns false.</param>
+ /// <param name="types">Types of the events to wait for.
+ /// If not provided, all events will be passed to the filter.</param>
+ /// <returns>Ignite event.</returns>
+ Task<T> WaitForLocalAsync<T>(IEventFilter<T> filter, IEnumerable<int> types) where T : IEvent;
+
+ /// <summary>
/// Queries local node for events using of specified types.
/// </summary>
/// <param name="types">Event types to be queried. Optional.</param>
[15/17] ignite git commit: IGNITE-1677: Signed .Net project.
Posted by ag...@apache.org.
IGNITE-1677: Signed .Net project.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/54c44b8c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/54c44b8c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/54c44b8c
Branch: refs/heads/ignite-950-new
Commit: 54c44b8c5dfe82853142a8bec0925d860697359b
Parents: cc1aa53
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Oct 27 17:48:39 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Oct 27 17:48:39 2015 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Benchmarks.csproj | 7 +++++++
.../Apache.Ignite.Benchmarks.snk | Bin 0 -> 596 bytes
.../Apache.Ignite.Core.Tests.TestDll.csproj | 9 +++++++++
.../Apache.Ignite.Core.Tests.TestDll.snk | Bin 0 -> 596 bytes
.../Apache.Ignite.Core.Tests.csproj | 9 +++++++++
.../Apache.Ignite.Core.Tests.snk | Bin 0 -> 596 bytes
.../Apache.Ignite.Core/Apache.Ignite.Core.csproj | 8 +++++---
.../dotnet/Apache.Ignite.Core/Apache.Ignite.Core.snk | Bin 0 -> 596 bytes
.../Apache.Ignite.Core/Properties/AssemblyInfo.cs | 4 ++--
.../dotnet/Apache.Ignite/Apache.Ignite.csproj | 7 +++++++
.../platforms/dotnet/Apache.Ignite/Apache.Ignite.snk | Bin 0 -> 596 bytes
.../Apache.Ignite.Examples.csproj | 7 +++++++
.../Apache.Ignite.Examples.snk | Bin 0 -> 596 bytes
.../Apache.Ignite.ExamplesDll.csproj | 9 +++++++++
.../Apache.Ignite.ExamplesDll.snk | Bin 0 -> 596 bytes
15 files changed, 55 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/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 26e4fff..99737b8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.csproj
@@ -33,6 +33,12 @@
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
</PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Apache.Ignite.Benchmarks.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -71,6 +77,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <None Include="Apache.Ignite.Benchmarks.snk" />
<None Include="App.config" />
<None Include="Config\benchmark.xml" />
</ItemGroup>
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.snk
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.snk b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.snk
new file mode 100644
index 0000000..886b6bb
Binary files /dev/null and b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Apache.Ignite.Benchmarks.snk differ
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj
index f213b34..c333bda 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.csproj
@@ -28,6 +28,12 @@
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
</PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Apache.Ignite.Core.Tests.TestDll.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -41,6 +47,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestClass.cs" />
</ItemGroup>
+ <ItemGroup>
+ <None Include="Apache.Ignite.Core.Tests.TestDll.snk" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.snk
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.snk b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.snk
new file mode 100644
index 0000000..10803d7
Binary files /dev/null and b/modules/platforms/dotnet/Apache.Ignite.Core.Tests.TestDll/Apache.Ignite.Core.Tests.TestDll.snk differ
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/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 7cbe784..10b3dcd 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
@@ -37,6 +37,12 @@
<OutputPath>bin\x86\Release\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Apache.Ignite.Core.Tests.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="nunit-console-runner">
@@ -234,6 +240,9 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
+ <ItemGroup>
+ <None Include="Apache.Ignite.Core.Tests.snk" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /Y $(SolutionDir)Apache.Ignite\bin\$(PlatformName)\$(ConfigurationName)\Apache.Ignite.exe $(ProjectDir)$(OutDir)
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.snk
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.snk b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.snk
new file mode 100644
index 0000000..ca659d6
Binary files /dev/null and b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.snk differ
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 5c2c6e7..e4450b6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -35,11 +35,10 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
- <SignAssembly>false</SignAssembly>
+ <SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
- <AssemblyOriginatorKeyFile>
- </AssemblyOriginatorKeyFile>
+ <AssemblyOriginatorKeyFile>Apache.Ignite.Core.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<DelaySign>false</DelaySign>
@@ -362,6 +361,9 @@
<Link>resources\release\x86\ignite.common.dll</Link>
</EmbeddedResource>
</ItemGroup>
+ <ItemGroup>
+ <None Include="Apache.Ignite.Core.snk" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.snk
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.snk b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.snk
new file mode 100644
index 0000000..799e742
Binary files /dev/null and b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.snk differ
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
index 6dd5706..c2f46b8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Properties/AssemblyInfo.cs
@@ -40,7 +40,7 @@ using System.Runtime.InteropServices;
#if !EXCLUDE_INTERNALS_VISIBLE_TO
-[assembly: InternalsVisibleTo("Apache.Ignite.Core.Tests")]
-[assembly: InternalsVisibleTo("Apache.Ignite.Benchmarks")]
+[assembly: InternalsVisibleTo("Apache.Ignite.Core.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a5bf8e0062a26bde53ccf0f8c42ef5b122a22052f99aecacb7028adcc163050324ee3c75ff40eb0cbe2d0426fa20eca03726cad90d7eb882ff47f5361567a82b676a27565f88b2479d7b9354ae0a1e526ee781b6e11de943d8f4a49efb53765f8c954022bede0fca86c133fab038af8dc88b67d6b6e5b9796d6ca490e699efab")]
+[assembly: InternalsVisibleTo("Apache.Ignite.Benchmarks, PublicKey=0024000004800000940000000602000000240000525341310004000001000100a3e0c1df4cbedbd4ed0e88808401c69b69ec12575ed1c056ac9f448e018fb29af19d236b7b03563aad66c48ab2045e72971ed098d4f65d4cdd38d65abcb39b4f84c626b22ccab2754375f0e8c97dc304fa146f0eddad5cc40a71803a8f15b0b0bb0bff0d4bf0ff6a64bb1044e0d71e6e2405b83fd4c1f7b3e2cfc2e9d50823d4")]
#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj b/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
index 0883660..a58a660 100644
--- a/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.csproj
@@ -28,6 +28,12 @@
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
</PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Apache.Ignite.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
@@ -59,6 +65,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <None Include="Apache.Ignite.snk" />
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.snk
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.snk b/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.snk
new file mode 100644
index 0000000..962d16a
Binary files /dev/null and b/modules/platforms/dotnet/Apache.Ignite/Apache.Ignite.snk differ
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
index ffa0de5..e28ab75 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.csproj
@@ -36,6 +36,12 @@
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Apache.Ignite.Examples.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="Apache.Ignite.Core">
<HintPath>..\..\Apache.Ignite\bin\$(Platform)\$(Configuration)\Apache.Ignite.Core.dll</HintPath>
@@ -67,6 +73,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <None Include="Apache.Ignite.Examples.snk" />
<None Include="App.config" />
</ItemGroup>
<ItemGroup />
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.snk
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.snk b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.snk
new file mode 100644
index 0000000..e1f913f
Binary files /dev/null and b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Apache.Ignite.Examples.snk differ
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
index 441e4e0..7b20fd5 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.csproj
@@ -33,6 +33,12 @@
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>Apache.Ignite.ExamplesDll.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
<ItemGroup>
<Reference Include="Apache.Ignite.Core">
<HintPath>..\..\Apache.Ignite\bin\$(Platform)\$(Configuration)\Apache.Ignite.Core.dll</HintPath>
@@ -62,6 +68,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\MapService.cs" />
</ItemGroup>
+ <ItemGroup>
+ <None Include="Apache.Ignite.ExamplesDll.snk" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
http://git-wip-us.apache.org/repos/asf/ignite/blob/54c44b8c/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.snk
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.snk b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.snk
new file mode 100644
index 0000000..7887c27
Binary files /dev/null and b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Apache.Ignite.ExamplesDll.snk differ
[09/17] ignite git commit: IGNITE-1644: Correct DateTime
serialization.
Posted by ag...@apache.org.
IGNITE-1644: Correct DateTime serialization.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/05e739f1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/05e739f1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/05e739f1
Branch: refs/heads/ignite-950-new
Commit: 05e739f1689cd801f669f3a668b5039ca0a7d653
Parents: 9d67c20
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Oct 27 13:50:29 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Oct 27 13:50:29 2015 +0300
----------------------------------------------------------------------
.../Portable/PortableApiSelfTest.cs | 60 ++-
.../Portable/PortableSelfTest.cs | 42 +-
.../Apache.Ignite.Core.csproj | 1 +
.../Impl/Portable/DateTimeHolder.cs | 68 +++
.../Impl/Portable/PortableBuilderField.cs | 56 ++-
.../Impl/Portable/PortableBuilderImpl.cs | 420 ++++++++++++++-----
.../Impl/Portable/PortableMarshaller.cs | 1 +
.../Impl/Portable/PortableReaderImpl.cs | 148 ++++---
.../Impl/Portable/PortableReflectiveRoutines.cs | 15 -
.../Impl/Portable/PortableSystemHandlers.cs | 94 ++++-
.../Impl/Portable/PortableUserObject.cs | 73 ++--
.../Impl/Portable/PortableUtils.cs | 19 +-
.../Impl/Portable/PortableWriterImpl.cs | 31 +-
.../Portable/IPortableBuilder.cs | 235 +++++++++++
14 files changed, 929 insertions(+), 334 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/05e739f1/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
index bb1cf06..c85c823 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
@@ -448,7 +448,7 @@ namespace Apache.Ignite.Core.Tests.Portable
IPortableBuilder builderItem =
_grid.GetPortables().GetBuilder(typeof(BuilderCollectionItem)).SetField("val", 1);
- builderCol.SetField<ICollection>("col", new ArrayList { builderItem });
+ builderCol.SetCollectionField("col", new ArrayList { builderItem });
IPortableObject portCol = builderCol.Build();
@@ -801,18 +801,18 @@ namespace Apache.Ignite.Core.Tests.Portable
[Test]
public void TestStringDateGuidEnum()
{
- DateTime? nDate = DateTime.Now.ToUniversalTime();
+ DateTime? nDate = DateTime.Now;
Guid? nGuid = Guid.NewGuid();
IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(StringDateGuidEnum))
.SetField("fStr", "str")
.SetField("fNDate", nDate)
- .SetField("fNGuid", nGuid)
+ .SetGuidField("fNGuid", nGuid)
.SetField("fEnum", TestEnum.One)
.SetField("fStrArr", new[] { "str" })
- .SetField("fDateArr", new[] { nDate })
- .SetField("fGuidArr", new[] { nGuid })
+ .SetArrayField("fDateArr", new[] { nDate })
+ .SetGuidArrayField("fGuidArr", new[] { nGuid })
.SetField("fEnumArr", new[] { TestEnum.One })
.SetHashCode(100)
.Build();
@@ -826,11 +826,11 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(8, meta.Fields.Count);
Assert.AreEqual(PortableTypeNames.TypeNameString, meta.GetFieldTypeName("fStr"));
- Assert.AreEqual(PortableTypeNames.TypeNameTimestamp, meta.GetFieldTypeName("fNDate"));
+ Assert.AreEqual(PortableTypeNames.TypeNameObject, meta.GetFieldTypeName("fNDate"));
Assert.AreEqual(PortableTypeNames.TypeNameGuid, meta.GetFieldTypeName("fNGuid"));
Assert.AreEqual(PortableTypeNames.TypeNameEnum, meta.GetFieldTypeName("fEnum"));
Assert.AreEqual(PortableTypeNames.TypeNameArrayString, meta.GetFieldTypeName("fStrArr"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayTimestamp, meta.GetFieldTypeName("fDateArr"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayObject, meta.GetFieldTypeName("fDateArr"));
Assert.AreEqual(PortableTypeNames.TypeNameArrayGuid, meta.GetFieldTypeName("fGuidArr"));
Assert.AreEqual(PortableTypeNames.TypeNameArrayEnum, meta.GetFieldTypeName("fEnumArr"));
@@ -854,18 +854,52 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
+ // Check builder field caching.
+ var builder = _grid.GetPortables().GetBuilder(portObj);
+
+ Assert.AreEqual("str", builder.GetField<string>("fStr"));
+ Assert.AreEqual(nDate, builder.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(nGuid, builder.GetField<Guid?>("fNGuid"));
+ Assert.AreEqual(TestEnum.One, builder.GetField<TestEnum>("fEnum"));
+ Assert.AreEqual(new[] { "str" }, builder.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] { nDate }, builder.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] { nGuid }, builder.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] { TestEnum.One }, builder.GetField<TestEnum[]>("fEnumArr"));
+
+ // Check reassemble.
+ portObj = builder.Build();
+
+ Assert.AreEqual("str", portObj.GetField<string>("fStr"));
+ Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
+ Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
+ Assert.AreEqual(TestEnum.One, portObj.GetField<TestEnum>("fEnum"));
+ Assert.AreEqual(new[] { "str" }, portObj.GetField<string[]>("fStrArr"));
+ Assert.AreEqual(new[] { nDate }, portObj.GetField<DateTime?[]>("fDateArr"));
+ Assert.AreEqual(new[] { nGuid }, portObj.GetField<Guid?[]>("fGuidArr"));
+ Assert.AreEqual(new[] { TestEnum.One }, portObj.GetField<TestEnum[]>("fEnumArr"));
+
+ obj = portObj.Deserialize<StringDateGuidEnum>();
+
+ Assert.AreEqual("str", obj.FStr);
+ Assert.AreEqual(nDate, obj.FnDate);
+ Assert.AreEqual(nGuid, obj.FnGuid);
+ Assert.AreEqual(TestEnum.One, obj.FEnum);
+ Assert.AreEqual(new[] { "str" }, obj.FStrArr);
+ Assert.AreEqual(new[] { nDate }, obj.FDateArr);
+ Assert.AreEqual(new[] { nGuid }, obj.FGuidArr);
+ Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
+
// Overwrite.
nDate = DateTime.Now.ToUniversalTime();
-
nGuid = Guid.NewGuid();
- portObj = _grid.GetPortables().GetBuilder(typeof(StringDateGuidEnum))
+ portObj = builder
.SetField("fStr", "str2")
- .SetField("fNDate", nDate)
+ .SetTimestampField("fNDate", nDate)
.SetField("fNGuid", nGuid)
.SetField("fEnum", TestEnum.Two)
.SetField("fStrArr", new[] { "str2" })
- .SetField("fDateArr", new[] { nDate })
+ .SetArrayField("fDateArr", new[] { nDate })
.SetField("fGuidArr", new[] { nGuid })
.SetField("fEnumArr", new[] { TestEnum.Two })
.SetHashCode(200)
@@ -1070,8 +1104,8 @@ namespace Apache.Ignite.Core.Tests.Portable
dict[3] = new CompositeInner(3);
IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(CompositeContainer)).SetHashCode(100)
- .SetField<ICollection>("col", col)
- .SetField("dict", dict).Build();
+ .SetCollectionField("col", col)
+ .SetDictionaryField("dict", dict).Build();
// 1. Check meta.
IPortableMetadata meta = portObj.GetMetadata();
http://git-wip-us.apache.org/repos/asf/ignite/blob/05e739f1/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
index 62d52f6..08e0b31 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
@@ -26,7 +26,6 @@ namespace Apache.Ignite.Core.Tests.Portable
using System.Collections;
using System.Collections.Generic;
using System.Linq;
- using System.Text;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Portable;
using Apache.Ignite.Core.Impl.Portable.IO;
@@ -529,6 +528,24 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(obj.UtcArrRaw, otherObj.UtcArrRaw);
}
+ /// <summary>
+ /// Tests the DateTime marshalling.
+ /// </summary>
+ [Test]
+ public void TestDateTime()
+ {
+ var time = DateTime.Now;
+ Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(time)), time);
+
+ var timeUtc = DateTime.UtcNow;
+ Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(timeUtc)), timeUtc);
+
+ // Check exception with non-UTC date
+ var stream = new PortableHeapStream(128);
+ var writer = _marsh.StartMarshal(stream);
+ Assert.Throws<InvalidOperationException>(() => writer.WriteTimestamp(DateTime.Now));
+ }
+
/**
* <summary>Check generic collections.</summary>
*/
@@ -1396,29 +1413,6 @@ namespace Apache.Ignite.Core.Tests.Portable
}
}
- private static string CollectionAsString(ICollection col)
- {
- if (col == null)
- return null;
- StringBuilder sb = new StringBuilder("[");
-
- bool first = true;
-
- foreach (object elem in col)
- {
- if (first)
- first = false;
- else
- sb.Append(", ");
-
- sb.Append(elem);
- }
-
- sb.Append("]");
-
- return sb.ToString();
- }
-
public class TestList : ArrayList
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/05e739f1/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index f314c99..04cbca1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -243,6 +243,7 @@
<Compile Include="Impl\Messaging\Messaging.cs" />
<Compile Include="Impl\Messaging\MessagingAsync.cs" />
<Compile Include="Impl\NativeMethods.cs" />
+ <Compile Include="Impl\Portable\DateTimeHolder.cs" />
<Compile Include="Impl\Portable\IO\IPortableStream.cs" />
<Compile Include="Impl\Portable\IO\PortableAbstractStream.cs" />
<Compile Include="Impl\Portable\IO\PortableHeapStream.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/05e739f1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/DateTimeHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/DateTimeHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/DateTimeHolder.cs
new file mode 100644
index 0000000..9c232a0
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/DateTimeHolder.cs
@@ -0,0 +1,68 @@
+/*
+ * 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.Impl.Portable
+{
+ using System;
+ using System.Diagnostics;
+ using Apache.Ignite.Core.Portable;
+
+ /// <summary>
+ /// Wraps Serializable item in a portable.
+ /// </summary>
+ internal class DateTimeHolder : IPortableWriteAware
+ {
+ /** */
+ private readonly DateTime _item;
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="item">The item to wrap.</param>
+ public DateTimeHolder(DateTime item)
+ {
+ _item = item;
+ }
+
+ /// <summary>
+ /// Constructor.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ public DateTimeHolder(IPortableReader reader)
+ {
+ Debug.Assert(reader != null);
+
+ _item = DateTime.FromBinary(reader.GetRawReader().ReadLong());
+ }
+
+ /// <summary>
+ /// Gets the item to wrap.
+ /// </summary>
+ public DateTime Item
+ {
+ get { return _item; }
+ }
+
+ /** <inheritDoc /> */
+ public void WritePortable(IPortableWriter writer)
+ {
+ Debug.Assert(writer != null);
+
+ writer.GetRawWriter().WriteLong(_item.ToBinary());
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/05e739f1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs
index 026d0d4..c54348d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderField.cs
@@ -24,28 +24,34 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
internal class PortableBuilderField
{
- /** Remove marker object. */
- public static readonly object RmvMarkerObj = new object();
-
/** Remove marker. */
- public static readonly PortableBuilderField RmvMarker =
- new PortableBuilderField(null, RmvMarkerObj);
+ public static readonly PortableBuilderField RmvMarker = new PortableBuilderField(null, null, 0);
/** Type. */
- private readonly Type _typ;
+ private readonly Type _type;
/** Value. */
- private readonly object _val;
+ private readonly object _value;
+
+ /** Write action. */
+ private readonly Action<PortableWriterImpl, object> _writeAction;
+
+ /** Type id. */
+ private readonly byte _typeId;
/// <summary>
/// Constructor.
/// </summary>
- /// <param name="typ">Type.</param>
- /// <param name="val">Value.</param>
- public PortableBuilderField(Type typ, object val)
+ /// <param name="type">Type.</param>
+ /// <param name="value">Value.</param>
+ /// <param name="typeId">The type identifier.</param>
+ /// <param name="writeAction">Optional write action.</param>
+ public PortableBuilderField(Type type, object value, byte typeId, Action<PortableWriterImpl, object> writeAction = null)
{
- _typ = typ;
- _val = val;
+ _type = type;
+ _value = value;
+ _typeId = typeId;
+ _writeAction = writeAction;
}
/// <summary>
@@ -53,10 +59,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
public Type Type
{
- get
- {
- return _typ;
- }
+ get { return _type; }
}
/// <summary>
@@ -64,10 +67,23 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
public object Value
{
- get
- {
- return _val;
- }
+ get { return _value; }
+ }
+
+ /// <summary>
+ /// Gets the write action.
+ /// </summary>
+ public Action<PortableWriterImpl, object> WriteAction
+ {
+ get { return _writeAction; }
+ }
+
+ /// <summary>
+ /// Gets the type identifier.
+ /// </summary>
+ public byte TypeId
+ {
+ get { return _typeId; }
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/05e739f1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
index ac7a957..9767037 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
@@ -20,7 +20,7 @@ namespace Apache.Ignite.Core.Impl.Portable
using System;
using System.Collections;
using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
+ using System.Diagnostics;
using System.IO;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Portable.IO;
@@ -32,11 +32,9 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
internal class PortableBuilderImpl : IPortableBuilder
{
- /** Type IDs for metadata. */
- private static readonly IDictionary<Type, int> TypeIds;
-
/** Cached dictionary with no values. */
- private static readonly IDictionary<int, object> EmptyVals = new Dictionary<int, object>();
+ private static readonly IDictionary<int, PortableBuilderField> EmptyVals =
+ new Dictionary<int, PortableBuilderField>();
/** Portables. */
private readonly PortablesImpl _portables;
@@ -54,55 +52,29 @@ namespace Apache.Ignite.Core.Impl.Portable
private IDictionary<string, PortableBuilderField> _vals;
/** Contextual fields. */
- private IDictionary<int, object> _cache;
+ private IDictionary<int, PortableBuilderField> _cache;
/** Hash code. */
private int _hashCode;
/** Current context. */
private Context _ctx;
-
- /// <summary>
- /// Static initializer.
- /// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")]
- static PortableBuilderImpl()
- {
- TypeIds = new Dictionary<Type, int>();
-
- // 1. Primitives.
- TypeIds[typeof(byte)] = PortableUtils.TypeByte;
- TypeIds[typeof(bool)] = PortableUtils.TypeBool;
- TypeIds[typeof(short)] = PortableUtils.TypeShort;
- TypeIds[typeof(char)] = PortableUtils.TypeChar;
- TypeIds[typeof(int)] = PortableUtils.TypeInt;
- TypeIds[typeof(long)] = PortableUtils.TypeLong;
- TypeIds[typeof(float)] = PortableUtils.TypeFloat;
- TypeIds[typeof(double)] = PortableUtils.TypeDouble;
- TypeIds[typeof(decimal)] = PortableUtils.TypeDecimal;
-
- TypeIds[typeof(byte[])] = PortableUtils.TypeArrayByte;
- TypeIds[typeof(bool[])] = PortableUtils.TypeArrayBool;
- TypeIds[typeof(short[])] = PortableUtils.TypeArrayShort;
- TypeIds[typeof(char[])] = PortableUtils.TypeArrayChar;
- TypeIds[typeof(int[])] = PortableUtils.TypeArrayInt;
- TypeIds[typeof(long[])] = PortableUtils.TypeArrayLong;
- TypeIds[typeof(float[])] = PortableUtils.TypeArrayFloat;
- TypeIds[typeof(double[])] = PortableUtils.TypeArrayDouble;
- TypeIds[typeof(decimal?[])] = PortableUtils.TypeArrayDecimal;
-
- // 2. String.
- TypeIds[typeof(string)] = PortableUtils.TypeString;
- TypeIds[typeof(string[])] = PortableUtils.TypeArrayString;
-
- // 3. Guid.
- TypeIds[typeof(Guid?)] = PortableUtils.TypeGuid;
- TypeIds[typeof(Guid?[])] = PortableUtils.TypeArrayGuid;
-
- // 4. Date.
- TypeIds[typeof(DateTime?)] = PortableUtils.TypeTimestamp;
- TypeIds[typeof(DateTime?[])] = PortableUtils.TypeArrayTimestamp;
- }
+
+ /** Write array action. */
+ private static readonly Action<PortableWriterImpl, object> WriteArrayAction =
+ (w, o) => w.WriteArrayInternal((Array) o);
+
+ /** Write collection action. */
+ private static readonly Action<PortableWriterImpl, object> WriteCollectionAction =
+ (w, o) => w.WriteCollection((ICollection) o);
+
+ /** Write timestamp action. */
+ private static readonly Action<PortableWriterImpl, object> WriteTimestampAction =
+ (w, o) => w.WriteTimestamp((DateTime?) o);
+
+ /** Write timestamp array action. */
+ private static readonly Action<PortableWriterImpl, object> WriteTimestampArrayAction =
+ (w, o) => w.WriteTimestampArray((DateTime?[])o);
/// <summary>
/// Constructor.
@@ -114,6 +86,10 @@ namespace Apache.Ignite.Core.Impl.Portable
public PortableBuilderImpl(PortablesImpl portables, PortableBuilderImpl parent,
PortableUserObject obj, IPortableTypeDescriptor desc)
{
+ Debug.Assert(portables != null);
+ Debug.Assert(obj != null);
+ Debug.Assert(desc != null);
+
_portables = portables;
_parent = parent ?? this;
_obj = obj;
@@ -136,22 +112,236 @@ namespace Apache.Ignite.Core.Impl.Portable
PortableBuilderField field;
if (_vals != null && _vals.TryGetValue(name, out field))
- return field != PortableBuilderField.RmvMarker ? (T)field.Value : default(T);
- T val = _obj.Field<T>(name, this);
+ return field != PortableBuilderField.RmvMarker ? (T) field.Value : default(T);
- if (_vals == null)
- _vals = new Dictionary<string, PortableBuilderField>(2);
+ int pos;
+
+ if (!_obj.TryGetFieldPosition(name, out pos))
+ return default(T);
+
+ T val;
+
+ if (TryGetCachedField(pos, out val))
+ return val;
- _vals[name] = new PortableBuilderField(typeof(T), val);
+ val = _obj.GetField<T>(pos, this);
+
+ var fld = CacheField(pos, val);
+
+ SetField0(name, fld);
return val;
}
/** <inheritDoc /> */
- public IPortableBuilder SetField<T>(string name, T val)
+ public IPortableBuilder SetField<T>(string fieldName, T val)
+ {
+ return SetField0(fieldName,
+ new PortableBuilderField(typeof (T), val, PortableSystemHandlers.GetTypeId(typeof (T))));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetArrayField<T>(string fieldName, T[] val)
+ {
+ return SetField0(fieldName,
+ new PortableBuilderField(typeof (T[]), val, PortableUtils.TypeArray, WriteArrayAction));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetBooleanField(string fieldName, bool val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (bool), val, PortableUtils.TypeBool,
+ (w, o) => w.WriteBoolean((bool) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetBooleanArrayField(string fieldName, bool[] val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (bool[]), val, PortableUtils.TypeArrayBool,
+ (w, o) => w.WriteBooleanArray((bool[]) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetByteField(string fieldName, byte val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (byte), val, PortableUtils.TypeByte,
+ (w, o) => w.WriteByte((byte) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetByteArrayField(string fieldName, byte[] val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (byte[]), val, PortableUtils.TypeArrayByte,
+ (w, o) => w.WriteByteArray((byte[]) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetCharField(string fieldName, char val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (char), val, PortableUtils.TypeChar,
+ (w, o) => w.WriteChar((char) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetCharArrayField(string fieldName, char[] val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (char[]), val, PortableUtils.TypeArrayChar,
+ (w, o) => w.WriteCharArray((char[]) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetCollectionField(string fieldName, ICollection val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (ICollection), val, PortableUtils.TypeCollection,
+ WriteCollectionAction));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetDecimalField(string fieldName, decimal? val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (decimal?), val, PortableUtils.TypeDecimal,
+ (w, o) => w.WriteDecimal((decimal?) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetDecimalArrayField(string fieldName, decimal?[] val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (decimal?[]), val, PortableUtils.TypeArrayDecimal,
+ (w, o) => w.WriteDecimalArray((decimal?[]) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetDictionaryField(string fieldName, IDictionary val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (IDictionary), val, PortableUtils.TypeDictionary,
+ (w, o) => w.WriteDictionary((IDictionary) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetDoubleField(string fieldName, double val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (double), val, PortableUtils.TypeDouble,
+ (w, o) => w.WriteDouble((double) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetDoubleArrayField(string fieldName, double[] val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (double[]), val, PortableUtils.TypeArrayDouble,
+ (w, o) => w.WriteDoubleArray((double[]) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetEnumField<T>(string fieldName, T val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (T), val, PortableUtils.TypeEnum,
+ (w, o) => w.WriteEnum((T) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetEnumArrayField<T>(string fieldName, T[] val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (T[]), val, PortableUtils.TypeArrayEnum,
+ (w, o) => w.WriteEnumArray((T[]) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetFloatField(string fieldName, float val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (float), val, PortableUtils.TypeFloat,
+ (w, o) => w.WriteFloat((float) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetFloatArrayField(string fieldName, float[] val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (float[]), val, PortableUtils.TypeArrayFloat,
+ (w, o) => w.WriteFloatArray((float[]) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetGuidField(string fieldName, Guid? val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (Guid?), val, PortableUtils.TypeGuid,
+ (w, o) => w.WriteGuid((Guid?) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetGuidArrayField(string fieldName, Guid?[] val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (Guid?[]), val, PortableUtils.TypeArrayGuid,
+ (w, o) => w.WriteGuidArray((Guid?[]) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetIntField(string fieldName, int val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (int), val, PortableUtils.TypeInt,
+ (w, o) => w.WriteInt((int) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetIntArrayField(string fieldName, int[] val)
{
- return SetField0(name, new PortableBuilderField(typeof(T), val));
+ return SetField0(fieldName, new PortableBuilderField(typeof (int[]), val, PortableUtils.TypeArrayInt,
+ (w, o) => w.WriteIntArray((int[]) o)));
}
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetLongField(string fieldName, long val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (long), val, PortableUtils.TypeLong,
+ (w, o) => w.WriteLong((long) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetLongArrayField(string fieldName, long[] val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (long[]), val, PortableUtils.TypeArrayLong,
+ (w, o) => w.WriteLongArray((long[]) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetShortField(string fieldName, short val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (short), val, PortableUtils.TypeShort,
+ (w, o) => w.WriteShort((short) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetShortArrayField(string fieldName, short[] val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (short[]), val, PortableUtils.TypeArrayShort,
+ (w, o) => w.WriteShortArray((short[]) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetStringField(string fieldName, string val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (string), val, PortableUtils.TypeString,
+ (w, o) => w.WriteString((string) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetStringArrayField(string fieldName, string[] val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (string[]), val, PortableUtils.TypeArrayString,
+ (w, o) => w.WriteStringArray((string[]) o)));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetTimestampField(string fieldName, DateTime? val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (DateTime?), val, PortableUtils.TypeTimestamp,
+ WriteTimestampAction));
+ }
+
+ /** <inheritDoc /> */
+ public IPortableBuilder SetTimestampArrayField(string fieldName, DateTime?[] val)
+ {
+ return SetField0(fieldName, new PortableBuilderField(typeof (DateTime?[]), val, PortableUtils.TypeArrayTimestamp,
+ WriteTimestampArrayAction));
+ }
/** <inheritDoc /> */
public IPortableBuilder RemoveField(string name)
@@ -215,15 +405,15 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="pos">Position.</param>
/// <param name="val">Value.</param>
/// <returns><c>true</c> if value is found in cache.</returns>
- public bool CachedField<T>(int pos, out T val)
+ public bool TryGetCachedField<T>(int pos, out T val)
{
if (_parent._cache != null)
{
- object res;
+ PortableBuilderField res;
if (_parent._cache.TryGetValue(pos, out res))
{
- val = res != null ? (T)res : default(T);
+ val = res != null ? (T) res.Value : default(T);
return true;
}
@@ -239,12 +429,46 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
/// <param name="pos">Position.</param>
/// <param name="val">Value.</param>
- public void CacheField(int pos, object val)
+ public PortableBuilderField CacheField<T>(int pos, T val)
{
if (_parent._cache == null)
- _parent._cache = new Dictionary<int, object>(2);
+ _parent._cache = new Dictionary<int, PortableBuilderField>(2);
+
+ var hdr = _obj.Data[pos];
+
+ var field = new PortableBuilderField(typeof(T), val, hdr, GetWriteAction(hdr));
+
+ _parent._cache[pos] = field;
+
+ return field;
+ }
+
+ /// <summary>
+ /// Gets the write action by header.
+ /// </summary>
+ /// <param name="header">The header.</param>
+ /// <returns>Write action.</returns>
+ private static Action<PortableWriterImpl, object> GetWriteAction(byte header)
+ {
+ // We need special actions for all cases where SetField(X) produces different result from SetSpecialField(X)
+ // Arrays, Collections, Dates
+
+ switch (header)
+ {
+ case PortableUtils.TypeArray:
+ return WriteArrayAction;
+
+ case PortableUtils.TypeCollection:
+ return WriteCollectionAction;
+
+ case PortableUtils.TypeTimestamp:
+ return WriteTimestampAction;
- _parent._cache[pos] = val;
+ case PortableUtils.TypeArrayTimestamp:
+ return WriteTimestampArrayAction;
+ }
+
+ return null;
}
/// <summary>
@@ -271,7 +495,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="desc">Portable type descriptor.</param>
/// <param name="hashCode">Hash code.</param>
/// <param name="vals">Values.</param>
- internal void Mutate(
+ private void Mutate(
PortableHeapStream inStream,
PortableHeapStream outStream,
IPortableTypeDescriptor desc,
@@ -288,13 +512,13 @@ namespace Apache.Ignite.Core.Impl.Portable
// Prepare fields.
IPortableMetadataHandler metaHnd = _portables.Marshaller.GetMetadataHandler(desc);
- IDictionary<int, object> vals0;
+ IDictionary<int, PortableBuilderField> vals0;
if (vals == null || vals.Count == 0)
vals0 = EmptyVals;
else
{
- vals0 = new Dictionary<int, object>(vals.Count);
+ vals0 = new Dictionary<int, PortableBuilderField>(vals.Count);
foreach (KeyValuePair<string, PortableBuilderField> valEntry in vals)
{
@@ -304,12 +528,12 @@ namespace Apache.Ignite.Core.Impl.Portable
throw new IgniteException("Collision in field ID detected (change field name or " +
"define custom ID mapper) [fieldName=" + valEntry.Key + ", fieldId=" + fieldId + ']');
- vals0[fieldId] = valEntry.Value.Value;
+ vals0[fieldId] = valEntry.Value;
// Write metadata if: 1) it is enabled for type; 2) type is not null (i.e. it is neither
// remove marker, nor a field read through "GetField" method.
if (metaHnd != null && valEntry.Value.Type != null)
- metaHnd.OnFieldWrite(fieldId, valEntry.Key, GetTypeId(valEntry.Value.Type));
+ metaHnd.OnFieldWrite(fieldId, valEntry.Key, valEntry.Value.TypeId);
}
}
@@ -345,7 +569,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="vals">Values to be replaced.</param>
/// <returns>Mutated object.</returns>
private void Mutate0(Context ctx, PortableHeapStream inStream, IPortableStream outStream,
- bool changeHash, int hash, IDictionary<int, object> vals)
+ bool changeHash, int hash, IDictionary<int, PortableBuilderField> vals)
{
int inStartPos = inStream.Position;
int outStartPos = outStream.Position;
@@ -394,10 +618,10 @@ namespace Apache.Ignite.Core.Impl.Portable
if (ctx.AddOldToNew(inStartPos, outStartPos, out hndPos))
{
// Object could be cached in parent builder.
- object cachedVal;
+ PortableBuilderField cachedVal;
if (_parent._cache != null && _parent._cache.TryGetValue(inStartPos, out cachedVal)) {
- ctx.Writer.Write(cachedVal);
+ WriteField(ctx, cachedVal);
}
else
{
@@ -418,11 +642,11 @@ namespace Apache.Ignite.Core.Impl.Portable
int inFieldLen = inStream.ReadInt();
int inFieldDataPos = inStream.Position;
- object fieldVal;
+ PortableBuilderField fieldVal;
bool fieldFound = vals.TryGetValue(inFieldId, out fieldVal);
- if (!fieldFound || fieldVal != PortableBuilderField.RmvMarkerObj)
+ if (!fieldFound || fieldVal != PortableBuilderField.RmvMarker)
{
outStream.WriteInt(inFieldId);
@@ -433,8 +657,8 @@ namespace Apache.Ignite.Core.Impl.Portable
if (fieldFound)
{
// Replace field with new value.
- if (fieldVal != PortableBuilderField.RmvMarkerObj)
- ctx.Writer.Write(fieldVal);
+ if (fieldVal != PortableBuilderField.RmvMarker)
+ WriteField(ctx, fieldVal);
vals.Remove(inFieldId);
}
@@ -442,9 +666,9 @@ namespace Apache.Ignite.Core.Impl.Portable
{
// If field was requested earlier, then we must write tracked value
if (_parent._cache != null && _parent._cache.TryGetValue(inFieldDataPos, out fieldVal))
- ctx.Writer.Write(fieldVal);
+ WriteField(ctx, fieldVal);
else
- // Filed is not tracked, re-write as is.
+ // Field is not tracked, re-write as is.
Mutate0(ctx, inStream, outStream, false, 0, EmptyVals);
}
@@ -460,9 +684,9 @@ namespace Apache.Ignite.Core.Impl.Portable
}
// Write remaining new fields.
- foreach (KeyValuePair<int, object> valEntry in vals)
+ foreach (var valEntry in vals)
{
- if (valEntry.Value != PortableBuilderField.RmvMarkerObj)
+ if (valEntry.Value != PortableBuilderField.RmvMarker)
{
outStream.WriteInt(valEntry.Key);
@@ -470,7 +694,7 @@ namespace Apache.Ignite.Core.Impl.Portable
outStream.Seek(4, SeekOrigin.Current);
- ctx.Writer.Write(valEntry.Value);
+ WriteField(ctx, valEntry.Value);
int fieldEndPos = outStream.Position;
@@ -518,6 +742,19 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/// <summary>
+ /// Writes the specified field.
+ /// </summary>
+ private static void WriteField(Context ctx, PortableBuilderField field)
+ {
+ var action = field.WriteAction;
+
+ if (action != null)
+ action(ctx.Writer, field.Value);
+ else
+ ctx.Writer.Write(field.Value);
+ }
+
+ /// <summary>
/// Process portable object inverting handles if needed.
/// </summary>
/// <param name="outStream">Output stream.</param>
@@ -740,33 +977,6 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/// <summary>
- /// Get's metadata field type ID for the given type.
- /// </summary>
- /// <param name="type">Type.</param>
- /// <returns>Type ID.</returns>
- private static int GetTypeId(Type type)
- {
- int typeId;
-
- if (TypeIds.TryGetValue(type, out typeId))
- return typeId;
-
- if (type.IsEnum)
- return PortableUtils.TypeEnum;
-
- if (type.IsArray)
- return type.GetElementType().IsEnum ? PortableUtils.TypeArrayEnum : PortableUtils.TypeArray;
-
- if (typeof (IDictionary).IsAssignableFrom(type))
- return PortableUtils.TypeDictionary;
-
- if (typeof (ICollection).IsAssignableFrom(type))
- return PortableUtils.TypeCollection;
-
- return PortableUtils.TypeObject;
- }
-
- /// <summary>
/// Transfer bytes from one stream to another.
/// </summary>
/// <param name="inStream">Input stream.</param>
http://git-wip-us.apache.org/repos/asf/ignite/blob/05e739f1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
index 2848df1..a8d7058 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
@@ -512,6 +512,7 @@ namespace Apache.Ignite.Core.Impl.Portable
AddSystemType(PortableUtils.TypeComputeActionJob, w => new ComputeActionJob(w));
AddSystemType(PortableUtils.TypeContinuousQueryRemoteFilterHolder, w => new ContinuousQueryFilterHolder(w));
AddSystemType(PortableUtils.TypeSerializableHolder, w => new SerializableObjectHolder(w));
+ AddSystemType(PortableUtils.TypeDateTimeHolder, w => new DateTimeHolder(w));
AddSystemType(PortableUtils.TypeCacheEntryProcessorHolder, w => new CacheEntryProcessorHolder(w));
AddSystemType(PortableUtils.TypeCacheEntryPredicateHolder, w => new CacheEntryFilterHolder(w));
AddSystemType(PortableUtils.TypeMessageListenerHolder, w => new MessageListenerHolder(w));
http://git-wip-us.apache.org/repos/asf/ignite/blob/05e739f1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
index 2d50499..422d628 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
@@ -109,7 +109,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public bool ReadBoolean(string fieldName)
{
- return ReadField(fieldName, r => r.ReadBoolean());
+ return ReadField(fieldName, r => r.ReadBoolean(), PortableUtils.TypeBool);
}
/** <inheritdoc /> */
@@ -121,19 +121,19 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public bool[] ReadBooleanArray(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadBooleanArray);
+ return ReadField(fieldName, PortableUtils.ReadBooleanArray, PortableUtils.TypeArrayBool);
}
/** <inheritdoc /> */
public bool[] ReadBooleanArray()
{
- return Read(PortableUtils.ReadBooleanArray);
+ return Read(PortableUtils.ReadBooleanArray, PortableUtils.TypeArrayBool);
}
/** <inheritdoc /> */
public byte ReadByte(string fieldName)
{
- return ReadField(fieldName, ReadByte);
+ return ReadField(fieldName, ReadByte, PortableUtils.TypeByte);
}
/** <inheritdoc /> */
@@ -145,19 +145,19 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public byte[] ReadByteArray(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadByteArray);
+ return ReadField(fieldName, PortableUtils.ReadByteArray, PortableUtils.TypeArrayByte);
}
/** <inheritdoc /> */
public byte[] ReadByteArray()
{
- return Read(PortableUtils.ReadByteArray);
+ return Read(PortableUtils.ReadByteArray, PortableUtils.TypeArrayByte);
}
/** <inheritdoc /> */
public short ReadShort(string fieldName)
{
- return ReadField(fieldName, ReadShort);
+ return ReadField(fieldName, ReadShort, PortableUtils.TypeShort);
}
/** <inheritdoc /> */
@@ -169,19 +169,19 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public short[] ReadShortArray(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadShortArray);
+ return ReadField(fieldName, PortableUtils.ReadShortArray, PortableUtils.TypeArrayShort);
}
/** <inheritdoc /> */
public short[] ReadShortArray()
{
- return Read(PortableUtils.ReadShortArray);
+ return Read(PortableUtils.ReadShortArray, PortableUtils.TypeArrayShort);
}
/** <inheritdoc /> */
public char ReadChar(string fieldName)
{
- return ReadField(fieldName, ReadChar);
+ return ReadField(fieldName, ReadChar, PortableUtils.TypeChar);
}
/** <inheritdoc /> */
@@ -193,19 +193,19 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public char[] ReadCharArray(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadCharArray);
+ return ReadField(fieldName, PortableUtils.ReadCharArray, PortableUtils.TypeArrayChar);
}
/** <inheritdoc /> */
public char[] ReadCharArray()
{
- return Read(PortableUtils.ReadCharArray);
+ return Read(PortableUtils.ReadCharArray, PortableUtils.TypeArrayChar);
}
/** <inheritdoc /> */
public int ReadInt(string fieldName)
{
- return ReadField(fieldName, ReadInt);
+ return ReadField(fieldName, ReadInt, PortableUtils.TypeInt);
}
/** <inheritdoc /> */
@@ -217,19 +217,19 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public int[] ReadIntArray(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadIntArray);
+ return ReadField(fieldName, PortableUtils.ReadIntArray, PortableUtils.TypeArrayInt);
}
/** <inheritdoc /> */
public int[] ReadIntArray()
{
- return Read(PortableUtils.ReadIntArray);
+ return Read(PortableUtils.ReadIntArray, PortableUtils.TypeArrayInt);
}
/** <inheritdoc /> */
public long ReadLong(string fieldName)
{
- return ReadField(fieldName, ReadLong);
+ return ReadField(fieldName, ReadLong, PortableUtils.TypeLong);
}
/** <inheritdoc /> */
@@ -241,19 +241,19 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public long[] ReadLongArray(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadLongArray);
+ return ReadField(fieldName, PortableUtils.ReadLongArray, PortableUtils.TypeArrayLong);
}
/** <inheritdoc /> */
public long[] ReadLongArray()
{
- return Read(PortableUtils.ReadLongArray);
+ return Read(PortableUtils.ReadLongArray, PortableUtils.TypeArrayLong);
}
/** <inheritdoc /> */
public float ReadFloat(string fieldName)
{
- return ReadField(fieldName, ReadFloat);
+ return ReadField(fieldName, ReadFloat, PortableUtils.TypeFloat);
}
/** <inheritdoc /> */
@@ -265,19 +265,19 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public float[] ReadFloatArray(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadFloatArray);
+ return ReadField(fieldName, PortableUtils.ReadFloatArray, PortableUtils.TypeArrayFloat);
}
/** <inheritdoc /> */
public float[] ReadFloatArray()
{
- return Read(PortableUtils.ReadFloatArray);
+ return Read(PortableUtils.ReadFloatArray, PortableUtils.TypeArrayFloat);
}
/** <inheritdoc /> */
public double ReadDouble(string fieldName)
{
- return ReadField(fieldName, ReadDouble);
+ return ReadField(fieldName, ReadDouble, PortableUtils.TypeDouble);
}
/** <inheritdoc /> */
@@ -289,133 +289,133 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public double[] ReadDoubleArray(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadDoubleArray);
+ return ReadField(fieldName, PortableUtils.ReadDoubleArray, PortableUtils.TypeArrayDouble);
}
/** <inheritdoc /> */
public double[] ReadDoubleArray()
{
- return Read(PortableUtils.ReadDoubleArray);
+ return Read(PortableUtils.ReadDoubleArray, PortableUtils.TypeArrayDouble);
}
/** <inheritdoc /> */
public decimal? ReadDecimal(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadDecimal);
+ return ReadField(fieldName, PortableUtils.ReadDecimal, PortableUtils.TypeDecimal);
}
/** <inheritdoc /> */
public decimal? ReadDecimal()
{
- return Read(PortableUtils.ReadDecimal);
+ return Read(PortableUtils.ReadDecimal, PortableUtils.TypeDecimal);
}
/** <inheritdoc /> */
public decimal?[] ReadDecimalArray(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadDecimalArray);
+ return ReadField(fieldName, PortableUtils.ReadDecimalArray, PortableUtils.TypeArrayDecimal);
}
/** <inheritdoc /> */
public decimal?[] ReadDecimalArray()
{
- return Read(PortableUtils.ReadDecimalArray);
+ return Read(PortableUtils.ReadDecimalArray, PortableUtils.TypeArrayDecimal);
}
/** <inheritdoc /> */
public DateTime? ReadTimestamp(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadTimestamp);
+ return ReadField(fieldName, PortableUtils.ReadTimestamp, PortableUtils.TypeTimestamp);
}
/** <inheritdoc /> */
public DateTime? ReadTimestamp()
{
- return Read(PortableUtils.ReadTimestamp);
+ return Read(PortableUtils.ReadTimestamp, PortableUtils.TypeTimestamp);
}
/** <inheritdoc /> */
public DateTime?[] ReadTimestampArray(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadTimestampArray);
+ return ReadField(fieldName, PortableUtils.ReadTimestampArray, PortableUtils.TypeArrayTimestamp);
}
/** <inheritdoc /> */
public DateTime?[] ReadTimestampArray()
{
- return Read(PortableUtils.ReadTimestampArray);
+ return Read(PortableUtils.ReadTimestampArray, PortableUtils.TypeArrayTimestamp);
}
/** <inheritdoc /> */
public string ReadString(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadString);
+ return ReadField(fieldName, PortableUtils.ReadString, PortableUtils.TypeString);
}
/** <inheritdoc /> */
public string ReadString()
{
- return Read(PortableUtils.ReadString);
+ return Read(PortableUtils.ReadString, PortableUtils.TypeString);
}
/** <inheritdoc /> */
public string[] ReadStringArray(string fieldName)
{
- return ReadField(fieldName, r => PortableUtils.ReadArray<string>(r, false));
+ return ReadField(fieldName, r => PortableUtils.ReadArray<string>(r, false), PortableUtils.TypeArrayString);
}
/** <inheritdoc /> */
public string[] ReadStringArray()
{
- return Read(r => PortableUtils.ReadArray<string>(r, false));
+ return Read(r => PortableUtils.ReadArray<string>(r, false), PortableUtils.TypeArrayString);
}
/** <inheritdoc /> */
public Guid? ReadGuid(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadGuid);
+ return ReadField(fieldName, PortableUtils.ReadGuid, PortableUtils.TypeGuid);
}
/** <inheritdoc /> */
public Guid? ReadGuid()
{
- return Read(PortableUtils.ReadGuid);
+ return Read(PortableUtils.ReadGuid, PortableUtils.TypeGuid);
}
/** <inheritdoc /> */
public Guid?[] ReadGuidArray(string fieldName)
{
- return ReadField(fieldName, r => PortableUtils.ReadArray<Guid?>(r, false));
+ return ReadField(fieldName, r => PortableUtils.ReadArray<Guid?>(r, false), PortableUtils.TypeArrayGuid);
}
/** <inheritdoc /> */
public Guid?[] ReadGuidArray()
{
- return Read(r => PortableUtils.ReadArray<Guid?>(r, false));
+ return Read(r => PortableUtils.ReadArray<Guid?>(r, false), PortableUtils.TypeArrayGuid);
}
/** <inheritdoc /> */
public T ReadEnum<T>(string fieldName)
{
- return ReadField(fieldName, PortableUtils.ReadEnum<T>);
+ return ReadField(fieldName, PortableUtils.ReadEnum<T>, PortableUtils.TypeEnum);
}
/** <inheritdoc /> */
public T ReadEnum<T>()
{
- return Read(PortableUtils.ReadEnum<T>);
+ return Read(PortableUtils.ReadEnum<T>, PortableUtils.TypeEnum);
}
/** <inheritdoc /> */
public T[] ReadEnumArray<T>(string fieldName)
{
- return ReadField(fieldName, r => PortableUtils.ReadArray<T>(r, true));
+ return ReadField(fieldName, r => PortableUtils.ReadArray<T>(r, true), PortableUtils.TypeArrayEnum);
}
/** <inheritdoc /> */
public T[] ReadEnumArray<T>()
{
- return Read(r => PortableUtils.ReadArray<T>(r, true));
+ return Read(r => PortableUtils.ReadArray<T>(r, true), PortableUtils.TypeArrayEnum);
}
/** <inheritdoc /> */
@@ -441,13 +441,13 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public T[] ReadArray<T>(string fieldName)
{
- return ReadField(fieldName, r => PortableUtils.ReadArray<T>(r, true));
+ return ReadField(fieldName, r => PortableUtils.ReadArray<T>(r, true), PortableUtils.TypeArray);
}
/** <inheritdoc /> */
public T[] ReadArray<T>()
{
- return Read(r => PortableUtils.ReadArray<T>(r, true));
+ return Read(r => PortableUtils.ReadArray<T>(r, true), PortableUtils.TypeArray);
}
/** <inheritdoc /> */
@@ -466,14 +466,14 @@ namespace Apache.Ignite.Core.Impl.Portable
public ICollection ReadCollection(string fieldName, PortableCollectionFactory factory,
PortableCollectionAdder adder)
{
- return ReadField(fieldName, r => PortableUtils.ReadCollection(r, factory, adder));
+ return ReadField(fieldName, r => PortableUtils.ReadCollection(r, factory, adder), PortableUtils.TypeCollection);
}
/** <inheritdoc /> */
public ICollection ReadCollection(PortableCollectionFactory factory,
PortableCollectionAdder adder)
{
- return Read(r => PortableUtils.ReadCollection(r, factory, adder));
+ return Read(r => PortableUtils.ReadCollection(r, factory, adder), PortableUtils.TypeCollection);
}
/** <inheritdoc /> */
@@ -491,13 +491,13 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public IDictionary ReadDictionary(string fieldName, PortableDictionaryFactory factory)
{
- return ReadField(fieldName, r => PortableUtils.ReadDictionary(r, factory));
+ return ReadField(fieldName, r => PortableUtils.ReadDictionary(r, factory), PortableUtils.TypeDictionary);
}
/** <inheritdoc /> */
public IDictionary ReadDictionary(PortableDictionaryFactory factory)
{
- return Read(r => PortableUtils.ReadDictionary(r, factory));
+ return Read(r => PortableUtils.ReadDictionary(r, factory), PortableUtils.TypeDictionary);
}
/// <summary>
@@ -716,9 +716,18 @@ namespace Apache.Ignite.Core.Impl.Portable
_curStruct = oldStruct;
_curRaw = oldRaw;
+ // Process wrappers. We could introduce a common interface, but for only 2 if-else is faster.
var wrappedSerializable = obj as SerializableObjectHolder;
- return wrappedSerializable != null ? (T) wrappedSerializable.Item : (T) obj;
+ if (wrappedSerializable != null)
+ return (T) wrappedSerializable.Item;
+
+ var wrappedDateTime = obj as DateTimeHolder;
+
+ if (wrappedDateTime != null)
+ return TypeCaster<T>.Cast(wrappedDateTime.Item);
+
+ return (T) obj;
}
}
finally
@@ -742,7 +751,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
object hndObj;
- if (_builder == null || !_builder.CachedField(hndPos, out hndObj))
+ if (_builder == null || !_builder.TryGetCachedField(hndPos, out hndObj))
{
if (_hnds == null || !_hnds.TryGetValue(hndPos, out hndObj))
{
@@ -861,17 +870,24 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <summary>
/// Determines whether header at current position is HDR_NULL.
/// </summary>
- private bool IsNullHeader()
+ private bool IsNotNullHeader(byte expHdr)
{
var hdr = ReadByte();
+
+ if (hdr == PortableUtils.HdrNull)
+ return false;
+
+ if (expHdr != hdr)
+ throw new PortableException(string.Format("Invalid header on deserialization. " +
+ "Expected: {0} but was: {1}", expHdr, hdr));
- return hdr != PortableUtils.HdrNull;
+ return true;
}
/// <summary>
/// Seeks the field by name, reads header and returns true if field is present and header is not null.
/// </summary>
- private bool SeekField(string fieldName)
+ private bool SeekField(string fieldName, byte expHdr)
{
if (_curRaw)
throw new PortableException("Cannot read named fields after raw data is read.");
@@ -881,47 +897,47 @@ namespace Apache.Ignite.Core.Impl.Portable
if (!SeekField(fieldId))
return false;
- return IsNullHeader();
+ return IsNotNullHeader(expHdr);
}
/// <summary>
/// Seeks specified field and invokes provided func.
/// </summary>
- private T ReadField<T>(string fieldName, Func<IPortableStream, T> readFunc)
+ private T ReadField<T>(string fieldName, Func<IPortableStream, T> readFunc, byte expHdr)
{
- return SeekField(fieldName) ? readFunc(Stream) : default(T);
+ return SeekField(fieldName, expHdr) ? readFunc(Stream) : default(T);
}
/// <summary>
/// Seeks specified field and invokes provided func.
/// </summary>
- private T ReadField<T>(string fieldName, Func<PortableReaderImpl, T> readFunc)
+ private T ReadField<T>(string fieldName, Func<PortableReaderImpl, T> readFunc, byte expHdr)
{
- return SeekField(fieldName) ? readFunc(this) : default(T);
+ return SeekField(fieldName, expHdr) ? readFunc(this) : default(T);
}
/// <summary>
/// Seeks specified field and invokes provided func.
/// </summary>
- private T ReadField<T>(string fieldName, Func<T> readFunc)
+ private T ReadField<T>(string fieldName, Func<T> readFunc, byte expHdr)
{
- return SeekField(fieldName) ? readFunc() : default(T);
+ return SeekField(fieldName, expHdr) ? readFunc() : default(T);
}
/// <summary>
/// Reads header and invokes specified func if the header is not null.
/// </summary>
- private T Read<T>(Func<PortableReaderImpl, T> readFunc)
+ private T Read<T>(Func<PortableReaderImpl, T> readFunc, byte expHdr)
{
- return IsNullHeader() ? readFunc(this) : default(T);
+ return IsNotNullHeader(expHdr) ? readFunc(this) : default(T);
}
/// <summary>
/// Reads header and invokes specified func if the header is not null.
/// </summary>
- private T Read<T>(Func<IPortableStream, T> readFunc)
+ private T Read<T>(Func<IPortableStream, T> readFunc, byte expHdr)
{
- return IsNullHeader() ? readFunc(Stream) : default(T);
+ return IsNotNullHeader(expHdr) ? readFunc(Stream) : default(T);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/05e739f1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
index d79cc0b..4aff797 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
@@ -254,11 +254,6 @@ namespace Apache.Ignite.Core.Impl.Portable
writeAction = GetWriter<Guid?[]>(field, (f, w, o) => w.WriteGuidArray(f, o));
readAction = GetReader(field, (f, r) => r.ReadGuidArray(f));
}
- else if (elemType == typeof(DateTime?))
- {
- writeAction = GetWriter<DateTime?[]>(field, (f, w, o) => w.WriteTimestampArray(f, o));
- readAction = GetReader(field, (f, r) => r.ReadTimestampArray(f));
- }
else if (elemType.IsEnum)
{
writeAction = GetWriter(field, MthdWriteEnumArray, elemType);
@@ -308,16 +303,6 @@ namespace Apache.Ignite.Core.Impl.Portable
writeAction = GetWriter<Guid?>(field, (f, w, o) => w.WriteGuid(f, o));
readAction = GetReader(field, (f, r) => r.ReadGuid(f));
}
- else if (type == typeof(DateTime))
- {
- writeAction = GetWriter<DateTime>(field, (f, w, o) => w.WriteTimestamp(f, o));
- readAction = GetReader(field, (f, r) => r.ReadTimestamp(f));
- }
- else if (nullable && nullableType == typeof(DateTime))
- {
- writeAction = GetWriter<DateTime?>(field, (f, w, o) => w.WriteTimestamp(f, o));
- readAction = GetReader(field, (f, r) => r.ReadTimestamp(f));
- }
else if (type.IsEnum)
{
writeAction = GetWriter<object>(field, (f, w, o) => w.WriteEnum(f, o), true);
http://git-wip-us.apache.org/repos/asf/ignite/blob/05e739f1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
index ed2e9ea..dabe5c8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
@@ -42,10 +42,50 @@ namespace Apache.Ignite.Core.Impl.Portable
new Dictionary<Type, PortableSystemWriteDelegate>();
/** Mutex for write handlers update. */
- private static readonly Object WriteHandlersMux = new Object();
+ private static readonly object WriteHandlersMux = new object();
/** Read handlers. */
private static readonly IPortableSystemReader[] ReadHandlers = new IPortableSystemReader[255];
+
+ /** Type ids. */
+ private static readonly Dictionary<Type, byte> TypeIds = new Dictionary<Type, byte>
+ {
+ {typeof (bool), PortableUtils.TypeBool},
+ {typeof (byte), PortableUtils.TypeByte},
+ {typeof (sbyte), PortableUtils.TypeByte},
+ {typeof (short), PortableUtils.TypeShort},
+ {typeof (ushort), PortableUtils.TypeShort},
+ {typeof (char), PortableUtils.TypeChar},
+ {typeof (int), PortableUtils.TypeInt},
+ {typeof (uint), PortableUtils.TypeInt},
+ {typeof (long), PortableUtils.TypeLong},
+ {typeof (ulong), PortableUtils.TypeLong},
+ {typeof (float), PortableUtils.TypeFloat},
+ {typeof (double), PortableUtils.TypeDouble},
+ {typeof (string), PortableUtils.TypeString},
+ {typeof (decimal), PortableUtils.TypeDecimal},
+ {typeof (Guid), PortableUtils.TypeGuid},
+ {typeof (Guid?), PortableUtils.TypeGuid},
+ {typeof (ArrayList), PortableUtils.TypeCollection},
+ {typeof (Hashtable), PortableUtils.TypeDictionary},
+ {typeof (DictionaryEntry), PortableUtils.TypeMapEntry},
+ {typeof (bool[]), PortableUtils.TypeArrayBool},
+ {typeof (byte[]), PortableUtils.TypeArrayByte},
+ {typeof (sbyte[]), PortableUtils.TypeArrayByte},
+ {typeof (short[]), PortableUtils.TypeArrayShort},
+ {typeof (ushort[]), PortableUtils.TypeArrayShort},
+ {typeof (char[]), PortableUtils.TypeArrayChar},
+ {typeof (int[]), PortableUtils.TypeArrayInt},
+ {typeof (uint[]), PortableUtils.TypeArrayInt},
+ {typeof (long[]), PortableUtils.TypeArrayLong},
+ {typeof (ulong[]), PortableUtils.TypeArrayLong},
+ {typeof (float[]), PortableUtils.TypeArrayFloat},
+ {typeof (double[]), PortableUtils.TypeArrayDouble},
+ {typeof (string[]), PortableUtils.TypeArrayString},
+ {typeof (decimal?[]), PortableUtils.TypeArrayDecimal},
+ {typeof (Guid?[]), PortableUtils.TypeArrayGuid},
+ {typeof (object[]), PortableUtils.TypeArray}
+ };
/// <summary>
/// Initializes the <see cref="PortableSystemHandlers"/> class.
@@ -214,8 +254,6 @@ namespace Apache.Ignite.Core.Impl.Portable
return WriteDecimalArray;
if (elemType == typeof(string))
return WriteStringArray;
- if (elemType == typeof(DateTime?))
- return WriteTimestampArray;
if (elemType == typeof(Guid?))
return WriteGuidArray;
// Enums.
@@ -231,10 +269,34 @@ namespace Apache.Ignite.Core.Impl.Portable
// We know how to write enums.
return WriteEnum;
+ if (type.IsSerializable)
+ return WriteSerializable;
+
return null;
}
/// <summary>
+ /// Find write handler for type.
+ /// </summary>
+ /// <param name="type">Type.</param>
+ /// <returns>Write handler or NULL.</returns>
+ public static byte GetTypeId(Type type)
+ {
+ byte res;
+
+ if (TypeIds.TryGetValue(type, out res))
+ return res;
+
+ if (type.IsEnum)
+ return PortableUtils.TypeEnum;
+
+ if (type.IsArray && type.GetElementType().IsEnum)
+ return PortableUtils.TypeArrayEnum;
+
+ return PortableUtils.TypeObject;
+ }
+
+ /// <summary>
/// Add write handler for type.
/// </summary>
/// <param name="type"></param>
@@ -295,9 +357,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="obj">Value.</param>
private static void WriteDate(PortableWriterImpl ctx, object obj)
{
- ctx.Stream.WriteByte(PortableUtils.TypeTimestamp);
-
- PortableUtils.WriteTimestamp((DateTime)obj, ctx.Stream);
+ ctx.Write(new DateTimeHolder((DateTime) obj));
}
/// <summary>
@@ -481,18 +541,6 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/// <summary>
- /// Write nullable date array.
- /// </summary>
- /// <param name="ctx">Context.</param>
- /// <param name="obj">Value.</param>
- private static void WriteTimestampArray(PortableWriterImpl ctx, object obj)
- {
- ctx.Stream.WriteByte(PortableUtils.TypeArrayTimestamp);
-
- PortableUtils.WriteTimestampArray((DateTime?[])obj, ctx.Stream);
- }
-
- /// <summary>
/// Write string array.
/// </summary>
/// <param name="ctx">Context.</param>
@@ -586,6 +634,16 @@ namespace Apache.Ignite.Core.Impl.Portable
PortableUtils.WriteEnum(ctx.Stream, (Enum)obj);
}
+ /// <summary>
+ /// Writes serializable.
+ /// </summary>
+ /// <param name="writer">The writer.</param>
+ /// <param name="o">The object.</param>
+ private static void WriteSerializable(PortableWriterImpl writer, object o)
+ {
+ writer.Write(new SerializableObjectHolder(o));
+ }
+
/**
* <summary>Read enum array.</summary>
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/05e739f1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
index 9df180d..c241b96 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUserObject.cs
@@ -80,7 +80,24 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public T GetField<T>(string fieldName)
{
- return Field<T>(fieldName, null);
+ int pos;
+
+ return TryGetFieldPosition(fieldName, out pos) ? GetField<T>(pos, null) : default(T);
+ }
+
+ /// <summary>
+ /// Gets field value on the given object.
+ /// </summary>
+ /// <param name="pos">Position.</param>
+ /// <param name="builder">Builder.</param>
+ /// <returns>Field value.</returns>
+ public T GetField<T>(int pos, PortableBuilderImpl builder)
+ {
+ IPortableStream stream = new PortableHeapStream(_data);
+
+ stream.Seek(pos, SeekOrigin.Begin);
+
+ return _marsh.Unmarshal<T>(stream, PortableMode.ForcePortable, builder);
}
/** <inheritdoc /> */
@@ -139,42 +156,15 @@ namespace Apache.Ignite.Core.Impl.Portable
get { return _offset; }
}
- /// <summary>
- /// Get field with builder.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="fieldName"></param>
- /// <param name="builder"></param>
- /// <returns></returns>
- public T Field<T>(string fieldName, PortableBuilderImpl builder)
+ public bool TryGetFieldPosition(string fieldName, out int pos)
{
- IPortableTypeDescriptor desc = _marsh.GetDescriptor(true, _typeId);
+ var desc = _marsh.GetDescriptor(true, _typeId);
InitializeFields();
int fieldId = PortableUtils.FieldId(_typeId, fieldName, desc.NameConverter, desc.Mapper);
- int pos;
-
- if (_fields.TryGetValue(fieldId, out pos))
- {
- if (builder != null)
- {
- // Read in scope of build process.
- T res;
-
- if (!builder.CachedField(pos, out res))
- {
- res = Field0<T>(pos, builder);
-
- builder.CacheField(pos, res);
- }
-
- return res;
- }
- return Field0<T>(pos, null);
- }
- return default(T);
+ return _fields.TryGetValue(fieldId, out pos);
}
/// <summary>
@@ -194,21 +184,6 @@ namespace Apache.Ignite.Core.Impl.Portable
}
}
- /// <summary>
- /// Gets field value on the given object.
- /// </summary>
- /// <param name="pos">Position.</param>
- /// <param name="builder">Builder.</param>
- /// <returns>Field value.</returns>
- private T Field0<T>(int pos, PortableBuilderImpl builder)
- {
- IPortableStream stream = new PortableHeapStream(_data);
-
- stream.Seek(pos, SeekOrigin.Begin);
-
- return _marsh.Unmarshal<T>(stream, PortableMode.ForcePortable, builder);
- }
-
/** <inheritdoc /> */
public override int GetHashCode()
{
@@ -247,8 +222,8 @@ namespace Apache.Ignite.Core.Impl.Portable
// 3. Check if objects have the same field values.
foreach (KeyValuePair<int, int> field in _fields)
{
- object fieldVal = Field0<object>(field.Value, null);
- object thatFieldVal = that.Field0<object>(that._fields[field.Key], null);
+ object fieldVal = GetField<object>(field.Value, null);
+ object thatFieldVal = that.GetField<object>(that._fields[field.Key], null);
if (!Equals(fieldVal, thatFieldVal))
return false;
@@ -332,7 +307,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
sb.Append(fieldName).Append('=');
- ToString0(sb, Field0<object>(fieldPos, null), handled);
+ ToString0(sb, GetField<object>(fieldPos, null), handled);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/05e739f1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
index dd72a8c..c9d6172 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
@@ -26,8 +26,6 @@ namespace Apache.Ignite.Core.Impl.Portable
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
- using System.Runtime.Serialization.Formatters.Binary;
- using System.Security.Policy;
using System.Text;
using Apache.Ignite.Core.Impl.Common;
@@ -189,9 +187,12 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Type: Compute job wrapper. */
public const byte TypeComputeJobWrapper = 86;
- /** Type: Compute job wrapper. */
+ /** Type: Serializable wrapper. */
public const byte TypeSerializableHolder = 87;
+ /** Type: DateTime wrapper. */
+ public const byte TypeDateTimeHolder = 93;
+
/** Type: action wrapper. */
public const byte TypeComputeActionJob = 88;
@@ -204,15 +205,9 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Type: message filter holder. */
public const byte TypeMessageListenerHolder = 92;
- /** Type: message filter holder. */
- public const byte TypePortableOrSerializableHolder = 93;
-
/** Type: stream receiver holder. */
public const byte TypeStreamReceiverHolder = 94;
- /** Type: DateTime. */
- public const byte TypeDateTime = 95;
-
/** Collection: custom. */
public const byte CollectionCustom = 0;
@@ -1753,7 +1748,11 @@ namespace Apache.Ignite.Core.Impl.Portable
*/
private static void ToJavaDate(DateTime date, out long high, out int low)
{
- long diff = date.ToUniversalTime().Ticks - JavaDateTicks;
+ if (date.Kind != DateTimeKind.Utc)
+ throw new InvalidOperationException(
+ "DateTime is not UTC. Only UTC DateTime can be used for interop with other platforms.");
+
+ long diff = date.Ticks - JavaDateTicks;
high = diff / TimeSpan.TicksPerMillisecond;
http://git-wip-us.apache.org/repos/asf/ignite/blob/05e739f1/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
index d5fb6ec..ab7adaa 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
@@ -951,6 +951,15 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="val">Object array.</param>
public void WriteArray<T>(T[] val)
{
+ WriteArrayInternal(val);
+ }
+
+ /// <summary>
+ /// Write object array.
+ /// </summary>
+ /// <param name="val">Object array.</param>
+ public void WriteArrayInternal(Array val)
+ {
if (val == null)
WriteNullRawField();
else
@@ -1025,7 +1034,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <summary>
/// Write NULL field.
/// </summary>
- public void WriteNullField()
+ private void WriteNullField()
{
_stream.WriteInt(1);
_stream.WriteByte(PU.HdrNull);
@@ -1034,7 +1043,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <summary>
/// Write NULL raw field.
/// </summary>
- public void WriteNullRawField()
+ private void WriteNullRawField()
{
_stream.WriteByte(PU.HdrNull);
}
@@ -1173,18 +1182,12 @@ namespace Apache.Ignite.Core.Impl.Portable
else
{
// Are we dealing with a well-known type?
- PortableSystemWriteDelegate handler = PortableSystemHandlers.GetWriteHandler(type);
+ var handler = PortableSystemHandlers.GetWriteHandler(type);
- if (handler != null)
- handler.Invoke(this, obj);
- else
- {
- if (type.IsSerializable)
- Write(new SerializableObjectHolder(obj));
- else
- // We did our best, object cannot be marshalled.
- throw new PortableException("Unsupported object type [type=" + type + ", object=" + obj + ']');
- }
+ if (handler == null) // We did our best, object cannot be marshalled.
+ throw new PortableException("Unsupported object type [type=" + type + ", object=" + obj + ']');
+
+ handler(this, obj);
}
}
@@ -1193,7 +1196,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
/// <param name="val">Object.</param>
/// <param name="type">Type.</param>
- public unsafe void WritePrimitive<T>(T val, Type type)
+ private unsafe void WritePrimitive<T>(T val, Type type)
{
// .Net defines 14 primitive types. We support 12 - excluding IntPtr and UIntPtr.
// Types check sequence is designed to minimize comparisons for the most frequent types.
[06/17] ignite git commit: IGNITE-1572: .Net: Removed unnecessary
wrappers.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs
index 0c9ecc5..a33ea24 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/SerializableObjectHolder.cs
@@ -17,6 +17,9 @@
namespace Apache.Ignite.Core.Impl.Portable
{
+ using System.Diagnostics;
+ using System.Runtime.Serialization.Formatters.Binary;
+ using Apache.Ignite.Core.Impl.Portable.IO;
using Apache.Ignite.Core.Portable;
/// <summary>
@@ -47,9 +50,11 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritDoc /> */
public void WritePortable(IPortableWriter writer)
{
+ Debug.Assert(writer != null);
+
var writer0 = (PortableWriterImpl)writer.GetRawWriter();
- writer0.WithDetach(w => PortableUtils.WriteSerializable(w, Item));
+ writer0.WithDetach(w => new BinaryFormatter().Serialize(new PortableStreamAdapter(w.Stream), Item));
}
/// <summary>
@@ -58,7 +63,11 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="reader">The reader.</param>
public SerializableObjectHolder(IPortableReader reader)
{
- _item = PortableUtils.ReadSerializable<object>((PortableReaderImpl)reader.GetRawReader());
+ Debug.Assert(reader != null);
+
+ var reader0 = (PortableReaderImpl) reader.GetRawReader();
+
+ _item = new BinaryFormatter().Deserialize(new PortableStreamAdapter(reader0.Stream), null);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
index 38a7175..ac65807f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
@@ -192,9 +192,9 @@ namespace Apache.Ignite.Core.Impl.Services
w.WriteObject(configuration.AffinityKey);
if (configuration.NodeFilter != null)
- w.WriteObject(new PortableOrSerializableObjectHolder(configuration.NodeFilter));
+ w.WriteObject(configuration.NodeFilter);
else
- w.WriteObject<PortableOrSerializableObjectHolder>(null);
+ w.WriteObject<object>(null);
});
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
index 3295904..9d986ec 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
@@ -978,7 +978,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
{
var reader = _ignite.Marshaller.StartUnmarshal(stream);
- var filter = (IClusterNodeFilter) reader.ReadObject<PortableOrSerializableObjectHolder>().Item;
+ var filter = reader.ReadObject<IClusterNodeFilter>();
return filter.Invoke(_ignite.GetNode(reader.ReadGuid())) ? 1 : 0;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
index 4f65840..44a7137 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
@@ -17,8 +17,6 @@
namespace Apache.Ignite.Core.Portable
{
- using System.Diagnostics.CodeAnalysis;
-
/// <summary>
/// Portable object builder. Provides ability to build portable objects dynamically
/// without having class definitions.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
index f8acb01..3dba104 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.ExamplesDll/Compute/AverageSalaryTask.cs
@@ -72,7 +72,7 @@ namespace Apache.Ignite.ExamplesDll.Compute
long sum = 0;
int count = 0;
- foreach (var t in results.Select(result => result.Data()))
+ foreach (var t in results.Select(result => result.Data))
{
sum += t.Item1;
count += t.Item2;
[17/17] ignite git commit: Ignite-950 - Property was incorrectly set.
Posted by ag...@apache.org.
Ignite-950 - Property was incorrectly set.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bc976b43
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bc976b43
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bc976b43
Branch: refs/heads/ignite-950-new
Commit: bc976b4344cb7db644eb848d2a7d4c1152fe85c9
Parents: 383b08a
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Oct 28 11:42:21 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Oct 28 11:42:21 2015 +0300
----------------------------------------------------------------------
.../cache/context/IgniteCacheTxExecutionContextTest.java | 4 ----
1 file changed, 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bc976b43/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java
index cd8109c..aaefc90 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheTxExecutionContextTest.java
@@ -31,10 +31,6 @@ import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
*
*/
public class IgniteCacheTxExecutionContextTest extends IgniteCacheAbstractExecutionContextTest {
- static {
- GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, PortableMarshaller.class.getName());
- }
-
/** {@inheritDoc} */
@Override protected CacheMode cacheMode() {
return CacheMode.PARTITIONED;
[14/17] ignite git commit: IGNITE-1652: .Net async API reworked.
Posted by ag...@apache.org.
IGNITE-1652: .Net async API reworked.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/cc1aa533
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/cc1aa533
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/cc1aa533
Branch: refs/heads/ignite-950-new
Commit: cc1aa5331bbcfe0f5c0b6fe1dc230dc855c9b8f7
Parents: 4097810
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Oct 27 17:46:19 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Oct 27 17:46:19 2015 +0300
----------------------------------------------------------------------
.../Interop/GetAsyncBenchmark.cs | 6 +-
.../Interop/PutAsyncBenchmark.cs | 6 +-
.../Cache/CacheAbstractTest.cs | 187 +++----
.../Cache/CacheTestAsyncWrapper.cs | 294 +++++++----
.../Cache/Query/CacheQueriesTest.cs | 8 -
.../Cache/Store/CacheStoreTest.cs | 17 +-
.../Compute/ComputeApiTest.cs | 11 +-
.../Dataload/DataStreamerTest.cs | 40 +-
.../Apache.Ignite.Core.Tests/EventsTest.cs | 39 +-
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 37 +-
.../Apache.Ignite.Core.Tests/FutureTest.cs | 104 +---
.../Apache.Ignite.Core.Tests/MessagingTest.cs | 42 +-
.../Services/ServicesAsyncWrapper.cs | 90 ++--
.../Apache.Ignite.Core.csproj | 11 -
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 370 ++++++++++---
.../Common/AsyncSupportedAttribute.cs | 33 --
.../Apache.Ignite.Core/Common/IAsyncSupport.cs | 52 --
.../dotnet/Apache.Ignite.Core/Common/IFuture.cs | 115 ----
.../Compute/ComputeTaskAdapter.cs | 2 +-
.../Apache.Ignite.Core/Compute/ICompute.cs | 210 +++++++-
.../Apache.Ignite.Core/Compute/IComputeTask.cs | 2 +-
.../Datastream/IDataStreamer.cs | 22 +-
.../dotnet/Apache.Ignite.Core/Events/IEvents.cs | 68 ++-
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 401 ++++++++++----
.../Impl/Cache/CacheProxyImpl.cs | 519 -------------------
.../Impl/Common/AsyncResult.cs | 71 ---
.../Impl/Common/CompletedAsyncResult.cs | 59 ---
.../Apache.Ignite.Core/Impl/Common/Future.cs | 203 +-------
.../Apache.Ignite.Core/Impl/Compute/Compute.cs | 135 ++++-
.../Impl/Compute/ComputeAsync.cs | 264 ----------
.../Impl/Compute/ComputeImpl.cs | 40 +-
.../Impl/Compute/ComputeTaskHolder.cs | 2 +-
.../Impl/Datastream/DataStreamerBatch.cs | 12 +-
.../Impl/Datastream/DataStreamerImpl.cs | 18 +-
.../Apache.Ignite.Core/Impl/Events/Events.cs | 129 +++--
.../Impl/Events/EventsAsync.cs | 159 ------
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 4 +-
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 9 -
.../Impl/Messaging/Messaging.cs | 97 ++--
.../Impl/Messaging/MessagingAsync.cs | 68 ---
.../Apache.Ignite.Core/Impl/PlatformTarget.cs | 21 +-
.../Impl/Services/Services.cs | 124 +++--
.../Impl/Services/ServicesAsync.cs | 89 ----
.../Impl/Transactions/AsyncTransaction.cs | 78 ---
.../Impl/Transactions/Transaction.cs | 78 ++-
.../Impl/Transactions/TransactionImpl.cs | 47 +-
.../Impl/Transactions/TransactionsImpl.cs | 10 +-
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 4 +-
.../Unmanaged/UnmanagedNonReleaseableTarget.cs | 9 +-
.../Apache.Ignite.Core/Messaging/IMessaging.cs | 28 +-
.../Apache.Ignite.Core/Services/IServices.cs | 98 +++-
.../Transactions/ITransaction.cs | 16 +-
.../Datagrid/CrossPlatformExample.cs | 14 +-
53 files changed, 1905 insertions(+), 2667 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/GetAsyncBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/GetAsyncBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/GetAsyncBenchmark.cs
index d7e0c41..9b99aa1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/GetAsyncBenchmark.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/GetAsyncBenchmark.cs
@@ -41,8 +41,6 @@ namespace Apache.Ignite.Benchmarks.Interop
for (int i = 0; i < Emps.Length; i++)
_cache.Put(i, Emps[i]);
-
- _cache = _cache.WithAsync();
}
/** <inheritDoc /> */
@@ -58,9 +56,7 @@ namespace Apache.Ignite.Benchmarks.Interop
{
int idx = BenchmarkUtils.GetRandomInt(Dataset);
- _cache.Get(idx);
-
- _cache.GetFuture<Employee>().ToTask().Wait();
+ _cache.GetAsync(idx).Wait();
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PutAsyncBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PutAsyncBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PutAsyncBenchmark.cs
index 475a0c6..5efe0ca 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PutAsyncBenchmark.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/PutAsyncBenchmark.cs
@@ -36,7 +36,7 @@ namespace Apache.Ignite.Benchmarks.Interop
{
base.OnStarted();
- _cache = Node.GetCache<object, object>(CacheName).WithAsync();
+ _cache = Node.GetCache<object, object>(CacheName);
}
/** <inheritDoc /> */
@@ -52,9 +52,7 @@ namespace Apache.Ignite.Benchmarks.Interop
{
int idx = BenchmarkUtils.GetRandomInt(Dataset);
- _cache.Put(idx, Emps[idx]);
-
- _cache.GetFuture<object>().Get();
+ _cache.PutAsync(idx, Emps[idx]).Wait();
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
index 19ea37d..ca85a2a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -525,7 +525,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestGetAsync()
{
- var cache = Cache().WithAsync().WrapAsync();
+ var cache = Cache().WrapAsync();
cache.Put(1, 1);
cache.Put(2, 2);
@@ -534,6 +534,9 @@ namespace Apache.Ignite.Core.Tests.Cache
Assert.AreEqual(2, cache.Get(2));
Assert.IsFalse(cache.ContainsKey(3));
Assert.Throws<KeyNotFoundException>(() => cache.Get(3));
+
+ Assert.AreEqual(1, Cache().TryGetAsync(1).Result.Value);
+ Assert.IsFalse(Cache().TryGetAsync(3).Result.Success);
}
[Test]
@@ -558,7 +561,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestGetAllAsync()
{
- var cache = Cache().WithAsync().WrapAsync();
+ var cache = Cache().WrapAsync();
cache.Put(1, 1);
cache.Put(2, 2);
@@ -631,7 +634,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestGetAndPutAsync()
{
- var cache = Cache().WithAsync().WrapAsync();
+ var cache = Cache().WrapAsync();
Assert.AreEqual(false, cache.ContainsKey(1));
@@ -661,7 +664,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestPutxAsync()
{
- var cache = Cache().WithAsync().WrapAsync();
+ var cache = Cache().WrapAsync();
cache.Put(1, 1);
@@ -703,7 +706,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestGetAndPutIfAbsentAsync()
{
- var cache = Cache().WithAsync().WrapAsync();
+ var cache = Cache().WrapAsync();
Assert.IsFalse(cache.ContainsKey(1));
@@ -723,7 +726,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestPutIfAbsentAsync()
{
- var cache = Cache().WithAsync().WrapAsync();
+ var cache = Cache().WrapAsync();
Assert.Throws<KeyNotFoundException>(() => cache.Get(1));
Assert.IsFalse(cache.ContainsKey(1));
@@ -772,7 +775,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestGetAndReplaceAsync()
{
- var cache = Cache().WithAsync().WrapAsync();
+ var cache = Cache().WrapAsync();
Assert.IsFalse(cache.ContainsKey(1));
@@ -824,7 +827,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestReplaceAsync()
{
- var cache = Cache().WithAsync().WrapAsync();
+ var cache = Cache().WrapAsync();
Assert.IsFalse(cache.ContainsKey(1));
@@ -856,7 +859,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestPutAllAsync()
{
- var cache = Cache().WithAsync().WrapAsync();
+ var cache = Cache().WrapAsync();
cache.PutAll(new Dictionary<int, int> { { 1, 1 }, { 2, 2 }, { 3, 3 } });
@@ -1207,7 +1210,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestGetAndRemoveAsync()
{
- var cache = Cache().WithAsync().WrapAsync();
+ var cache = Cache().WrapAsync();
cache.Put(1, 1);
@@ -1251,7 +1254,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestRemoveAsync()
{
- var cache = Cache().WithAsync().WrapAsync();
+ var cache = Cache().WrapAsync();
cache.Put(1, 1);
@@ -1288,7 +1291,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestRemoveAllAsync()
{
- var cache = Cache().WithAsync().WrapAsync();
+ var cache = Cache().WrapAsync();
List<int> keys = PrimaryKeysForCache(cache, 2);
@@ -1331,7 +1334,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestRemoveAllKeysAsync()
{
- var cache = Cache().WithAsync().WrapAsync();
+ var cache = Cache().WrapAsync();
Assert.AreEqual(0, cache.GetSize());
@@ -1572,7 +1575,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestPutGetPortableAsync()
{
- var cache = Cache<int, PortablePerson>().WithAsync().WrapAsync();
+ var cache = Cache<int, PortablePerson>().WrapAsync();
PortablePerson obj1 = new PortablePerson("obj1", 1);
@@ -1601,28 +1604,22 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestGetAsync2()
{
- var cache = Cache().WithAsync();
+ var cache = Cache();
for (int i = 0; i < 100; i++)
- {
cache.Put(i, i);
- cache.GetFuture<object>().Get();
- }
-
- var futs = new List<IFuture<int>>();
+ var futs = new List<Task<int>>();
for (int i = 0; i < 1000; i++)
{
- cache.Get(i % 100);
-
- futs.Add(cache.GetFuture<int>());
+ futs.Add(cache.GetAsync(i % 100));
}
for (int i = 0; i < 1000; i++) {
- Assert.AreEqual(i % 100, futs[i].Get(), "Unexpected result: " + i);
+ Assert.AreEqual(i % 100, futs[i].Result, "Unexpected result: " + i);
- Assert.IsTrue(futs[i].IsDone);
+ Assert.IsTrue(futs[i].IsCompleted);
}
}
@@ -1630,30 +1627,22 @@ namespace Apache.Ignite.Core.Tests.Cache
[Category(TestUtils.CategoryIntensive)]
public void TestGetAsyncMultithreaded()
{
- var cache = Cache().WithAsync();
+ var cache = Cache();
for (int i = 0; i < 100; i++)
- {
cache.Put(i, i);
- cache.GetFuture<object>().Get();
- }
-
TestUtils.RunMultiThreaded(() =>
{
for (int i = 0; i < 100; i++)
{
- var futs = new List<IFuture<int>>();
+ var futs = new List<Task<int>>();
for (int j = 0; j < 100; j++)
- {
- cache.Get(j);
-
- futs.Add(cache.GetFuture<int>());
- }
+ futs.Add(cache.GetAsync(j));
for (int j = 0; j < 100; j++)
- Assert.AreEqual(j, futs[j].Get());
+ Assert.AreEqual(j, futs[j].Result);
}
}, 10);
}
@@ -1662,7 +1651,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Category(TestUtils.CategoryIntensive)]
public void TestPutxAsyncMultithreaded()
{
- var cache = Cache().WithAsync();
+ var cache = Cache();
TestUtils.RunMultiThreaded(() =>
{
@@ -1670,17 +1659,13 @@ namespace Apache.Ignite.Core.Tests.Cache
for (int i = 0; i < 50; i++)
{
- var futs = new List<IFuture<object>>();
+ var futs = new List<Task>();
for (int j = 0; j < 10; j++)
- {
- cache.Put(rnd.Next(1000), i);
-
- futs.Add(cache.GetFuture<object>());
- }
+ futs.Add(cache.PutAsync(rnd.Next(1000), i));
foreach (var fut in futs)
- fut.Get();
+ fut.Wait();
}
}, 5);
}
@@ -1689,7 +1674,7 @@ namespace Apache.Ignite.Core.Tests.Cache
[Category(TestUtils.CategoryIntensive)]
public void TestPutGetAsyncMultithreaded()
{
- var cache = Cache<CacheTestKey, PortablePerson>().WithAsync();
+ var cache = Cache<CacheTestKey, PortablePerson>();
const int threads = 10;
const int objPerThread = 1000;
@@ -1701,22 +1686,20 @@ namespace Apache.Ignite.Core.Tests.Cache
// ReSharper disable once AccessToModifiedClosure
int threadIdx = Interlocked.Increment(ref cntr);
- var futs = new List<IFuture<object>>();
+ var futs = new List<Task>();
for (int i = 0; i < objPerThread; i++)
{
int key = threadIdx * objPerThread + i;
- cache.Put(new CacheTestKey(key), new PortablePerson("Person-" + key, key));
-
- futs.Add(cache.GetFuture<object>());
+ futs.Add(cache.PutAsync(new CacheTestKey(key), new PortablePerson("Person-" + key, key)));
}
foreach (var fut in futs)
{
- fut.Get();
+ fut.Wait();
- Assert.IsTrue(fut.IsDone);
+ Assert.IsTrue(fut.IsCompleted);
}
}, threads);
@@ -1728,8 +1711,7 @@ namespace Apache.Ignite.Core.Tests.Cache
{
int key = threadIdx * objPerThread + i;
- cache.Get(new CacheTestKey(key));
- var p = cache.GetFuture<PortablePerson>().Get();
+ var p = cache.GetAsync(new CacheTestKey(key)).Result;
Assert.IsNotNull(p);
Assert.AreEqual(key, p.Age);
@@ -1747,9 +1729,7 @@ namespace Apache.Ignite.Core.Tests.Cache
{
int key = threadIdx * objPerThread + i;
- cache.Put(new CacheTestKey(key), new PortablePerson("Person-" + key, key));
-
- cache.GetFuture<object>().Get();
+ cache.PutAsync(new CacheTestKey(key), new PortablePerson("Person-" + key, key)).Wait();
}
}, threads);
@@ -1759,15 +1739,13 @@ namespace Apache.Ignite.Core.Tests.Cache
{
int threadIdx = Interlocked.Increment(ref cntr);
- var futs = new List<IFuture<PortablePerson>>();
+ var futs = new List<Task<PortablePerson>>();
for (int i = 0; i < objPerThread; i++)
{
int key = threadIdx * objPerThread + i;
- cache.Get(new CacheTestKey(key));
-
- futs.Add(cache.GetFuture<PortablePerson>());
+ futs.Add(cache.GetAsync(new CacheTestKey(key)));
}
for (int i = 0; i < objPerThread; i++)
@@ -1776,7 +1754,7 @@ namespace Apache.Ignite.Core.Tests.Cache
int key = threadIdx * objPerThread + i;
- var p = fut.Get();
+ var p = fut.Result;
Assert.IsNotNull(p);
Assert.AreEqual(key, p.Age);
@@ -1789,8 +1767,8 @@ namespace Apache.Ignite.Core.Tests.Cache
//[Category(TestUtils.CATEGORY_INTENSIVE)]
public void TestAsyncMultithreadedKeepPortable()
{
- var cache = Cache().WithAsync().WithKeepPortable<CacheTestKey, PortablePerson>();
- var portCache = Cache().WithAsync().WithKeepPortable<CacheTestKey, IPortableObject>();
+ var cache = Cache().WithKeepPortable<CacheTestKey, PortablePerson>();
+ var portCache = Cache().WithKeepPortable<CacheTestKey, IPortableObject>();
const int threads = 10;
const int objPerThread = 1000;
@@ -1802,19 +1780,19 @@ namespace Apache.Ignite.Core.Tests.Cache
// ReSharper disable once AccessToModifiedClosure
int threadIdx = Interlocked.Increment(ref cntr);
- var futs = new List<IFuture<object>>();
+ var futs = new List<Task>();
for (int i = 0; i < objPerThread; i++)
{
int key = threadIdx * objPerThread + i;
- cache.Put(new CacheTestKey(key), new PortablePerson("Person-" + key, key));
+ var task = cache.PutAsync(new CacheTestKey(key), new PortablePerson("Person-" + key, key));
- futs.Add(cache.GetFuture<object>());
+ futs.Add(task);
}
foreach (var fut in futs)
- Assert.IsNull(fut.Get());
+ fut.Wait();
}, threads);
for (int i = 0; i < threads; i++)
@@ -1839,15 +1817,13 @@ namespace Apache.Ignite.Core.Tests.Cache
{
int threadIdx = Interlocked.Increment(ref cntr);
- var futs = new List<IFuture<IPortableObject>>();
+ var futs = new List<Task<IPortableObject>>();
for (int i = 0; i < objPerThread; i++)
{
int key = threadIdx * objPerThread + i;
- portCache.Get(new CacheTestKey(key));
-
- futs.Add(cache.GetFuture<IPortableObject>());
+ futs.Add(portCache.GetAsync(new CacheTestKey(key)));
}
for (int i = 0; i < objPerThread; i++)
@@ -1856,7 +1832,7 @@ namespace Apache.Ignite.Core.Tests.Cache
int key = threadIdx * objPerThread + i;
- var p = fut.Get();
+ var p = fut.Result;
Assert.IsNotNull(p);
Assert.AreEqual(key, p.GetField<int>("age"));
@@ -1870,22 +1846,20 @@ namespace Apache.Ignite.Core.Tests.Cache
{
int threadIdx = Interlocked.Increment(ref cntr);
- var futs = new List<IFuture<bool>>();
+ var futs = new List<Task<bool>>();
for (int i = 0; i < objPerThread; i++)
{
int key = threadIdx * objPerThread + i;
- cache.Remove(new CacheTestKey(key));
-
- futs.Add(cache.GetFuture<bool>());
+ futs.Add(cache.RemoveAsync(new CacheTestKey(key)));
}
for (int i = 0; i < objPerThread; i++)
{
var fut = futs[i];
- Assert.AreEqual(true, fut.Get());
+ Assert.IsTrue(fut.Result);
}
}, threads);
}
@@ -2050,16 +2024,11 @@ namespace Apache.Ignite.Core.Tests.Cache
if (async)
{
- var asyncTx = tx.WithAsync();
-
- asyncTx.Commit();
-
- var fut = asyncTx.GetFuture();
+ var task = tx.CommitAsync();
- fut.Get();
+ task.Wait();
- Assert.IsTrue(fut.IsDone);
- Assert.AreEqual(fut.Get(), null);
+ Assert.IsTrue(task.IsCompleted);
}
else
tx.Commit();
@@ -2398,24 +2367,22 @@ namespace Apache.Ignite.Core.Tests.Cache
// Expected
}
- tx = Transactions.TxStart().WithAsync();
+ tx = Transactions.TxStart();
Assert.AreEqual(TransactionState.Active, tx.State);
- tx.Commit();
-
- tx.GetFuture().Get();
+ tx.CommitAsync().Wait();
Assert.AreEqual(TransactionState.Committed, tx.State);
- tx.Rollback(); // Illegal, but should not fail here; will fail in future
+ var task = tx.RollbackAsync(); // Illegal, but should not fail here; will fail in task
try
{
- tx.GetFuture<object>().Get();
+ task.Wait();
Assert.Fail();
}
- catch (InvalidOperationException)
+ catch (AggregateException)
{
// Expected
}
@@ -2492,22 +2459,21 @@ namespace Apache.Ignite.Core.Tests.Cache
[Category(TestUtils.CategoryIntensive)]
public void TestFuturesGc()
{
- var cache = Cache().WithAsync();
+ var cache = Cache();
- cache.Put(1, 1);
+ cache.PutAsync(1, 1);
for (int i = 0; i < 10; i++)
{
TestUtils.RunMultiThreaded(() =>
{
for (int j = 0; j < 1000; j++)
- cache.Get(1);
+ cache.GetAsync(1);
}, 5);
GC.Collect();
- cache.Get(1);
- Assert.AreEqual(1, cache.GetFuture<int>().Get());
+ Assert.AreEqual(1, cache.GetAsync(1).Result);
}
Thread.Sleep(2000);
@@ -2872,7 +2838,7 @@ namespace Apache.Ignite.Core.Tests.Cache
private void TestInvoke<T>(bool async) where T: AddArgCacheEntryProcessor, new()
{
- var cache = async ? Cache().WithAsync().WrapAsync() : Cache();
+ var cache = async ? Cache().WrapAsync() : Cache();
cache.Clear();
@@ -2954,7 +2920,7 @@ namespace Apache.Ignite.Core.Tests.Cache
public void TestInvokeAll<T>(bool async, int entryCount) where T : AddArgCacheEntryProcessor, new()
{
- var cache = async ? Cache().WithAsync().WrapAsync() : Cache();
+ var cache = async ? Cache().WrapAsync() : Cache();
var entries = Enumerable.Range(1, entryCount).ToDictionary(x => x, x => x + 1);
@@ -3018,26 +2984,25 @@ namespace Apache.Ignite.Core.Tests.Cache
[Test]
public void TestSkipStore()
{
- CacheProxyImpl<int, int> cache = (CacheProxyImpl<int, int>)Cache();
+ var cache = (CacheImpl<int, int>) Cache();
- Assert.IsFalse(cache.SkipStore);
+ Assert.IsFalse(cache.IsSkipStore);
// Ensure correct flag set.
- CacheProxyImpl<int, int> cacheSkipStore1 = (CacheProxyImpl<int, int>)cache.WithSkipStore();
+ var cacheSkipStore1 = (CacheImpl<int, int>) cache.WithSkipStore();
Assert.AreNotSame(cache, cacheSkipStore1);
- Assert.IsFalse(cache.SkipStore);
- Assert.IsTrue(cacheSkipStore1.SkipStore);
+ Assert.IsFalse(cache.IsSkipStore);
+ Assert.IsTrue(cacheSkipStore1.IsSkipStore);
// Ensure that the same instance is returned if flag is already set.
- CacheProxyImpl<int, int> cacheSkipStore2 = (CacheProxyImpl<int, int>)cacheSkipStore1.WithSkipStore();
+ var cacheSkipStore2 = (CacheImpl<int, int>) cacheSkipStore1.WithSkipStore();
- Assert.IsTrue(cacheSkipStore2.SkipStore);
+ Assert.IsTrue(cacheSkipStore2.IsSkipStore);
Assert.AreSame(cacheSkipStore1, cacheSkipStore2);
// Ensure other flags are preserved.
- Assert.IsTrue(((CacheProxyImpl<int, int>)cache.WithKeepPortable<int, int>().WithSkipStore()).IsKeepPortable);
- Assert.IsTrue(cache.WithAsync().WithSkipStore().IsAsync);
+ Assert.IsTrue(((CacheImpl<int, int>) cache.WithKeepPortable<int, int>().WithSkipStore()).IsKeepPortable);
}
[Test]
@@ -3061,7 +3026,7 @@ namespace Apache.Ignite.Core.Tests.Cache
var fut = cache.Rebalance();
- Assert.IsNull(fut.Get());
+
}
[Test]
@@ -3125,7 +3090,7 @@ namespace Apache.Ignite.Core.Tests.Cache
private void TestKeepPortableFlag(bool async)
{
- var cache0 = async ? Cache().WithAsync().WrapAsync() : Cache();
+ var cache0 = async ? Cache().WrapAsync() : Cache();
var cache = cache0.WithKeepPortable<int, PortablePerson>();
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/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 1b5321c..f6deb42 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
@@ -17,9 +17,11 @@
namespace Apache.Ignite.Core.Tests.Cache
{
+ using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cache.Expiry;
using Apache.Ignite.Core.Cache.Query;
@@ -39,38 +41,12 @@ namespace Apache.Ignite.Core.Tests.Cache
/// <param name="cache">The cache to be wrapped.</param>
public CacheTestAsyncWrapper(ICache<TK, TV> cache)
{
- Debug.Assert(cache.IsAsync, "GridCacheTestAsyncWrapper only works with async caches.");
+ Debug.Assert(cache != null);
_cache = cache;
}
/** <inheritDoc /> */
- public ICache<TK, TV> WithAsync()
- {
- return this;
- }
-
- /** <inheritDoc /> */
- public bool IsAsync
- {
- get { return true; }
- }
-
- /** <inheritDoc /> */
- public IFuture GetFuture()
- {
- Debug.Fail("GridCacheTestAsyncWrapper.Future() should not be called. It always returns null.");
- return null;
- }
-
- /** <inheritDoc /> */
- public IFuture<TResult> GetFuture<TResult>()
- {
- Debug.Fail("GridCacheTestAsyncWrapper.Future() should not be called. It always returns null.");
- return null;
- }
-
- /** <inheritDoc /> */
public string Name
{
get { return _cache.Name; }
@@ -83,7 +59,6 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
-
public bool IsEmpty()
{
return _cache.IsEmpty();
@@ -116,36 +91,55 @@ namespace Apache.Ignite.Core.Tests.Cache
/** <inheritDoc /> */
public void LoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
{
- _cache.LoadCache(p, args);
- WaitResult();
+ WaitResult(_cache.LoadCacheAsync(p, args));
+ }
+
+ /** <inheritDoc /> */
+ public Task LoadCacheAsync(ICacheEntryFilter<TK, TV> p, params object[] args)
+ {
+ return _cache.LoadCacheAsync(p, args);
}
/** <inheritDoc /> */
public void LocalLoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
{
- _cache.LocalLoadCache(p, args);
- WaitResult();
+ WaitResult(_cache.LocalLoadCacheAsync(p, args));
+ }
+
+ /** <inheritDoc /> */
+ public Task LocalLoadCacheAsync(ICacheEntryFilter<TK, TV> p, params object[] args)
+ {
+ return _cache.LocalLoadCacheAsync(p, args);
}
/** <inheritDoc /> */
public bool ContainsKey(TK key)
{
- _cache.ContainsKey(key);
- return GetResult<bool>();
+ return GetResult(_cache.ContainsKeyAsync(key));
+ }
+
+ /** <inheritDoc /> */
+ public Task<bool> ContainsKeyAsync(TK key)
+ {
+ return _cache.ContainsKeyAsync(key);
}
/** <inheritDoc /> */
public bool ContainsKeys(IEnumerable<TK> keys)
{
- _cache.ContainsKeys(keys);
- return GetResult<bool>();
+ return GetResult(_cache.ContainsKeysAsync(keys));
+ }
+
+ /** <inheritDoc /> */
+ public Task<bool> ContainsKeysAsync(IEnumerable<TK> keys)
+ {
+ return _cache.ContainsKeysAsync(keys);
}
/** <inheritDoc /> */
public TV LocalPeek(TK key, params CachePeekMode[] modes)
{
- _cache.LocalPeek(key, modes);
- return GetResult<TV>();
+ return _cache.LocalPeek(key, modes);
}
/** <inheritDoc /> */
@@ -164,8 +158,13 @@ namespace Apache.Ignite.Core.Tests.Cache
/** <inheritDoc /> */
public TV Get(TK key)
{
- _cache.Get(key);
- return GetResult<TV>();
+ return GetResult(_cache.GetAsync(key));
+ }
+
+ /** <inheritDoc /> */
+ public Task<TV> GetAsync(TK key)
+ {
+ return _cache.GetAsync(key);
}
/** <inheritDoc /> */
@@ -175,73 +174,129 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
+ public Task<CacheResult<TV>> TryGetAsync(TK key)
+ {
+ return _cache.TryGetAsync(key);
+ }
+
+ /** <inheritDoc /> */
public IDictionary<TK, TV> GetAll(IEnumerable<TK> keys)
{
- _cache.GetAll(keys);
- return GetResult<IDictionary<TK, TV>>();
+ return GetResult(_cache.GetAllAsync(keys));
+ }
+
+ /** <inheritDoc /> */
+ public Task<IDictionary<TK, TV>> GetAllAsync(IEnumerable<TK> keys)
+ {
+ return _cache.GetAllAsync(keys);
}
/** <inheritDoc /> */
public void Put(TK key, TV val)
{
- _cache.Put(key, val);
- WaitResult();
+ WaitResult(_cache.PutAsync(key, val));
+ }
+
+ /** <inheritDoc /> */
+ public Task PutAsync(TK key, TV val)
+ {
+ return _cache.PutAsync(key, val);
}
/** <inheritDoc /> */
public CacheResult<TV> GetAndPut(TK key, TV val)
{
- _cache.GetAndPut(key, val);
- return GetResult<CacheResult<TV>>();
+ return GetResult(_cache.GetAndPutAsync(key, val));
+ }
+
+ /** <inheritDoc /> */
+ public Task<CacheResult<TV>> GetAndPutAsync(TK key, TV val)
+ {
+ return _cache.GetAndPutAsync(key, val);
}
/** <inheritDoc /> */
public CacheResult<TV> GetAndReplace(TK key, TV val)
{
- _cache.GetAndReplace(key, val);
- return GetResult<CacheResult<TV>>();
+ return GetResult(_cache.GetAndReplaceAsync(key, val));
+ }
+
+ /** <inheritDoc /> */
+ public Task<CacheResult<TV>> GetAndReplaceAsync(TK key, TV val)
+ {
+ return _cache.GetAndReplaceAsync(key, val);
}
/** <inheritDoc /> */
public CacheResult<TV> GetAndRemove(TK key)
{
- _cache.GetAndRemove(key);
- return GetResult<CacheResult<TV>>();
+ return GetResult(_cache.GetAndRemoveAsync(key));
+ }
+
+ /** <inheritDoc /> */
+ public Task<CacheResult<TV>> GetAndRemoveAsync(TK key)
+ {
+ return _cache.GetAndRemoveAsync(key);
}
/** <inheritDoc /> */
public bool PutIfAbsent(TK key, TV val)
{
- _cache.PutIfAbsent(key, val);
- return GetResult<bool>();
+ return GetResult(_cache.PutIfAbsentAsync(key, val));
+ }
+
+ /** <inheritDoc /> */
+ public Task<bool> PutIfAbsentAsync(TK key, TV val)
+ {
+ return _cache.PutIfAbsentAsync(key, val);
}
/** <inheritDoc /> */
public CacheResult<TV> GetAndPutIfAbsent(TK key, TV val)
{
- _cache.GetAndPutIfAbsent(key, val);
- return GetResult<CacheResult<TV>>();
+ return GetResult(_cache.GetAndPutIfAbsentAsync(key, val));
+ }
+
+ /** <inheritDoc /> */
+ public Task<CacheResult<TV>> GetAndPutIfAbsentAsync(TK key, TV val)
+ {
+ return _cache.GetAndPutIfAbsentAsync(key, val);
}
/** <inheritDoc /> */
public bool Replace(TK key, TV val)
{
- _cache.Replace(key, val);
- return GetResult<bool>();
+ return GetResult(_cache.ReplaceAsync(key, val));
+ }
+
+ /** <inheritDoc /> */
+ public Task<bool> ReplaceAsync(TK key, TV val)
+ {
+ return _cache.ReplaceAsync(key, val);
}
/** <inheritDoc /> */
public bool Replace(TK key, TV oldVal, TV newVal)
{
- _cache.Replace(key, oldVal, newVal);
- return GetResult<bool>();
+ return GetResult(_cache.ReplaceAsync(key, oldVal, newVal));
+ }
+
+ /** <inheritDoc /> */
+ public Task<bool> ReplaceAsync(TK key, TV oldVal, TV newVal)
+ {
+ return _cache.ReplaceAsync(key, oldVal, newVal);
}
/** <inheritDoc /> */
public void PutAll(IDictionary<TK, TV> vals)
{
- _cache.PutAll(vals);
- WaitResult();
+ WaitResult(_cache.PutAllAsync(vals));
+ }
+
+ /** <inheritDoc /> */
+ public Task PutAllAsync(IDictionary<TK, TV> vals)
+ {
+ return _cache.PutAllAsync(vals);
}
/** <inheritDoc /> */
@@ -253,20 +308,37 @@ namespace Apache.Ignite.Core.Tests.Cache
/** <inheritDoc /> */
public void Clear()
{
- _cache.Clear();
- WaitResult();
+ WaitResult(_cache.ClearAsync());
+ }
+
+ /** <inheritDoc /> */
+ public Task ClearAsync()
+ {
+ return _cache.ClearAsync();
}
/** <inheritDoc /> */
public void Clear(TK key)
{
- _cache.Clear(key);
+ WaitResult(_cache.ClearAsync(key));
+ }
+
+ /** <inheritDoc /> */
+ public Task ClearAsync(TK key)
+ {
+ return _cache.ClearAsync(key);
}
/** <inheritDoc /> */
public void ClearAll(IEnumerable<TK> keys)
{
- _cache.ClearAll(keys);
+ WaitResult(_cache.ClearAllAsync(keys));
+ }
+
+ /** <inheritDoc /> */
+ public Task ClearAllAsync(IEnumerable<TK> keys)
+ {
+ return _cache.ClearAllAsync(keys);
}
/** <inheritDoc /> */
@@ -284,29 +356,49 @@ namespace Apache.Ignite.Core.Tests.Cache
/** <inheritDoc /> */
public bool Remove(TK key)
{
- _cache.Remove(key);
- return GetResult<bool>();
+ return GetResult(_cache.RemoveAsync(key));
+ }
+
+ /** <inheritDoc /> */
+ public Task<bool> RemoveAsync(TK key)
+ {
+ return _cache.RemoveAsync(key);
}
/** <inheritDoc /> */
public bool Remove(TK key, TV val)
{
- _cache.Remove(key, val);
- return GetResult<bool>();
+ return GetResult(_cache.RemoveAsync(key, val));
+ }
+
+ /** <inheritDoc /> */
+ public Task<bool> RemoveAsync(TK key, TV val)
+ {
+ return _cache.RemoveAsync(key, val);
}
/** <inheritDoc /> */
public void RemoveAll(IEnumerable<TK> keys)
{
- _cache.RemoveAll(keys);
- WaitResult();
+ WaitResult(_cache.RemoveAllAsync(keys));
+ }
+
+ /** <inheritDoc /> */
+ public Task RemoveAllAsync(IEnumerable<TK> keys)
+ {
+ return _cache.RemoveAllAsync(keys);
}
/** <inheritDoc /> */
public void RemoveAll()
{
- _cache.RemoveAll();
- WaitResult();
+ WaitResult(_cache.RemoveAllAsync());
+ }
+
+ /** <inheritDoc /> */
+ public Task RemoveAllAsync()
+ {
+ return _cache.RemoveAllAsync();
}
/** <inheritDoc /> */
@@ -318,8 +410,13 @@ namespace Apache.Ignite.Core.Tests.Cache
/** <inheritDoc /> */
public int GetSize(params CachePeekMode[] modes)
{
- _cache.GetSize(modes);
- return GetResult<int>();
+ return GetResult(_cache.GetSizeAsync(modes));
+ }
+
+ /** <inheritDoc /> */
+ public Task<int> GetSizeAsync(params CachePeekMode[] modes)
+ {
+ return _cache.GetSizeAsync(modes);
}
/** <inheritDoc /> */
@@ -361,18 +458,26 @@ namespace Apache.Ignite.Core.Tests.Cache
/** <inheritDoc /> */
public TRes Invoke<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
{
- _cache.Invoke(key, processor, arg);
-
- return GetResult<TRes>();
+ return GetResult(_cache.InvokeAsync(key, processor, arg));
+ }
+
+ /** <inheritDoc /> */
+ public Task<TRes> InvokeAsync<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
+ {
+ return _cache.InvokeAsync(key, processor, arg);
}
/** <inheritDoc /> */
public IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
{
- _cache.InvokeAll(keys, processor, arg);
+ return GetResult(_cache.InvokeAllAsync(keys, processor, arg));
+ }
- return GetResult<IDictionary<TK, ICacheEntryProcessorResult<TRes>>>();
+ /** <inheritDoc /> */
+ public Task<IDictionary<TK, ICacheEntryProcessorResult<TRes>>> InvokeAllAsync<TArg, TRes>(IEnumerable<TK> keys, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
+ {
+ return _cache.InvokeAllAsync(keys, processor, arg);
}
/** <inheritDoc /> */
@@ -400,7 +505,7 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
- public IFuture Rebalance()
+ public Task Rebalance()
{
return _cache.Rebalance();
}
@@ -424,19 +529,34 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/// <summary>
- /// Waits for the async result.
+ /// Waits the result of a task, unwraps exceptions.
/// </summary>
- private void WaitResult()
+ /// <param name="task">The task.</param>
+ private static void WaitResult(Task task)
{
- GetResult<object>();
+ try
+ {
+ task.Wait();
+ }
+ catch (AggregateException ex)
+ {
+ throw ex.InnerException;
+ }
}
/// <summary>
- /// Gets the async result.
+ /// Gets the result of a task, unwraps exceptions.
/// </summary>
- private T GetResult<T>()
- {
- return _cache.GetFuture<T>().Get();
+ private static T GetResult<T>(Task<T> task)
+ {
+ try
+ {
+ return task.Result;
+ }
+ catch (Exception ex)
+ {
+ throw ex.InnerException;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index ba104c0..78173e0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -194,14 +194,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
[SuppressMessage("ReSharper", "ReturnValueOfPureMethodIsNotUsed")]
public void TestCursor()
{
- var cache0 = Cache().WithAsync();
-
- cache0.WithAsync().Put(1, new QueryPerson("Ivanov", 30));
-
- IFuture<object> res = cache0.GetFuture<object>();
-
- res.Get();
-
Cache().Put(1, new QueryPerson("Ivanov", 30));
Cache().Put(1, new QueryPerson("Petrov", 40));
Cache().Put(1, new QueryPerson("Sidorov", 50));
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
index bfafcf4..bd0f3a7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
@@ -222,26 +222,17 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestLoadCacheAsync()
{
- var cache = Cache().WithAsync();
+ var cache = Cache();
Assert.AreEqual(0, cache.GetSize());
- cache.LocalLoadCache(new CacheEntryFilter(), 100, 10);
-
- var fut = cache.GetFuture<object>();
+ cache.LocalLoadCacheAsync(new CacheEntryFilter(), 100, 10).Wait();
- fut.Get();
-
- Assert.IsTrue(fut.IsDone);
-
- cache.GetSize();
- Assert.AreEqual(5, cache.GetFuture<int>().ToTask().Result);
+ Assert.AreEqual(5, cache.GetSizeAsync().Result);
for (int i = 105; i < 110; i++)
{
- cache.Get(i);
-
- Assert.AreEqual("val_" + i, cache.GetFuture<string>().ToTask().Result);
+ Assert.AreEqual("val_" + i, cache.GetAsync(i).Result);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
index b0388cd..cb2c8b4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -931,9 +931,9 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestBroadcastTaskAsync()
{
- var gridCompute = _grid1.GetCompute().WithAsync();
- Assert.IsNull(gridCompute.ExecuteJavaTask<ICollection>(BroadcastTask, null));
- var res = gridCompute.GetFuture<ICollection>().Get().OfType<Guid>().ToList();
+ var gridCompute = _grid1.GetCompute();
+
+ var res = gridCompute.ExecuteJavaTaskAsync<ICollection>(BroadcastTask, null).Result.OfType<Guid>().ToList();
Assert.AreEqual(3, res.Count);
Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
@@ -944,9 +944,8 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(2, prj.GetNodes().Count);
- var compute = prj.GetCompute().WithAsync();
- Assert.IsNull(compute.ExecuteJavaTask<IList>(BroadcastTask, null));
- var filteredRes = compute.GetFuture<IList>().Get();
+ var compute = prj.GetCompute();
+ var filteredRes = compute.ExecuteJavaTaskAsync<IList>(BroadcastTask, null).Result;
Assert.AreEqual(2, filteredRes.Count);
Assert.IsTrue(filteredRes.Contains(res.ElementAt(0)));
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
index bad2cf7..c9dea5c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
@@ -32,13 +32,13 @@ namespace Apache.Ignite.Core.Tests.Dataload
/// <summary>
/// Data streamer tests.
/// </summary>
- public class DataStreamerTest
+ public sealed class DataStreamerTest
{
/** Node name. */
- protected const string GridName = "grid";
+ private const string GridName = "grid";
/** Cache name. */
- protected const string CacheName = "partitioned";
+ private const string CacheName = "partitioned";
/** Node. */
private IIgnite _grid;
@@ -50,7 +50,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
/// Initialization routine.
/// </summary>
[TestFixtureSetUp]
- public virtual void InitClient()
+ public void InitClient()
{
_grid = Ignition.Start(GetIgniteConfiguration(GridName));
@@ -63,7 +63,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
///
/// </summary>
[TestFixtureTearDown]
- public virtual void StopGrids()
+ public void StopGrids()
{
Ignition.StopAll(true);
}
@@ -72,7 +72,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
///
/// </summary>
[SetUp]
- public virtual void BeforeTest()
+ public void BeforeTest()
{
Console.WriteLine("Test started: " + TestContext.CurrentContext.Test.Name);
@@ -178,7 +178,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
ldr.TryFlush();
- fut.Get();
+ fut.Wait();
Assert.AreEqual(1, _cache.Get(1));
}
@@ -196,14 +196,14 @@ namespace Apache.Ignite.Core.Tests.Dataload
Thread.Sleep(100);
- Assert.IsFalse(fut.IsDone);
+ Assert.IsFalse(fut.IsCompleted);
ldr.PerNodeBufferSize = 2;
ldr.AddData(2, 2);
ldr.AddData(3, 3);
- ldr.AddData(4, 4).Get();
- fut.Get();
+ ldr.AddData(4, 4).Wait();
+ fut.Wait();
Assert.AreEqual(1, _cache.Get(1));
Assert.AreEqual(2, _cache.Get(2));
@@ -216,7 +216,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
new KeyValuePair<int, int>(6, 6),
new KeyValuePair<int, int>(7, 7),
new KeyValuePair<int, int>(8, 8)
- }).Get();
+ }).Wait();
Assert.AreEqual(5, _cache.Get(5));
Assert.AreEqual(6, _cache.Get(6));
@@ -237,7 +237,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
ldr.Close(false);
- fut.Get();
+ fut.Wait();
Assert.AreEqual(1, _cache.Get(1));
}
@@ -255,7 +255,7 @@ namespace Apache.Ignite.Core.Tests.Dataload
ldr.Close(true);
- fut.Get();
+ fut.Wait();
Assert.IsFalse(_cache.ContainsKey(1));
}
@@ -292,29 +292,29 @@ namespace Apache.Ignite.Core.Tests.Dataload
// Test auto flush turning on.
var fut = ldr.AddData(1, 1);
Thread.Sleep(100);
- Assert.IsFalse(fut.IsDone);
+ Assert.IsFalse(fut.IsCompleted);
ldr.AutoFlushFrequency = 1000;
- fut.Get();
+ fut.Wait();
// Test forced flush after frequency change.
fut = ldr.AddData(2, 2);
- ldr.AutoFlushFrequency = long.MaxValue;
- fut.Get();
+ ldr.AutoFlushFrequency = long.MaxValue;
+ fut.Wait();
// Test another forced flush after frequency change.
fut = ldr.AddData(3, 3);
ldr.AutoFlushFrequency = 1000;
- fut.Get();
+ fut.Wait();
// Test flush before stop.
fut = ldr.AddData(4, 4);
ldr.AutoFlushFrequency = 0;
- fut.Get();
+ fut.Wait();
// Test flush after second turn on.
fut = ldr.AddData(5, 5);
ldr.AutoFlushFrequency = 1000;
- fut.Get();
+ fut.Wait();
Assert.AreEqual(1, _cache.Get(1));
Assert.AreEqual(2, _cache.Get(2));
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
index 33841ad..2dd03da 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
@@ -308,55 +308,50 @@ namespace Apache.Ignite.Core.Tests
var timeout = TimeSpan.FromSeconds(3);
- if (async)
- events = events.WithAsync();
-
var eventType = EventType.TaskExecutionAll;
events.EnableLocal(eventType);
- Func<Func<IEvent>, Task<IEvent>> getWaitTask;
+ Func<IEventFilter<IEvent>, int[], Task<IEvent>> getWaitTask;
if (async)
- getWaitTask = func =>
+ getWaitTask = (filter, types) =>
{
- Assert.IsNull(func());
- var task = events.GetFuture<IEvent>().ToTask();
+ var task = events.WaitForLocalAsync(filter, types);
GenerateTaskEvent();
return task;
};
else
- getWaitTask = func =>
+ getWaitTask = (filter, types) =>
{
- var task = Task.Factory.StartNew(func);
+ var task = Task.Factory.StartNew(() => events.WaitForLocal(filter, types));
Thread.Sleep(500); // allow task to start and begin waiting for events
GenerateTaskEvent();
return task;
};
// No params
- var waitTask = getWaitTask(() => events.WaitForLocal());
+ var waitTask = getWaitTask(null, new int[0]);
waitTask.Wait(timeout);
// Event types
- waitTask = getWaitTask(() => events.WaitForLocal(EventType.TaskReduced));
+ waitTask = getWaitTask(null, new[] {EventType.TaskReduced});
Assert.IsTrue(waitTask.Wait(timeout));
Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
Assert.AreEqual(EventType.TaskReduced, waitTask.Result.Type);
// Filter
- waitTask = getWaitTask(() => events.WaitForLocal(
- new EventFilter<IEvent>(e => e.Type == EventType.TaskReduced)));
+ waitTask = getWaitTask(new EventFilter<IEvent>(e => e.Type == EventType.TaskReduced), new int[0]);
Assert.IsTrue(waitTask.Wait(timeout));
Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
Assert.AreEqual(EventType.TaskReduced, waitTask.Result.Type);
// Filter & types
- waitTask = getWaitTask(() => events.WaitForLocal(
- new EventFilter<IEvent>(e => e.Type == EventType.TaskReduced), EventType.TaskReduced));
+ waitTask = getWaitTask(new EventFilter<IEvent>(e => e.Type == EventType.TaskReduced),
+ new[] {EventType.TaskReduced});
Assert.IsTrue(waitTask.Wait(timeout));
Assert.IsInstanceOf(typeof(TaskEvent), waitTask.Result);
@@ -444,19 +439,11 @@ namespace Apache.Ignite.Core.Tests
var oldEvents = events.RemoteQuery(eventFilter);
- if (async)
- events = events.WithAsync();
-
GenerateTaskEvent();
- var remoteQuery = events.RemoteQuery(eventFilter, EventsTestHelper.Timeout, EventType.JobExecutionAll);
-
- if (async)
- {
- Assert.IsNull(remoteQuery);
-
- remoteQuery = events.GetFuture<List<IEvent>>().Get().ToList();
- }
+ var remoteQuery = !async
+ ? events.RemoteQuery(eventFilter, EventsTestHelper.Timeout, EventType.JobExecutionAll)
+ : events.RemoteQueryAsync(eventFilter, EventsTestHelper.Timeout, EventType.JobExecutionAll).Result;
var qryResult = remoteQuery.Except(oldEvents).Cast<JobEvent>().ToList();
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
index 7a5a725..b971876 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
@@ -217,9 +217,6 @@ namespace Apache.Ignite.Core.Tests
{
var cache = grid.GetCache<TK, int>("partitioned_atomic").WithNoRetries();
- if (async)
- cache = cache.WithAsync();
-
if (typeof (TK) == typeof (IPortableObject))
cache = cache.WithKeepPortable<TK, int>();
@@ -231,21 +228,23 @@ namespace Apache.Ignite.Core.Tests
// Do a lot of puts so that one fails during Ignite stop
for (var i = 0; i < 1000000; i++)
{
- cache.PutAll(Enumerable.Range(1, 100).ToDictionary(k => keyFunc(k, grid), k => i));
+ var dict = Enumerable.Range(1, 100).ToDictionary(k => keyFunc(k, grid), k => i);
if (async)
- cache.GetFuture().Get();
+ cache.PutAllAsync(dict).Wait();
+ else
+ cache.PutAll(dict);
}
}
- catch (CachePartialUpdateException ex)
+ catch (AggregateException ex)
{
- var failedKeys = ex.GetFailedKeys<TK>();
-
- Assert.IsTrue(failedKeys.Any());
-
- var failedKeysObj = ex.GetFailedKeys<object>();
+ CheckPartialUpdateException<TK>((CachePartialUpdateException) ex.InnerException);
- Assert.IsTrue(failedKeysObj.Any());
+ return;
+ }
+ catch (CachePartialUpdateException ex)
+ {
+ CheckPartialUpdateException<TK>(ex);
return;
}
@@ -268,6 +267,20 @@ namespace Apache.Ignite.Core.Tests
}
/// <summary>
+ /// Checks the partial update exception.
+ /// </summary>
+ private static void CheckPartialUpdateException<TK>(CachePartialUpdateException ex)
+ {
+ var failedKeys = ex.GetFailedKeys<TK>();
+
+ Assert.IsTrue(failedKeys.Any());
+
+ var failedKeysObj = ex.GetFailedKeys<object>();
+
+ Assert.IsTrue(failedKeysObj.Any());
+ }
+
+ /// <summary>
/// Starts the grid.
/// </summary>
private static IIgnite StartGrid(string gridName = null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
index 226d4b4..be5bbbc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
@@ -21,7 +21,6 @@ namespace Apache.Ignite.Core.Tests
using System.Collections.Generic;
using System.Threading;
using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Compute;
using Apache.Ignite.Core.Portable;
using NUnit.Framework;
@@ -57,9 +56,9 @@ namespace Apache.Ignite.Core.Tests
}
});
- _cache = grid.GetCache<object, object>(null).WithAsync();
+ _cache = grid.GetCache<object, object>(null);
- _compute = grid.GetCompute().WithAsync();
+ _compute = grid.GetCompute();
}
/// <summary>
@@ -71,72 +70,19 @@ namespace Apache.Ignite.Core.Tests
TestUtils.KillProcesses();
}
- [Test]
- public void TestListen()
- {
- // Listen(Action callback)
- TestListen((fut, act) => fut.Listen(act));
-
- // Listen(Action<IFuture> callback)
- TestListen((fut, act) => ((IFuture)fut).Listen(f =>
- {
- Assert.AreEqual(f, fut);
- act();
- }));
-
- // Listen(Action<IFuture<T>> callback)
- TestListen((fut, act) => fut.Listen(f =>
- {
- Assert.AreEqual(f, fut);
- act();
- }));
- }
-
- private void TestListen(Action<IFuture<object>, Action> listenAction)
- {
- _compute.Broadcast(new SleepAction());
-
- var fut = _compute.GetFuture<object>();
-
- var listenCount = 0;
-
- // Multiple subscribers before completion
- for (var i = 0; i < 10; i++)
- listenAction(fut, () => Interlocked.Increment(ref listenCount));
-
- Assert.IsFalse(fut.IsDone);
-
- Assert.IsNull(fut.Get());
-
- Thread.Sleep(100); // wait for future completion thread
-
- Assert.AreEqual(10, listenCount);
-
- // Multiple subscribers after completion
- for (var i = 0; i < 10; i++)
- listenAction(fut, () => Interlocked.Decrement(ref listenCount));
-
- Assert.AreEqual(0, listenCount);
- }
[Test]
public void TestToTask()
{
- _cache.Put(1, 1);
-
- _cache.GetFuture().ToTask().Wait();
-
- _cache.Get(1);
+ _cache.PutAsync(1, 1).Wait();
- var task1 = _cache.GetFuture<int>().ToTask();
+ var task1 = _cache.GetAsync(1);
Assert.AreEqual(1, task1.Result);
Assert.IsTrue(task1.IsCompleted);
- _compute.Broadcast(new SleepAction());
-
- var task2 = _compute.GetFuture().ToTask();
+ var task2 = _compute.BroadcastAsync(new SleepAction());
Assert.IsFalse(task2.IsCompleted);
@@ -145,38 +91,6 @@ namespace Apache.Ignite.Core.Tests
task2.Wait();
Assert.IsTrue(task2.IsCompleted);
-
- Assert.AreEqual(null, task2.Result);
- }
-
- [Test]
- public void TestGetWithTimeout()
- {
- _compute.Broadcast(new SleepAction());
-
- var fut = _compute.GetFuture();
-
- Assert.Throws<TimeoutException>(() => fut.Get(TimeSpan.FromMilliseconds(100)));
-
- fut.Get(TimeSpan.FromSeconds(1));
-
- Assert.IsTrue(fut.IsDone);
- }
-
- [Test]
- public void TestToAsyncResult()
- {
- _compute.Broadcast(new SleepAction());
-
- IFuture fut = _compute.GetFuture();
-
- var asyncRes = fut.ToAsyncResult();
-
- Assert.IsFalse(asyncRes.IsCompleted);
-
- Assert.IsTrue(asyncRes.AsyncWaitHandle.WaitOne(1000));
-
- Assert.IsTrue(asyncRes.IsCompleted);
}
[Test]
@@ -203,13 +117,9 @@ namespace Apache.Ignite.Core.Tests
{
var key = typeof(T).Name;
- _cache.Put(key, value);
-
- _cache.GetFuture().Get();
-
- _cache.Get(key);
+ _cache.PutAsync(key, value).Wait();
- Assert.AreEqual(value, _cache.GetFuture<T>().Get());
+ Assert.AreEqual(value, _cache.GetAsync(key).Result);
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
index 274c25e..e424426 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MessagingTest.cs
@@ -192,7 +192,7 @@ namespace Apache.Ignite.Core.Tests
var senders = Task.Factory.StartNew(() => TestUtils.RunMultiThreaded(() =>
{
- messaging.Send((object) NextMessage());
+ messaging.Send(NextMessage());
Thread.Sleep(50);
}, threadCnt, runSeconds));
@@ -252,7 +252,7 @@ namespace Apache.Ignite.Core.Tests
var sharedResult = Thread.VolatileRead(ref sharedReceived);
- messaging.Send((object)NextMessage());
+ messaging.Send(NextMessage());
Thread.Sleep(MessagingTestHelper.MessageTimeout);
@@ -285,15 +285,14 @@ namespace Apache.Ignite.Core.Tests
/// <summary>
/// Tests RemoteListen.
/// </summary>
- public void TestRemoteListen(object topic, bool async = false)
+ private void TestRemoteListen(object topic, bool async = false)
{
- var messaging = async ? _grid1.GetMessaging().WithAsync() : _grid1.GetMessaging();
+ var messaging =_grid1.GetMessaging();
var listener = MessagingTestHelper.GetListener();
- var listenId = messaging.RemoteListen(listener, topic);
-
- if (async)
- listenId = messaging.GetFuture<Guid>().Get();
+ var listenId = async
+ ? messaging.RemoteListenAsync(listener, topic).Result
+ : messaging.RemoteListen(listener, topic);
// Test sending
CheckSend(topic, msg: messaging, remoteListen: true);
@@ -302,17 +301,16 @@ namespace Apache.Ignite.Core.Tests
CheckNoMessage(NextId());
// Test multiple subscriptions for the same filter
- var listenId2 = messaging.RemoteListen(listener, topic);
-
- if (async)
- listenId2 = messaging.GetFuture<Guid>().Get();
+ var listenId2 = async
+ ? messaging.RemoteListenAsync(listener, topic).Result
+ : messaging.RemoteListen(listener, topic);
CheckSend(topic, msg: messaging, remoteListen: true, repeatMultiplier: 2); // expect twice the messages
- messaging.StopRemoteListen(listenId2);
-
if (async)
- messaging.GetFuture().Get();
+ messaging.StopRemoteListenAsync(listenId2).Wait();
+ else
+ messaging.StopRemoteListen(listenId2);
CheckSend(topic, msg: messaging, remoteListen: true); // back to normal after unsubscription
@@ -321,10 +319,10 @@ namespace Apache.Ignite.Core.Tests
Assert.AreEqual("Unable to cast object of type 'System.Double' to type 'System.String'.", ex.Message);
// Test end listen
- messaging.StopRemoteListen(listenId);
-
if (async)
- messaging.GetFuture().Get();
+ messaging.StopRemoteListenAsync(listenId).Wait();
+ else
+ messaging.StopRemoteListen(listenId);
CheckNoMessage(topic);
}
@@ -371,7 +369,7 @@ namespace Apache.Ignite.Core.Tests
var senders = Task.Factory.StartNew(() => TestUtils.RunMultiThreaded(() =>
{
MessagingTestHelper.ClearReceived(int.MaxValue);
- messaging.Send((object) NextMessage());
+ messaging.Send(NextMessage());
Thread.Sleep(50);
}, threadCnt, runSeconds));
@@ -390,7 +388,7 @@ namespace Apache.Ignite.Core.Tests
MessagingTestHelper.ListenResult = false;
- messaging.Send((object) NextMessage()); // send a message to make filters return false
+ messaging.Send(NextMessage()); // send a message to make filters return false
Thread.Sleep(MessagingTestHelper.MessageTimeout); // wait for all to unsubscribe
@@ -400,7 +398,7 @@ namespace Apache.Ignite.Core.Tests
var sharedResult = MessagingTestHelper.ReceivedMessages.Count;
- messaging.Send((object) NextMessage());
+ messaging.Send(NextMessage());
Thread.Sleep(MessagingTestHelper.MessageTimeout);
@@ -439,7 +437,7 @@ namespace Apache.Ignite.Core.Tests
// Single message
MessagingTestHelper.ClearReceived(expectedRepeat);
- msg.Send((object) messages[0], topic);
+ msg.Send(messages[0], topic);
MessagingTestHelper.VerifyReceive(cluster, messages.Take(1), m => m.ToList(), expectedRepeat);
if (single)
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
index ba45dbd..b5ff9c2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesAsyncWrapper.cs
@@ -17,10 +17,10 @@
namespace Apache.Ignite.Core.Tests.Services
{
+ using System;
using System.Collections.Generic;
- using System.Diagnostics;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Services;
/// <summary>
@@ -37,88 +37,104 @@ namespace Apache.Ignite.Core.Tests.Services
/// <param name="services">Services to wrap.</param>
public ServicesAsyncWrapper(IServices services)
{
- _services = services.WithAsync();
+ _services = services;
}
/** <inheritDoc /> */
- public IServices WithAsync()
+ public IClusterGroup ClusterGroup
{
- return this;
+ get { return _services.ClusterGroup; }
}
/** <inheritDoc /> */
- public bool IsAsync
+ public void DeployClusterSingleton(string name, IService service)
{
- get { return true; }
+ _services.DeployClusterSingletonAsync(name, service).Wait();
}
/** <inheritDoc /> */
- public IFuture GetFuture()
+ public Task DeployClusterSingletonAsync(string name, IService service)
{
- Debug.Fail("ServicesAsyncWrapper.Future() should not be called. It always returns null.");
- return null;
+ return _services.DeployClusterSingletonAsync(name, service);
}
/** <inheritDoc /> */
- public IFuture<TResult> GetFuture<TResult>()
+ public void DeployNodeSingleton(string name, IService service)
{
- Debug.Fail("ServicesAsyncWrapper.Future() should not be called. It always returns null.");
- return null;
+ _services.DeployNodeSingletonAsync(name, service).Wait();
}
/** <inheritDoc /> */
- public IClusterGroup ClusterGroup
+ public Task DeployNodeSingletonAsync(string name, IService service)
{
- get { return _services.ClusterGroup; }
+ return _services.DeployNodeSingletonAsync(name, service);
}
/** <inheritDoc /> */
- public void DeployClusterSingleton(string name, IService service)
+ public void DeployKeyAffinitySingleton<TK>(string name, IService service, string cacheName, TK affinityKey)
{
- _services.DeployClusterSingleton(name, service);
- WaitResult();
+ _services.DeployKeyAffinitySingletonAsync(name, service, cacheName, affinityKey).Wait();
}
/** <inheritDoc /> */
- public void DeployNodeSingleton(string name, IService service)
+ public Task DeployKeyAffinitySingletonAsync<TK>(string name, IService service, string cacheName, TK affinityKey)
{
- _services.DeployNodeSingleton(name, service);
- WaitResult();
+ return _services.DeployKeyAffinitySingletonAsync(name, service, cacheName, affinityKey);
}
/** <inheritDoc /> */
- public void DeployKeyAffinitySingleton<TK>(string name, IService service, string cacheName, TK affinityKey)
+ public void DeployMultiple(string name, IService service, int totalCount, int maxPerNodeCount)
{
- _services.DeployKeyAffinitySingleton(name, service, cacheName, affinityKey);
- WaitResult();
+ try
+ {
+ _services.DeployMultipleAsync(name, service, totalCount, maxPerNodeCount).Wait();
+ }
+ catch (AggregateException ex)
+ {
+ throw ex.InnerException;
+ }
}
/** <inheritDoc /> */
- public void DeployMultiple(string name, IService service, int totalCount, int maxPerNodeCount)
+ public Task DeployMultipleAsync(string name, IService service, int totalCount, int maxPerNodeCount)
{
- _services.DeployMultiple(name, service, totalCount, maxPerNodeCount);
- WaitResult();
+ return _services.DeployMultipleAsync(name, service, totalCount, maxPerNodeCount);
}
/** <inheritDoc /> */
public void Deploy(ServiceConfiguration configuration)
{
- _services.Deploy(configuration);
- WaitResult();
+ _services.DeployAsync(configuration).Wait();
+ }
+
+ /** <inheritDoc /> */
+ public Task DeployAsync(ServiceConfiguration configuration)
+ {
+ return _services.DeployAsync(configuration);
}
/** <inheritDoc /> */
public void Cancel(string name)
{
- _services.Cancel(name);
- WaitResult();
+ _services.CancelAsync(name).Wait();
+ }
+
+ /** <inheritDoc /> */
+ public Task CancelAsync(string name)
+ {
+ return _services.CancelAsync(name);
}
/** <inheritDoc /> */
public void CancelAll()
{
- _services.CancelAll();
- WaitResult();
+ _services.CancelAllAsync().Wait();
+ }
+
+ /** <inheritDoc /> */
+ public Task CancelAllAsync()
+ {
+ return _services.CancelAllAsync();
}
/** <inheritDoc /> */
@@ -162,13 +178,5 @@ namespace Apache.Ignite.Core.Tests.Services
{
return new ServicesAsyncWrapper(_services.WithServerKeepPortable());
}
-
- /// <summary>
- /// Waits for the async result.
- /// </summary>
- private void WaitResult()
- {
- _services.GetFuture().Get();
- }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 04cbca1..5c2c6e7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -91,8 +91,6 @@
<Compile Include="Cluster\IClusterNode.cs" />
<Compile Include="Cluster\IClusterNodeFilter.cs" />
<Compile Include="Common\IgniteException.cs" />
- <Compile Include="Common\IAsyncSupport.cs" />
- <Compile Include="Common\IFuture.cs" />
<Compile Include="Common\IgniteGuid.cs" />
<Compile Include="Compute\ComputeExecutionRejectedException.cs" />
<Compile Include="Compute\ComputeJobAdapter.cs" />
@@ -134,7 +132,6 @@
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="IgniteConfiguration.cs" />
<Compile Include="Ignition.cs" />
- <Compile Include="Common\AsyncSupportedAttribute.cs" />
<Compile Include="IIgnite.cs" />
<Compile Include="Impl\Cache\CacheAffinityImpl.cs" />
<Compile Include="Impl\Cache\CacheEntry.cs" />
@@ -149,7 +146,6 @@
<Compile Include="Impl\Cache\CacheLock.cs" />
<Compile Include="Impl\Cache\CacheMetricsImpl.cs" />
<Compile Include="Impl\Cache\CacheOp.cs" />
- <Compile Include="Impl\Cache\CacheProxyImpl.cs" />
<Compile Include="Impl\Cache\Event\CacheEntryCreateEvent.cs" />
<Compile Include="Impl\Cache\Event\CacheEntryRemoveEvent.cs" />
<Compile Include="Impl\Cache\Event\CacheEntryUpdateEvent.cs" />
@@ -172,9 +168,7 @@
<Compile Include="Impl\Collections\MultiValueDictionary.cs" />
<Compile Include="Impl\Collections\ReadOnlyCollection.cs" />
<Compile Include="Impl\Collections\ReadOnlyDictionary.cs" />
- <Compile Include="Impl\Common\AsyncResult.cs" />
<Compile Include="Impl\Common\Classpath.cs" />
- <Compile Include="Impl\Common\CompletedAsyncResult.cs" />
<Compile Include="Impl\Common\CopyOnWriteConcurrentDictionary.cs" />
<Compile Include="Impl\Common\DelegateConverter.cs" />
<Compile Include="Impl\Common\DelegateTypeDescriptor.cs" />
@@ -196,7 +190,6 @@
<Compile Include="Impl\Compute\Closure\ComputeSingleClosureTask.cs" />
<Compile Include="Impl\Compute\Closure\IComputeResourceInjector.cs" />
<Compile Include="Impl\Compute\Compute.cs" />
- <Compile Include="Impl\Compute\ComputeAsync.cs" />
<Compile Include="Impl\Compute\ComputeFunc.cs" />
<Compile Include="Impl\Compute\ComputeImpl.cs" />
<Compile Include="Impl\Compute\ComputeJob.cs" />
@@ -212,7 +205,6 @@
<Compile Include="Impl\Datastream\StreamReceiverHolder.cs" />
<Compile Include="Impl\DataStructures\AtomicLong.cs" />
<Compile Include="Impl\Events\Events.cs" />
- <Compile Include="Impl\Events\EventsAsync.cs" />
<Compile Include="Impl\Events\RemoteListenEventFilter.cs" />
<Compile Include="Impl\ExceptionUtils.cs" />
<Compile Include="Impl\IgniteConfigurationEx.cs" />
@@ -241,7 +233,6 @@
<Compile Include="Impl\Memory\PlatformUnpooledMemory.cs" />
<Compile Include="Impl\Messaging\MessageListenerHolder.cs" />
<Compile Include="Impl\Messaging\Messaging.cs" />
- <Compile Include="Impl\Messaging\MessagingAsync.cs" />
<Compile Include="Impl\NativeMethods.cs" />
<Compile Include="Impl\Portable\DateTimeHolder.cs" />
<Compile Include="Impl\Portable\IO\IPortableStream.cs" />
@@ -294,8 +285,6 @@
<Compile Include="Impl\Services\ServiceProxyInvoker.cs" />
<Compile Include="Impl\Services\ServiceProxySerializer.cs" />
<Compile Include="Impl\Services\Services.cs" />
- <Compile Include="Impl\Services\ServicesAsync.cs" />
- <Compile Include="Impl\Transactions\AsyncTransaction.cs" />
<Compile Include="Impl\Transactions\Transaction.cs" />
<Compile Include="Impl\Transactions\TransactionImpl.cs" />
<Compile Include="Impl\Transactions\TransactionMetricsImpl.cs" />
[08/17] ignite git commit: IGNITE-1644: Correct DateTime
serialization.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/05e739f1/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
index 44a7137..ad92223 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableBuilder.cs
@@ -17,6 +17,9 @@
namespace Apache.Ignite.Core.Portable
{
+ using System;
+ using System.Collections;
+
/// <summary>
/// Portable object builder. Provides ability to build portable objects dynamically
/// without having class definitions.
@@ -71,5 +74,237 @@ namespace Apache.Ignite.Core.Portable
/// </summary>
/// <returns>Resulting portable object.</returns>
IPortableObject Build();
+
+ /// <summary>
+ /// Sets the array field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetArrayField<T>(string fieldName, T[] val);
+
+ /// <summary>
+ /// Sets the boolean field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetBooleanField(string fieldName, bool val);
+
+ /// <summary>
+ /// Sets the boolean array field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetBooleanArrayField(string fieldName, bool[] val);
+
+ /// <summary>
+ /// Sets the byte field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetByteField(string fieldName, byte val);
+
+ /// <summary>
+ /// Sets the byte array field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetByteArrayField(string fieldName, byte[] val);
+
+ /// <summary>
+ /// Sets the char field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetCharField(string fieldName, char val);
+
+ /// <summary>
+ /// Sets the char array field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetCharArrayField(string fieldName, char[] val);
+
+ /// <summary>
+ /// Sets the collection field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetCollectionField(string fieldName, ICollection val);
+
+ /// <summary>
+ /// Sets the decimal field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetDecimalField(string fieldName, decimal? val);
+
+ /// <summary>
+ /// Sets the decimal array field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetDecimalArrayField(string fieldName, decimal?[] val);
+
+ /// <summary>
+ /// Sets the dictionary field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetDictionaryField(string fieldName, IDictionary val);
+
+ /// <summary>
+ /// Sets the double field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetDoubleField(string fieldName, double val);
+
+ /// <summary>
+ /// Sets the double array field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetDoubleArrayField(string fieldName, double[] val);
+
+ /// <summary>
+ /// Sets the enum field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetEnumField<T>(string fieldName, T val);
+
+ /// <summary>
+ /// Sets the enum array field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetEnumArrayField<T>(string fieldName, T[] val);
+
+ /// <summary>
+ /// Sets the float field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetFloatField(string fieldName, float val);
+
+ /// <summary>
+ /// Sets the float array field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetFloatArrayField(string fieldName, float[] val);
+
+ /// <summary>
+ /// Sets the guid field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetGuidField(string fieldName, Guid? val);
+
+ /// <summary>
+ /// Sets the guid array field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetGuidArrayField(string fieldName, Guid?[] val);
+
+ /// <summary>
+ /// Sets the int field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetIntField(string fieldName, int val);
+
+ /// <summary>
+ /// Sets the int array field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetIntArrayField(string fieldName, int[] val);
+
+ /// <summary>
+ /// Sets the long field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetLongField(string fieldName, long val);
+
+ /// <summary>
+ /// Sets the long array field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetLongArrayField(string fieldName, long[] val);
+
+ /// <summary>
+ /// Sets the short field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetShortField(string fieldName, short val);
+
+ /// <summary>
+ /// Sets the short array field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetShortArrayField(string fieldName, short[] val);
+
+ /// <summary>
+ /// Sets the string field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetStringField(string fieldName, string val);
+
+ /// <summary>
+ /// Sets the string array field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetStringArrayField(string fieldName, string[] val);
+
+ /// <summary>
+ /// Sets the timestamp field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetTimestampField(string fieldName, DateTime? val);
+
+ /// <summary>
+ /// Sets the timestamp array field.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="val">The value.</param>
+ /// <returns>Current builder instance.</returns>
+ IPortableBuilder SetTimestampArrayField(string fieldName, DateTime?[] val);
}
}
[12/17] ignite git commit: IGNITE-1652: .Net async API reworked.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index af230b3..4ceb292 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -22,12 +22,11 @@ namespace Apache.Ignite.Core.Impl.Cache
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
- using System.Threading;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cache.Expiry;
using Apache.Ignite.Core.Cache.Query;
using Apache.Ignite.Core.Cache.Query.Continuous;
- using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Cache.Query;
using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
using Apache.Ignite.Core.Impl.Common;
@@ -67,13 +66,8 @@ namespace Apache.Ignite.Core.Impl.Cache
/** Flag: no-retries.*/
private readonly bool _flagNoRetries;
- /**
- * Result converter for async InvokeAll operation.
- * In future result processing there is only one TResult generic argument,
- * and we can't get the type of ICacheEntryProcessorResult at compile time from it.
- * This field caches converter for the last InvokeAll operation to avoid using reflection.
- */
- private readonly ThreadLocal<object> _invokeAllConverter = new ThreadLocal<object>();
+ /** Async instance. */
+ private readonly Lazy<CacheImpl<TK, TV>> _asyncInstance;
/// <summary>
/// Constructor.
@@ -93,54 +87,62 @@ namespace Apache.Ignite.Core.Impl.Cache
_flagKeepPortable = flagKeepPortable;
_flagAsync = flagAsync;
_flagNoRetries = flagNoRetries;
+
+ _asyncInstance = new Lazy<CacheImpl<TK, TV>>(() => new CacheImpl<TK, TV>(this));
}
- /** <inheritDoc /> */
- public IIgnite Ignite
+ /// <summary>
+ /// Initializes a new async instance.
+ /// </summary>
+ /// <param name="cache">The cache.</param>
+ private CacheImpl(CacheImpl<TK, TV> cache) : base(UU.CacheWithAsync(cache.Target), cache.Marshaller)
{
- get
- {
- return _ignite;
- }
+ _ignite = cache._ignite;
+ _flagSkipStore = cache._flagSkipStore;
+ _flagKeepPortable = cache._flagKeepPortable;
+ _flagAsync = true;
+ _flagNoRetries = cache._flagNoRetries;
}
/** <inheritDoc /> */
- public bool IsAsync
+ public IIgnite Ignite
{
- get { return _flagAsync; }
+ get { return _ignite; }
}
/** <inheritDoc /> */
- public IFuture GetFuture()
+ private bool IsAsync
{
- throw new NotSupportedException("GetFuture() should be called through CacheProxyImpl");
+ get { return _flagAsync; }
}
- /** <inheritDoc /> */
- public IFuture<TResult> GetFuture<TResult>()
+ /// <summary>
+ /// Gets and resets task for previous asynchronous operation.
+ /// </summary>
+ /// <param name="lastAsyncOp">The last async op id.</param>
+ /// <returns>
+ /// Task for previous asynchronous operation.
+ /// </returns>
+ private Task GetTask(CacheOp lastAsyncOp)
{
- throw new NotSupportedException("GetFuture() should be called through CacheProxyImpl");
+ return GetTask<object>(lastAsyncOp);
}
/// <summary>
- /// Gets and resets future for previous asynchronous operation.
+ /// Gets and resets task for previous asynchronous operation.
/// </summary>
+ /// <typeparam name="TResult">The type of the result.</typeparam>
/// <param name="lastAsyncOp">The last async op id.</param>
+ /// <param name="converter">The converter.</param>
/// <returns>
- /// Future for previous asynchronous operation.
+ /// Task for previous asynchronous operation.
/// </returns>
- /// <exception cref="System.InvalidOperationException">Asynchronous mode is disabled</exception>
- internal IFuture<TResult> GetFuture<TResult>(CacheOp lastAsyncOp)
+ private Task<TResult> GetTask<TResult>(CacheOp lastAsyncOp, Func<PortableReaderImpl, TResult> converter = null)
{
- if (!_flagAsync)
- throw IgniteUtils.GetAsyncModeDisabledException();
-
- var converter = GetFutureResultConverter<TResult>(lastAsyncOp);
-
- _invokeAllConverter.Value = null;
+ Debug.Assert(_flagAsync);
return GetFuture((futId, futTypeId) => UU.TargetListenFutureForOperation(Target, futId, futTypeId,
- (int) lastAsyncOp), _flagKeepPortable, converter);
+ (int) lastAsyncOp), _flagKeepPortable, converter).Task;
}
/** <inheritDoc /> */
@@ -151,6 +153,7 @@ namespace Apache.Ignite.Core.Impl.Cache
/** <inheritDoc /> */
+ /** <inheritDoc /> */
public bool IsEmpty()
{
return GetSize() == 0;
@@ -225,13 +228,6 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public ICache<TK, TV> WithAsync()
- {
- return _flagAsync ? this : new CacheImpl<TK, TV>(_ignite, UU.CacheWithAsync(Target), Marshaller,
- _flagSkipStore, _flagKeepPortable, true, _flagNoRetries);
- }
-
- /** <inheritDoc /> */
public bool IsKeepPortable
{
get { return _flagKeepPortable; }
@@ -244,11 +240,27 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
+ public Task LoadCacheAsync(ICacheEntryFilter<TK, TV> p, params object[] args)
+ {
+ AsyncInstance.LoadCache(p, args);
+
+ return AsyncInstance.GetTask(CacheOp.LoadCache);
+ }
+
+ /** <inheritDoc /> */
public void LocalLoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
{
LoadCache0(p, args, (int)CacheOp.LocLoadCache);
}
+ /** <inheritDoc /> */
+ public Task LocalLoadCacheAsync(ICacheEntryFilter<TK, TV> p, params object[] args)
+ {
+ AsyncInstance.LocalLoadCache(p, args);
+
+ return AsyncInstance.GetTask(CacheOp.LocLoadCache);
+ }
+
/// <summary>
/// Loads the cache.
/// </summary>
@@ -276,7 +288,15 @@ namespace Apache.Ignite.Core.Impl.Cache
IgniteArgumentCheck.NotNull(key, "key");
return DoOutOp((int)CacheOp.ContainsKey, key) == True;
- }
+ }
+
+ /** <inheritDoc /> */
+ public Task<bool> ContainsKeyAsync(TK key)
+ {
+ AsyncInstance.ContainsKey(key);
+
+ return AsyncInstance.GetTask<bool>(CacheOp.ContainsKey);
+ }
/** <inheritDoc /> */
public bool ContainsKeys(IEnumerable<TK> keys)
@@ -284,7 +304,15 @@ namespace Apache.Ignite.Core.Impl.Cache
IgniteArgumentCheck.NotNull(keys, "keys");
return DoOutOp((int)CacheOp.ContainsKeys, writer => WriteEnumerable(writer, keys)) == True;
- }
+ }
+
+ /** <inheritDoc /> */
+ public Task<bool> ContainsKeysAsync(IEnumerable<TK> keys)
+ {
+ AsyncInstance.ContainsKeys(keys);
+
+ return AsyncInstance.GetTask<bool>(CacheOp.ContainsKeys);
+ }
/** <inheritDoc /> */
public TV LocalPeek(TK key, params CachePeekMode[] modes)
@@ -355,6 +383,20 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
+ public Task<TV> GetAsync(TK key)
+ {
+ AsyncInstance.Get(key);
+
+ return AsyncInstance.GetTask(CacheOp.Get, reader =>
+ {
+ if (reader != null)
+ return reader.ReadObject<TV>();
+
+ throw GetKeyNotFoundException();
+ });
+ }
+
+ /** <inheritDoc /> */
public bool TryGet(TK key, out TV value)
{
IgniteArgumentCheck.NotNull(key, "key");
@@ -370,6 +412,16 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
+ public Task<CacheResult<TV>> TryGetAsync(TK key)
+ {
+ IgniteArgumentCheck.NotNull(key, "key");
+
+ AsyncInstance.Get(key);
+
+ return AsyncInstance.GetTask(CacheOp.Get, GetCacheResult);
+ }
+
+ /** <inheritDoc /> */
public IDictionary<TK, TV> GetAll(IEnumerable<TK> keys)
{
IgniteArgumentCheck.NotNull(keys, "keys");
@@ -384,6 +436,14 @@ namespace Apache.Ignite.Core.Impl.Cache
});
}
+ /** <inheritDoc /> */
+ public Task<IDictionary<TK, TV>> GetAllAsync(IEnumerable<TK> keys)
+ {
+ AsyncInstance.GetAll(keys);
+
+ return AsyncInstance.GetTask(CacheOp.GetAll, r => r == null ? null : ReadGetAllDictionary(r));
+ }
+
/** <inheritdoc /> */
public void Put(TK key, TV val)
{
@@ -395,6 +455,14 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
+ public Task PutAsync(TK key, TV val)
+ {
+ AsyncInstance.Put(key, val);
+
+ return AsyncInstance.GetTask(CacheOp.Put);
+ }
+
+ /** <inheritDoc /> */
public CacheResult<TV> GetAndPut(TK key, TV val)
{
IgniteArgumentCheck.NotNull(key, "key");
@@ -405,13 +473,29 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
+ public Task<CacheResult<TV>> GetAndPutAsync(TK key, TV val)
+ {
+ AsyncInstance.GetAndPut(key, val);
+
+ return AsyncInstance.GetTask(CacheOp.GetAndPut, GetCacheResult);
+ }
+
+ /** <inheritDoc /> */
public CacheResult<TV> GetAndReplace(TK key, TV val)
{
IgniteArgumentCheck.NotNull(key, "key");
IgniteArgumentCheck.NotNull(val, "val");
- return DoOutInOpNullable<TK, TV, TV>((int)CacheOp.GetAndReplace, key, val);
+ return DoOutInOpNullable<TK, TV, TV>((int) CacheOp.GetAndReplace, key, val);
+ }
+
+ /** <inheritDoc /> */
+ public Task<CacheResult<TV>> GetAndReplaceAsync(TK key, TV val)
+ {
+ AsyncInstance.GetAndReplace(key, val);
+
+ return AsyncInstance.GetTask(CacheOp.GetAndReplace, GetCacheResult);
}
/** <inheritDoc /> */
@@ -422,6 +506,14 @@ namespace Apache.Ignite.Core.Impl.Cache
return DoOutInOpNullable<TK, TV>((int)CacheOp.GetAndRemove, key);
}
+ /** <inheritDoc /> */
+ public Task<CacheResult<TV>> GetAndRemoveAsync(TK key)
+ {
+ AsyncInstance.GetAndRemove(key);
+
+ return AsyncInstance.GetTask(CacheOp.GetAndRemove, GetCacheResult);
+ }
+
/** <inheritdoc /> */
public bool PutIfAbsent(TK key, TV val)
{
@@ -432,6 +524,14 @@ namespace Apache.Ignite.Core.Impl.Cache
return DoOutOp((int) CacheOp.PutIfAbsent, key, val) == True;
}
+ /** <inheritDoc /> */
+ public Task<bool> PutIfAbsentAsync(TK key, TV val)
+ {
+ AsyncInstance.PutIfAbsent(key, val);
+
+ return AsyncInstance.GetTask<bool>(CacheOp.PutIfAbsent);
+ }
+
/** <inheritdoc /> */
public CacheResult<TV> GetAndPutIfAbsent(TK key, TV val)
{
@@ -442,6 +542,14 @@ namespace Apache.Ignite.Core.Impl.Cache
return DoOutInOpNullable<TK, TV, TV>((int)CacheOp.GetAndPutIfAbsent, key, val);
}
+ /** <inheritDoc /> */
+ public Task<CacheResult<TV>> GetAndPutIfAbsentAsync(TK key, TV val)
+ {
+ AsyncInstance.GetAndPutIfAbsent(key, val);
+
+ return AsyncInstance.GetTask(CacheOp.GetAndPutIfAbsent, GetCacheResult);
+ }
+
/** <inheritdoc /> */
public bool Replace(TK key, TV val)
{
@@ -449,7 +557,15 @@ namespace Apache.Ignite.Core.Impl.Cache
IgniteArgumentCheck.NotNull(val, "val");
- return DoOutOp((int)CacheOp.Replace2, key, val) == True;
+ return DoOutOp((int) CacheOp.Replace2, key, val) == True;
+ }
+
+ /** <inheritDoc /> */
+ public Task<bool> ReplaceAsync(TK key, TV val)
+ {
+ AsyncInstance.Replace(key, val);
+
+ return AsyncInstance.GetTask<bool>(CacheOp.Replace2);
}
/** <inheritdoc /> */
@@ -464,6 +580,14 @@ namespace Apache.Ignite.Core.Impl.Cache
return DoOutOp((int)CacheOp.Replace3, key, oldVal, newVal) == True;
}
+ /** <inheritDoc /> */
+ public Task<bool> ReplaceAsync(TK key, TV oldVal, TV newVal)
+ {
+ AsyncInstance.Replace(key, oldVal, newVal);
+
+ return AsyncInstance.GetTask<bool>(CacheOp.Replace3);
+ }
+
/** <inheritdoc /> */
public void PutAll(IDictionary<TK, TV> vals)
{
@@ -471,7 +595,15 @@ namespace Apache.Ignite.Core.Impl.Cache
DoOutOp((int) CacheOp.PutAll, writer => WriteDictionary(writer, vals));
}
-
+
+ /** <inheritDoc /> */
+ public Task PutAllAsync(IDictionary<TK, TV> vals)
+ {
+ AsyncInstance.PutAll(vals);
+
+ return AsyncInstance.GetTask(CacheOp.PutAll);
+ }
+
/** <inheritdoc /> */
public void LocalEvict(IEnumerable<TK> keys)
{
@@ -486,12 +618,28 @@ namespace Apache.Ignite.Core.Impl.Cache
UU.CacheClear(Target);
}
+ /** <inheritDoc /> */
+ public Task ClearAsync()
+ {
+ AsyncInstance.Clear();
+
+ return AsyncInstance.GetTask();
+ }
+
/** <inheritdoc /> */
public void Clear(TK key)
{
IgniteArgumentCheck.NotNull(key, "key");
- DoOutOp((int)CacheOp.Clear, key);
+ DoOutOp((int) CacheOp.Clear, key);
+ }
+
+ /** <inheritDoc /> */
+ public Task ClearAsync(TK key)
+ {
+ AsyncInstance.Clear(key);
+
+ return AsyncInstance.GetTask(CacheOp.Clear);
}
/** <inheritdoc /> */
@@ -502,6 +650,14 @@ namespace Apache.Ignite.Core.Impl.Cache
DoOutOp((int)CacheOp.ClearAll, writer => WriteEnumerable(writer, keys));
}
+ /** <inheritDoc /> */
+ public Task ClearAllAsync(IEnumerable<TK> keys)
+ {
+ AsyncInstance.ClearAll(keys);
+
+ return AsyncInstance.GetTask(CacheOp.ClearAll);
+ }
+
/** <inheritdoc /> */
public void LocalClear(TK key)
{
@@ -523,7 +679,15 @@ namespace Apache.Ignite.Core.Impl.Cache
{
IgniteArgumentCheck.NotNull(key, "key");
- return DoOutOp((int)CacheOp.RemoveObj, key) == True;
+ return DoOutOp((int) CacheOp.RemoveObj, key) == True;
+ }
+
+ /** <inheritDoc /> */
+ public Task<bool> RemoveAsync(TK key)
+ {
+ AsyncInstance.Remove(key);
+
+ return AsyncInstance.GetTask<bool>(CacheOp.RemoveObj);
}
/** <inheritDoc /> */
@@ -537,6 +701,14 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
+ public Task<bool> RemoveAsync(TK key, TV val)
+ {
+ AsyncInstance.Remove(key, val);
+
+ return AsyncInstance.GetTask<bool>(CacheOp.RemoveBool);
+ }
+
+ /** <inheritDoc /> */
public void RemoveAll(IEnumerable<TK> keys)
{
IgniteArgumentCheck.NotNull(keys, "keys");
@@ -545,12 +717,28 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
+ public Task RemoveAllAsync(IEnumerable<TK> keys)
+ {
+ AsyncInstance.RemoveAll(keys);
+
+ return AsyncInstance.GetTask(CacheOp.RemoveAll);
+ }
+
+ /** <inheritDoc /> */
public void RemoveAll()
{
UU.CacheRemoveAll(Target);
}
/** <inheritDoc /> */
+ public Task RemoveAllAsync()
+ {
+ AsyncInstance.RemoveAll();
+
+ return AsyncInstance.GetTask();
+ }
+
+ /** <inheritDoc /> */
public int GetLocalSize(params CachePeekMode[] modes)
{
return Size0(true, modes);
@@ -562,6 +750,14 @@ namespace Apache.Ignite.Core.Impl.Cache
return Size0(false, modes);
}
+ /** <inheritDoc /> */
+ public Task<int> GetSizeAsync(params CachePeekMode[] modes)
+ {
+ AsyncInstance.GetSize(modes);
+
+ return AsyncInstance.GetTask<int>();
+ }
+
/// <summary>
/// Internal size routine.
/// </summary>
@@ -601,6 +797,25 @@ namespace Apache.Ignite.Core.Impl.Cache
input => GetResultOrThrow<TRes>(Unmarshal<object>(input)));
}
+ /** <inheritDoc /> */
+ public Task<TRes> InvokeAsync<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
+ {
+ AsyncInstance.Invoke(key, processor, arg);
+
+ return AsyncInstance.GetTask(CacheOp.Invoke, r =>
+ {
+ if (r == null)
+ return default(TRes);
+
+ var hasError = r.ReadBoolean();
+
+ if (hasError)
+ throw ReadException(r.Stream);
+
+ return r.ReadObject<TRes>();
+ });
+ }
+
/** <inheritdoc /> */
public IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
@@ -612,19 +827,21 @@ namespace Apache.Ignite.Core.Impl.Cache
var holder = new CacheEntryProcessorHolder(processor, arg,
(e, a) => processor.Process((IMutableCacheEntry<TK, TV>)e, (TArg)a), typeof(TK), typeof(TV));
- return DoOutInOp((int)CacheOp.InvokeAll, writer =>
- {
- WriteEnumerable(writer, keys);
- writer.Write(holder);
- },
- input =>
- {
- if (IsAsync)
- _invokeAllConverter.Value = (Func<PortableReaderImpl, IDictionary<TK, ICacheEntryProcessorResult<TRes>>>)
- (reader => ReadInvokeAllResults<TRes>(reader.Stream));
+ return DoOutInOp((int) CacheOp.InvokeAll,
+ writer =>
+ {
+ WriteEnumerable(writer, keys);
+ writer.Write(holder);
+ },
+ input => ReadInvokeAllResults<TRes>(input));
+ }
- return ReadInvokeAllResults<TRes>(input);
- });
+ /** <inheritDoc /> */
+ public Task<IDictionary<TK, ICacheEntryProcessorResult<TRes>>> InvokeAllAsync<TArg, TRes>(IEnumerable<TK> keys, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
+ {
+ AsyncInstance.InvokeAll(keys, processor, arg);
+
+ return AsyncInstance.GetTask(CacheOp.InvokeAll, reader => ReadInvokeAllResults<TRes>(reader.Stream));
}
/** <inheritdoc /> */
@@ -673,9 +890,9 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public IFuture Rebalance()
+ public Task Rebalance()
{
- return GetFuture<object>((futId, futTyp) => UU.CacheRebalance(Target, futId));
+ return GetFuture<object>((futId, futTyp) => UU.CacheRebalance(Target, futId)).Task;
}
/** <inheritDoc /> */
@@ -689,11 +906,11 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/// <summary>
- /// Gets a value indicating whether this instance is in no-retries mode.
+ /// Gets the asynchronous instance.
/// </summary>
- internal bool IsNoRetries
+ private CacheImpl<TK, TV> AsyncInstance
{
- get { return _flagNoRetries; }
+ get { return _asyncInstance.Value; }
}
#region Queries
@@ -970,59 +1187,15 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/// <summary>
- /// Gets the future result converter based on the last operation id.
+ /// Gets the cache result.
/// </summary>
- /// <typeparam name="TResult">The type of the future result.</typeparam>
- /// <param name="lastAsyncOpId">The last op id.</param>
- /// <returns>Future result converter.</returns>
- private Func<PortableReaderImpl, TResult> GetFutureResultConverter<TResult>(CacheOp lastAsyncOpId)
+ private static CacheResult<TV> GetCacheResult(PortableReaderImpl reader)
{
- switch (lastAsyncOpId)
- {
- case CacheOp.Get:
- return reader =>
- {
- if (reader != null)
- return reader.ReadObject<TResult>();
-
- throw GetKeyNotFoundException();
- };
-
- case CacheOp.GetAll:
- return reader => reader == null ? default(TResult) : (TResult) ReadGetAllDictionary(reader);
+ var res = reader == null
+ ? new CacheResult<TV>()
+ : new CacheResult<TV>(reader.ReadObject<TV>());
- case CacheOp.Invoke:
- return reader =>
- {
- if (reader == null)
- return default(TResult);
-
- var hasError = reader.ReadBoolean();
-
- if (hasError)
- throw ReadException(reader.Stream);
-
- return reader.ReadObject<TResult>();
- };
-
- case CacheOp.InvokeAll:
- return _invokeAllConverter.Value as Func<PortableReaderImpl, TResult>;
-
- case CacheOp.GetAndPut:
- case CacheOp.GetAndPutIfAbsent:
- case CacheOp.GetAndRemove:
- case CacheOp.GetAndReplace:
- return reader =>
- {
- var res = reader == null
- ? new CacheResult<TV>()
- : new CacheResult<TV>(reader.ReadObject<TV>());
-
- return TypeCaster<TResult>.Cast(res);
- };
- }
-
- return null;
+ return res;
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
deleted file mode 100644
index aaaf8c3..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheProxyImpl.cs
+++ /dev/null
@@ -1,519 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Cache
-{
- using System.Collections;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Diagnostics.CodeAnalysis;
- using System.Threading;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Cache.Expiry;
- using Apache.Ignite.Core.Cache.Query;
- using Apache.Ignite.Core.Cache.Query.Continuous;
- using Apache.Ignite.Core.Common;
-
- /// <summary>
- /// Cache proxy.
- /// </summary>
- [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
- internal class CacheProxyImpl<TK, TV> : ICache<TK, TV>
- {
- /** wrapped cache instance */
- private readonly CacheImpl<TK, TV> _cache;
-
- /** */
- private readonly ThreadLocal<CacheOp> _lastAsyncOp = new ThreadLocal<CacheOp>(() => CacheOp.None);
-
- /// <summary>
- /// Initializes a new instance of the <see cref="CacheProxyImpl{K, V}"/> class.
- /// </summary>
- /// <param name="cache">The cache to wrap.</param>
- public CacheProxyImpl(CacheImpl<TK, TV> cache)
- {
- Debug.Assert(cache != null);
-
- _cache = cache;
- }
-
- /** <inheritDoc /> */
- public ICache<TK, TV> WithSkipStore()
- {
- return _cache.IsSkipStore ? this : new CacheProxyImpl<TK, TV>((CacheImpl<TK, TV>)_cache.WithSkipStore());
- }
-
- /** <inheritDoc /> */
- public ICache<TK, TV> WithExpiryPolicy(IExpiryPolicy plc)
- {
- return new CacheProxyImpl<TK, TV>((CacheImpl<TK, TV>)_cache.WithExpiryPolicy(plc));
- }
-
- /** <inheritDoc /> */
- public ICache<TK, TV> WithAsync()
- {
- return IsAsync ? this : new CacheProxyImpl<TK, TV>((CacheImpl<TK, TV>) _cache.WithAsync());
- }
-
- /** <inheritDoc /> */
- public bool IsAsync
- {
- get { return _cache.IsAsync; }
- }
-
- /** <inheritDoc /> */
- public IFuture GetFuture()
- {
- return GetFuture<object>();
- }
-
- /** <inheritDoc /> */
- public IFuture<TResult> GetFuture<TResult>()
- {
- var fut = _cache.GetFuture<TResult>(_lastAsyncOp.Value);
-
- ClearLastAsyncOp();
-
- return fut;
- }
-
- /** <inheritDoc /> */
- public IEnumerator<ICacheEntry<TK, TV>> GetEnumerator()
- {
- return _cache.GetEnumerator();
- }
-
- /** <inheritDoc /> */
- IEnumerator IEnumerable.GetEnumerator()
- {
- return ((IEnumerable) _cache).GetEnumerator();
- }
-
- /** <inheritDoc /> */
- public string Name
- {
- get { return _cache.Name; }
- }
-
- /** <inheritDoc /> */
- public IIgnite Ignite
- {
- get { return _cache.Ignite; }
- }
-
- /** <inheritDoc /> */
-
- public bool IsEmpty()
- {
- return _cache.IsEmpty();
- }
-
- /** <inheritDoc /> */
- public bool IsKeepPortable
- {
- get { return _cache.IsKeepPortable; }
- }
-
- /// <summary>
- /// Skip store flag.
- /// </summary>
- internal bool SkipStore
- {
- get { return _cache.IsSkipStore; }
- }
-
- /** <inheritDoc /> */
- public ICache<TK1, TV1> WithKeepPortable<TK1, TV1>()
- {
- return new CacheProxyImpl<TK1, TV1>((CacheImpl<TK1, TV1>) _cache.WithKeepPortable<TK1, TV1>());
- }
-
- /** <inheritDoc /> */
- public void LoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
- {
- _cache.LoadCache(p, args);
-
- SetLastAsyncOp(CacheOp.LoadCache);
- }
-
- /** <inheritDoc /> */
- public void LocalLoadCache(ICacheEntryFilter<TK, TV> p, params object[] args)
- {
- _cache.LocalLoadCache(p, args);
-
- SetLastAsyncOp(CacheOp.LocLoadCache);
- }
-
- /** <inheritDoc /> */
- public bool ContainsKey(TK key)
- {
- var result = _cache.ContainsKey(key);
-
- SetLastAsyncOp(CacheOp.ContainsKey);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public bool ContainsKeys(IEnumerable<TK> keys)
- {
- var result = _cache.ContainsKeys(keys);
-
- SetLastAsyncOp(CacheOp.ContainsKeys);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public TV LocalPeek(TK key, params CachePeekMode[] modes)
- {
- return _cache.LocalPeek(key, modes);
- }
-
- /** <inheritDoc /> */
- public bool TryLocalPeek(TK key, out TV value, params CachePeekMode[] modes)
- {
- return _cache.TryLocalPeek(key, out value, modes);
- }
-
- /** <inheritDoc /> */
- public TV this[TK key]
- {
- get { return _cache[key]; }
- set { _cache[key] = value; }
- }
-
- /** <inheritDoc /> */
- public TV Get(TK key)
- {
- var result = _cache.Get(key);
-
- SetLastAsyncOp(CacheOp.Get);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public bool TryGet(TK key, out TV value)
- {
- return _cache.TryGet(key, out value);
- }
-
- /** <inheritDoc /> */
- public IDictionary<TK, TV> GetAll(IEnumerable<TK> keys)
- {
- var result = _cache.GetAll(keys);
-
- SetLastAsyncOp(CacheOp.GetAll);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public void Put(TK key, TV val)
- {
- _cache.Put(key, val);
-
- SetLastAsyncOp(CacheOp.Put);
- }
-
- /** <inheritDoc /> */
- public CacheResult<TV> GetAndPut(TK key, TV val)
- {
- var result = _cache.GetAndPut(key, val);
-
- SetLastAsyncOp(CacheOp.GetAndPut);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public CacheResult<TV> GetAndReplace(TK key, TV val)
- {
- var result = _cache.GetAndReplace(key, val);
-
- SetLastAsyncOp(CacheOp.GetAndReplace);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public CacheResult<TV> GetAndRemove(TK key)
- {
- var result = _cache.GetAndRemove(key);
-
- SetLastAsyncOp(CacheOp.GetAndRemove);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public bool PutIfAbsent(TK key, TV val)
- {
- var result = _cache.PutIfAbsent(key, val);
-
- SetLastAsyncOp(CacheOp.PutIfAbsent);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public CacheResult<TV> GetAndPutIfAbsent(TK key, TV val)
- {
- var result = _cache.GetAndPutIfAbsent(key, val);
-
- SetLastAsyncOp(CacheOp.GetAndPutIfAbsent);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public bool Replace(TK key, TV val)
- {
- var result = _cache.Replace(key, val);
-
- SetLastAsyncOp(CacheOp.Replace2);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public bool Replace(TK key, TV oldVal, TV newVal)
- {
- var result = _cache.Replace(key, oldVal, newVal);
-
- SetLastAsyncOp(CacheOp.Replace3);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public void PutAll(IDictionary<TK, TV> vals)
- {
- _cache.PutAll(vals);
-
- SetLastAsyncOp(CacheOp.PutAll);
- }
-
- /** <inheritDoc /> */
- public void LocalEvict(IEnumerable<TK> keys)
- {
- _cache.LocalEvict(keys);
- }
-
- /** <inheritDoc /> */
- public void Clear()
- {
- _cache.Clear();
-
- ClearLastAsyncOp();
- }
-
- /** <inheritDoc /> */
- public void Clear(TK key)
- {
- _cache.Clear(key);
-
- SetLastAsyncOp(CacheOp.Clear);
- }
-
- /** <inheritDoc /> */
- public void ClearAll(IEnumerable<TK> keys)
- {
- _cache.ClearAll(keys);
-
- SetLastAsyncOp(CacheOp.ClearAll);
- }
-
- /** <inheritDoc /> */
- public void LocalClear(TK key)
- {
- _cache.LocalClear(key);
- }
-
- /** <inheritDoc /> */
- public void LocalClearAll(IEnumerable<TK> keys)
- {
- _cache.LocalClearAll(keys);
- }
-
- /** <inheritDoc /> */
- public bool Remove(TK key)
- {
- var result = _cache.Remove(key);
-
- SetLastAsyncOp(CacheOp.RemoveObj);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public bool Remove(TK key, TV val)
- {
- var result = _cache.Remove(key, val);
-
- SetLastAsyncOp(CacheOp.RemoveBool);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public void RemoveAll(IEnumerable<TK> keys)
- {
- _cache.RemoveAll(keys);
-
- SetLastAsyncOp(CacheOp.RemoveAll);
- }
-
- /** <inheritDoc /> */
- public void RemoveAll()
- {
- _cache.RemoveAll();
-
- ClearLastAsyncOp();
- }
-
- /** <inheritDoc /> */
- public int GetLocalSize(params CachePeekMode[] modes)
- {
- return _cache.GetLocalSize(modes);
- }
-
- /** <inheritDoc /> */
- public int GetSize(params CachePeekMode[] modes)
- {
- var result = _cache.GetSize(modes);
-
- ClearLastAsyncOp();
-
- return result;
- }
-
- /** <inheritDoc /> */
- public void LocalPromote(IEnumerable<TK> keys)
- {
- _cache.LocalPromote(keys);
- }
-
- /** <inheritDoc /> */
- public IQueryCursor<ICacheEntry<TK, TV>> Query(QueryBase qry)
- {
- return _cache.Query(qry);
- }
-
- /** <inheritDoc /> */
- public IQueryCursor<IList> QueryFields(SqlFieldsQuery qry)
- {
- return _cache.QueryFields(qry);
- }
-
- /** <inheritDoc /> */
- public IContinuousQueryHandle QueryContinuous(ContinuousQuery<TK, TV> qry)
- {
- return _cache.QueryContinuous(qry);
- }
-
- /** <inheritDoc /> */
- public IContinuousQueryHandle<ICacheEntry<TK, TV>> QueryContinuous(ContinuousQuery<TK, TV> qry, QueryBase initialQry)
- {
- return _cache.QueryContinuous(qry, initialQry);
- }
-
- /** <inheritDoc /> */
- public IEnumerable<ICacheEntry<TK, TV>> GetLocalEntries(params CachePeekMode[] peekModes)
- {
- return _cache.GetLocalEntries(peekModes);
- }
-
- /** <inheritDoc /> */
- public TRes Invoke<TArg, TRes>(TK key, ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
- {
- var result = _cache.Invoke(key, processor, arg);
-
- SetLastAsyncOp(CacheOp.Invoke);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public IDictionary<TK, ICacheEntryProcessorResult<TRes>> InvokeAll<TArg, TRes>(IEnumerable<TK> keys,
- ICacheEntryProcessor<TK, TV, TArg, TRes> processor, TArg arg)
- {
- var result = _cache.InvokeAll(keys, processor, arg);
-
- SetLastAsyncOp(CacheOp.InvokeAll);
-
- return result;
- }
-
- /** <inheritDoc /> */
- public ICacheLock Lock(TK key)
- {
- return _cache.Lock(key);
- }
-
- /** <inheritDoc /> */
- public ICacheLock LockAll(IEnumerable<TK> keys)
- {
- return _cache.LockAll(keys);
- }
-
- /** <inheritDoc /> */
- public bool IsLocalLocked(TK key, bool byCurrentThread)
- {
- return _cache.IsLocalLocked(key, byCurrentThread);
- }
-
- /** <inheritDoc /> */
- public ICacheMetrics GetMetrics()
- {
- return _cache.GetMetrics();
- }
-
- /** <inheritDoc /> */
- public IFuture Rebalance()
- {
- return _cache.Rebalance();
- }
-
- /** <inheritDoc /> */
- public ICache<TK, TV> WithNoRetries()
- {
- return _cache.IsNoRetries ? this : new CacheProxyImpl<TK, TV>((CacheImpl<TK, TV>) _cache.WithNoRetries());
- }
-
- /// <summary>
- /// Sets the last asynchronous op id.
- /// </summary>
- /// <param name="opId">The op identifier.</param>
- private void SetLastAsyncOp(CacheOp opId)
- {
- if (IsAsync)
- _lastAsyncOp.Value = opId;
- }
-
- /// <summary>
- /// Clears the last asynchronous op id.
- /// This should be called in the end of each method that supports async and does not call SetLastAsyncOp.
- /// </summary>
- private void ClearLastAsyncOp()
- {
- if (IsAsync)
- _lastAsyncOp.Value = CacheOp.None;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs
deleted file mode 100644
index 4e5c396..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/AsyncResult.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Common
-{
- using System;
- using System.Diagnostics.CodeAnalysis;
- using System.Threading;
- using Apache.Ignite.Core.Common;
-
- /// <summary>
- /// Adapts IGridFuture to the IAsyncResult.
- /// </summary>
- [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable",
- Justification = "Implementing IDisposable has no point since we return this class as IAsyncResult " +
- "to the client, and IAsyncResult is not IDisposable.")]
- public class AsyncResult : IAsyncResult
- {
- /** */
- private readonly ManualResetEvent _waitHandle;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="AsyncResult"/> class.
- /// </summary>
- /// <param name="fut">The future to wrap.</param>
- public AsyncResult(IFuture fut)
- {
- _waitHandle = new ManualResetEvent(false);
-
- fut.Listen(() => _waitHandle.Set());
- }
-
- /** <inheritdoc /> */
- public bool IsCompleted
- {
- get { return _waitHandle.WaitOne(0); }
- }
-
- /** <inheritdoc /> */
- public WaitHandle AsyncWaitHandle
- {
- get { return _waitHandle; }
- }
-
- /** <inheritdoc /> */
- public object AsyncState
- {
- get { return null; }
- }
-
- /** <inheritdoc /> */
- public bool CompletedSynchronously
- {
- get { return false; }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
deleted file mode 100644
index febe969..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/CompletedAsyncResult.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Common
-{
- using System;
- using System.Diagnostics.CodeAnalysis;
- using System.Threading;
-
- /// <summary>
- /// Represents an IAsyncResult that is completed.
- /// </summary>
- [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable",
- Justification = "Implementing IDisposable has no point since we return this class as IAsyncResult " +
- "to the client, and IAsyncResult is not IDisposable.")]
- public class CompletedAsyncResult : IAsyncResult
- {
- /** */
- private readonly WaitHandle _asyncWaitHandle = new ManualResetEvent(true);
-
- /** <inheritdoc /> */
- public bool IsCompleted
- {
- get { return true; }
- }
-
- /** <inheritdoc /> */
- public WaitHandle AsyncWaitHandle
- {
- get { return _asyncWaitHandle; }
- }
-
- /** <inheritdoc /> */
- public object AsyncState
- {
- get { return null; }
- }
-
- /** <inheritdoc /> */
- public bool CompletedSynchronously
- {
- get { return false; }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
index 70bebc4..4bf8a32 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
@@ -18,11 +18,8 @@
namespace Apache.Ignite.Core.Impl.Common
{
using System;
- using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
- using System.Threading;
using System.Threading.Tasks;
- using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Portable.IO;
/// <summary>
@@ -30,22 +27,13 @@ namespace Apache.Ignite.Core.Impl.Common
/// </summary>
[SuppressMessage("ReSharper", "ParameterHidesMember")]
[CLSCompliant(false)]
- public sealed class Future<T> : IFutureInternal, IFuture<T>
+ public sealed class Future<T> : IFutureInternal
{
/** Converter. */
private readonly IFutureConverter<T> _converter;
- /** Result. */
- private T _res;
-
- /** Caught cxception. */
- private Exception _err;
-
- /** Done flag. */
- private volatile bool _done;
-
- /** Listener(s). Either Action or List{Action}. */
- private object _callbacks;
+ /** Task completion source. */
+ private readonly TaskCompletionSource<T> _taskCompletionSource = new TaskCompletionSource<T>();
/// <summary>
/// Constructor.
@@ -57,139 +45,22 @@ namespace Apache.Ignite.Core.Impl.Common
}
/** <inheritdoc/> */
- public bool IsDone
- {
- get { return _done; }
- }
-
- /** <inheritdoc/> */
public T Get()
{
- if (!_done)
+ try
{
- lock (this)
- {
- while (!_done)
- Monitor.Wait(this);
- }
+ return Task.Result;
}
-
- return Get0();
- }
-
- /** <inheritdoc/> */
- public T Get(TimeSpan timeout)
- {
- long ticks = timeout.Ticks;
-
- if (ticks < 0)
- throw new ArgumentException("Timeout cannot be negative.");
-
- if (ticks == 0)
- return Get();
-
- if (!_done)
+ catch (AggregateException ex)
{
- // Fallback to locked mode.
- lock (this)
- {
- long endTime = DateTime.Now.Ticks + ticks;
-
- if (!_done)
- {
- while (true)
- {
- Monitor.Wait(this, timeout);
-
- if (_done)
- break;
-
- ticks = endTime - DateTime.Now.Ticks;
-
- if (ticks <= 0)
- throw new TimeoutException("Timeout waiting for future completion.");
-
- timeout = TimeSpan.FromTicks(ticks);
- }
- }
- }
+ throw ex.InnerException;
}
-
- return Get0();
- }
-
- /** <inheritdoc/> */
- public void Listen(Action callback)
- {
- Listen((Action<IFuture<T>>) (fut => callback()));
}
/** <inheritdoc/> */
- public void Listen(Action<IFuture> callback)
+ public Task<T> Task
{
- Listen((Action<IFuture<T>>)callback);
- }
-
- /** <inheritdoc/> */
- public void Listen(Action<IFuture<T>> callback)
- {
- IgniteArgumentCheck.NotNull(callback, "callback");
-
- if (!_done)
- {
- lock (this)
- {
- if (!_done)
- {
- AddCallback(callback);
-
- return;
- }
- }
- }
-
- callback(this);
- }
-
- /// <summary>
- /// Get result or throw an error.
- /// </summary>
- private T Get0()
- {
- if (_err != null)
- throw _err;
-
- return _res;
- }
-
- /** <inheritdoc/> */
- public IAsyncResult ToAsyncResult()
- {
- return _done ? (IAsyncResult) new CompletedAsyncResult() : new AsyncResult(this);
- }
-
- /** <inheritdoc/> */
- Task<object> IFuture.ToTask()
- {
- return Task.Factory.FromAsync(ToAsyncResult(), x => (object) Get());
- }
-
- /** <inheritdoc/> */
- public Task<T> ToTask()
- {
- return Task.Factory.FromAsync(ToAsyncResult(), x => Get());
- }
-
- /** <inheritdoc/> */
- object IFuture.Get(TimeSpan timeout)
- {
- return Get(timeout);
- }
-
- /** <inheritdoc/> */
- object IFuture.Get()
- {
- return Get();
+ get { return _taskCompletionSource.Task; }
}
/** <inheritdoc /> */
@@ -209,7 +80,7 @@ namespace Apache.Ignite.Core.Impl.Common
/** <inheritdoc /> */
public void OnError(Exception err)
{
- OnDone(default(T), err);
+ _taskCompletionSource.TrySetException(err);
}
/** <inheritdoc /> */
@@ -238,7 +109,7 @@ namespace Apache.Ignite.Core.Impl.Common
/// <param name="res">Result.</param>
internal void OnResult(T res)
{
- OnDone(res, null);
+ _taskCompletionSource.TrySetResult(res);
}
/// <summary>
@@ -248,54 +119,10 @@ namespace Apache.Ignite.Core.Impl.Common
/// <param name="err">Error.</param>
public void OnDone(T res, Exception err)
{
- object callbacks0 = null;
-
- lock (this)
- {
- if (!_done)
- {
- _res = res;
- _err = err;
-
- _done = true;
-
- Monitor.PulseAll(this);
-
- // Notify listeners outside the lock
- callbacks0 = _callbacks;
- _callbacks = null;
- }
- }
-
- if (callbacks0 != null)
- {
- var list = callbacks0 as List<Action<IFuture<T>>>;
-
- if (list != null)
- list.ForEach(x => x(this));
- else
- ((Action<IFuture<T>>) callbacks0)(this);
- }
- }
-
- /// <summary>
- /// Adds a callback.
- /// </summary>
- private void AddCallback(Action<IFuture<T>> callback)
- {
- if (_callbacks == null)
- {
- _callbacks = callback;
-
- return;
- }
-
- var list = _callbacks as List<Action<IFuture<T>>> ??
- new List<Action<IFuture<T>>> {(Action<IFuture<T>>) _callbacks};
-
- list.Add(callback);
-
- _callbacks = list;
+ if (err != null)
+ OnError(err);
+ else
+ OnResult(res);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
index d7fc59f..d0e920a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Compute.cs
@@ -20,8 +20,8 @@ namespace Apache.Ignite.Core.Impl.Compute
using System;
using System.Collections.Generic;
using System.Diagnostics;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Compute;
/// <summary>
@@ -44,30 +44,6 @@ namespace Apache.Ignite.Core.Impl.Compute
}
/** <inheritDoc /> */
- public ICompute WithAsync()
- {
- return new ComputeAsync(_compute);
- }
-
- /** <inheritDoc /> */
- public bool IsAsync
- {
- get { return false; }
- }
-
- /** <inheritDoc /> */
- public IFuture GetFuture()
- {
- throw IgniteUtils.GetAsyncModeDisabledException();
- }
-
- /** <inheritDoc /> */
- public IFuture<TResult> GetFuture<TResult>()
- {
- throw IgniteUtils.GetAsyncModeDisabledException();
- }
-
- /** <inheritDoc /> */
public IClusterGroup ClusterGroup
{
get { return _compute.ClusterGroup; }
@@ -104,53 +80,108 @@ namespace Apache.Ignite.Core.Impl.Compute
}
/** <inheritDoc /> */
+ public Task<TRes> ExecuteJavaTaskAsync<TRes>(string taskName, object taskArg)
+ {
+ return _compute.ExecuteJavaTaskAsync<TRes>(taskName, taskArg).Task;
+ }
+
+ /** <inheritDoc /> */
public TReduceRes Execute<TArg, TJobRes, TReduceRes>(IComputeTask<TArg, TJobRes, TReduceRes> task, TArg taskArg)
{
return _compute.Execute(task, taskArg).Get();
}
/** <inheritDoc /> */
+ public Task<TRes> ExecuteAsync<TArg, TJobRes, TRes>(IComputeTask<TArg, TJobRes, TRes> task, TArg taskArg)
+ {
+ return _compute.Execute(task, taskArg).Task;
+ }
+
+ /** <inheritDoc /> */
public TJobRes Execute<TArg, TJobRes>(IComputeTask<TArg, TJobRes> task)
{
return _compute.Execute(task, null).Get();
}
/** <inheritDoc /> */
+ public Task<TRes> ExecuteAsync<TJobRes, TRes>(IComputeTask<TJobRes, TRes> task)
+ {
+ return _compute.Execute(task, null).Task;
+ }
+
+ /** <inheritDoc /> */
public TReduceRes Execute<TArg, TJobRes, TReduceRes>(Type taskType, TArg taskArg)
{
return _compute.Execute<TArg, TJobRes, TReduceRes>(taskType, taskArg).Get();
}
+ /** <inheritDoc /> */
+ public Task<TReduceRes> ExecuteAsync<TArg, TJobRes, TReduceRes>(Type taskType, TArg taskArg)
+ {
+ return _compute.Execute<TArg, TJobRes, TReduceRes>(taskType, taskArg).Task;
+ }
+
+ /** <inheritDoc /> */
public TReduceRes Execute<TArg, TReduceRes>(Type taskType)
{
return _compute.Execute<object, TArg, TReduceRes>(taskType, null).Get();
}
/** <inheritDoc /> */
+ public Task<TReduceRes> ExecuteAsync<TArg, TReduceRes>(Type taskType)
+ {
+ return _compute.Execute<object, TArg, TReduceRes>(taskType, null).Task;
+ }
+
+ /** <inheritDoc /> */
public TJobRes Call<TJobRes>(IComputeFunc<TJobRes> clo)
{
return _compute.Execute(clo).Get();
}
/** <inheritDoc /> */
+ public Task<TRes> CallAsync<TRes>(IComputeFunc<TRes> clo)
+ {
+ return _compute.Execute(clo).Task;
+ }
+
+ /** <inheritDoc /> */
public TJobRes AffinityCall<TJobRes>(string cacheName, object affinityKey, IComputeFunc<TJobRes> clo)
{
return _compute.AffinityCall(cacheName, affinityKey, clo).Get();
}
/** <inheritDoc /> */
+ public Task<TRes> AffinityCallAsync<TRes>(string cacheName, object affinityKey, IComputeFunc<TRes> clo)
+ {
+ return _compute.AffinityCall(cacheName, affinityKey, clo).Task;
+ }
+
+ /** <inheritDoc /> */
public TJobRes Call<TJobRes>(Func<TJobRes> func)
{
return _compute.Execute(func).Get();
}
/** <inheritDoc /> */
+ public Task<TRes> CallAsync<TFuncRes, TRes>(IEnumerable<IComputeFunc<TFuncRes>> clos, IComputeReducer<TFuncRes, TRes> reducer)
+ {
+ return _compute.Execute(clos, reducer).Task;
+ }
+
+ /** <inheritDoc /> */
public ICollection<TJobRes> Call<TJobRes>(IEnumerable<IComputeFunc<TJobRes>> clos)
{
return _compute.Execute(clos).Get();
}
/** <inheritDoc /> */
+ public Task<ICollection<TRes>> CallAsync<TRes>(IEnumerable<IComputeFunc<TRes>> clos)
+ {
+ return _compute.Execute(clos).Task;
+ }
+
+ /** <inheritDoc /> */
public TReduceRes Call<TJobRes, TReduceRes>(IEnumerable<IComputeFunc<TJobRes>> clos,
IComputeReducer<TJobRes, TReduceRes> reducer)
{
@@ -164,52 +195,106 @@ namespace Apache.Ignite.Core.Impl.Compute
}
/** <inheritDoc /> */
+ public Task<ICollection<TRes>> BroadcastAsync<TRes>(IComputeFunc<TRes> clo)
+ {
+ return _compute.Broadcast(clo).Task;
+ }
+
+ /** <inheritDoc /> */
public ICollection<TJobRes> Broadcast<T, TJobRes>(IComputeFunc<T, TJobRes> clo, T arg)
{
return _compute.Broadcast(clo, arg).Get();
}
/** <inheritDoc /> */
+ public Task<ICollection<TRes>> BroadcastAsync<TArg, TRes>(IComputeFunc<TArg, TRes> clo, TArg arg)
+ {
+ return _compute.Broadcast(clo, arg).Task;
+ }
+
+ /** <inheritDoc /> */
public void Broadcast(IComputeAction action)
{
_compute.Broadcast(action).Get();
}
/** <inheritDoc /> */
+ public Task BroadcastAsync(IComputeAction action)
+ {
+ return _compute.Broadcast(action).Task;
+ }
+
+ /** <inheritDoc /> */
public void Run(IComputeAction action)
{
_compute.Run(action).Get();
}
/** <inheritDoc /> */
+ public Task RunAsync(IComputeAction action)
+ {
+ return _compute.Run(action).Task;
+ }
+
+ /** <inheritDoc /> */
public void AffinityRun(string cacheName, object affinityKey, IComputeAction action)
{
_compute.AffinityRun(cacheName, affinityKey, action).Get();
}
/** <inheritDoc /> */
+ public Task AffinityRunAsync(string cacheName, object affinityKey, IComputeAction action)
+ {
+ return _compute.AffinityRun(cacheName, affinityKey, action).Task;
+ }
+
+ /** <inheritDoc /> */
public void Run(IEnumerable<IComputeAction> actions)
{
_compute.Run(actions).Get();
}
/** <inheritDoc /> */
+ public Task RunAsync(IEnumerable<IComputeAction> actions)
+ {
+ return _compute.Run(actions).Task;
+ }
+
+ /** <inheritDoc /> */
public TJobRes Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg)
{
return _compute.Apply(clo, arg).Get();
}
/** <inheritDoc /> */
+ public Task<TRes> ApplyAsync<TArg, TRes>(IComputeFunc<TArg, TRes> clo, TArg arg)
+ {
+ return _compute.Apply(clo, arg).Task;
+ }
+
+ /** <inheritDoc /> */
public ICollection<TJobRes> Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, IEnumerable<TArg> args)
{
return _compute.Apply(clo, args).Get();
}
/** <inheritDoc /> */
+ public Task<ICollection<TRes>> ApplyAsync<TArg, TRes>(IComputeFunc<TArg, TRes> clo, IEnumerable<TArg> args)
+ {
+ return _compute.Apply(clo, args).Task;
+ }
+
+ /** <inheritDoc /> */
public TReduceRes Apply<TArg, TJobRes, TReduceRes>(IComputeFunc<TArg, TJobRes> clo,
IEnumerable<TArg> args, IComputeReducer<TJobRes, TReduceRes> rdc)
{
return _compute.Apply(clo, args, rdc).Get();
}
+
+ /** <inheritDoc /> */
+ public Task<TRes> ApplyAsync<TArg, TFuncRes, TRes>(IComputeFunc<TArg, TFuncRes> clo, IEnumerable<TArg> args, IComputeReducer<TFuncRes, TRes> rdc)
+ {
+ return _compute.Apply(clo, args, rdc).Task;
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
deleted file mode 100644
index 89c5b83..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeAsync.cs
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Compute
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Globalization;
- using System.Threading;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Compute;
-
- /// <summary>
- /// Asynchronous Compute facade.
- /// </summary>
- [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
- internal class ComputeAsync : ICompute
- {
- /** */
- protected readonly ComputeImpl Compute;
-
- /** Current future. */
- private readonly ThreadLocal<IFuture> _curFut = new ThreadLocal<IFuture>();
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ComputeAsync"/> class.
- /// </summary>
- /// <param name="computeImpl">The compute implementation.</param>
- internal ComputeAsync(ComputeImpl computeImpl)
- {
- Compute = computeImpl;
- }
-
- /** <inheritDoc /> */
- public ICompute WithAsync()
- {
- return this;
- }
-
- /** <inheritDoc /> */
- public bool IsAsync
- {
- get { return true; }
- }
-
- /** <inheritDoc /> */
- public IFuture GetFuture()
- {
- return GetFuture<object>();
- }
-
- /** <inheritDoc /> */
- public IFuture<TResult> GetFuture<TResult>()
- {
- var fut = _curFut.Value;
-
- if (fut == null)
- throw new InvalidOperationException("Asynchronous operation not started.");
-
- var fut0 = fut as IFuture<TResult>;
-
- if (fut0 == null)
- throw new InvalidOperationException(
- string.Format(CultureInfo.InvariantCulture,
- "Requested future type {0} is incompatible with current future type {1}",
- typeof (IFuture<TResult>), fut.GetType()));
-
- _curFut.Value = null;
-
- return fut0;
- }
-
- /** <inheritDoc /> */
- public IClusterGroup ClusterGroup
- {
- get { return Compute.ClusterGroup; }
- }
-
- /** <inheritDoc /> */
- public ICompute WithNoFailover()
- {
- Compute.WithNoFailover();
-
- return this;
- }
-
- /** <inheritDoc /> */
- public ICompute WithTimeout(long timeout)
- {
- Compute.WithTimeout(timeout);
-
- return this;
- }
-
- /** <inheritDoc /> */
- public ICompute WithKeepPortable()
- {
- Compute.WithKeepPortable();
-
- return this;
- }
-
- /** <inheritDoc /> */
- public TReduceRes ExecuteJavaTask<TReduceRes>(string taskName, object taskArg)
- {
- _curFut.Value = Compute.ExecuteJavaTaskAsync<TReduceRes>(taskName, taskArg);
-
- return default(TReduceRes);
- }
-
- /** <inheritDoc /> */
- public TReduceRes Execute<TArg, TJobRes, TReduceRes>(IComputeTask<TArg, TJobRes, TReduceRes> task, TArg taskArg)
- {
- _curFut.Value = Compute.Execute(task, taskArg);
-
- return default(TReduceRes);
- }
-
- /** <inheritDoc /> */
- public TReduceRes Execute<TJobRes, TReduceRes>(IComputeTask<TJobRes, TReduceRes> task)
- {
- _curFut.Value = Compute.Execute(task, null);
-
- return default(TReduceRes);
- }
-
- /** <inheritDoc /> */
- public TReduceRes Execute<TArg, TJobRes, TReduceRes>(Type taskType, TArg taskArg)
- {
- _curFut.Value = Compute.Execute<TArg, TJobRes, TReduceRes>(taskType, taskArg);
-
- return default(TReduceRes);
- }
-
- /** <inheritDoc /> */
- public TReduceRes Execute<TJobRes, TReduceRes>(Type taskType)
- {
- _curFut.Value = Compute.Execute<object, TJobRes, TReduceRes>(taskType, null);
-
- return default(TReduceRes);
- }
-
- /** <inheritDoc /> */
- public TJobRes Call<TJobRes>(IComputeFunc<TJobRes> clo)
- {
- _curFut.Value = Compute.Execute(clo);
-
- return default(TJobRes);
- }
-
- /** <inheritDoc /> */
- public TJobRes AffinityCall<TJobRes>(string cacheName, object affinityKey, IComputeFunc<TJobRes> clo)
- {
- Compute.AffinityCall(cacheName, affinityKey, clo);
-
- return default(TJobRes);
- }
-
- /** <inheritDoc /> */
- public TJobRes Call<TJobRes>(Func<TJobRes> func)
- {
- _curFut.Value = Compute.Execute(func);
-
- return default(TJobRes);
- }
-
- /** <inheritDoc /> */
- public ICollection<TJobRes> Call<TJobRes>(IEnumerable<IComputeFunc<TJobRes>> clos)
- {
- _curFut.Value = Compute.Execute(clos);
-
- return null;
- }
-
- /** <inheritDoc /> */
- public TReduceRes Call<TJobRes, TReduceRes>(IEnumerable<IComputeFunc<TJobRes>> clos, IComputeReducer<TJobRes, TReduceRes> reducer)
- {
- _curFut.Value = Compute.Execute(clos, reducer);
-
- return default(TReduceRes);
- }
-
- /** <inheritDoc /> */
- public ICollection<TJobRes> Broadcast<TJobRes>(IComputeFunc<TJobRes> clo)
- {
- _curFut.Value = Compute.Broadcast(clo);
-
- return null;
- }
-
- /** <inheritDoc /> */
- public ICollection<TJobRes> Broadcast<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg)
- {
- _curFut.Value = Compute.Broadcast(clo, arg);
-
- return null;
- }
-
- /** <inheritDoc /> */
- public void Broadcast(IComputeAction action)
- {
- _curFut.Value = Compute.Broadcast(action);
- }
-
- /** <inheritDoc /> */
- public void Run(IComputeAction action)
- {
- _curFut.Value = Compute.Run(action);
- }
-
- /** <inheritDoc /> */
- public void AffinityRun(string cacheName, object affinityKey, IComputeAction action)
- {
- Compute.AffinityRun(cacheName, affinityKey, action);
- }
-
- /** <inheritDoc /> */
- public void Run(IEnumerable<IComputeAction> actions)
- {
- _curFut.Value = Compute.Run(actions);
- }
-
- /** <inheritDoc /> */
- public TJobRes Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg)
- {
- _curFut.Value = Compute.Apply(clo, arg);
-
- return default(TJobRes);
- }
-
- /** <inheritDoc /> */
- public ICollection<TJobRes> Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, IEnumerable<TArg> args)
- {
- _curFut.Value = Compute.Apply(clo, args);
-
- return null;
- }
-
- /** <inheritDoc /> */
- public TReduceRes Apply<TArg, TJobRes, TReduceRes>(IComputeFunc<TArg, TJobRes> clo,
- IEnumerable<TArg> args, IComputeReducer<TJobRes, TReduceRes> rdc)
- {
- _curFut.Value = Compute.Apply(clo, args, rdc);
-
- return default(TReduceRes);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
index abd54da..7adc49f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeImpl.cs
@@ -150,7 +150,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// If task for given name has not been deployed yet,
/// then 'taskName' will be used as task class name to auto-deploy the task.
/// </summary>
- public IFuture<TReduceRes> ExecuteJavaTaskAsync<TReduceRes>(string taskName, object taskArg)
+ public Future<TReduceRes> ExecuteJavaTaskAsync<TReduceRes>(string taskName, object taskArg)
{
IgniteArgumentCheck.NotNullOrEmpty(taskName, "taskName");
@@ -158,7 +158,7 @@ namespace Apache.Ignite.Core.Impl.Compute
try
{
- IFuture<TReduceRes> fut = null;
+ Future<TReduceRes> fut = null;
DoOutInOp(OpExecAsync, writer =>
{
@@ -183,7 +183,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="task">Task to execute.</param>
/// <param name="taskArg">Optional task argument.</param>
/// <returns>Task result.</returns>
- public IFuture<TReduceRes> Execute<TArg, TJobRes, TReduceRes>(IComputeTask<TArg, TJobRes, TReduceRes> task,
+ public Future<TReduceRes> Execute<TArg, TJobRes, TReduceRes>(IComputeTask<TArg, TJobRes, TReduceRes> task,
TArg taskArg)
{
IgniteArgumentCheck.NotNull(task, "task");
@@ -204,7 +204,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="taskType">Task type.</param>
/// <param name="taskArg">Optional task argument.</param>
/// <returns>Task result.</returns>
- public IFuture<TReduceRes> Execute<TArg, TJobRes, TReduceRes>(Type taskType, TArg taskArg)
+ public Future<TReduceRes> Execute<TArg, TJobRes, TReduceRes>(Type taskType, TArg taskArg)
{
IgniteArgumentCheck.NotNull(taskType, "taskType");
@@ -224,7 +224,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// </summary>
/// <param name="clo">Job to execute.</param>
/// <returns>Job result for this execution.</returns>
- public IFuture<TJobRes> Execute<TJobRes>(IComputeFunc<TJobRes> clo)
+ public Future<TJobRes> Execute<TJobRes>(IComputeFunc<TJobRes> clo)
{
IgniteArgumentCheck.NotNull(clo, "clo");
@@ -238,7 +238,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// </summary>
/// <param name="func">Func to execute.</param>
/// <returns>Job result for this execution.</returns>
- public IFuture<TJobRes> Execute<TJobRes>(Func<TJobRes> func)
+ public Future<TJobRes> Execute<TJobRes>(Func<TJobRes> func)
{
IgniteArgumentCheck.NotNull(func, "func");
@@ -253,7 +253,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// </summary>
/// <param name="clos">Collection of jobs to execute.</param>
/// <returns>Collection of job results for this execution.</returns>
- public IFuture<ICollection<TJobRes>> Execute<TJobRes>(IEnumerable<IComputeFunc<TJobRes>> clos)
+ public Future<ICollection<TJobRes>> Execute<TJobRes>(IEnumerable<IComputeFunc<TJobRes>> clos)
{
IgniteArgumentCheck.NotNull(clos, "clos");
@@ -272,7 +272,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="clos">Collection of jobs to execute.</param>
/// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
/// <returns>Collection of job results for this execution.</returns>
- public IFuture<TReduceRes> Execute<TJobRes, TReduceRes>(IEnumerable<IComputeFunc<TJobRes>> clos,
+ public Future<TReduceRes> Execute<TJobRes, TReduceRes>(IEnumerable<IComputeFunc<TJobRes>> clos,
IComputeReducer<TJobRes, TReduceRes> rdc)
{
IgniteArgumentCheck.NotNull(clos, "clos");
@@ -290,7 +290,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// </summary>
/// <param name="clo">Job to broadcast to all projection nodes.</param>
/// <returns>Collection of results for this execution.</returns>
- public IFuture<ICollection<TJobRes>> Broadcast<TJobRes>(IComputeFunc<TJobRes> clo)
+ public Future<ICollection<TJobRes>> Broadcast<TJobRes>(IComputeFunc<TJobRes> clo)
{
IgniteArgumentCheck.NotNull(clo, "clo");
@@ -305,7 +305,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="clo">Job to broadcast to all projection nodes.</param>
/// <param name="arg">Job closure argument.</param>
/// <returns>Collection of results for this execution.</returns>
- public IFuture<ICollection<TJobRes>> Broadcast<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg)
+ public Future<ICollection<TJobRes>> Broadcast<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg)
{
IgniteArgumentCheck.NotNull(clo, "clo");
@@ -317,7 +317,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// Broadcasts given job to all nodes in grid projection.
/// </summary>
/// <param name="action">Job to broadcast to all projection nodes.</param>
- public IFuture<object> Broadcast(IComputeAction action)
+ public Future<object> Broadcast(IComputeAction action)
{
IgniteArgumentCheck.NotNull(action, "action");
@@ -329,7 +329,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// Executes provided job on a node in this grid projection.
/// </summary>
/// <param name="action">Job to execute.</param>
- public IFuture<object> Run(IComputeAction action)
+ public Future<object> Run(IComputeAction action)
{
IgniteArgumentCheck.NotNull(action, "action");
@@ -341,7 +341,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// Executes collection of jobs on Ignite nodes within this grid projection.
/// </summary>
/// <param name="actions">Jobs to execute.</param>
- public IFuture<object> Run(IEnumerable<IComputeAction> actions)
+ public Future<object> Run(IEnumerable<IComputeAction> actions)
{
IgniteArgumentCheck.NotNull(actions, "actions");
@@ -369,7 +369,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="clo">Job to run.</param>
/// <param name="arg">Job argument.</param>
/// <returns>Job result for this execution.</returns>
- public IFuture<TJobRes> Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg)
+ public Future<TJobRes> Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo, TArg arg)
{
IgniteArgumentCheck.NotNull(clo, "clo");
@@ -385,7 +385,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="clo">Job to run.</param>
/// <param name="args">Job arguments.</param>
/// <returns>Collection of job results.</returns>
- public IFuture<ICollection<TJobRes>> Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo,
+ public Future<ICollection<TJobRes>> Apply<TArg, TJobRes>(IComputeFunc<TArg, TJobRes> clo,
IEnumerable<TArg> args)
{
IgniteArgumentCheck.NotNull(clo, "clo");
@@ -413,7 +413,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="args">Job arguments.</param>
/// <param name="rdc">Reducer to reduce all job results into one individual return value.</param>
/// <returns>Reduced job result for this execution.</returns>
- public IFuture<TReduceRes> Apply<TArg, TJobRes, TReduceRes>(IComputeFunc<TArg, TJobRes> clo,
+ public Future<TReduceRes> Apply<TArg, TJobRes, TReduceRes>(IComputeFunc<TArg, TJobRes> clo,
IEnumerable<TArg> args, IComputeReducer<TJobRes, TReduceRes> rdc)
{
IgniteArgumentCheck.NotNull(clo, "clo");
@@ -440,7 +440,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="cacheName">Name of the cache to use for affinity co-location.</param>
/// <param name="affinityKey">Affinity key.</param>
/// <param name="action">Job to execute.</param>
- public IFuture AffinityRun(string cacheName, object affinityKey, IComputeAction action)
+ public Future<object> AffinityRun(string cacheName, object affinityKey, IComputeAction action)
{
IgniteArgumentCheck.NotNull(action, "action");
@@ -458,7 +458,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="clo">Job to execute.</param>
/// <returns>Job result for this execution.</returns>
/// <typeparam name="TJobRes">Type of job result.</typeparam>
- public IFuture<TJobRes> AffinityCall<TJobRes>(string cacheName, object affinityKey, IComputeFunc<TJobRes> clo)
+ public Future<TJobRes> AffinityCall<TJobRes>(string cacheName, object affinityKey, IComputeFunc<TJobRes> clo)
{
IgniteArgumentCheck.NotNull(clo, "clo");
@@ -483,7 +483,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <param name="jobs">Jobs.</param>
/// <param name="broadcast">Broadcast flag.</param>
/// <returns>Future.</returns>
- private IFuture<TReduceRes> ExecuteClosures0<TArg, TJobRes, TReduceRes>(
+ private Future<TReduceRes> ExecuteClosures0<TArg, TJobRes, TReduceRes>(
IComputeTask<TArg, TJobRes, TReduceRes> task, IComputeJob job,
ICollection<IComputeJob> jobs, bool broadcast)
{
@@ -503,7 +503,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <returns>Future.</returns>
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
Justification = "User code can throw any exception")]
- private IFuture<TReduceRes> ExecuteClosures0<TArg, TJobRes, TReduceRes>(
+ private Future<TReduceRes> ExecuteClosures0<TArg, TJobRes, TReduceRes>(
IComputeTask<TArg, TJobRes, TReduceRes> task, IComputeJob job = null,
IEnumerable<IComputeJob> jobs = null, int opId = OpUnicast, int jobsCount = 0,
Action<PortableWriterImpl> writeAction = null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
index ef27889..1cd13a8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
@@ -379,7 +379,7 @@ namespace Apache.Ignite.Core.Impl.Compute
/// <summary>
/// Task completion future.
/// </summary>
- internal IFuture<TR> Future
+ internal Future<TR> Future
{
get { return _fut; }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
index 49cbc5a..576c805 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerBatch.cs
@@ -22,7 +22,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
- using Apache.Ignite.Core.Common;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Portable;
@@ -69,15 +69,15 @@ namespace Apache.Ignite.Core.Impl.Datastream
if (prev != null)
Thread.MemoryBarrier(); // Prevent "prev" field escape.
- _fut.Listen(() => ParentsCompleted());
+ _fut.Task.ContinueWith(x => ParentsCompleted());
}
/// <summary>
- /// Gets the future.
+ /// Gets the task.
/// </summary>
- public IFuture Future
+ public Task Task
{
- get { return _fut; }
+ get { return _fut.Task; }
}
/// <summary>
@@ -264,7 +264,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
return false;
}
- return _fut.IsDone;
+ return _fut.Task.IsCompleted;
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
index 9894e93..586d19f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/DataStreamerImpl.cs
@@ -21,7 +21,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
- using Apache.Ignite.Core.Common;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Datastream;
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Portable;
@@ -326,13 +326,13 @@ namespace Apache.Ignite.Core.Impl.Datastream
}
/** <inheritDoc /> */
- public IFuture Future
+ public Task Task
{
get
{
ThrowIfDisposed();
- return _closeFut;
+ return _closeFut.Task;
}
}
@@ -396,7 +396,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
}
/** <inheritDoc /> */
- public IFuture AddData(TK key, TV val)
+ public Task AddData(TK key, TV val)
{
ThrowIfDisposed();
@@ -406,7 +406,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
}
/** <inheritDoc /> */
- public IFuture AddData(KeyValuePair<TK, TV> pair)
+ public Task AddData(KeyValuePair<TK, TV> pair)
{
ThrowIfDisposed();
@@ -414,7 +414,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
}
/** <inheritDoc /> */
- public IFuture AddData(ICollection<KeyValuePair<TK, TV>> entries)
+ public Task AddData(ICollection<KeyValuePair<TK, TV>> entries)
{
ThrowIfDisposed();
@@ -424,7 +424,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
}
/** <inheritDoc /> */
- public IFuture RemoveData(TK key)
+ public Task RemoveData(TK key)
{
ThrowIfDisposed();
@@ -585,7 +585,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
/// <param name="val">Value.</param>
/// <param name="cnt">Items count.</param>
/// <returns>Future.</returns>
- private IFuture Add0(object val, int cnt)
+ private Task Add0(object val, int cnt)
{
int bufSndSize0 = _bufSndSize;
@@ -610,7 +610,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
// Batch is too big, schedule flush.
Flush0(batch0, false, PlcContinue);
- return batch0.Future;
+ return batch0.Task;
}
}
[02/17] ignite git commit: IGNITE-1619: Reworked serialization of
generic collections.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
index 6b5e20d..ff3fb85 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Impl.Portable
{
using System;
using System.Collections;
- using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
@@ -33,15 +32,6 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="obj">Object to write.</param>
internal delegate void PortableSystemWriteDelegate(PortableWriterImpl writer, object obj);
- /// <summary>
- /// Typed write delegate.
- /// </summary>
- /// <param name="stream">Stream.</param>
- /// <param name="obj">Object to write.</param>
- // ReSharper disable once TypeParameterCanBeVariant
- // Generic variance in a delegate causes performance hit
- internal delegate void PortableSystemTypedWriteDelegate<T>(IPortableStream stream, T obj);
-
/**
* <summary>Collection of predefined handlers for various system types.</summary>
*/
@@ -57,20 +47,6 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Read handlers. */
private static readonly IPortableSystemReader[] ReadHandlers = new IPortableSystemReader[255];
- /** Write handler: collection. */
- public static readonly PortableSystemWriteDelegate WriteHndCollection = WriteCollection;
-
- /** Write handler: dictionary. */
- public static readonly PortableSystemWriteDelegate WriteHndDictionary = WriteDictionary;
-
- /** Write handler: generic collection. */
- public static readonly PortableSystemWriteDelegate WriteHndGenericCollection =
- WriteGenericCollection;
-
- /** Write handler: generic dictionary. */
- public static readonly PortableSystemWriteDelegate WriteHndGenericDictionary =
- WriteGenericDictionary;
-
/// <summary>
/// Initializes the <see cref="PortableSystemHandlers"/> class.
/// </summary>
@@ -132,21 +108,21 @@ namespace Apache.Ignite.Core.Impl.Portable
new PortableSystemReader<DateTime?[]>(s => PortableUtils.ReadDateArray(s, false));
// 7. String array.
- ReadHandlers[PortableUtils.TypeArrayString] = new PortableSystemGenericArrayReader<string>();
+ ReadHandlers[PortableUtils.TypeArrayString] = new PortableSystemTypedArrayReader<string>();
// 8. Guid array.
- ReadHandlers[PortableUtils.TypeArrayGuid] = new PortableSystemGenericArrayReader<Guid?>();
+ ReadHandlers[PortableUtils.TypeArrayGuid] = new PortableSystemTypedArrayReader<Guid?>();
// 9. Array.
ReadHandlers[PortableUtils.TypeArray] = new PortableSystemReader(ReadArray);
- // 12. Arbitrary collection.
+ // 11. Arbitrary collection.
ReadHandlers[PortableUtils.TypeCollection] = new PortableSystemReader(ReadCollection);
// 13. Arbitrary dictionary.
ReadHandlers[PortableUtils.TypeDictionary] = new PortableSystemReader(ReadDictionary);
- // 14. Map entry.
+ // 15. Map entry.
ReadHandlers[PortableUtils.TypeMapEntry] = new PortableSystemReader(ReadMapEntry);
// 16. Enum.
@@ -168,17 +144,14 @@ namespace Apache.Ignite.Core.Impl.Portable
// Have we ever met this type?
if (writeHandlers0 != null && writeHandlers0.TryGetValue(type, out res))
return res;
- else
- {
- // Determine write handler for type and add it.
- res = FindWriteHandler(type);
- if (res != null)
- AddWriteHandler(type, res);
+ // Determine write handler for type and add it.
+ res = FindWriteHandler(type);
- return res;
- }
+ if (res != null)
+ AddWriteHandler(type, res);
+ return res;
}
/// <summary>
@@ -191,21 +164,21 @@ namespace Apache.Ignite.Core.Impl.Portable
// 1. Well-known types.
if (type == typeof (string))
return WriteString;
- else if (type == typeof(decimal))
+ if (type == typeof(decimal))
return WriteDecimal;
- else if (type == typeof(DateTime))
+ if (type == typeof(DateTime))
return WriteDate;
- else if (type == typeof(Guid))
+ if (type == typeof(Guid))
return WriteGuid;
- else if (type == typeof (PortableUserObject))
+ if (type == typeof (PortableUserObject))
return WritePortable;
- else if (type == typeof (ArrayList))
+ if (type == typeof (ArrayList))
return WriteArrayList;
- else if (type == typeof(Hashtable))
+ if (type == typeof(Hashtable))
return WriteHashtable;
- else if (type == typeof(DictionaryEntry))
+ if (type == typeof(DictionaryEntry))
return WriteMapEntry;
- else if (type.IsArray)
+ if (type.IsArray)
{
// We know how to write any array type.
Type elemType = type.GetElementType();
@@ -213,62 +186,56 @@ namespace Apache.Ignite.Core.Impl.Portable
// Primitives.
if (elemType == typeof (bool))
return WriteBoolArray;
- else if (elemType == typeof(byte))
+ if (elemType == typeof(byte))
return WriteByteArray;
- else if (elemType == typeof(short))
+ if (elemType == typeof(short))
return WriteShortArray;
- else if (elemType == typeof(char))
+ if (elemType == typeof(char))
return WriteCharArray;
- else if (elemType == typeof(int))
+ if (elemType == typeof(int))
return WriteIntArray;
- else if (elemType == typeof(long))
+ if (elemType == typeof(long))
return WriteLongArray;
- else if (elemType == typeof(float))
+ if (elemType == typeof(float))
return WriteFloatArray;
- else if (elemType == typeof(double))
+ if (elemType == typeof(double))
return WriteDoubleArray;
// Non-CLS primitives.
- else if (elemType == typeof(sbyte))
+ if (elemType == typeof(sbyte))
return WriteSbyteArray;
- else if (elemType == typeof(ushort))
+ if (elemType == typeof(ushort))
return WriteUshortArray;
- else if (elemType == typeof(uint))
+ if (elemType == typeof(uint))
return WriteUintArray;
- else if (elemType == typeof(ulong))
+ if (elemType == typeof(ulong))
return WriteUlongArray;
// Special types.
else if (elemType == typeof (decimal?))
return WriteDecimalArray;
- else if (elemType == typeof(string))
+ if (elemType == typeof(string))
return WriteStringArray;
// else if (elemType == typeof(DateTime))
// return WriteDateArray;
- else if (elemType == typeof(DateTime?))
+ if (elemType == typeof(DateTime?))
return WriteNullableDateArray;
// else if (elemType == typeof(Guid))
// return WriteGuidArray;
- else if (elemType == typeof(Guid?))
+ if (elemType == typeof(Guid?))
return WriteNullableGuidArray;
// Enums.
if (elemType.IsEnum)
return WriteEnumArray;
- // Regular array.
- return WriteArray;
+ // Object array.
+ if (elemType == typeof (object))
+ return WriteArray;
}
- else if (type.IsEnum)
+
+ if (type.IsEnum)
// We know how to write enums.
return WriteEnum;
- else
- {
- // We know how to write collections.
- PortableCollectionInfo info = PortableCollectionInfo.Info(type);
-
- if (info.IsAny)
- return info.WriteHandler;
- return null;
- }
+ return null;
}
/// <summary>
@@ -584,7 +551,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
ctx.Stream.WriteByte(PortableUtils.TypeArrayEnum);
- PortableUtils.WriteArray((Array)obj, ctx, true);
+ PortableUtils.WriteArray((Array)obj, ctx);
}
/**
@@ -594,55 +561,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
ctx.Stream.WriteByte(PortableUtils.TypeArray);
- PortableUtils.WriteArray((Array)obj, ctx, true);
- }
-
- /**
- * <summary>Write collection.</summary>
- */
- private static void WriteCollection(PortableWriterImpl ctx, object obj)
- {
- ctx.Stream.WriteByte(PortableUtils.TypeCollection);
-
- PortableUtils.WriteCollection((ICollection)obj, ctx);
- }
-
- /**
- * <summary>Write generic collection.</summary>
- */
- private static void WriteGenericCollection(PortableWriterImpl ctx, object obj)
- {
- PortableCollectionInfo info = PortableCollectionInfo.Info(obj.GetType());
-
- Debug.Assert(info.IsGenericCollection, "Not generic collection: " + obj.GetType().FullName);
-
- ctx.Stream.WriteByte(PortableUtils.TypeCollection);
-
- info.WriteGeneric(ctx, obj);
- }
-
- /**
- * <summary>Write dictionary.</summary>
- */
- private static void WriteDictionary(PortableWriterImpl ctx, object obj)
- {
- ctx.Stream.WriteByte(PortableUtils.TypeDictionary);
-
- PortableUtils.WriteDictionary((IDictionary)obj, ctx);
- }
-
- /**
- * <summary>Write generic dictionary.</summary>
- */
- private static void WriteGenericDictionary(PortableWriterImpl ctx, object obj)
- {
- PortableCollectionInfo info = PortableCollectionInfo.Info(obj.GetType());
-
- Debug.Assert(info.IsGenericDictionary, "Not generic dictionary: " + obj.GetType().FullName);
-
- ctx.Stream.WriteByte(PortableUtils.TypeDictionary);
-
- info.WriteGeneric(ctx, obj);
+ PortableUtils.WriteArray((Array)obj, ctx);
}
/**
@@ -652,7 +571,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
ctx.Stream.WriteByte(PortableUtils.TypeCollection);
- PortableUtils.WriteTypedCollection((ICollection)obj, ctx, PortableUtils.CollectionArrayList);
+ PortableUtils.WriteCollection((ICollection)obj, ctx, PortableUtils.CollectionArrayList);
}
/**
@@ -662,7 +581,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
ctx.Stream.WriteByte(PortableUtils.TypeDictionary);
- PortableUtils.WriteTypedDictionary((IDictionary)obj, ctx, PortableUtils.MapHashMap);
+ PortableUtils.WriteDictionary((IDictionary)obj, ctx, PortableUtils.MapHashMap);
}
/**
@@ -700,7 +619,7 @@ namespace Apache.Ignite.Core.Impl.Portable
*/
private static object ReadEnumArray(PortableReaderImpl ctx, Type type)
{
- return PortableUtils.ReadArray(ctx, true, type.GetElementType());
+ return PortableUtils.ReadTypedArray(ctx, true, type.GetElementType());
}
/**
@@ -710,7 +629,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
var elemType = type.IsArray ? type.GetElementType() : typeof(object);
- return PortableUtils.ReadArray(ctx, true, elemType);
+ return PortableUtils.ReadTypedArray(ctx, true, elemType);
}
/**
@@ -718,11 +637,7 @@ namespace Apache.Ignite.Core.Impl.Portable
*/
private static object ReadCollection(PortableReaderImpl ctx, Type type)
{
- PortableCollectionInfo info = PortableCollectionInfo.Info(type);
-
- return info.IsGenericCollection
- ? info.ReadGeneric(ctx)
- : PortableUtils.ReadCollection(ctx, null, null);
+ return PortableUtils.ReadCollection(ctx, null, null);
}
/**
@@ -730,11 +645,7 @@ namespace Apache.Ignite.Core.Impl.Portable
*/
private static object ReadDictionary(PortableReaderImpl ctx, Type type)
{
- PortableCollectionInfo info = PortableCollectionInfo.Info(type);
-
- return info.IsGenericDictionary
- ? info.ReadGeneric(ctx)
- : PortableUtils.ReadDictionary(ctx, null);
+ return PortableUtils.ReadDictionary(ctx, null);
}
/**
@@ -746,104 +657,10 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/**
- * <summary>Create new ArrayList.</summary>
- * <param name="len">Length.</param>
- * <returns>ArrayList.</returns>
- */
- public static ICollection CreateArrayList(int len)
- {
- return new ArrayList(len);
- }
-
- /**
* <summary>Add element to array list.</summary>
* <param name="col">Array list.</param>
* <param name="elem">Element.</param>
*/
- public static void AddToArrayList(ICollection col, object elem)
- {
- ((ArrayList) col).Add(elem);
- }
-
- /**
- * <summary>Create new List.</summary>
- * <param name="len">Length.</param>
- * <returns>List.</returns>
- */
- public static ICollection<T> CreateList<T>(int len)
- {
- return new List<T>(len);
- }
-
- /**
- * <summary>Create new LinkedList.</summary>
- * <param name="len">Length.</param>
- * <returns>LinkedList.</returns>
- */
- public static ICollection<T> CreateLinkedList<T>(int len)
- {
- return new LinkedList<T>();
- }
-
- /**
- * <summary>Create new HashSet.</summary>
- * <param name="len">Length.</param>
- * <returns>HashSet.</returns>
- */
- public static ICollection<T> CreateHashSet<T>(int len)
- {
- return new HashSet<T>();
- }
-
- /**
- * <summary>Create new SortedSet.</summary>
- * <param name="len">Length.</param>
- * <returns>SortedSet.</returns>
- */
- public static ICollection<T> CreateSortedSet<T>(int len)
- {
- return new SortedSet<T>();
- }
-
- /**
- * <summary>Create new Hashtable.</summary>
- * <param name="len">Length.</param>
- * <returns>Hashtable.</returns>
- */
- public static IDictionary CreateHashtable(int len)
- {
- return new Hashtable(len);
- }
-
- /**
- * <summary>Create new Dictionary.</summary>
- * <param name="len">Length.</param>
- * <returns>Dictionary.</returns>
- */
- public static IDictionary<TK, TV> CreateDictionary<TK, TV>(int len)
- {
- return new Dictionary<TK, TV>(len);
- }
-
- /**
- * <summary>Create new SortedDictionary.</summary>
- * <param name="len">Length.</param>
- * <returns>SortedDictionary.</returns>
- */
- public static IDictionary<TK, TV> CreateSortedDictionary<TK, TV>(int len)
- {
- return new SortedDictionary<TK, TV>();
- }
-
- /**
- * <summary>Create new ConcurrentDictionary.</summary>
- * <param name="len">Length.</param>
- * <returns>ConcurrentDictionary.</returns>
- */
- public static IDictionary<TK, TV> CreateConcurrentDictionary<TK, TV>(int len)
- {
- return new ConcurrentDictionary<TK, TV>(Environment.ProcessorCount, len);
- }
/**
@@ -930,11 +747,11 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <summary>
/// Reader without boxing.
/// </summary>
- private class PortableSystemGenericArrayReader<T> : IPortableSystemReader
+ private class PortableSystemTypedArrayReader<T> : IPortableSystemReader
{
public TResult Read<TResult>(PortableReaderImpl ctx)
{
- return TypeCaster<TResult>.Cast(PortableUtils.ReadGenericArray<T>(ctx, false));
+ return TypeCaster<TResult>.Cast(PortableUtils.ReadArray<T>(ctx, false));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
index ed8d5e1..26cf5b5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
@@ -170,15 +170,6 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Type: native job result holder. */
public const byte TypePortableJobResHolder = 76;
- /** Type: .Net configuration. */
- public const byte TypeDotNetCfg = 202;
-
- /** Type: .Net portable configuration. */
- public const byte TypeDotNetPortableCfg = 203;
-
- /** Type: .Net portable type configuration. */
- public const byte TypeDotNetPortableTypCfg = 204;
-
/** Type: Ignite proxy. */
public const byte TypeIgniteProxy = 74;
@@ -212,9 +203,6 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Type: entry predicate holder. */
public const byte TypeCacheEntryPredicateHolder = 90;
- /** Type: product license. */
- public const byte TypeProductLicense = 78;
-
/** Type: message filter holder. */
public const byte TypeMessageListenerHolder = 92;
@@ -284,12 +272,6 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Dictionary type. */
public static readonly Type TypDictionary = typeof(IDictionary);
- /** Generic collection type. */
- public static readonly Type TypGenericCollection = typeof(ICollection<>);
-
- /** Generic dictionary type. */
- public static readonly Type TypGenericDictionary = typeof(IDictionary<,>);
-
/** Ticks for Java epoch. */
private static readonly long JavaDateTicks = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).Ticks;
@@ -300,25 +282,9 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Default poratble marshaller. */
private static readonly PortableMarshaller Marsh = new PortableMarshaller(null);
- /** Method: WriteGenericCollection. */
- public static readonly MethodInfo MtdhWriteGenericCollection =
- typeof(PortableUtils).GetMethod("WriteGenericCollection", _bindFlagsStatic);
-
- /** Method: ReadGenericCollection. */
- public static readonly MethodInfo MtdhReadGenericCollection =
- typeof(PortableUtils).GetMethod("ReadGenericCollection", _bindFlagsStatic);
-
- /** Method: WriteGenericDictionary. */
- public static readonly MethodInfo MtdhWriteGenericDictionary =
- typeof(PortableUtils).GetMethod("WriteGenericDictionary", _bindFlagsStatic);
-
- /** Method: ReadGenericDictionary. */
- public static readonly MethodInfo MtdhReadGenericDictionary =
- typeof(PortableUtils).GetMethod("ReadGenericDictionary", _bindFlagsStatic);
-
- /** Method: ReadGenericArray. */
- public static readonly MethodInfo MtdhReadGenericArray =
- typeof(PortableUtils).GetMethod("ReadGenericArray", _bindFlagsStatic);
+ /** Method: ReadArray. */
+ public static readonly MethodInfo MtdhReadArray =
+ typeof(PortableUtils).GetMethod("ReadArray", _bindFlagsStatic);
/** Cached UTF8 encoding. */
private static readonly Encoding Utf8 = Encoding.UTF8;
@@ -1006,7 +972,7 @@ namespace Apache.Ignite.Core.Impl.Portable
var vals = new decimal?[len];
for (int i = 0; i < len; i++)
- vals[i] = stream.ReadByte() == HdrNull ? (decimal?) null : ReadDecimal(stream);
+ vals[i] = stream.ReadByte() == HdrNull ? null : ReadDecimal(stream);
return vals;
}
@@ -1098,19 +1064,17 @@ namespace Apache.Ignite.Core.Impl.Portable
return vals;
}
-
+
/// <summary>
/// Write array.
/// </summary>
/// <param name="val">Array.</param>
/// <param name="ctx">Write context.</param>
- /// <param name="typed">Typed flag.</param>
- public static void WriteArray(Array val, PortableWriterImpl ctx, bool typed)
+ public static void WriteArray(Array val, PortableWriterImpl ctx)
{
IPortableStream stream = ctx.Stream;
- if (typed)
- stream.WriteInt(ObjTypeId);
+ stream.WriteInt(ObjTypeId);
stream.WriteInt(val.Length);
@@ -1125,14 +1089,14 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="typed">Typed flag.</param>
/// <param name="elementType">Type of the element.</param>
/// <returns>Array.</returns>
- public static object ReadArray(PortableReaderImpl ctx, bool typed, Type elementType)
+ public static object ReadTypedArray(PortableReaderImpl ctx, bool typed, Type elementType)
{
Func<PortableReaderImpl, bool, object> result;
if (!ArrayReaders.TryGetValue(elementType, out result))
result = ArrayReaders.GetOrAdd(elementType, t =>
DelegateConverter.CompileFunc<Func<PortableReaderImpl, bool, object>>(null,
- MtdhReadGenericArray.MakeGenericMethod(t),
+ MtdhReadArray.MakeGenericMethod(t),
new[] {typeof (PortableReaderImpl), typeof (bool)}, new[] {false, false, true}));
return result(ctx, typed);
@@ -1144,9 +1108,9 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="ctx">Read context.</param>
/// <param name="typed">Typed flag.</param>
/// <returns>Array.</returns>
- public static T[] ReadGenericArray<T>(PortableReaderImpl ctx, bool typed)
+ public static T[] ReadArray<T>(PortableReaderImpl ctx, bool typed)
{
- IPortableStream stream = ctx.Stream;
+ var stream = ctx.Stream;
if (typed)
stream.ReadInt();
@@ -1186,9 +1150,29 @@ namespace Apache.Ignite.Core.Impl.Portable
*/
public static void WriteCollection(ICollection val, PortableWriterImpl ctx)
{
- byte colType = val.GetType() == typeof(ArrayList) ? CollectionArrayList : CollectionCustom;
+ var valType = val.GetType();
+
+ byte colType;
- WriteTypedCollection(val, ctx, colType);
+ if (valType.IsGenericType)
+ {
+ var genType = valType.GetGenericTypeDefinition();
+
+ if (genType == typeof (List<>))
+ colType = CollectionArrayList;
+ else if (genType == typeof (LinkedList<>))
+ colType = CollectionLinkedList;
+ else if (genType == typeof (SortedSet<>))
+ colType = CollectionSortedSet;
+ else if (genType == typeof (ConcurrentBag<>))
+ colType = CollectionConcurrentBag;
+ else
+ colType = CollectionCustom;
+ }
+ else
+ colType = valType == typeof (ArrayList) ? CollectionArrayList : CollectionCustom;
+
+ WriteCollection(val, ctx, colType);
}
/**
@@ -1197,7 +1181,7 @@ namespace Apache.Ignite.Core.Impl.Portable
* <param name="ctx">Write context.</param>
* <param name="colType">Collection type.</param>
*/
- public static void WriteTypedCollection(ICollection val, PortableWriterImpl ctx, byte colType)
+ public static void WriteCollection(ICollection val, PortableWriterImpl ctx, byte colType)
{
ctx.Stream.WriteInt(val.Count);
@@ -1217,19 +1201,30 @@ namespace Apache.Ignite.Core.Impl.Portable
public static ICollection ReadCollection(PortableReaderImpl ctx,
PortableCollectionFactory factory, PortableCollectionAdder adder)
{
- if (factory == null)
- factory = PortableSystemHandlers.CreateArrayList;
-
- if (adder == null)
- adder = PortableSystemHandlers.AddToArrayList;
-
IPortableStream stream = ctx.Stream;
int len = stream.ReadInt();
- ctx.Stream.Seek(1, SeekOrigin.Current);
+ byte colType = ctx.Stream.ReadByte();
- ICollection res = factory.Invoke(len);
+ ICollection res;
+
+ if (factory == null)
+ {
+ if (colType == CollectionLinkedList)
+ res = new LinkedList<object>();
+ else if (colType == CollectionSortedSet)
+ res = new SortedSet<object>();
+ else if (colType == CollectionConcurrentBag)
+ res = new ConcurrentBag<object>();
+ else
+ res = new ArrayList(len);
+ }
+ else
+ res = factory.Invoke(len);
+
+ if (adder == null)
+ adder = (col, elem) => { ((ArrayList) col).Add(elem); };
for (int i = 0; i < len; i++)
adder.Invoke(res, ctx.Deserialize<object>());
@@ -1238,95 +1233,33 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/**
- * <summary>Write generic collection.</summary>
- * <param name="val">Value.</param>
- * <param name="ctx">Write context.</param>
- */
- public static void WriteGenericCollection<T>(ICollection<T> val, PortableWriterImpl ctx)
- {
- Type type = val.GetType().GetGenericTypeDefinition();
-
- byte colType;
-
- if (type == typeof(List<>))
- colType = CollectionArrayList;
- else if (type == typeof(LinkedList<>))
- colType = CollectionLinkedList;
- else if (type == typeof(HashSet<>))
- colType = CollectionHashSet;
- else if (type == typeof(SortedSet<>))
- colType = CollectionSortedSet;
- else
- colType = CollectionCustom;
-
- WriteTypedGenericCollection(val, ctx, colType);
- }
-
- /**
- * <summary>Write generic non-null collection with known type.</summary>
+ * <summary>Write dictionary.</summary>
* <param name="val">Value.</param>
* <param name="ctx">Write context.</param>
- * <param name="colType">Collection type.</param>
*/
- public static void WriteTypedGenericCollection<T>(ICollection<T> val, PortableWriterImpl ctx,
- byte colType)
+ public static void WriteDictionary(IDictionary val, PortableWriterImpl ctx)
{
- ctx.Stream.WriteInt(val.Count);
-
- ctx.Stream.WriteByte(colType);
+ var valType = val.GetType();
- foreach (T elem in val)
- ctx.Write(elem);
- }
-
- /**
- * <summary>Read generic collection.</summary>
- * <param name="ctx">Context.</param>
- * <param name="factory">Factory delegate.</param>
- * <returns>Collection.</returns>
- */
- public static ICollection<T> ReadGenericCollection<T>(PortableReaderImpl ctx,
- PortableGenericCollectionFactory<T> factory)
- {
- int len = ctx.Stream.ReadInt();
+ byte dictType;
- if (len >= 0)
+ if (valType.IsGenericType)
{
- byte colType = ctx.Stream.ReadByte();
-
- if (factory == null)
- {
- // Need to detect factory automatically.
- if (colType == CollectionLinkedList)
- factory = PortableSystemHandlers.CreateLinkedList<T>;
- else if (colType == CollectionHashSet)
- factory = PortableSystemHandlers.CreateHashSet<T>;
- else if (colType == CollectionSortedSet)
- factory = PortableSystemHandlers.CreateSortedSet<T>;
- else
- factory = PortableSystemHandlers.CreateList<T>;
- }
-
- ICollection<T> res = factory.Invoke(len);
-
- for (int i = 0; i < len; i++)
- res.Add(ctx.Deserialize<T>());
-
- return res;
+ var genType = valType.GetGenericTypeDefinition();
+
+ if (genType == typeof (Dictionary<,>))
+ dictType = MapHashMap;
+ else if (genType == typeof (SortedDictionary<,>))
+ dictType = MapSortedMap;
+ else if (genType == typeof (ConcurrentDictionary<,>))
+ dictType = MapConcurrentHashMap;
+ else
+ dictType = MapCustom;
}
- return null;
- }
-
- /**
- * <summary>Write dictionary.</summary>
- * <param name="val">Value.</param>
- * <param name="ctx">Write context.</param>
- */
- public static void WriteDictionary(IDictionary val, PortableWriterImpl ctx)
- {
- byte dictType = val.GetType() == typeof(Hashtable) ? MapHashMap : MapCustom;
+ else
+ dictType = valType == typeof (Hashtable) ? MapHashMap : MapCustom;
- WriteTypedDictionary(val, ctx, dictType);
+ WriteDictionary(val, ctx, dictType);
}
/**
@@ -1335,7 +1268,7 @@ namespace Apache.Ignite.Core.Impl.Portable
* <param name="ctx">Write context.</param>
* <param name="dictType">Dictionary type.</param>
*/
- public static void WriteTypedDictionary(IDictionary val, PortableWriterImpl ctx, byte dictType)
+ public static void WriteDictionary(IDictionary val, PortableWriterImpl ctx, byte dictType)
{
ctx.Stream.WriteInt(val.Count);
@@ -1357,16 +1290,26 @@ namespace Apache.Ignite.Core.Impl.Portable
public static IDictionary ReadDictionary(PortableReaderImpl ctx,
PortableDictionaryFactory factory)
{
- if (factory == null)
- factory = PortableSystemHandlers.CreateHashtable;
-
IPortableStream stream = ctx.Stream;
int len = stream.ReadInt();
- ctx.Stream.Seek(1, SeekOrigin.Current);
+ byte colType = ctx.Stream.ReadByte();
+
+ IDictionary res;
+
+ if (factory == null)
+ {
+ if (colType == MapSortedMap)
+ res = new SortedDictionary<object, object>();
+ else if (colType == MapConcurrentHashMap)
+ res = new ConcurrentDictionary<object, object>(Environment.ProcessorCount, len);
+ else
+ res = new Hashtable(len);
+ }
+ else
+ res = factory.Invoke(len);
- IDictionary res = factory.Invoke(len);
for (int i = 0; i < len; i++)
{
@@ -1380,89 +1323,6 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/**
- * <summary>Write generic dictionary.</summary>
- * <param name="val">Value.</param>
- * <param name="ctx">Write context.</param>
- */
- public static void WriteGenericDictionary<TK, TV>(IDictionary<TK, TV> val, PortableWriterImpl ctx)
- {
- Type type = val.GetType().GetGenericTypeDefinition();
-
- byte dictType;
-
- if (type == typeof(Dictionary<,>))
- dictType = MapHashMap;
- else if (type == typeof(SortedDictionary<,>))
- dictType = MapSortedMap;
- else if (type == typeof(ConcurrentDictionary<,>))
- dictType = MapConcurrentHashMap;
- else
- dictType = MapCustom;
-
- WriteTypedGenericDictionary(val, ctx, dictType);
- }
-
- /**
- * <summary>Write generic non-null dictionary with known type.</summary>
- * <param name="val">Value.</param>
- * <param name="ctx">Write context.</param>
- * <param name="dictType">Dictionary type.</param>
- */
- public static void WriteTypedGenericDictionary<TK, TV>(IDictionary<TK, TV> val,
- PortableWriterImpl ctx, byte dictType)
- {
- ctx.Stream.WriteInt(val.Count);
-
- ctx.Stream.WriteByte(dictType);
-
- foreach (KeyValuePair<TK, TV> entry in val)
- {
- ctx.Write(entry.Key);
- ctx.Write(entry.Value);
- }
- }
-
- /**
- * <summary>Read generic dictionary.</summary>
- * <param name="ctx">Context.</param>
- * <param name="factory">Factory delegate.</param>
- * <returns>Collection.</returns>
- */
- public static IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(PortableReaderImpl ctx,
- PortableGenericDictionaryFactory<TK, TV> factory)
- {
- int len = ctx.Stream.ReadInt();
-
- if (len >= 0)
- {
- byte colType = ctx.Stream.ReadByte();
-
- if (factory == null)
- {
- if (colType == MapSortedMap)
- factory = PortableSystemHandlers.CreateSortedDictionary<TK, TV>;
- else if (colType == MapConcurrentHashMap)
- factory = PortableSystemHandlers.CreateConcurrentDictionary<TK, TV>;
- else
- factory = PortableSystemHandlers.CreateDictionary<TK, TV>;
- }
-
- IDictionary<TK, TV> res = factory.Invoke(len);
-
- for (int i = 0; i < len; i++)
- {
- TK key = ctx.Deserialize<TK>();
- TV val = ctx.Deserialize<TV>();
-
- res[key] = val;
- }
-
- return res;
- }
- return null;
- }
-
- /**
* <summary>Write map entry.</summary>
* <param name="ctx">Write context.</param>
* <param name="val">Value.</param>
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
index ffa475e..b75292f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
@@ -867,7 +867,7 @@ namespace Apache.Ignite.Core.Impl.Portable
int pos = SkipFieldLength();
_stream.WriteByte(PU.TypeArrayEnum);
- PortableUtils.WriteArray(val, this, true);
+ PortableUtils.WriteArray(val, this);
WriteFieldLength(_stream, pos);
}
@@ -885,7 +885,7 @@ namespace Apache.Ignite.Core.Impl.Portable
else
{
_stream.WriteByte(PU.TypeArrayEnum);
- PortableUtils.WriteArray(val, this, true);
+ PortableUtils.WriteArray(val, this);
}
}
@@ -924,10 +924,10 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <summary>
/// Write named object array.
/// </summary>
- /// <typeparam name="T"></typeparam>
+ /// <typeparam name="T">Element type.</typeparam>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Object array.</param>
- public void WriteObjectArray<T>(string fieldName, T[] val)
+ public void WriteArray<T>(string fieldName, T[] val)
{
WriteFieldId(fieldName, PU.TypeArray);
@@ -938,7 +938,7 @@ namespace Apache.Ignite.Core.Impl.Portable
int pos = SkipFieldLength();
_stream.WriteByte(PU.TypeArray);
- PortableUtils.WriteArray(val, this, true);
+ PortableUtils.WriteArray(val, this);
WriteFieldLength(_stream, pos);
}
@@ -947,16 +947,16 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <summary>
/// Write object array.
/// </summary>
- /// <typeparam name="T"></typeparam>
+ /// <typeparam name="T">Element type.</typeparam>
/// <param name="val">Object array.</param>
- public void WriteObjectArray<T>(T[] val)
+ public void WriteArray<T>(T[] val)
{
if (val == null)
WriteNullRawField();
else
{
_stream.WriteByte(PU.TypeArray);
- PortableUtils.WriteArray(val, this, true);
+ PortableUtils.WriteArray(val, this);
}
}
@@ -975,7 +975,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
int pos = SkipFieldLength();
- Write(val);
+ WriteCollection(val);
WriteFieldLength(_stream, pos);
}
@@ -987,39 +987,8 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="val">Collection.</param>
public void WriteCollection(ICollection val)
{
- Write(val);
- }
-
- /// <summary>
- /// Write named generic collection.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="fieldName">Field name.</param>
- /// <param name="val">Collection.</param>
- public void WriteGenericCollection<T>(string fieldName, ICollection<T> val)
- {
- WriteFieldId(fieldName, PU.TypeCollection);
-
- if (val == null)
- WriteNullField();
- else
- {
- int pos = SkipFieldLength();
-
- Write(val);
-
- WriteFieldLength(_stream, pos);
- }
- }
-
- /// <summary>
- /// Write generic collection.
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="val">Collection.</param>
- public void WriteGenericCollection<T>(ICollection<T> val)
- {
- Write(val);
+ WriteByte(PU.TypeCollection);
+ PU.WriteCollection(val, this);
}
/// <summary>
@@ -1037,7 +1006,7 @@ namespace Apache.Ignite.Core.Impl.Portable
{
int pos = SkipFieldLength();
- Write(val);
+ WriteDictionary(val);
WriteFieldLength(_stream, pos);
}
@@ -1049,37 +1018,8 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="val">Dictionary.</param>
public void WriteDictionary(IDictionary val)
{
- Write(val);
- }
-
- /// <summary>
- /// Write named generic dictionary.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <param name="val">Dictionary.</param>
- public void WriteGenericDictionary<TK, TV>(string fieldName, IDictionary<TK, TV> val)
- {
- WriteFieldId(fieldName, PU.TypeDictionary);
-
- if (val == null)
- WriteNullField();
- else
- {
- int pos = SkipFieldLength();
-
- Write(val);
-
- WriteFieldLength(_stream, pos);
- }
- }
-
- /// <summary>
- /// Write generic dictionary.
- /// </summary>
- /// <param name="val">Dictionary.</param>
- public void WriteGenericDictionary<TK, TV>(IDictionary<TK, TV> val)
- {
- Write(val);
+ WriteByte(PU.TypeDictionary);
+ PU.WriteDictionary(val, this);
}
/// <summary>
@@ -1118,7 +1058,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
/// <param name="builder">Builder.</param>
/// <returns>Previous builder.</returns>
- internal PortableBuilderImpl Builder(PortableBuilderImpl builder)
+ internal PortableBuilderImpl SetBuilder(PortableBuilderImpl builder)
{
PortableBuilderImpl ret = _builder;
@@ -1239,11 +1179,10 @@ namespace Apache.Ignite.Core.Impl.Portable
handler.Invoke(this, obj);
else
{
- // Last chance: is object seializable?
if (type.IsSerializable)
Write(new SerializableObjectHolder(obj));
else
- // We did our best, object cannot be marshalled.
+ // We did our best, object cannot be marshalled.
throw new PortableException("Unsupported object type [type=" + type + ", object=" + obj + ']');
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
index a3e8dd5..f0408a8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Portable
{
using System;
using System.Collections;
- using System.Collections.Generic;
/// <summary>
/// Raw reader for portable objects.
@@ -206,10 +205,10 @@ namespace Apache.Ignite.Core.Portable
/// Read object array.
/// </summary>
/// <returns>Object array.</returns>
- T[] ReadObjectArray<T>();
+ T[] ReadArray<T>();
/// <summary>
- /// Read collection.
+ /// Read collection.
/// </summary>
/// <returns>Collection.</returns>
ICollection ReadCollection();
@@ -223,19 +222,6 @@ namespace Apache.Ignite.Core.Portable
ICollection ReadCollection(PortableCollectionFactory factory, PortableCollectionAdder adder);
/// <summary>
- /// Read generic collection.
- /// </summary>
- /// <returns>Collection.</returns>
- ICollection<T> ReadGenericCollection<T>();
-
- /// <summary>
- /// Read generic collection.
- /// </summary>
- /// <param name="factory">Factory.</param>
- /// <returns>Collection.</returns>
- ICollection<T> ReadGenericCollection<T>(PortableGenericCollectionFactory<T> factory);
-
- /// <summary>
/// Read dictionary.
/// </summary>
/// <returns>Dictionary.</returns>
@@ -247,18 +233,5 @@ namespace Apache.Ignite.Core.Portable
/// <param name="factory">Factory.</param>
/// <returns>Dictionary.</returns>
IDictionary ReadDictionary(PortableDictionaryFactory factory);
-
- /// <summary>
- /// Read generic dictionary.
- /// </summary>
- /// <returns>Dictionary.</returns>
- IDictionary<TK, TV> ReadGenericDictionary<TK, TV>();
-
- /// <summary>
- /// Read generic dictionary.
- /// </summary>
- /// <param name="factory">Factory.</param>
- /// <returns>Dictionary.</returns>
- IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(PortableGenericDictionaryFactory<TK, TV> factory);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
index cc14f45..71b0c07 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Portable
{
using System;
using System.Collections;
- using System.Collections.Generic;
/// <summary>
/// Raw writer for portable objects.
@@ -192,30 +191,30 @@ namespace Apache.Ignite.Core.Portable
/// Write object array.
/// </summary>
/// <param name="val">Object array.</param>
- void WriteObjectArray<T>(T[] val);
+ void WriteArray<T>(T[] val);
/// <summary>
- /// Write collection.
+ /// Writes a collection in interoperable form.
+ ///
+ /// Use this method to communicate with other platforms
+ /// or with nodes that need to read collection elements in portable form.
+ ///
+ /// When there is no need for portables or interoperability, please use <see cref="WriteObject{T}" />,
+ /// which will properly preserve generic collection type.
/// </summary>
/// <param name="val">Collection.</param>
void WriteCollection(ICollection val);
/// <summary>
- /// Write generic collection.
- /// </summary>
- /// <param name="val">Collection.</param>
- void WriteGenericCollection<T>(ICollection<T> val);
-
- /// <summary>
- /// Write dictionary.
+ /// Writes a dictionary in interoperable form.
+ ///
+ /// Use this method to communicate with other platforms
+ /// or with nodes that need to read dictionary elements in portable form.
+ ///
+ /// When there is no need for portables or interoperability, please use <see cref="WriteObject{T}" />,
+ /// which will properly preserve generic dictionary type.
/// </summary>
/// <param name="val">Dictionary.</param>
void WriteDictionary(IDictionary val);
-
- /// <summary>
- /// Write generic dictionary.
- /// </summary>
- /// <param name="val">Dictionary.</param>
- void WriteGenericDictionary<TK, TV>(IDictionary<TK, TV> val);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
index ed86b7e..03702d3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Portable
{
using System;
using System.Collections;
- using System.Collections.Generic;
/// <summary>
/// Delegate for collection creation.
@@ -36,13 +35,6 @@ namespace Apache.Ignite.Core.Portable
public delegate void PortableCollectionAdder(ICollection col, object elem);
/// <summary>
- /// Delegate for generic collection creation.
- /// </summary>
- /// <param name="size">Collection size.</param>
- /// <returns>Collection.</returns>
- public delegate ICollection<T> PortableGenericCollectionFactory<T>(int size);
-
- /// <summary>
/// Delegate for dictionary creation.
/// </summary>
/// <param name="size">Dictionary size.</param>
@@ -50,13 +42,6 @@ namespace Apache.Ignite.Core.Portable
public delegate IDictionary PortableDictionaryFactory(int size);
/// <summary>
- /// Delegate for generic collection creation.
- /// </summary>
- /// <param name="size">Collection size.</param>
- /// <returns>Collection.</returns>
- public delegate IDictionary<TK, TV> PortableGenericDictionaryFactory<TK, TV>(int size);
-
- /// <summary>
/// Reader for portable objects.
/// </summary>
public interface IPortableReader
@@ -268,7 +253,7 @@ namespace Apache.Ignite.Core.Portable
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <returns>Object array.</returns>
- T[] ReadObjectArray<T>(string fieldName);
+ T[] ReadArray<T>(string fieldName);
/// <summary>
/// Read named collection.
@@ -287,21 +272,6 @@ namespace Apache.Ignite.Core.Portable
ICollection ReadCollection(string fieldName, PortableCollectionFactory factory, PortableCollectionAdder adder);
/// <summary>
- /// Read named generic collection.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <returns>Collection.</returns>
- ICollection<T> ReadGenericCollection<T>(string fieldName);
-
- /// <summary>
- /// Read named generic collection.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <param name="factory">Factory.</param>
- /// <returns>Collection.</returns>
- ICollection<T> ReadGenericCollection<T>(string fieldName, PortableGenericCollectionFactory<T> factory);
-
- /// <summary>
/// Read named dictionary.
/// </summary>
/// <param name="fieldName">Field name.</param>
@@ -317,21 +287,6 @@ namespace Apache.Ignite.Core.Portable
IDictionary ReadDictionary(string fieldName, PortableDictionaryFactory factory);
/// <summary>
- /// Read named generic dictionary.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <returns>Dictionary.</returns>
- IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(string fieldName);
-
- /// <summary>
- /// Read named generic dictionary.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <param name="factory">Factory.</param>
- /// <returns>Dictionary.</returns>
- IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(string fieldName, PortableGenericDictionaryFactory<TK, TV> factory);
-
- /// <summary>
/// Get raw reader.
/// </summary>
/// <returns>Raw reader.</returns>
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
index 670a137..6e5d680 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Portable
{
using System;
using System.Collections;
- using System.Collections.Generic;
/// <summary>
/// Writer for portable objects.
@@ -220,37 +219,35 @@ namespace Apache.Ignite.Core.Portable
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Object array.</param>
- void WriteObjectArray<T>(string fieldName, T[] val);
+ void WriteArray<T>(string fieldName, T[] val);
/// <summary>
- /// Write named collection.
+ /// Writes a named collection in interoperable form.
+ ///
+ /// Use this method to communicate with other platforms
+ /// or with nodes that need to read collection elements in portable form.
+ ///
+ /// When there is no need for portables or interoperability, please use <see cref="WriteObject{T}" />,
+ /// which will properly preserve generic collection type.
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Collection.</param>
void WriteCollection(string fieldName, ICollection val);
/// <summary>
- /// Write named generic collection.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <param name="val">Collection.</param>
- void WriteGenericCollection<T>(string fieldName, ICollection<T> val);
-
- /// <summary>
- /// Write named dictionary.
+ /// Writes a named dictionary in interoperable form.
+ ///
+ /// Use this method to communicate with other platforms
+ /// or with nodes that need to read dictionary elements in portable form.
+ ///
+ /// When there is no need for portables or interoperability, please use <see cref="WriteObject{T}" />,
+ /// which will properly preserve generic dictionary type.
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Dictionary.</param>
void WriteDictionary(string fieldName, IDictionary val);
/// <summary>
- /// Write named generic dictionary.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <param name="val">Dictionary.</param>
- void WriteGenericDictionary<TK, TV>(string fieldName, IDictionary<TK, TV> val);
-
- /// <summary>
/// Get raw writer.
/// </summary>
/// <returns>Raw writer.</returns>
[16/17] ignite git commit: Merge branch 'ignite-1282' of
https://git-wip-us.apache.org/repos/asf/ignite into ignite-950-new
Posted by ag...@apache.org.
Merge branch 'ignite-1282' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-950-new
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/383b08ac
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/383b08ac
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/383b08ac
Branch: refs/heads/ignite-950-new
Commit: 383b08ac4cdb857f7dc346f30ecb7be7817d8380
Parents: 52ac93b 54c44b8
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Oct 28 10:10:18 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Oct 28 10:10:18 2015 +0300
----------------------------------------------------------------------
.../portable/GridPortableMarshaller.java | 6 +
.../portable/PortableClassDescriptor.java | 69 ++-
.../internal/portable/PortableContext.java | 59 +-
.../portable/PortableMetaDataCollector.java | 5 +
.../internal/portable/PortableReaderExImpl.java | 157 ++++--
.../ignite/internal/portable/PortableUtils.java | 28 +-
.../internal/portable/PortableWriterExImpl.java | 93 +++-
.../portable/builder/PortableBuilderReader.java | 52 +-
.../CacheObjectPortableProcessorImpl.java | 4 +
.../platform/PlatformContextImpl.java | 9 +-
.../cache/affinity/PlatformAffinity.java | 5 +-
.../transactions/PlatformTransactions.java | 5 +-
.../marshaller/portable/PortableMarshaller.java | 22 -
.../ignite/portable/PortableRawReader.java | 6 +
.../ignite/portable/PortableRawWriter.java | 6 +
.../apache/ignite/portable/PortableReader.java | 7 +
.../portable/PortableTypeConfiguration.java | 19 -
.../apache/ignite/portable/PortableWriter.java | 7 +
.../GridPortableBuilderAdditionalSelfTest.java | 65 ++-
.../portable/GridPortableBuilderSelfTest.java | 50 +-
.../GridPortableMarshallerSelfTest.java | 47 +-
.../mutabletest/GridPortableTestClasses.java | 9 +
.../platforms/cpp/common/include/Makefile.am | 3 +-
.../cpp/common/include/ignite/common/utils.h | 81 +++
.../cpp/common/project/vs/common.vcxproj | 1 +
.../common/project/vs/common.vcxproj.filters | 3 +
.../cpp/core-test/src/cache_query_test.cpp | 21 +-
.../platforms/cpp/core-test/src/cache_test.cpp | 19 +-
.../cpp/core-test/src/ignition_test.cpp | 19 +-
.../platforms/cpp/core/include/ignite/ignite.h | 1 +
.../core/include/ignite/ignite_configuration.h | 81 +--
.../cpp/core/include/ignite/impl/ignite_impl.h | 27 +-
modules/platforms/cpp/core/src/ignition.cpp | 18 +-
.../platforms/cpp/core/src/impl/ignite_impl.cpp | 5 +
modules/platforms/cpp/ignite/Makefile.am | 39 ++
modules/platforms/cpp/ignite/configure.ac | 62 +++
modules/platforms/cpp/ignite/project/README.TXT | 1 +
.../platforms/cpp/ignite/project/vs/README.TXT | 1 +
.../cpp/ignite/project/vs/ignite.vcxproj | 167 ++++++
.../ignite/project/vs/ignite.vcxproj.filters | 25 +
modules/platforms/cpp/ignite/src/ignite.cpp | 225 ++++++++
modules/platforms/cpp/project/vs/ignite.sln | 10 +
.../Apache.Ignite.Benchmarks.csproj | 7 +
.../Apache.Ignite.Benchmarks.snk | Bin 0 -> 596 bytes
.../Interop/GetAsyncBenchmark.cs | 6 +-
.../Interop/PutAsyncBenchmark.cs | 6 +-
.../Interop/TaskBenchmark.cs | 2 +-
.../Apache.Ignite.Benchmarks/Model/TestModel.cs | 8 +-
.../Apache.Ignite.Core.Tests.TestDll.csproj | 9 +
.../Apache.Ignite.Core.Tests.TestDll.snk | Bin 0 -> 596 bytes
.../Apache.Ignite.Core.Tests.csproj | 9 +
.../Apache.Ignite.Core.Tests.snk | Bin 0 -> 596 bytes
.../Cache/CacheAbstractTest.cs | 212 ++++---
.../Cache/CacheTestAsyncWrapper.cs | 294 +++++++---
.../Cache/Query/CacheQueriesTest.cs | 8 -
.../Continuous/ContinuousQueryAbstractTest.cs | 2 +-
.../Cache/Store/CacheStoreTest.cs | 17 +-
.../Compute/ComputeApiTest.cs | 34 +-
.../Compute/ComputeMultithreadedTest.cs | 4 +-
.../Compute/FailoverTaskSelfTest.cs | 2 +-
.../Compute/IgniteExceptionTaskSelfTest.cs | 11 +-
.../Compute/PortableTaskTest.cs | 60 +-
.../Compute/ResourceTaskTest.cs | 8 +-
.../Compute/TaskAdapterTest.cs | 4 +-
.../Compute/TaskResultTest.cs | 6 +-
.../Dataload/DataStreamerTest.cs | 40 +-
.../Apache.Ignite.Core.Tests/EventsTest.cs | 39 +-
.../Examples/PathUtil.cs | 1 -
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 37 +-
.../Apache.Ignite.Core.Tests/FutureTest.cs | 104 +---
.../IgniteManagerTest.cs | 1 -
.../Apache.Ignite.Core.Tests/LifecycleTest.cs | 3 +-
.../Apache.Ignite.Core.Tests/MessagingTest.cs | 42 +-
.../Portable/PortableApiSelfTest.cs | 190 +++----
.../Portable/PortableSelfTest.cs | 333 ++++++-----
.../Process/IgniteProcess.cs | 1 -
.../SerializationTest.cs | 4 +-
.../Services/ServicesAsyncWrapper.cs | 90 +--
.../Apache.Ignite.Core.csproj | 24 +-
.../Apache.Ignite.Core/Apache.Ignite.Core.snk | Bin 0 -> 596 bytes
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 370 +++++++++++--
.../Apache.Ignite.Core/Cache/ICacheAffinity.cs | 4 +-
.../Common/AsyncSupportedAttribute.cs | 33 --
.../Apache.Ignite.Core/Common/IAsyncSupport.cs | 52 --
.../dotnet/Apache.Ignite.Core/Common/IFuture.cs | 115 ----
.../Compute/ComputeJobAdapter.cs | 2 +-
.../Compute/ComputeJobResultPolicy.cs | 2 +-
.../Compute/ComputeTaskAdapter.cs | 6 +-
.../ComputeTaskNoResultCacheAttribute.cs | 2 +-
.../Apache.Ignite.Core/Compute/ICompute.cs | 210 ++++++-
.../Apache.Ignite.Core/Compute/IComputeJob.cs | 4 +-
.../Compute/IComputeJobResult.cs | 25 +-
.../Apache.Ignite.Core/Compute/IComputeTask.cs | 4 +-
.../Datastream/IDataStreamer.cs | 22 +-
.../Datastream/StreamTransformer.cs | 2 +-
.../Apache.Ignite.Core/Events/EventBase.cs | 2 +-
.../dotnet/Apache.Ignite.Core/Events/IEvents.cs | 68 ++-
.../dotnet/Apache.Ignite.Core/Ignition.cs | 4 +-
.../Impl/Cache/CacheAffinityImpl.cs | 10 +-
.../Impl/Cache/CacheEntryFilterHolder.cs | 4 +-
.../Impl/Cache/CacheEntryProcessorHolder.cs | 8 +-
.../Cache/CacheEntryProcessorResultHolder.cs | 3 +-
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 416 +++++++++-----
.../Impl/Cache/CacheProxyImpl.cs | 519 ------------------
.../Continuous/ContinuousQueryFilterHolder.cs | 7 +-
.../Impl/Cache/Store/CacheStore.cs | 5 +-
.../Impl/Cluster/ClusterGroupImpl.cs | 7 +-
.../Impl/Cluster/ClusterMetricsImpl.cs | 6 +-
.../Impl/Cluster/ClusterNodeImpl.cs | 7 +-
.../Impl/Common/AsyncResult.cs | 71 ---
.../Impl/Common/CompletedAsyncResult.cs | 59 --
.../Impl/Common/DelegateConverter.cs | 30 +-
.../Apache.Ignite.Core/Impl/Common/Future.cs | 203 +------
.../Impl/Common/PortableResultWrapper.cs | 67 ---
.../Closure/ComputeAbstractClosureTask.cs | 4 +-
.../Impl/Compute/Closure/ComputeActionJob.cs | 4 +-
.../Impl/Compute/Closure/ComputeFuncJob.cs | 10 +-
.../Compute/Closure/ComputeMultiClosureTask.cs | 2 +-
.../Impl/Compute/Closure/ComputeOutFuncJob.cs | 4 +-
.../Closure/ComputeReducingClosureTask.cs | 2 +-
.../Compute/Closure/ComputeSingleClosureTask.cs | 2 +-
.../Apache.Ignite.Core/Impl/Compute/Compute.cs | 135 ++++-
.../Impl/Compute/ComputeAsync.cs | 264 ---------
.../Impl/Compute/ComputeFunc.cs | 4 +-
.../Impl/Compute/ComputeImpl.cs | 40 +-
.../Impl/Compute/ComputeJob.cs | 4 +-
.../Impl/Compute/ComputeJobHolder.cs | 6 +-
.../Compute/ComputeJobResultGenericWrapper.cs | 15 +-
.../Impl/Compute/ComputeJobResultImpl.cs | 15 +-
.../Impl/Compute/ComputeOutFunc.cs | 4 +-
.../Impl/Compute/ComputeTaskHolder.cs | 22 +-
.../Impl/Datastream/DataStreamerBatch.cs | 12 +-
.../Impl/Datastream/DataStreamerImpl.cs | 18 +-
.../Impl/Datastream/StreamReceiverHolder.cs | 6 +-
.../Apache.Ignite.Core/Impl/Events/Events.cs | 133 +++--
.../Impl/Events/EventsAsync.cs | 159 ------
.../Impl/Events/RemoteListenEventFilter.cs | 3 +-
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 4 +-
.../Apache.Ignite.Core/Impl/IgniteManager.cs | 4 +-
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 9 -
.../Impl/Messaging/MessageListenerHolder.cs | 4 +-
.../Impl/Messaging/Messaging.cs | 97 ++--
.../Impl/Messaging/MessagingAsync.cs | 68 ---
.../Apache.Ignite.Core/Impl/PlatformTarget.cs | 21 +-
.../Impl/Portable/DateTimeHolder.cs | 68 +++
.../Portable/Metadata/PortableMetadataImpl.cs | 10 +-
.../Impl/Portable/PortableBuilderField.cs | 56 +-
.../Impl/Portable/PortableBuilderImpl.cs | 429 +++++++++++----
.../Impl/Portable/PortableCollectionInfo.cs | 251 ---------
.../Impl/Portable/PortableMarshaller.cs | 4 +-
.../PortableOrSerializableObjectHolder.cs | 64 ---
.../Impl/Portable/PortableReaderExtensions.cs | 52 ++
.../Impl/Portable/PortableReaderImpl.cs | 240 ++++----
.../Impl/Portable/PortableReflectiveRoutines.cs | 51 +-
.../Portable/PortableReflectiveSerializer.cs | 2 +-
.../Impl/Portable/PortableSystemHandlers.cs | 413 +++++---------
.../Impl/Portable/PortableUserObject.cs | 73 +--
.../Impl/Portable/PortableUtils.cs | 546 ++++---------------
.../Impl/Portable/PortableWriterImpl.cs | 150 ++---
.../Impl/Portable/SerializableObjectHolder.cs | 13 +-
.../Impl/Services/Services.cs | 128 +++--
.../Impl/Services/ServicesAsync.cs | 89 ---
.../Impl/Transactions/AsyncTransaction.cs | 78 ---
.../Impl/Transactions/Transaction.cs | 78 ++-
.../Impl/Transactions/TransactionImpl.cs | 47 +-
.../Impl/Transactions/TransactionMetricsImpl.cs | 4 +-
.../Impl/Transactions/TransactionsImpl.cs | 10 +-
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 6 +-
.../Unmanaged/UnmanagedNonReleaseableTarget.cs | 9 +-
.../Apache.Ignite.Core/Messaging/IMessaging.cs | 28 +-
.../Portable/IPortableBuilder.cs | 235 +++++++-
.../Portable/IPortableRawReader.cs | 57 +-
.../Portable/IPortableRawWriter.cs | 35 +-
.../Portable/IPortableReader.cs | 73 +--
.../Portable/IPortableWriter.cs | 37 +-
.../Portable/PortableTypeNames.cs | 10 +-
.../Properties/AssemblyInfo.cs | 5 +-
.../Apache.Ignite.Core/Services/IServices.cs | 98 +++-
.../Transactions/ITransaction.cs | 16 +-
.../dotnet/Apache.Ignite/Apache.Ignite.csproj | 7 +
.../dotnet/Apache.Ignite/Apache.Ignite.snk | Bin 0 -> 596 bytes
.../Apache.Ignite.Examples.csproj | 7 +
.../Apache.Ignite.Examples.snk | Bin 0 -> 596 bytes
.../Datagrid/CrossPlatformExample.cs | 14 +-
.../Apache.Ignite.ExamplesDll.csproj | 9 +
.../Apache.Ignite.ExamplesDll.snk | Bin 0 -> 596 bytes
.../Compute/AverageSalaryTask.cs | 2 +-
187 files changed, 4838 insertions(+), 5247 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/383b08ac/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
----------------------------------------------------------------------
[03/17] ignite git commit: IGNITE-1619: Reworked serialization of
generic collections.
Posted by ag...@apache.org.
IGNITE-1619: Reworked serialization of generic collections.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f65a53e4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f65a53e4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f65a53e4
Branch: refs/heads/ignite-950-new
Commit: f65a53e419346a45e2e26f4c4da84107d227e45f
Parents: b1b5428
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Fri Oct 23 11:22:22 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Oct 23 11:22:22 2015 +0300
----------------------------------------------------------------------
.../cache/affinity/PlatformAffinity.java | 5 +-
.../Compute/ComputeApiTest.cs | 27 +-
.../Apache.Ignite.Core.Tests/LifecycleTest.cs | 3 +-
.../Portable/PortableApiSelfTest.cs | 112 +++----
.../Portable/PortableSelfTest.cs | 235 ++++++++++----
.../Apache.Ignite.Core.csproj | 2 +-
.../Apache.Ignite.Core/Cache/ICacheAffinity.cs | 4 +-
.../dotnet/Apache.Ignite.Core/Ignition.cs | 4 +-
.../Impl/Cache/CacheAffinityImpl.cs | 10 +-
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 2 +-
.../Impl/Cache/Store/CacheStore.cs | 5 +-
.../Impl/Cluster/ClusterGroupImpl.cs | 7 +-
.../Impl/Cluster/ClusterNodeImpl.cs | 7 +-
.../Impl/Common/DelegateConverter.cs | 30 +-
.../Portable/Metadata/PortableMetadataImpl.cs | 2 +-
.../Impl/Portable/PortableBuilderImpl.cs | 23 +-
.../Impl/Portable/PortableCollectionInfo.cs | 251 ---------------
.../Impl/Portable/PortableReaderExtensions.cs | 52 +++
.../Impl/Portable/PortableReaderImpl.cs | 70 +----
.../Impl/Portable/PortableReflectiveRoutines.cs | 36 +--
.../Impl/Portable/PortableSystemHandlers.cs | 277 +++-------------
.../Impl/Portable/PortableUtils.cs | 314 +++++--------------
.../Impl/Portable/PortableWriterImpl.cs | 93 +-----
.../Portable/IPortableRawReader.cs | 31 +-
.../Portable/IPortableRawWriter.cs | 31 +-
.../Portable/IPortableReader.cs | 47 +--
.../Portable/IPortableWriter.cs | 33 +-
27 files changed, 538 insertions(+), 1175 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity.java
index 9dd7416..0d2098b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/affinity/PlatformAffinity.java
@@ -29,6 +29,7 @@ import org.apache.ignite.internal.portable.PortableRawReaderEx;
import org.apache.ignite.internal.portable.PortableRawWriterEx;
import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
import org.apache.ignite.internal.processors.platform.PlatformContext;
+import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.jetbrains.annotations.Nullable;
@@ -248,7 +249,7 @@ public class PlatformAffinity extends PlatformAbstractTarget {
}
case OP_MAP_KEYS_TO_NODES: {
- Collection<Object> keys = reader.readCollection();
+ Collection<Object> keys = PlatformUtils.readCollection(reader);
Map<ClusterNode, Collection<Object>> map = aff.mapKeysToNodes(keys);
@@ -265,7 +266,7 @@ public class PlatformAffinity extends PlatformAbstractTarget {
}
case OP_MAP_PARTITIONS_TO_NODES: {
- Collection<Integer> parts = reader.readCollection();
+ Collection<Integer> parts = PlatformUtils.readCollection(reader);
Map<Integer, ClusterNode> map = aff.mapPartitionsToNodes(parts);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
index f7ab05b..4c451e7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -19,6 +19,7 @@
namespace Apache.Ignite.Core.Tests.Compute
{
using System;
+ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
@@ -786,12 +787,12 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(1, res1.Length);
Assert.AreEqual(1, res1[0]);
- IList<int> res2 = _grid1.GetCompute().ExecuteJavaTask<IList<int>>(EchoTask, EchoTypeCollection);
+ var res2 = _grid1.GetCompute().ExecuteJavaTask<IList>(EchoTask, EchoTypeCollection);
Assert.AreEqual(1, res2.Count);
Assert.AreEqual(1, res2[0]);
- IDictionary<int, int> res3 = _grid1.GetCompute().ExecuteJavaTask<IDictionary<int, int>>(EchoTask, EchoTypeMap);
+ var res3 = _grid1.GetCompute().ExecuteJavaTask<IDictionary>(EchoTask, EchoTypeMap);
Assert.AreEqual(1, res3.Count);
Assert.AreEqual(1, res3[1]);
@@ -846,12 +847,12 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestEchoTaskPortableArray()
{
- var res = _grid1.GetCompute().ExecuteJavaTask<PlatformComputePortable[]>(EchoTask, EchoTypePortableArray);
+ var res = _grid1.GetCompute().ExecuteJavaTask<object[]>(EchoTask, EchoTypePortableArray);
Assert.AreEqual(3, res.Length);
for (var i = 0; i < res.Length; i++)
- Assert.AreEqual(i + 1, res[i].Field);
+ Assert.AreEqual(i + 1, ((PlatformComputePortable) res[i]).Field);
}
/// <summary>
@@ -906,7 +907,7 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestBroadcastTask()
{
- ICollection<Guid> res = _grid1.GetCompute().ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
+ var res = _grid1.GetCompute().ExecuteJavaTask<ICollection>(BroadcastTask, null).OfType<Guid>().ToList();
Assert.AreEqual(3, res.Count);
Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
@@ -917,7 +918,7 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(2, prj.GetNodes().Count);
- ICollection<Guid> filteredRes = prj.GetCompute().ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
+ var filteredRes = prj.GetCompute().ExecuteJavaTask<ICollection>(BroadcastTask, null).OfType<Guid>().ToList();
Assert.AreEqual(2, filteredRes.Count);
Assert.IsTrue(filteredRes.Contains(res.ElementAt(0)));
@@ -931,8 +932,8 @@ namespace Apache.Ignite.Core.Tests.Compute
public void TestBroadcastTaskAsync()
{
var gridCompute = _grid1.GetCompute().WithAsync();
- Assert.IsNull(gridCompute.ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null));
- ICollection<Guid> res = gridCompute.GetFuture<ICollection<Guid>>().Get();
+ Assert.IsNull(gridCompute.ExecuteJavaTask<ICollection>(BroadcastTask, null));
+ var res = gridCompute.GetFuture<ICollection>().Get().OfType<Guid>().ToList();
Assert.AreEqual(3, res.Count);
Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
@@ -944,8 +945,8 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(2, prj.GetNodes().Count);
var compute = prj.GetCompute().WithAsync();
- Assert.IsNull(compute.ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null));
- ICollection<Guid> filteredRes = compute.GetFuture<ICollection<Guid>>().Get();
+ Assert.IsNull(compute.ExecuteJavaTask<IList>(BroadcastTask, null));
+ var filteredRes = compute.GetFuture<IList>().Get();
Assert.AreEqual(2, filteredRes.Count);
Assert.IsTrue(filteredRes.Contains(res.ElementAt(0)));
@@ -1051,7 +1052,8 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestWithNoFailover()
{
- ICollection<Guid> res = _grid1.GetCompute().WithNoFailover().ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
+ var res = _grid1.GetCompute().WithNoFailover().ExecuteJavaTask<ICollection>(BroadcastTask, null)
+ .OfType<Guid>().ToList();
Assert.AreEqual(3, res.Count);
Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
@@ -1065,7 +1067,8 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestWithTimeout()
{
- ICollection<Guid> res = _grid1.GetCompute().WithTimeout(1000).ExecuteJavaTask<ICollection<Guid>>(BroadcastTask, null);
+ var res = _grid1.GetCompute().WithTimeout(1000).ExecuteJavaTask<ICollection>(BroadcastTask, null)
+ .OfType<Guid>().ToList();
Assert.AreEqual(3, res.Count);
Assert.AreEqual(1, _grid1.GetCluster().ForNodeIds(res.ElementAt(0)).GetNodes().Count);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/LifecycleTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/LifecycleTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/LifecycleTest.cs
index 84f446c..dd79d43 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/LifecycleTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/LifecycleTest.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Tests
{
using System;
+ using System.Collections;
using System.Collections.Generic;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl;
@@ -128,7 +129,7 @@ namespace Apache.Ignite.Core.Tests
CheckEvent(AfterStartEvts[3], grid, grid, 0, null);
// 2. Test Java start events.
- IList<int> res = grid.GetCompute().ExecuteJavaTask<IList<int>>(
+ var res = grid.GetCompute().ExecuteJavaTask<IList>(
"org.apache.ignite.platform.lifecycle.PlatformJavaLifecycleTask", null);
Assert.AreEqual(2, res.Count);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
index 009a2da..53e066d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
@@ -256,7 +256,8 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(1, portObj.Deserialize<ToPortableNoMeta>().Val);
// 5. Object array.
- IPortableObject[] portObjArr = api.ToPortable<IPortableObject[]>(new[] { new ToPortable(1) });
+ var portObjArr = api.ToPortable<object[]>(new object[] {new ToPortable(1)})
+ .OfType<IPortableObject>().ToArray();
Assert.AreEqual(1, portObjArr.Length);
Assert.AreEqual(1, portObjArr[0].GetField<int>("Val"));
@@ -447,7 +448,7 @@ namespace Apache.Ignite.Core.Tests.Portable
IPortableBuilder builderItem =
_grid.GetPortables().GetBuilder(typeof(BuilderCollectionItem)).SetField("val", 1);
- builderCol.SetField<ICollection>("col", new List<IPortableBuilder> { builderItem });
+ builderCol.SetField<ICollection>("col", new ArrayList { builderItem });
IPortableObject portCol = builderCol.Build();
@@ -458,11 +459,11 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual("col", meta.Fields.First());
Assert.AreEqual(PortableTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
- ICollection<IPortableObject> portColItems = portCol.GetField<ICollection<IPortableObject>>("col");
+ var portColItems = portCol.GetField<ArrayList>("col");
Assert.AreEqual(1, portColItems.Count);
- IPortableObject portItem = portColItems.First();
+ var portItem = (IPortableObject) portColItems[0];
meta = portItem.GetMetadata();
@@ -475,7 +476,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.IsNotNull(col.Col);
Assert.AreEqual(1, col.Col.Count);
- Assert.AreEqual(1, col.Col.First().Val);
+ Assert.AreEqual(1, ((BuilderCollectionItem) col.Col[0]).Val);
// Add more portable objects to collection.
builderCol = _grid.GetPortables().GetBuilder(portCol);
@@ -498,10 +499,10 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(4, col.Col.Count);
- BuilderCollectionItem item0 = col.Col.ElementAt(0);
- BuilderCollectionItem item1 = col.Col.ElementAt(1);
- BuilderCollectionItem item2 = col.Col.ElementAt(2);
- BuilderCollectionItem item3 = col.Col.ElementAt(3);
+ var item0 = (BuilderCollectionItem) col.Col[0];
+ var item1 = (BuilderCollectionItem) col.Col[1];
+ var item2 = (BuilderCollectionItem) col.Col[2];
+ var item3 = (BuilderCollectionItem) col.Col[3];
Assert.AreEqual(2, item0.Val);
@@ -525,8 +526,8 @@ namespace Apache.Ignite.Core.Tests.Portable
col = portCol.Deserialize<BuilderCollection>();
- item0 = col.Col.ElementAt(0);
- item1 = col.Col.ElementAt(1);
+ item0 = (BuilderCollectionItem) col.Col[0];
+ item1 = (BuilderCollectionItem) col.Col[1];
Assert.AreEqual(3, item0.Val);
Assert.AreSame(item0, item1);
@@ -918,7 +919,7 @@ namespace Apache.Ignite.Core.Tests.Portable
public void TestCompositeArray()
{
// 1. Test simple array.
- CompositeInner[] inArr = { new CompositeInner(1) };
+ object[] inArr = { new CompositeInner(1) };
IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
.SetField("inArr", inArr).Build();
@@ -931,7 +932,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(100, portObj.GetHashCode());
- IPortableObject[] portInArr = portObj.GetField<IPortableObject[]>("inArr");
+ IPortableObject[] portInArr = portObj.GetField<object[]>("inArr").Cast<IPortableObject>().ToArray();
Assert.AreEqual(1, portInArr.Length);
Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
@@ -940,17 +941,15 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.IsNull(arr.OutArr);
Assert.AreEqual(1, arr.InArr.Length);
- Assert.AreEqual(1, arr.InArr[0].Val);
+ Assert.AreEqual(1, ((CompositeInner) arr.InArr[0]).Val);
// 2. Test addition to array.
- portInArr = new[] { portInArr[0], null };
-
portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(200)
- .SetField("inArr", portInArr).Build();
+ .SetField("inArr", new object[] { portInArr[0], null }).Build();
Assert.AreEqual(200, portObj.GetHashCode());
- portInArr = portObj.GetField<IPortableObject[]>("inArr");
+ portInArr = portObj.GetField<object[]>("inArr").Cast<IPortableObject>().ToArray();
Assert.AreEqual(2, portInArr.Length);
Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
@@ -960,17 +959,17 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.IsNull(arr.OutArr);
Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(1, arr.InArr[0].Val);
+ Assert.AreEqual(1, ((CompositeInner) arr.InArr[0]).Val);
Assert.IsNull(arr.InArr[1]);
portInArr[1] = _grid.GetPortables().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(300)
- .SetField("inArr", portInArr).Build();
+ .SetField("inArr", portInArr.OfType<object>().ToArray()).Build();
Assert.AreEqual(300, portObj.GetHashCode());
- portInArr = portObj.GetField<IPortableObject[]>("inArr");
+ portInArr = portObj.GetField<object[]>("inArr").Cast<IPortableObject>().ToArray();
Assert.AreEqual(2, portInArr.Length);
Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
@@ -980,20 +979,20 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.IsNull(arr.OutArr);
Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(1, arr.InArr[0].Val);
- Assert.AreEqual(2, arr.InArr[1].Val);
+ Assert.AreEqual(1, ((CompositeInner)arr.InArr[0]).Val);
+ Assert.AreEqual(2, ((CompositeInner)arr.InArr[1]).Val);
// 3. Test top-level handle inversion.
CompositeInner inner = new CompositeInner(1);
- inArr = new[] { inner, inner };
+ inArr = new object[] { inner, inner };
portObj = _grid.GetPortables().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
.SetField("inArr", inArr).Build();
Assert.AreEqual(100, portObj.GetHashCode());
- portInArr = portObj.GetField<IPortableObject[]>("inArr");
+ portInArr = portObj.GetField<object[]>("inArr").Cast<IPortableObject>().ToArray();
Assert.AreEqual(2, portInArr.Length);
Assert.AreEqual(1, portInArr[0].GetField<int>("val"));
@@ -1003,17 +1002,17 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.IsNull(arr.OutArr);
Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(1, arr.InArr[0].Val);
- Assert.AreEqual(1, arr.InArr[1].Val);
+ Assert.AreEqual(1, ((CompositeInner)arr.InArr[0]).Val);
+ Assert.AreEqual(1, ((CompositeInner)arr.InArr[1]).Val);
portInArr[0] = _grid.GetPortables().GetBuilder(typeof(CompositeInner)).SetField("val", 2).Build();
portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(200)
- .SetField("inArr", portInArr).Build();
+ .SetField("inArr", portInArr.ToArray<object>()).Build();
Assert.AreEqual(200, portObj.GetHashCode());
- portInArr = portObj.GetField<IPortableObject[]>("inArr");
+ portInArr = portObj.GetField<object[]>("inArr").Cast<IPortableObject>().ToArray();
Assert.AreEqual(2, portInArr.Length);
Assert.AreEqual(2, portInArr[0].GetField<int>("val"));
@@ -1023,14 +1022,14 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.IsNull(arr.OutArr);
Assert.AreEqual(2, arr.InArr.Length);
- Assert.AreEqual(2, arr.InArr[0].Val);
- Assert.AreEqual(1, arr.InArr[1].Val);
+ Assert.AreEqual(2, ((CompositeInner)arr.InArr[0]).Val);
+ Assert.AreEqual(1, ((CompositeInner)arr.InArr[1]).Val);
// 4. Test nested object handle inversion.
CompositeOuter[] outArr = { new CompositeOuter(inner), new CompositeOuter(inner) };
portObj = _grid.GetPortables().GetBuilder(typeof(CompositeArray)).SetHashCode(100)
- .SetField("outArr", outArr).Build();
+ .SetField("outArr", outArr.ToArray<object>()).Build();
meta = portObj.GetMetadata();
@@ -1041,7 +1040,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(100, portObj.GetHashCode());
- IPortableObject[] portOutArr = portObj.GetField<IPortableObject[]>("outArr");
+ var portOutArr = portObj.GetField<object[]>("outArr").Cast<IPortableObject>().ToArray();
Assert.AreEqual(2, portOutArr.Length);
Assert.AreEqual(1, portOutArr[0].GetField<IPortableObject>("inner").GetField<int>("val"));
@@ -1051,18 +1050,18 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.IsNull(arr.InArr);
Assert.AreEqual(2, arr.OutArr.Length);
- Assert.AreEqual(1, arr.OutArr[0].Inner.Val);
- Assert.AreEqual(1, arr.OutArr[1].Inner.Val);
+ Assert.AreEqual(1, ((CompositeOuter) arr.OutArr[0]).Inner.Val);
+ Assert.AreEqual(1, ((CompositeOuter) arr.OutArr[0]).Inner.Val);
portOutArr[0] = _grid.GetPortables().GetBuilder(typeof(CompositeOuter))
.SetField("inner", new CompositeInner(2)).Build();
portObj = _grid.GetPortables().GetBuilder(portObj).SetHashCode(200)
- .SetField("outArr", portOutArr).Build();
+ .SetField("outArr", portOutArr.ToArray<object>()).Build();
Assert.AreEqual(200, portObj.GetHashCode());
- portInArr = portObj.GetField<IPortableObject[]>("outArr");
+ portInArr = portObj.GetField<object[]>("outArr").Cast<IPortableObject>().ToArray();
Assert.AreEqual(2, portInArr.Length);
Assert.AreEqual(2, portOutArr[0].GetField<IPortableObject>("inner").GetField<int>("val"));
@@ -1072,8 +1071,8 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.IsNull(arr.InArr);
Assert.AreEqual(2, arr.OutArr.Length);
- Assert.AreEqual(2, arr.OutArr[0].Inner.Val);
- Assert.AreEqual(1, arr.OutArr[1].Inner.Val);
+ Assert.AreEqual(2, ((CompositeOuter)arr.OutArr[0]).Inner.Val);
+ Assert.AreEqual(1, ((CompositeOuter)arr.OutArr[1]).Inner.Val);
}
/// <summary>
@@ -1083,60 +1082,40 @@ namespace Apache.Ignite.Core.Tests.Portable
public void TestCompositeContainer()
{
ArrayList col = new ArrayList();
- ICollection<CompositeInner> gCol = new List<CompositeInner>();
IDictionary dict = new Hashtable();
- IDictionary<int, CompositeInner> gDict = new Dictionary<int, CompositeInner>();
col.Add(new CompositeInner(1));
- gCol.Add(new CompositeInner(2));
dict[3] = new CompositeInner(3);
- gDict[4] = new CompositeInner(4);
IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(CompositeContainer)).SetHashCode(100)
.SetField<ICollection>("col", col)
- .SetField("gCol", gCol)
- .SetField("dict", dict)
- .SetField("gDict", gDict).Build();
+ .SetField("dict", dict).Build();
// 1. Check meta.
IPortableMetadata meta = portObj.GetMetadata();
Assert.AreEqual(typeof(CompositeContainer).Name, meta.TypeName);
- Assert.AreEqual(4, meta.Fields.Count);
+ Assert.AreEqual(2, meta.Fields.Count);
Assert.AreEqual(PortableTypeNames.TypeNameCollection, meta.GetFieldTypeName("col"));
- Assert.AreEqual(PortableTypeNames.TypeNameCollection, meta.GetFieldTypeName("gCol"));
Assert.AreEqual(PortableTypeNames.TypeNameMap, meta.GetFieldTypeName("dict"));
- Assert.AreEqual(PortableTypeNames.TypeNameMap, meta.GetFieldTypeName("gDict"));
// 2. Check in portable form.
Assert.AreEqual(1, portObj.GetField<ICollection>("col").Count);
Assert.AreEqual(1, portObj.GetField<ICollection>("col").OfType<IPortableObject>().First()
.GetField<int>("val"));
- Assert.AreEqual(1, portObj.GetField<ICollection<IPortableObject>>("gCol").Count);
- Assert.AreEqual(2, portObj.GetField<ICollection<IPortableObject>>("gCol").First().GetField<int>("val"));
-
Assert.AreEqual(1, portObj.GetField<IDictionary>("dict").Count);
Assert.AreEqual(3, ((IPortableObject) portObj.GetField<IDictionary>("dict")[3]).GetField<int>("val"));
- Assert.AreEqual(1, portObj.GetField<IDictionary<int, IPortableObject>>("gDict").Count);
- Assert.AreEqual(4, portObj.GetField<IDictionary<int, IPortableObject>>("gDict")[4].GetField<int>("val"));
-
// 3. Check in deserialized form.
CompositeContainer obj = portObj.Deserialize<CompositeContainer>();
Assert.AreEqual(1, obj.Col.Count);
Assert.AreEqual(1, obj.Col.OfType<CompositeInner>().First().Val);
- Assert.AreEqual(1, obj.GCol.Count);
- Assert.AreEqual(2, obj.GCol.First().Val);
-
Assert.AreEqual(1, obj.Dict.Count);
Assert.AreEqual(3, ((CompositeInner) obj.Dict[3]).Val);
-
- Assert.AreEqual(1, obj.GDict.Count);
- Assert.AreEqual(4, obj.GDict[4].Val);
}
/// <summary>
@@ -1587,8 +1566,8 @@ namespace Apache.Ignite.Core.Tests.Portable
/// </summary>
public class CompositeArray
{
- public CompositeInner[] InArr;
- public CompositeOuter[] OutArr;
+ public object[] InArr;
+ public object[] OutArr;
}
/// <summary>
@@ -1597,10 +1576,7 @@ namespace Apache.Ignite.Core.Tests.Portable
public class CompositeContainer
{
public ICollection Col;
- public ICollection<CompositeInner> GCol;
-
public IDictionary Dict;
- public IDictionary<int, CompositeInner> GDict;
}
/// <summary>
@@ -1719,13 +1695,13 @@ namespace Apache.Ignite.Core.Tests.Portable
public class BuilderCollection
{
/** */
- public ICollection<BuilderCollectionItem> Col;
+ public readonly ArrayList Col;
/// <summary>
///
/// </summary>
/// <param name="col"></param>
- public BuilderCollection(ICollection<BuilderCollectionItem> col)
+ public BuilderCollection(ArrayList col)
{
Col = col;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
index 36faf36..f06bf43 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
@@ -551,22 +551,55 @@ namespace Apache.Ignite.Core.Tests.Portable
[Test]
public void TestGenericCollections()
{
- ICollection<string> list = new List<string>();
+ var list = new List<string> {"1"};
- list.Add("1");
+ var data = _marsh.Marshal(list);
- byte[] data = _marsh.Marshal(list);
+ var newObjList = _marsh.Unmarshal<IList<string>>(data);
- ICollection<object> newObjList = _marsh.Unmarshal<List<object>>(data);
+ CollectionAssert.AreEquivalent(list, newObjList);
+ }
- Assert.NotNull(newObjList);
+ /// <summary>
+ /// Tests marshal aware type with generic collections.
+ /// </summary>
+ [Test]
+ public void TestGenericCollectionsType()
+ {
+ var marsh = new PortableMarshaller(new PortableConfiguration
+ {
+ TypeConfigurations = new List<PortableTypeConfiguration>
+ {
+ new PortableTypeConfiguration(typeof (PrimitiveFieldType)),
+ new PortableTypeConfiguration(typeof (GenericCollectionsType<PrimitiveFieldType, SerializableObject>))
+ }
+ });
- ICollection<string> newList = new List<string>();
+ var obj = new GenericCollectionsType<PrimitiveFieldType, SerializableObject>
+ {
+ Keys = new[] {new PrimitiveFieldType(), new PrimitiveFieldType()},
+ Values =
+ new List<SerializableObject>
+ {
+ new SerializableObject {Foo = 1},
+ new SerializableObject {Foo = 5}
+ },
+ Pairs = new Dictionary<PrimitiveFieldType, SerializableObject>
+ {
+ {new PrimitiveFieldType(), new SerializableObject {Foo = 10}},
+ {new PrimitiveFieldType {PByte = 10}, new SerializableObject {Foo = 20}}
+ },
+ Objects = new object[] {1, 2, "3", 4.4}
+ };
+
+ var data = marsh.Marshal(obj);
- foreach (object obj in newObjList)
- newList.Add((string)obj);
+ var result = marsh.Unmarshal<GenericCollectionsType<PrimitiveFieldType, SerializableObject>>(data);
- CollectionAssert.AreEquivalent(list, newList);
+ CollectionAssert.AreEquivalent(obj.Keys, result.Keys);
+ CollectionAssert.AreEquivalent(obj.Values, result.Values);
+ CollectionAssert.AreEquivalent(obj.Pairs, result.Pairs);
+ CollectionAssert.AreEquivalent(obj.Objects, result.Objects);
}
/**
@@ -840,40 +873,42 @@ namespace Apache.Ignite.Core.Tests.Portable
[Test]
public void TestCollectionsReflective()
{
- ICollection<PortableTypeConfiguration> typeCfgs =
- new List<PortableTypeConfiguration>();
-
- typeCfgs.Add(new PortableTypeConfiguration(typeof(CollectionsType)));
- typeCfgs.Add(new PortableTypeConfiguration(typeof(InnerObjectType)));
-
- PortableConfiguration cfg = new PortableConfiguration();
-
- cfg.TypeConfigurations = typeCfgs;
-
- PortableMarshaller marsh = new PortableMarshaller(cfg);
-
- CollectionsType obj = new CollectionsType();
-
- ArrayList list = new ArrayList();
-
- list.Add(true);
- list.Add((byte)1);
- list.Add((short)2);
- list.Add('a');
- list.Add(3);
- list.Add((long)4);
- list.Add((float)5);
- list.Add((double)6);
-
- list.Add("string");
- list.Add(Guid.NewGuid());
-
- InnerObjectType innerObj = new InnerObjectType();
-
- innerObj.PInt1 = 1;
- innerObj.PInt2 = 2;
+ var marsh = new PortableMarshaller(new PortableConfiguration
+ {
+ TypeConfigurations = new List<PortableTypeConfiguration>
+ {
+ new PortableTypeConfiguration(typeof (CollectionsType)),
+ new PortableTypeConfiguration(typeof (InnerObjectType))
+ }
+ });
- list.Add(innerObj);
+ var obj = new CollectionsType
+ {
+ Hashtable = new Hashtable {{1, 2}, {3, 4}},
+ LinkedList = new LinkedList<int>(new[] {1, 2, 3}),
+ SortedDict = new SortedDictionary<string, int> {{"1", 2}},
+ Dict = new Dictionary<int, string> {{1, "2"}},
+ Arr = new[] {new InnerObjectType()}
+ };
+
+ var list = new ArrayList
+ {
+ true,
+ (byte) 1,
+ (short) 2,
+ 'a',
+ 3,
+ (long) 4,
+ (float) 5,
+ (double) 6,
+ "string",
+ Guid.NewGuid(),
+ new InnerObjectType
+ {
+ PInt1 = 1,
+ PInt2 = 2
+ }
+ };
obj.Col1 = list;
@@ -1138,17 +1173,20 @@ namespace Apache.Ignite.Core.Tests.Portable
DateTime?[] nDateArr = { DateTime.Now.ToUniversalTime() };
// Use special object.
- SpecialArray obj1 = new SpecialArray();
-
- obj1.GuidArr = guidArr;
- obj1.NGuidArr = nGuidArr;
- obj1.DateArr = dateArr;
- obj1.NDateArr = nDateArr;
+ SpecialArray obj1 = new SpecialArray
+ {
+ GuidArr = guidArr,
+ NGuidArr = nGuidArr,
+ DateArr = dateArr,
+ NDateArr = nDateArr
+ };
byte[] bytes = marsh.Marshal(obj1);
IPortableObject portObj = marsh.Unmarshal<IPortableObject>(bytes, PortableMode.ForcePortable);
+ Assert.IsNotNull(portObj.Deserialize<SpecialArray>());
+
Assert.AreEqual(guidArr, portObj.GetField<Guid[]>("guidArr"));
Assert.AreEqual(nGuidArr, portObj.GetField<Guid?[]>("nGuidArr"));
Assert.AreEqual(dateArr, portObj.GetField<DateTime[]>("dateArr"));
@@ -1270,6 +1308,7 @@ namespace Apache.Ignite.Core.Tests.Portable
}
}
+ [Serializable]
public class InnerObjectType
{
public int PInt1 { get; set; }
@@ -1306,36 +1345,70 @@ namespace Apache.Ignite.Core.Tests.Portable
public ArrayList Col2 { get; set; }
+ public Hashtable Hashtable { get; set; }
+
+ public Dictionary<int, string> Dict { get; set; }
+
+ public InnerObjectType[] Arr { get; set; }
+
+ public SortedDictionary<string, int> SortedDict { get; set; }
+
+ public LinkedList<int> LinkedList { get; set; }
+
/** <inheritdoc /> */
public override bool Equals(object obj)
{
if (this == obj)
return true;
- if (obj != null && obj is CollectionsType)
- {
- CollectionsType that = (CollectionsType)obj;
+ var that = obj as CollectionsType;
- return CompareCollections(Col1, that.Col1) && CompareCollections(Col2, that.Col2);
- }
- return false;
+ return that != null
+ && CompareCollections(Col1, that.Col1)
+ && CompareCollections(Col2, that.Col2)
+ && CompareCollections(Hashtable, that.Hashtable)
+ && CompareCollections(Dict, that.Dict)
+ && CompareCollections(Arr, that.Arr)
+ && CompareCollections(SortedDict, that.SortedDict)
+ && CompareCollections(LinkedList, that.LinkedList);
}
/** <inheritdoc /> */
public override int GetHashCode()
{
- int res = Col1 != null ? Col1.GetHashCode() : 0;
+ int res = 0;
- res = 31 * res + (Col2 != null ? Col2.GetHashCode() : 0);
+ foreach (var col in new object[] {Col1, Col2, Hashtable, Dict, Arr, SortedDict, LinkedList})
+ res = 31*res + (col != null ? col.GetHashCode() : 0);
return res;
}
+ }
- /** <inheritdoc /> */
- public override string ToString()
+ public class GenericCollectionsType<TKey, TValue> : IPortableMarshalAware
+ {
+ public ICollection<TKey> Keys { get; set; }
+
+ public ICollection<TValue> Values { get; set; }
+
+ public IDictionary<TKey, TValue> Pairs { get; set; }
+
+ public ICollection<object> Objects { get; set; }
+
+ public void WritePortable(IPortableWriter writer)
+ {
+ writer.WriteObject("Keys", Keys);
+ writer.WriteObject("Values", Values);
+ writer.WriteObject("Pairs", Pairs);
+ writer.WriteObject("Objects", Objects);
+ }
+
+ public void ReadPortable(IPortableReader reader)
{
- return "CollectoinsType[col1=" + CollectionAsString(Col1) +
- ", col2=" + CollectionAsString(Col2) + ']';
+ Keys = (ICollection<TKey>) reader.ReadObject<object>("Keys");
+ Values = (ICollection<TValue>) reader.ReadObject<object>("Values");
+ Pairs = (IDictionary<TKey, TValue>) reader.ReadObject<object>("Pairs");
+ Objects = (ICollection<object>) reader.ReadObject<object>("Objects");
}
}
@@ -1450,18 +1523,18 @@ namespace Apache.Ignite.Core.Tests.Portable
{
public void WritePortable(IPortableWriter writer)
{
- writer.WriteObjectArray("a", GuidArr);
- writer.WriteObjectArray("b", NGuidArr);
- writer.WriteObjectArray("c", DateArr);
- writer.WriteObjectArray("d", NDateArr);
+ writer.WriteObject("a", GuidArr);
+ writer.WriteObject("b", NGuidArr);
+ writer.WriteObject("c", DateArr);
+ writer.WriteObject("d", NDateArr);
}
public void ReadPortable(IPortableReader reader)
{
- GuidArr = reader.ReadObjectArray<Guid>("a");
- NGuidArr = reader.ReadObjectArray<Guid?>("b");
- DateArr = reader.ReadObjectArray<DateTime>("c");
- NDateArr = reader.ReadObjectArray<DateTime?>("d");
+ GuidArr = reader.ReadObject<Guid[]>("a");
+ NGuidArr = reader.ReadObject<Guid?[]>("b");
+ DateArr = reader.ReadObject<DateTime[]>("c");
+ NDateArr = reader.ReadObject<DateTime?[]>("d");
}
}
@@ -1472,6 +1545,7 @@ namespace Apache.Ignite.Core.Tests.Portable
public TestEnum[] PEnumArray { get; set; }
}
+ [Serializable]
public class PrimitiveFieldType
{
public bool PBool { get; set; }
@@ -2068,5 +2142,30 @@ namespace Apache.Ignite.Core.Tests.Portable
UtcArrRaw = rawReader.ReadDateArray(false);
}
}
+
+ [Serializable]
+ private class SerializableObject
+ {
+ public int Foo { get; set; }
+
+ private bool Equals(SerializableObject other)
+ {
+ return Foo == other.Foo;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != GetType()) return false;
+
+ return Equals((SerializableObject) obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return Foo;
+ }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index a45d6ed..be96fd9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -257,7 +257,6 @@
<Compile Include="Impl\Portable\Metadata\PortableMetadataImpl.cs" />
<Compile Include="Impl\Portable\PortableBuilderField.cs" />
<Compile Include="Impl\Portable\PortableBuilderImpl.cs" />
- <Compile Include="Impl\Portable\PortableCollectionInfo.cs" />
<Compile Include="Impl\Portable\PortableFullTypeDescriptor.cs" />
<Compile Include="Impl\Portable\PortableHandleDictionary.cs" />
<Compile Include="Impl\Portable\PortableMarshalAwareSerializer.cs" />
@@ -265,6 +264,7 @@
<Compile Include="Impl\Portable\PortableMode.cs" />
<Compile Include="Impl\Portable\PortableObjectHandle.cs" />
<Compile Include="Impl\Portable\PortableOrSerializableObjectHolder.cs" />
+ <Compile Include="Impl\Portable\PortableReaderExtensions.cs" />
<Compile Include="Impl\Portable\PortableReaderHandleDictionary.cs" />
<Compile Include="Impl\Portable\PortableReaderImpl.cs" />
<Compile Include="Impl\Portable\PortableReflectiveRoutines.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheAffinity.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheAffinity.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheAffinity.cs
index 64f34d7..f61fd4b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheAffinity.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICacheAffinity.cs
@@ -114,7 +114,7 @@ namespace Apache.Ignite.Core.Cache
/// </summary>
/// <param name="keys">Keys to map to nodes.</param>
/// <returns>Map of nodes to keys or empty map if there are no alive nodes for this cache.</returns>
- IDictionary<IClusterNode, IList<TK>> MapKeysToNodes<TK>(IList<TK> keys);
+ IDictionary<IClusterNode, IList<TK>> MapKeysToNodes<TK>(IEnumerable<TK> keys);
/// <summary>
/// This method provides ability to detect to which primary node the given key
@@ -145,7 +145,7 @@ namespace Apache.Ignite.Core.Cache
/// </summary>
/// <param name="parts">Partition ids.</param>
/// <returns>Mapping of given partitions to their primary nodes.</returns>
- IDictionary<int, IClusterNode> MapPartitionsToNodes(IList<int> parts);
+ IDictionary<int, IClusterNode> MapPartitionsToNodes(IEnumerable<int> parts);
/// <summary>
/// Gets primary and backup nodes for partition. Note that primary node is always
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
index d02b5ac..6547c2b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -335,7 +335,7 @@ namespace Apache.Ignite.Core
/// </summary>
/// <param name="reader">Reader.</param>
/// <returns>Lifecycle bean.</returns>
- internal static ILifecycleBean CreateLifecycleBean(PortableReaderImpl reader)
+ private static ILifecycleBean CreateLifecycleBean(PortableReaderImpl reader)
{
// 1. Instantiate.
string assemblyName = reader.ReadString();
@@ -344,7 +344,7 @@ namespace Apache.Ignite.Core
object bean = IgniteUtils.CreateInstance(assemblyName, clsName);
// 2. Set properties.
- IDictionary<string, object> props = reader.ReadGenericDictionary<string, object>();
+ var props = reader.ReadDictionaryAsGeneric<string, object>();
IgniteUtils.SetProperties(bean, props);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
index 37bf73a..4d9cd2d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheAffinityImpl.cs
@@ -175,12 +175,12 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public IDictionary<IClusterNode, IList<TK>> MapKeysToNodes<TK>(IList<TK> keys)
+ public IDictionary<IClusterNode, IList<TK>> MapKeysToNodes<TK>(IEnumerable<TK> keys)
{
IgniteArgumentCheck.NotNull(keys, "keys");
- return DoOutInOp(OpMapKeysToNodes, w => w.WriteObject(keys),
- reader => ReadDictionary(reader, ReadNode, r => r.ReadObject<IList<TK>>()));
+ return DoOutInOp(OpMapKeysToNodes, w => WriteEnumerable(w, keys),
+ reader => ReadDictionary(reader, ReadNode, r => (IList<TK>) r.ReadCollectionAsList<TK>()));
}
/** <inheritDoc /> */
@@ -206,12 +206,12 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
- public IDictionary<int, IClusterNode> MapPartitionsToNodes(IList<int> parts)
+ public IDictionary<int, IClusterNode> MapPartitionsToNodes(IEnumerable<int> parts)
{
IgniteArgumentCheck.NotNull(parts, "parts");
return DoOutInOp(OpMapPartitionsToNodes,
- w => w.WriteObject(parts),
+ w => WriteEnumerable(w, parts),
reader => ReadDictionary(reader, r => r.ReadInt(), ReadNode));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index 5a01006..c689bb4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -266,7 +266,7 @@ namespace Apache.Ignite.Core.Impl.Cache
else
writer.WriteObject<CacheEntryFilterHolder>(null);
- writer.WriteObjectArray(args);
+ writer.WriteArray(args);
});
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
index aac32c7..1eeb3a0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
@@ -17,7 +17,6 @@
namespace Apache.Ignite.Core.Impl.Cache.Store
{
- using System;
using System.Collections;
using System.Diagnostics;
using Apache.Ignite.Core.Cache.Store;
@@ -107,7 +106,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
var assemblyName = reader.ReadString();
var className = reader.ReadString();
var convertPortable = reader.ReadBoolean();
- var propertyMap = reader.ReadGenericDictionary<string, object>();
+ var propertyMap = reader.ReadDictionaryAsGeneric<string, object>();
var store = (ICacheStore) IgniteUtils.CreateInstance(assemblyName, className);
@@ -166,7 +165,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
switch (opType)
{
case OpLoadCache:
- _store.LoadCache((k, v) => WriteObjects(cb, grid, k, v), rawReader.ReadObjectArray<object>());
+ _store.LoadCache((k, v) => WriteObjects(cb, grid, k, v), rawReader.ReadArray<object>());
break;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
index b1f19ab..85762e3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterGroupImpl.cs
@@ -541,13 +541,10 @@ namespace Apache.Ignite.Core.Impl.Cluster
public IPortableMetadata GetMetadata(int typeId)
{
return DoOutInOp<IPortableMetadata>(OpMetadata,
- writer =>
- {
- writer.WriteInt(typeId);
- },
+ writer => writer.WriteInt(typeId),
stream =>
{
- PortableReaderImpl reader = Marshaller.StartUnmarshal(stream, false);
+ var reader = Marshaller.StartUnmarshal(stream, false);
return reader.ReadBoolean() ? new PortableMetadataImpl(reader) : null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
index 1913cef..4e458f1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterNodeImpl.cs
@@ -23,6 +23,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Impl.Collections;
using Apache.Ignite.Core.Impl.Common;
+ using Apache.Ignite.Core.Impl.Portable;
using Apache.Ignite.Core.Portable;
/// <summary>
@@ -72,9 +73,9 @@ namespace Apache.Ignite.Core.Impl.Cluster
_id = id.Value;
- _attrs = reader.ReadGenericDictionary<string, object>().AsReadOnly();
- _addrs = reader.ReadGenericCollection<string>().AsReadOnly();
- _hosts = reader.ReadGenericCollection<string>().AsReadOnly();
+ _attrs = reader.ReadDictionaryAsGeneric<string, object>().AsReadOnly();
+ _addrs = reader.ReadCollectionAsList<string>().AsReadOnly();
+ _hosts = reader.ReadCollectionAsList<string>().AsReadOnly();
_order = reader.ReadLong();
_isLocal = reader.ReadBoolean();
_isDaemon = reader.ReadBoolean();
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
index 7f83588..d32d475 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/DelegateConverter.cs
@@ -148,18 +148,15 @@ namespace Apache.Ignite.Core.Impl.Common
/// Compiles a generic ctor with arbitrary number of arguments.
/// </summary>
/// <typeparam name="T">Result func type.</typeparam>
- /// <param name="type">Type to be created by ctor.</param>
+ /// <param name="ctor">Contructor info.</param>
/// <param name="argTypes">Argument types.</param>
/// <param name="convertResultToObject">if set to <c>true</c> [convert result to object].
- /// Flag that indicates whether ctor return value should be converted to object.
- /// </param>
+ /// Flag that indicates whether ctor return value should be converted to object.</param>
/// <returns>
/// Compiled generic constructor.
/// </returns>
- public static T CompileCtor<T>(Type type, Type[] argTypes, bool convertResultToObject = true)
+ public static T CompileCtor<T>(ConstructorInfo ctor, Type[] argTypes, bool convertResultToObject = true)
{
- var ctor = type.GetConstructor(argTypes);
-
Debug.Assert(ctor != null);
var args = new ParameterExpression[argTypes.Length];
@@ -175,12 +172,31 @@ namespace Apache.Ignite.Core.Impl.Common
Expression ctorExpr = Expression.New(ctor, argsConverted); // ctor takes args of specific types
if (convertResultToObject)
- ctorExpr = Expression.Convert(ctorExpr, typeof (object)); // convert ctor result to object
+ ctorExpr = Expression.Convert(ctorExpr, typeof(object)); // convert ctor result to object
return Expression.Lambda<T>(ctorExpr, args).Compile(); // lambda takes args as objects
}
/// <summary>
+ /// Compiles a generic ctor with arbitrary number of arguments.
+ /// </summary>
+ /// <typeparam name="T">Result func type.</typeparam>
+ /// <param name="type">Type to be created by ctor.</param>
+ /// <param name="argTypes">Argument types.</param>
+ /// <param name="convertResultToObject">if set to <c>true</c> [convert result to object].
+ /// Flag that indicates whether ctor return value should be converted to object.
+ /// </param>
+ /// <returns>
+ /// Compiled generic constructor.
+ /// </returns>
+ public static T CompileCtor<T>(Type type, Type[] argTypes, bool convertResultToObject = true)
+ {
+ var ctor = type.GetConstructor(argTypes);
+
+ return CompileCtor<T>(ctor, argTypes, convertResultToObject);
+ }
+
+ /// <summary>
/// Compiles the field setter.
/// </summary>
/// <param name="field">The field.</param>
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
index 06578c0..4031d17 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
@@ -124,7 +124,7 @@ namespace Apache.Ignite.Core.Impl.Portable.Metadata
TypeId = reader.ReadInt();
TypeName = reader.ReadString();
AffinityKeyFieldName = reader.ReadString();
- _fields = reader.ReadGenericDictionary<string, int>();
+ _fields = reader.ReadDictionaryAsGeneric<string, int>();
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
index 69c2811..3241c1c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
@@ -18,6 +18,7 @@
namespace Apache.Ignite.Core.Impl.Portable
{
using System;
+ using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
@@ -176,7 +177,7 @@ namespace Apache.Ignite.Core.Impl.Portable
PortableWriterImpl writer = _portables.Marshaller.StartMarshal(outStream);
- writer.Builder(this);
+ writer.SetBuilder(this);
// All related builders will work in this context with this writer.
_parent._ctx = new Context(writer);
@@ -282,7 +283,7 @@ namespace Apache.Ignite.Core.Impl.Portable
IDictionary<string, PortableBuilderField> vals)
{
// Set correct builder to writer frame.
- PortableBuilderImpl oldBuilder = _parent._ctx.Writer.Builder(_parent);
+ PortableBuilderImpl oldBuilder = _parent._ctx.Writer.SetBuilder(_parent);
int streamPos = inStream.Position;
@@ -312,7 +313,7 @@ namespace Apache.Ignite.Core.Impl.Portable
// Write metadata if: 1) it is enabled for type; 2) type is not null (i.e. it is neither
// remove marker, nor a field read through "GetField" method.
if (metaHnd != null && valEntry.Value.Type != null)
- metaHnd.OnFieldWrite(fieldId, valEntry.Key, TypeId(valEntry.Value.Type));
+ metaHnd.OnFieldWrite(fieldId, valEntry.Key, GetTypeId(valEntry.Value.Type));
}
}
@@ -331,7 +332,7 @@ namespace Apache.Ignite.Core.Impl.Portable
finally
{
// Restore builder frame.
- _parent._ctx.Writer.Builder(oldBuilder);
+ _parent._ctx.Writer.SetBuilder(oldBuilder);
inStream.Seek(streamPos, SeekOrigin.Begin);
}
@@ -747,20 +748,26 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
/// <param name="type">Type.</param>
/// <returns>Type ID.</returns>
- private static int TypeId(Type type)
+ private static int GetTypeId(Type type)
{
int typeId;
if (TypeIds.TryGetValue(type, out typeId))
return typeId;
+
if (type.IsEnum)
return PortableUtils.TypeEnum;
+
if (type.IsArray)
return type.GetElementType().IsEnum ? PortableUtils.TypeArrayEnum : PortableUtils.TypeArray;
- PortableCollectionInfo colInfo = PortableCollectionInfo.Info(type);
- return colInfo.IsAny ? colInfo.IsCollection || colInfo.IsGenericCollection ?
- PortableUtils.TypeCollection : PortableUtils.TypeDictionary : PortableUtils.TypeObject;
+ if (typeof (IDictionary).IsAssignableFrom(type))
+ return PortableUtils.TypeDictionary;
+
+ if (typeof (ICollection).IsAssignableFrom(type))
+ return PortableUtils.TypeCollection;
+
+ return PortableUtils.TypeObject;
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableCollectionInfo.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableCollectionInfo.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableCollectionInfo.cs
deleted file mode 100644
index fc61833..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableCollectionInfo.cs
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Portable
-{
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Reflection;
- using Apache.Ignite.Core.Impl.Common;
-
- /**
- * <summary>Collection info helper.</summary>
- */
- internal class PortableCollectionInfo
- {
- /** Flag: none. */
- private const byte FlagNone = 0;
-
- /** Flag: generic dictionary. */
- private const byte FlagGenericDictionary = 1;
-
- /** Flag: generic collection. */
- private const byte FlagGenericCollection = 2;
-
- /** Flag: dictionary. */
- private const byte FlagDictionary = 3;
-
- /** Flag: collection. */
- private const byte FlagCollection = 4;
-
- /** Cache "none" value. */
- private static readonly PortableCollectionInfo None =
- new PortableCollectionInfo(FlagNone, null, null, null);
-
- /** Cache "dictionary" value. */
- private static readonly PortableCollectionInfo Dictionary =
- new PortableCollectionInfo(FlagDictionary, PortableSystemHandlers.WriteHndDictionary, null, null);
-
- /** Cache "collection" value. */
- private static readonly PortableCollectionInfo Collection =
- new PortableCollectionInfo(FlagCollection, PortableSystemHandlers.WriteHndCollection, null, null);
-
- /** Cached infos. */
- private static readonly IDictionary<Type, PortableCollectionInfo> Infos =
- new ConcurrentDictionary<Type, PortableCollectionInfo>(64, 32);
-
- /**
- * <summary>Get collection info for type.</summary>
- * <param name="type">Type.</param>
- * <returns>Collection info.</returns>
- */
- public static PortableCollectionInfo Info(Type type)
- {
- PortableCollectionInfo info;
-
- if (!Infos.TryGetValue(type, out info))
- {
- info = Info0(type);
-
- Infos[type] = info;
- }
-
- return info;
- }
-
- /**
- * <summary>Internal routine to get collection info for type.</summary>
- * <param name="type">Type.</param>
- * <returns>Collection info.</returns>
- */
- private static PortableCollectionInfo Info0(Type type)
- {
- if (type.IsGenericType)
- {
- if (type.GetGenericTypeDefinition() == PortableUtils.TypGenericDictionary)
- {
- MethodInfo writeMthd =
- PortableUtils.MtdhWriteGenericDictionary.MakeGenericMethod(type.GetGenericArguments());
- MethodInfo readMthd =
- PortableUtils.MtdhReadGenericDictionary.MakeGenericMethod(type.GetGenericArguments());
-
- return new PortableCollectionInfo(FlagGenericDictionary,
- PortableSystemHandlers.WriteHndGenericDictionary, writeMthd, readMthd);
- }
-
- Type genTyp = type.GetInterface(PortableUtils.TypGenericDictionary.FullName);
-
- if (genTyp != null)
- {
- MethodInfo writeMthd =
- PortableUtils.MtdhWriteGenericDictionary.MakeGenericMethod(genTyp.GetGenericArguments());
- MethodInfo readMthd =
- PortableUtils.MtdhReadGenericDictionary.MakeGenericMethod(genTyp.GetGenericArguments());
-
- return new PortableCollectionInfo(FlagGenericDictionary,
- PortableSystemHandlers.WriteHndGenericDictionary, writeMthd, readMthd);
- }
-
- if (type.GetGenericTypeDefinition() == PortableUtils.TypGenericCollection)
- {
- MethodInfo writeMthd =
- PortableUtils.MtdhWriteGenericCollection.MakeGenericMethod(type.GetGenericArguments());
- MethodInfo readMthd =
- PortableUtils.MtdhReadGenericCollection.MakeGenericMethod(type.GetGenericArguments());
-
- return new PortableCollectionInfo(FlagGenericCollection,
- PortableSystemHandlers.WriteHndGenericCollection, writeMthd, readMthd);
- }
-
- genTyp = type.GetInterface(PortableUtils.TypGenericCollection.FullName);
-
- if (genTyp != null)
- {
- MethodInfo writeMthd =
- PortableUtils.MtdhWriteGenericCollection.MakeGenericMethod(genTyp.GetGenericArguments());
- MethodInfo readMthd =
- PortableUtils.MtdhReadGenericCollection.MakeGenericMethod(genTyp.GetGenericArguments());
-
- return new PortableCollectionInfo(FlagGenericCollection,
- PortableSystemHandlers.WriteHndGenericCollection, writeMthd, readMthd);
- }
- }
-
- if (type == PortableUtils.TypDictionary || type.GetInterface(PortableUtils.TypDictionary.FullName) != null)
- return Dictionary;
- if (type == PortableUtils.TypCollection || type.GetInterface(PortableUtils.TypCollection.FullName) != null)
- return Collection;
- return None;
- }
-
- /** Flag. */
- private readonly byte _flag;
-
- /** Write handler. */
- private readonly PortableSystemWriteDelegate _writeHnd;
-
- /** Generic write func. */
- private readonly Action<object, PortableWriterImpl> _writeFunc;
-
- /** Generic read func. */
- private readonly Func<PortableReaderImpl, object, object> _readFunc;
-
- /**
- * <summary>Constructor.</summary>
- * <param name="flag0">Flag.</param>
- * <param name="writeHnd0">Write handler.</param>
- * <param name="writeMthd0">Generic write method.</param>
- * <param name="readMthd0">Generic read method.</param>
- */
- private PortableCollectionInfo(byte flag0, PortableSystemWriteDelegate writeHnd0,
- MethodInfo writeMthd0, MethodInfo readMthd0)
- {
- _flag = flag0;
- _writeHnd = writeHnd0;
-
- if (writeMthd0 != null)
- _writeFunc = DelegateConverter.CompileFunc<Action<object, PortableWriterImpl>>(null, writeMthd0, null,
- new[] {true, false, false});
-
- if (readMthd0 != null)
- _readFunc = DelegateConverter.CompileFunc<Func<PortableReaderImpl, object, object>>(null, readMthd0,
- null, new[] {false, true, false});
- }
-
- /**
- * <summary>Generic dictionary flag.</summary>
- */
- public bool IsGenericDictionary
- {
- get { return _flag == FlagGenericDictionary; }
- }
-
- /**
- * <summary>Generic collection flag.</summary>
- */
- public bool IsGenericCollection
- {
- get { return _flag == FlagGenericCollection; }
- }
-
- /**
- * <summary>Dictionary flag.</summary>
- */
- public bool IsDictionary
- {
- get { return _flag == FlagDictionary; }
- }
-
- /**
- * <summary>Collection flag.</summary>
- */
- public bool IsCollection
- {
- get { return _flag == FlagCollection; }
- }
-
- /**
- * <summary>Whether at least one flag is set..</summary>
- */
- public bool IsAny
- {
- get { return _flag != FlagNone; }
- }
-
- /**
- * <summary>Write handler.</summary>
- */
- public PortableSystemWriteDelegate WriteHandler
- {
- get { return _writeHnd; }
- }
-
- /// <summary>
- /// Reads the generic collection.
- /// </summary>
- public object ReadGeneric(PortableReaderImpl reader)
- {
- Debug.Assert(reader != null);
- Debug.Assert(_readFunc != null);
-
- return _readFunc(reader, null);
- }
-
- /// <summary>
- /// Writes the generic collection.
- /// </summary>
- public void WriteGeneric(PortableWriterImpl writer, object value)
- {
- Debug.Assert(writer != null);
- Debug.Assert(_writeFunc != null);
-
- _writeFunc(value, writer);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderExtensions.cs
new file mode 100644
index 0000000..3f0de91
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderExtensions.cs
@@ -0,0 +1,52 @@
+/*
+ * 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.Impl.Portable
+{
+ using System.Collections.Generic;
+ using Apache.Ignite.Core.Portable;
+
+ /// <summary>
+ /// Reader extensions.
+ /// </summary>
+ internal static class PortableReaderExtensions
+ {
+ /// <summary>
+ /// Reads untyped collection as a generic list.
+ /// </summary>
+ /// <typeparam name="T">Type of list element.</typeparam>
+ /// <param name="reader">The reader.</param>
+ /// <returns>Resulting generic list.</returns>
+ public static List<T> ReadCollectionAsList<T>(this IPortableRawReader reader)
+ {
+ return ((List<T>) reader.ReadCollection(size => new List<T>(size),
+ (col, elem) => ((List<T>) col).Add((T) elem)));
+ }
+
+ /// <summary>
+ /// Reads untyped dictionary as generic dictionary.
+ /// </summary>
+ /// <typeparam name="TKey">The type of the key.</typeparam>
+ /// <typeparam name="TValue">The type of the value.</typeparam>
+ /// <param name="reader">The reader.</param>
+ /// <returns>Resulting dictionary.</returns>
+ public static Dictionary<TKey, TValue> ReadDictionaryAsGeneric<TKey, TValue>(this IPortableRawReader reader)
+ {
+ return (Dictionary<TKey, TValue>) reader.ReadDictionary(size => new Dictionary<TKey, TValue>(size));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
index dd78702..6e06007 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
@@ -385,13 +385,13 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public string[] ReadStringArray(string fieldName)
{
- return ReadField(fieldName, r => PortableUtils.ReadGenericArray<string>(r, false));
+ return ReadField(fieldName, r => PortableUtils.ReadArray<string>(r, false));
}
/** <inheritdoc /> */
public string[] ReadStringArray()
{
- return Read(r => PortableUtils.ReadGenericArray<string>(r, false));
+ return Read(r => PortableUtils.ReadArray<string>(r, false));
}
/** <inheritdoc /> */
@@ -409,13 +409,13 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public Guid?[] ReadGuidArray(string fieldName)
{
- return ReadField(fieldName, r => PortableUtils.ReadGenericArray<Guid?>(r, false));
+ return ReadField(fieldName, r => PortableUtils.ReadArray<Guid?>(r, false));
}
/** <inheritdoc /> */
public Guid?[] ReadGuidArray()
{
- return Read(r => PortableUtils.ReadGenericArray<Guid?>(r, false));
+ return Read(r => PortableUtils.ReadArray<Guid?>(r, false));
}
/** <inheritdoc /> */
@@ -433,13 +433,13 @@ namespace Apache.Ignite.Core.Impl.Portable
/** <inheritdoc /> */
public T[] ReadEnumArray<T>(string fieldName)
{
- return ReadField(fieldName, r => PortableUtils.ReadGenericArray<T>(r, true));
+ return ReadField(fieldName, r => PortableUtils.ReadArray<T>(r, true));
}
/** <inheritdoc /> */
public T[] ReadEnumArray<T>()
{
- return Read(r => PortableUtils.ReadGenericArray<T>(r, true));
+ return Read(r => PortableUtils.ReadArray<T>(r, true));
}
/** <inheritdoc /> */
@@ -463,15 +463,15 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/** <inheritdoc /> */
- public T[] ReadObjectArray<T>(string fieldName)
+ public T[] ReadArray<T>(string fieldName)
{
- return ReadField(fieldName, r => PortableUtils.ReadGenericArray<T>(r, true));
+ return ReadField(fieldName, r => PortableUtils.ReadArray<T>(r, true));
}
/** <inheritdoc /> */
- public T[] ReadObjectArray<T>()
+ public T[] ReadArray<T>()
{
- return Read(r => PortableUtils.ReadGenericArray<T>(r, true));
+ return Read(r => PortableUtils.ReadArray<T>(r, true));
}
/** <inheritdoc /> */
@@ -501,31 +501,6 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/** <inheritdoc /> */
- public ICollection<T> ReadGenericCollection<T>(string fieldName)
- {
- return ReadGenericCollection<T>(fieldName, null);
- }
-
- /** <inheritdoc /> */
- public ICollection<T> ReadGenericCollection<T>()
- {
- return ReadGenericCollection((PortableGenericCollectionFactory<T>) null);
- }
-
- /** <inheritdoc /> */
- public ICollection<T> ReadGenericCollection<T>(string fieldName,
- PortableGenericCollectionFactory<T> factory)
- {
- return ReadField(fieldName, r => PortableUtils.ReadGenericCollection(r, factory));
- }
-
- /** <inheritdoc /> */
- public ICollection<T> ReadGenericCollection<T>(PortableGenericCollectionFactory<T> factory)
- {
- return Read(r => PortableUtils.ReadGenericCollection(r, factory));
- }
-
- /** <inheritdoc /> */
public IDictionary ReadDictionary(string fieldName)
{
return ReadDictionary(fieldName, null);
@@ -549,31 +524,6 @@ namespace Apache.Ignite.Core.Impl.Portable
return Read(r => PortableUtils.ReadDictionary(r, factory));
}
- /** <inheritdoc /> */
- public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(string fieldName)
- {
- return ReadGenericDictionary<TK, TV>(fieldName, null);
- }
-
- /** <inheritdoc /> */
- public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>()
- {
- return ReadGenericDictionary((PortableGenericDictionaryFactory<TK, TV>) null);
- }
-
- /** <inheritdoc /> */
- public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(string fieldName,
- PortableGenericDictionaryFactory<TK, TV> factory)
- {
- return ReadField(fieldName, r => PortableUtils.ReadGenericDictionary(r, factory));
- }
-
- /** <inheritdoc /> */
- public IDictionary<TK, TV> ReadGenericDictionary<TK, TV>(PortableGenericDictionaryFactory<TK, TV> factory)
- {
- return Read(r => PortableUtils.ReadGenericDictionary(r, factory));
- }
-
/// <summary>
/// Enable detach mode for the next object read.
/// </summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/f65a53e4/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
index 907c480..261a172 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
@@ -55,15 +55,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Method: read array. */
private static readonly MethodInfo MthdReadObjArray =
- typeof(IPortableReader).GetMethod("ReadObjectArray", new[] { typeof(string) });
-
- /** Method: read generic collection. */
- private static readonly MethodInfo MthdReadGenericCollection =
- typeof(IPortableReader).GetMethod("ReadGenericCollection", new[] { typeof(string) });
-
- /** Method: read generic dictionary. */
- private static readonly MethodInfo MthdReadGenericDictionary =
- typeof(IPortableReader).GetMethod("ReadGenericDictionary", new[] { typeof(string) });
+ typeof(IPortableReader).GetMethod("ReadArray", new[] { typeof(string) });
/** Method: read object. */
private static readonly MethodInfo MthdReadObj=
@@ -75,15 +67,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Method: write array. */
private static readonly MethodInfo MthdWriteObjArray =
- typeof(IPortableWriter).GetMethod("WriteObjectArray");
-
- /** Method: write generic collection. */
- private static readonly MethodInfo MthdWriteGenericCollection =
- typeof(IPortableWriter).GetMethod("WriteGenericCollection");
-
- /** Method: write generic dictionary. */
- private static readonly MethodInfo MthdWriteGenericDictionary =
- typeof(IPortableWriter).GetMethod("WriteGenericDictionary");
+ typeof(IPortableWriter).GetMethod("WriteArray");
/** Method: read object. */
private static readonly MethodInfo MthdWriteObj =
@@ -339,24 +323,12 @@ namespace Apache.Ignite.Core.Impl.Portable
writeAction = GetWriter<object>(field, (f, w, o) => w.WriteEnum(f, o), true);
readAction = GetReader(field, MthdReadEnum);
}
- else if (genericDef == PortableUtils.TypGenericDictionary ||
- type.GetInterface(PortableUtils.TypGenericDictionary.FullName) != null)
- {
- writeAction = GetWriter(field, MthdWriteGenericDictionary, type.GetGenericArguments());
- readAction = GetReader(field, MthdReadGenericDictionary, type.GetGenericArguments());
- }
- else if (genericDef == PortableUtils.TypGenericCollection ||
- type.GetInterface(PortableUtils.TypGenericCollection.FullName) != null)
- {
- writeAction = GetWriter(field, MthdWriteGenericCollection, type.GetGenericArguments());
- readAction = GetReader(field, MthdReadGenericCollection, type.GetGenericArguments());
- }
- else if (type == PortableUtils.TypDictionary || type.GetInterface(PortableUtils.TypDictionary.FullName) != null)
+ else if (type == PortableUtils.TypDictionary || type.GetInterface(PortableUtils.TypDictionary.FullName) != null && !type.IsGenericType)
{
writeAction = GetWriter<IDictionary>(field, (f, w, o) => w.WriteDictionary(f, o));
readAction = GetReader(field, (f, r) => r.ReadDictionary(f));
}
- else if (type == PortableUtils.TypCollection || type.GetInterface(PortableUtils.TypCollection.FullName) != null)
+ else if (type == PortableUtils.TypCollection || type.GetInterface(PortableUtils.TypCollection.FullName) != null && !type.IsGenericType)
{
writeAction = GetWriter<ICollection>(field, (f, w, o) => w.WriteCollection(f, o));
readAction = GetReader(field, (f, r) => r.ReadCollection(f));
[10/17] ignite git commit: IGNITE-1467: Created standalone CPP
application.
Posted by ag...@apache.org.
IGNITE-1467: Created standalone CPP application.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/40978109
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/40978109
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/40978109
Branch: refs/heads/ignite-950-new
Commit: 40978109fc0996caab6b26ba797e33d3e1e6d235
Parents: 05e739f
Author: isapego <is...@gridgain.com>
Authored: Tue Oct 27 14:07:29 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Oct 27 14:07:29 2015 +0300
----------------------------------------------------------------------
.../platforms/cpp/common/include/Makefile.am | 3 +-
.../cpp/common/include/ignite/common/utils.h | 81 +++++++
.../cpp/common/project/vs/common.vcxproj | 1 +
.../common/project/vs/common.vcxproj.filters | 3 +
.../cpp/core-test/src/cache_query_test.cpp | 21 +-
.../platforms/cpp/core-test/src/cache_test.cpp | 19 +-
.../cpp/core-test/src/ignition_test.cpp | 19 +-
.../platforms/cpp/core/include/ignite/ignite.h | 1 +
.../core/include/ignite/ignite_configuration.h | 81 +------
.../cpp/core/include/ignite/impl/ignite_impl.h | 27 ++-
modules/platforms/cpp/core/src/ignition.cpp | 18 +-
.../platforms/cpp/core/src/impl/ignite_impl.cpp | 5 +
modules/platforms/cpp/ignite/Makefile.am | 39 ++++
modules/platforms/cpp/ignite/configure.ac | 62 +++++
modules/platforms/cpp/ignite/project/README.TXT | 1 +
.../platforms/cpp/ignite/project/vs/README.TXT | 1 +
.../cpp/ignite/project/vs/ignite.vcxproj | 167 ++++++++++++++
.../ignite/project/vs/ignite.vcxproj.filters | 25 +++
modules/platforms/cpp/ignite/src/ignite.cpp | 225 +++++++++++++++++++
modules/platforms/cpp/project/vs/ignite.sln | 10 +
20 files changed, 685 insertions(+), 124 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/common/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/Makefile.am b/modules/platforms/cpp/common/include/Makefile.am
index 5db1d4a..7a02225 100644
--- a/modules/platforms/cpp/common/include/Makefile.am
+++ b/modules/platforms/cpp/common/include/Makefile.am
@@ -19,4 +19,5 @@ ACLOCAL_AMFLAGS = "-Im4"
nobase_include_HEADERS = ignite/common/concurrent.h \
ignite/common/java.h \
- ignite/common/exports.h
+ ignite/common/exports.h \
+ ignite/common/utils.h
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/common/include/ignite/common/utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/utils.h b/modules/platforms/cpp/common/include/ignite/common/utils.h
new file mode 100644
index 0000000..4b590d9
--- /dev/null
+++ b/modules/platforms/cpp/common/include/ignite/common/utils.h
@@ -0,0 +1,81 @@
+#pragma once
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef _IGNITE_COMMON_UTILS
+#define _IGNITE_COMMON_UTILS
+
+#include <string>
+#include <sstream>
+#include <algorithm>
+
+namespace ignite
+{
+ namespace common
+ {
+ namespace util
+ {
+ /**
+ * Transform string into lowercase.
+ *
+ * @param str String to be transformed.
+ */
+ inline void IntoLower(std::string& str)
+ {
+ std::transform(str.begin(), str.end(), str.begin(), ::tolower);
+ }
+
+ /**
+ * Get lowercase version of the string.
+ *
+ * @param str Input string.
+ * @return Lowercased version of the string.
+ */
+ inline std::string ToLower(const std::string& str)
+ {
+ std::string res(str);
+ IntoLower(res);
+ return res;
+ }
+
+ /**
+ * Get string representation of long in decimal form.
+ *
+ * @param val Long value to be converted to string.
+ * @return String contataining decimal representation of the value.
+ */
+ inline std::string LongToString(long val)
+ {
+ std::stringstream tmp;
+ tmp << val;
+ return tmp.str();
+ }
+
+ /**
+ * Parse string to try and get int value.
+ *
+ * @param str String to be parsed.
+ * @return String contataining decimal representation of the value.
+ */
+ inline int ParseInt(const std::string& str)
+ {
+ return atoi(str.c_str());
+ }
+ }
+ }
+}
+
+#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/common/project/vs/common.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/common.vcxproj b/modules/platforms/cpp/common/project/vs/common.vcxproj
index c5c790e..0fa1d0e 100644
--- a/modules/platforms/cpp/common/project/vs/common.vcxproj
+++ b/modules/platforms/cpp/common/project/vs/common.vcxproj
@@ -182,6 +182,7 @@
<ClInclude Include="..\..\include\ignite\common\concurrent.h" />
<ClInclude Include="..\..\include\ignite\common\exports.h" />
<ClInclude Include="..\..\include\ignite\common\java.h" />
+ <ClInclude Include="..\..\include\ignite\common\utils.h" />
<ClInclude Include="..\..\os\win\include\ignite\common\common.h" />
<ClInclude Include="..\..\os\win\include\ignite\common\concurrent_os.h" />
<ClInclude Include="targetver.h" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/common.vcxproj.filters b/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
index 3d4ae54..01a47a0 100644
--- a/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
+++ b/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
@@ -28,6 +28,9 @@
<ClInclude Include="targetver.h">
<Filter>Misc</Filter>
</ClInclude>
+ <ClInclude Include="..\..\include\ignite\common\utils.h">
+ <Filter>Code</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\os\win\src\common.cpp">
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/core-test/src/cache_query_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_query_test.cpp b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
index 47009f4..1605d74 100644
--- a/modules/platforms/cpp/core-test/src/cache_query_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
@@ -187,17 +187,12 @@ struct CacheQueryTestSuiteFixture {
CacheQueryTestSuiteFixture()
{
IgniteConfiguration cfg;
-
- IgniteJvmOption opts[5];
-
- opts[0] = IgniteJvmOption("-Xdebug");
- opts[1] = IgniteJvmOption("-Xnoagent");
- opts[2] = IgniteJvmOption("-Djava.compiler=NONE");
- opts[3] = IgniteJvmOption("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
- opts[4] = IgniteJvmOption("-XX:+HeapDumpOnOutOfMemoryError");
-
- cfg.jvmOptsLen = 5;
- cfg.jvmOpts = opts;
+
+ cfg.jvmOpts.push_back("-Xdebug");
+ cfg.jvmOpts.push_back("-Xnoagent");
+ cfg.jvmOpts.push_back("-Djava.compiler=NONE");
+ cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+ cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
#ifdef IGNITE_TESTS_32
cfg.jvmInitMem = 256;
@@ -209,9 +204,7 @@ struct CacheQueryTestSuiteFixture {
char* cfgPath = getenv("IGNITE_NATIVE_TEST_CPP_CONFIG_PATH");
- std::string cfgPathStr = std::string(cfgPath).append("/").append("cache-query.xml");
-
- cfg.springCfgPath = const_cast<char*>(cfgPathStr.c_str());
+ cfg.springCfgPath = std::string(cfgPath).append("/").append("cache-query.xml");
IgniteError err;
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/core-test/src/cache_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_test.cpp b/modules/platforms/cpp/core-test/src/cache_test.cpp
index 3239d89..691095f 100644
--- a/modules/platforms/cpp/core-test/src/cache_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_test.cpp
@@ -95,16 +95,11 @@ struct CacheTestSuiteFixture {
{
IgniteConfiguration cfg;
- IgniteJvmOption opts[5];
-
- opts[0] = IgniteJvmOption("-Xdebug");
- opts[1] = IgniteJvmOption("-Xnoagent");
- opts[2] = IgniteJvmOption("-Djava.compiler=NONE");
- opts[3] = IgniteJvmOption("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
- opts[4] = IgniteJvmOption("-XX:+HeapDumpOnOutOfMemoryError");
-
- cfg.jvmOptsLen = 5;
- cfg.jvmOpts = opts;
+ cfg.jvmOpts.push_back("-Xdebug");
+ cfg.jvmOpts.push_back("-Xnoagent");
+ cfg.jvmOpts.push_back("-Djava.compiler=NONE");
+ cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+ cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
#ifdef IGNITE_TESTS_32
cfg.jvmInitMem = 256;
@@ -116,9 +111,7 @@ struct CacheTestSuiteFixture {
char* cfgPath = getenv("IGNITE_NATIVE_TEST_CPP_CONFIG_PATH");
- std::string cfgPathStr = std::string(cfgPath).append("/").append("cache-test.xml");
-
- cfg.springCfgPath = const_cast<char*>(cfgPathStr.c_str());
+ cfg.springCfgPath = std::string(cfgPath).append("/").append("cache-test.xml");
for (int i = 0; i < 2; i++)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/core-test/src/ignition_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/ignition_test.cpp b/modules/platforms/cpp/core-test/src/ignition_test.cpp
index e0e26d3..7d1284a 100644
--- a/modules/platforms/cpp/core-test/src/ignition_test.cpp
+++ b/modules/platforms/cpp/core-test/src/ignition_test.cpp
@@ -33,16 +33,11 @@ BOOST_AUTO_TEST_CASE(TestIgnition)
{
IgniteConfiguration cfg;
- IgniteJvmOption opts[5];
-
- opts[0] = IgniteJvmOption("-Xdebug");
- opts[1] = IgniteJvmOption("-Xnoagent");
- opts[2] = IgniteJvmOption("-Djava.compiler=NONE");
- opts[3] = IgniteJvmOption("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
- opts[4] = IgniteJvmOption("-XX:+HeapDumpOnOutOfMemoryError");
-
- cfg.jvmOptsLen = 5;
- cfg.jvmOpts = opts;
+ cfg.jvmOpts.push_back("-Xdebug");
+ cfg.jvmOpts.push_back("-Xnoagent");
+ cfg.jvmOpts.push_back("-Djava.compiler=NONE");
+ cfg.jvmOpts.push_back("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005");
+ cfg.jvmOpts.push_back("-XX:+HeapDumpOnOutOfMemoryError");
#ifdef IGNITE_TESTS_32
cfg.jvmInitMem = 256;
@@ -54,9 +49,7 @@ BOOST_AUTO_TEST_CASE(TestIgnition)
char* cfgPath = getenv("IGNITE_NATIVE_TEST_CPP_CONFIG_PATH");
- std::string cfgPathStr = std::string(cfgPath).append("/").append("cache-test.xml");
-
- cfg.springCfgPath = const_cast<char*>(cfgPathStr.c_str());
+ cfg.springCfgPath = std::string(cfgPath).append("/").append("cache-test.xml");
IgniteError err;
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/core/include/ignite/ignite.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/ignite.h b/modules/platforms/cpp/core/include/ignite/ignite.h
index 8fc9b02..f194b1a 100644
--- a/modules/platforms/cpp/core/include/ignite/ignite.h
+++ b/modules/platforms/cpp/core/include/ignite/ignite.h
@@ -29,6 +29,7 @@ namespace ignite
*/
class IGNITE_IMPORT_EXPORT Ignite
{
+ friend class impl::IgniteImpl;
public:
/**
* Default constructor.
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/core/include/ignite/ignite_configuration.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/ignite_configuration.h b/modules/platforms/cpp/core/include/ignite/ignite_configuration.h
index 4e79e73..c4c6c8e 100644
--- a/modules/platforms/cpp/core/include/ignite/ignite_configuration.h
+++ b/modules/platforms/cpp/core/include/ignite/ignite_configuration.h
@@ -19,87 +19,29 @@
#define _IGNITE_CONFIGURATION
#include <stdint.h>
+#include <string>
+#include <list>
#include "ignite/impl/utils.h"
namespace ignite
-{
- /**
- * Single JVM option.
- */
- struct IgniteJvmOption
- {
- /** Option. */
- char* opt;
-
- /**
- * Default constructor.
- */
- IgniteJvmOption() : opt(NULL)
- {
- // No-op.
- }
-
- /**
- * Copy constructor.
- *
- * @param option Other instance.
- */
- IgniteJvmOption(const IgniteJvmOption& option) : opt()
- {
- this->opt = impl::utils::CopyChars(option.opt);
- }
-
- /**
- * Constructor.
- *
- * @param opt Option.
- */
- IgniteJvmOption(const char* opt) : opt()
- {
- this->opt = impl::utils::CopyChars(opt);
- }
-
- /**
- * Destructor.
- */
- ~IgniteJvmOption()
- {
- impl::utils::ReleaseChars(opt);
- }
-
- /**
- * Copy operator.
- *
- * @param option Other instance.
- * @return This instance.
- */
- IgniteJvmOption& operator=(const IgniteJvmOption& option)
- {
- impl::utils::ReleaseChars(opt);
-
- this->opt = impl::utils::CopyChars(option.opt);
-
- return *this;
- }
- };
-
+{
/**
* Ignite configuration.
*/
struct IgniteConfiguration
{
/** Path to Ignite home. */
- char* igniteHome;
+ std::string igniteHome;
/** Path to Spring configuration file. */
- char* springCfgPath;
+ std::string springCfgPath;
/** Path ot JVM libbrary. */
- char* jvmLibPath;
+ std::string jvmLibPath;
/** JVM classpath. */
- char* jvmClassPath;
+ std::string jvmClassPath;
/** Initial amount of JVM memory. */
int32_t jvmInitMem;
@@ -108,16 +50,13 @@ namespace ignite
int32_t jvmMaxMem;
/** Additional JVM options. */
- IgniteJvmOption* jvmOpts;
-
- /** Additional JVM options count. */
- int32_t jvmOptsLen;
+ std::list<std::string> jvmOpts;
/**
* Constructor.
*/
- IgniteConfiguration() : igniteHome(NULL), springCfgPath(NULL), jvmLibPath(NULL), jvmClassPath(NULL),
- jvmInitMem(512), jvmMaxMem(1024), jvmOpts(NULL), jvmOptsLen(0)
+ IgniteConfiguration() : igniteHome(), springCfgPath(), jvmLibPath(), jvmClassPath(),
+ jvmInitMem(512), jvmMaxMem(1024), jvmOpts()
{
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
index 1aeab29..318ff5c 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
@@ -26,13 +26,13 @@
#include "ignite/impl/utils.h"
namespace ignite
-{
+{
namespace impl
- {
+ {
/**
* Ignite implementation.
*/
- class IgniteImpl
+ class IGNITE_FRIEND_EXPORT IgniteImpl
{
friend class Ignite;
public:
@@ -57,6 +57,13 @@ namespace ignite
const char* GetName() const;
/**
+ * Get JNI context associated with this instance.
+ *
+ * @return JNI context for this instance.
+ */
+ common::java::JniContext* GetContext();
+
+ /**
* Get cache.
*
* @param name Cache name.
@@ -130,6 +137,19 @@ namespace ignite
return new cache::CacheImpl(name0, env, cacheJavaRef);
}
+
+ /**
+ * Get instance of the implementation from the proxy class.
+ * Internal method. Should not be used by user.
+ *
+ * @param proxy Proxy instance containing IgniteImpl.
+ * @return IgniteImpl instance associated with the proxy or null-pointer.
+ */
+ template<typename T>
+ static IgniteImpl* GetFromProxy(T& proxy)
+ {
+ return proxy.impl.Get();
+ }
private:
/** Environment. */
ignite::common::concurrent::SharedPointer<IgniteEnvironment> env;
@@ -140,7 +160,6 @@ namespace ignite
IGNITE_NO_COPY_ASSIGNMENT(IgniteImpl)
};
}
-
}
#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/core/src/ignition.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/ignition.cpp b/modules/platforms/cpp/core/src/ignition.cpp
index c69789f..edac373 100644
--- a/modules/platforms/cpp/core/src/ignition.cpp
+++ b/modules/platforms/cpp/core/src/ignition.cpp
@@ -75,7 +75,7 @@ namespace ignite
*/
char** CreateJvmOptions(const IgniteConfiguration& cfg, const std::string* home, const std::string& cp, int* optsLen)
{
- *optsLen = 3 + (home ? 1 : 0) + cfg.jvmOptsLen;
+ *optsLen = 3 + (home ? 1 : 0) + static_cast<int>(cfg.jvmOpts.size());
char** opts = new char*[*optsLen];
int idx = 0;
@@ -100,8 +100,8 @@ namespace ignite
*(opts + idx++) = CopyChars(xmxStr.c_str());
// 4. Set the rest options.
- for (int i = 0; i < cfg.jvmOptsLen; i++) {
- char* optCopy = CopyChars(cfg.jvmOpts[i].opt);
+ for (std::list<std::string>::const_iterator i = cfg.jvmOpts.begin(); i != cfg.jvmOpts.end(); ++i) {
+ char* optCopy = CopyChars(i->c_str());
opts[idx++] = optCopy;
}
@@ -147,7 +147,7 @@ namespace ignite
bool jvmLibFound;
std::string jvmLib;
- if (cfg.jvmLibPath)
+ if (!cfg.jvmLibPath.empty())
{
std::string jvmLibPath = std::string(cfg.jvmLibPath);
@@ -182,7 +182,7 @@ namespace ignite
bool homeFound;
std::string home;
- if (cfg.igniteHome)
+ if (!cfg.igniteHome.empty())
{
std::string homePath = std::string(cfg.igniteHome);
@@ -194,7 +194,7 @@ namespace ignite
// 3. Create classpath.
std::string cp;
- if (cfg.jvmClassPath)
+ if (!cfg.jvmClassPath.empty())
{
std::string usrCp = cfg.jvmClassPath;
@@ -233,9 +233,11 @@ namespace ignite
// 5. Start Ignite.
if (!failed)
{
- char* springCfgPath0 = CopyChars(cfg.springCfgPath);
+ char* springCfgPath0 = NULL;
- if (!springCfgPath0)
+ if (!cfg.springCfgPath.empty())
+ springCfgPath0 = CopyChars(cfg.springCfgPath.c_str());
+ else
springCfgPath0 = CopyChars(DFLT_CFG);
char* name0 = CopyChars(name);
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/core/src/impl/ignite_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/ignite_impl.cpp b/modules/platforms/cpp/core/src/impl/ignite_impl.cpp
index c0eab68..28909eb 100644
--- a/modules/platforms/cpp/core/src/impl/ignite_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/ignite_impl.cpp
@@ -38,5 +38,10 @@ namespace ignite
{
return env.Get()->InstanceName();
}
+
+ JniContext* IgniteImpl::GetContext()
+ {
+ return env.Get()->Context();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/ignite/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/ignite/Makefile.am b/modules/platforms/cpp/ignite/Makefile.am
new file mode 100644
index 0000000..ad405da
--- /dev/null
+++ b/modules/platforms/cpp/ignite/Makefile.am
@@ -0,0 +1,39 @@
+##
+## 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.
+##
+
+ACLOCAL_AMFLAGS = "-Im4"
+
+SUBDIRS = .
+DIST_SUBDIRS = .
+
+AM_CPPFLAGS = -I$(srcdir)/include -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -DIGNITE_IMPL
+AM_CXXFLAGS = -Wall -std=c++0x
+
+noinst_PROGRAMS = ignite
+
+ignite_SOURCES = src/ignite.cpp
+
+ignite_LDFLAGS = -static-libtool-libs -L/usr/local/lib -lignite
+
+run-check: check
+ ./ignite
+
+clean-local: clean-check
+ $(RM) *.gcno *.gcda
+
+clean-check:
+ $(RM) $(ignite_OBJECTS)
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/ignite/configure.ac
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/ignite/configure.ac b/modules/platforms/cpp/ignite/configure.ac
new file mode 100644
index 0000000..7705797
--- /dev/null
+++ b/modules/platforms/cpp/ignite/configure.ac
@@ -0,0 +1,62 @@
+#
+# 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.
+#
+
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.69])
+AC_INIT([Apache Ignite C++ Runner], [1.5.0], [dev@ignite.apache.org], [ignite], [ignite.apache.org])
+AC_CONFIG_SRCDIR(src)
+
+AC_CANONICAL_SYSTEM
+AC_CONFIG_MACRO_DIR([m4])
+AC_LANG([C++])
+
+# Initialize automake
+AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
+AC_CONFIG_HEADER(config.h)
+
+AM_PROG_AR
+
+# Checks for programs.
+GXX="-g -O2"
+
+AC_PROG_CXX
+
+# Initialize Libtool
+LT_INIT
+
+# Checks for libraries.
+AC_CHECK_LIB([pthread], [pthread_mutex_lock])
+
+# Checks for header files.
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_INLINE
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_INT8_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+
+# Checks for library functions.
+AC_FUNC_ERROR_AT_LINE
+
+AC_CONFIG_FILES(Makefile)
+
+AC_OUTPUT
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/ignite/project/README.TXT
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/ignite/project/README.TXT b/modules/platforms/cpp/ignite/project/README.TXT
new file mode 100644
index 0000000..97f4c64
--- /dev/null
+++ b/modules/platforms/cpp/ignite/project/README.TXT
@@ -0,0 +1 @@
+Contains IDE projects artifacts.
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/ignite/project/vs/README.TXT
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/ignite/project/vs/README.TXT b/modules/platforms/cpp/ignite/project/vs/README.TXT
new file mode 100644
index 0000000..f4fb456
--- /dev/null
+++ b/modules/platforms/cpp/ignite/project/vs/README.TXT
@@ -0,0 +1 @@
+Contains Visual Studio project artifacts.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/ignite/project/vs/ignite.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/ignite/project/vs/ignite.vcxproj b/modules/platforms/cpp/ignite/project/vs/ignite.vcxproj
new file mode 100644
index 0000000..4ce915e
--- /dev/null
+++ b/modules/platforms/cpp/ignite/project/vs/ignite.vcxproj
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{69688B4D-3EE0-43F5-A1C6-29B5D2DDE949}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>ignite</RootNamespace>
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ <ProjectName>ignite</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v100</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v100</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v100</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v100</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>
+ </LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\core\os\win\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;IGNITE_IMPL;_CRT_SECURE_NO_WARNINGS;IGNITE_FRIEND;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Async</ExceptionHandling>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\core\os\win\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>_DEBUG;IGNITE_IMPL;_CRT_SECURE_NO_WARNINGS;IGNITE_FRIEND;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Async</ExceptionHandling>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\core\os\win\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;IGNITE_IMPL;_CRT_SECURE_NO_WARNINGS;IGNITE_FRIEND;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Async</ExceptionHandling>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <AdditionalIncludeDirectories>$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(ProjectDir)\..\..\..\common\include;$(ProjectDir)\..\..\..\common\os\win\include;$(ProjectDir)\..\..\..\core\include;$(ProjectDir)\..\..\..\core\os\win\include;$(BOOST_HOME)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>NDEBUG;IGNITE_IMPL;_CRT_SECURE_NO_WARNINGS;IGNITE_FRIEND;_CRTDBG_MAP_ALLOC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Async</ExceptionHandling>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <Text Include="ReadMe.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\ignite.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\common\project\vs\common.vcxproj">
+ <Project>{4f7e4917-4612-4b96-9838-025711ade391}</Project>
+ </ProjectReference>
+ <ProjectReference Include="..\..\..\core\project\vs\core.vcxproj">
+ <Project>{e2dea693-f2ea-43c2-a813-053378f6e4db}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/ignite/project/vs/ignite.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/ignite/project/vs/ignite.vcxproj.filters b/modules/platforms/cpp/ignite/project/vs/ignite.vcxproj.filters
new file mode 100644
index 0000000..f39c60a
--- /dev/null
+++ b/modules/platforms/cpp/ignite/project/vs/ignite.vcxproj.filters
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Code">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Headers">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resources">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="ReadMe.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\src\ignite.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
+ </ItemGroup>
+</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/ignite/src/ignite.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/ignite/src/ignite.cpp b/modules/platforms/cpp/ignite/src/ignite.cpp
new file mode 100644
index 0000000..56860b3
--- /dev/null
+++ b/modules/platforms/cpp/ignite/src/ignite.cpp
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <algorithm>
+#include <list>
+#include <string>
+#include <iterator>
+
+#include "ignite/ignite_configuration.h"
+#include "ignite/ignition.h"
+#include "ignite/common/utils.h"
+
+typedef std::list<std::string> StringList;
+typedef std::set<std::string> StringSet;
+
+namespace config
+{
+ using ignite::common::util::ToLower;
+
+ /** Command line argument: Ignite home. */
+ const std::string CmdIgniteHome = ToLower("-IgniteHome=");
+
+ /** Command line argument: Spring config URL. */
+ const std::string CmdSpringCfgUrl = ToLower("-SpringConfigUrl=");
+
+ /** Command line argument: Path to JVM library. */
+ const std::string CmdJvmLib = ToLower("-JvmLibPath=");
+
+ /** Command line argument: JVM classpath. */
+ const std::string CmdJvmClasspath = ToLower("-JvmClasspath=");
+
+ /** Command line argument: JVM option prefix. */
+ const std::string CmdJvmOpt = ToLower("-J");
+
+ /** Command line argument: JvmInitialMemoryMB. */
+ const std::string CmdJvmMinMem = ToLower("-JvmInitialMemoryMB=");
+
+ /** Command line argument: JvmMaxMemoryMB. */
+ const std::string CmdJvmMaxMem = ToLower("-JvmMaxMemoryMB=");
+
+ /**
+ * Convert configuration to arguments.
+ *
+ * @param cfg Input configuration.
+ * @param args Output arguments.
+ */
+ void ToArgs(const ignite::IgniteConfiguration& cfg, StringList& args)
+ {
+ using ignite::common::util::LongToString;
+
+ if (!cfg.igniteHome.empty())
+ args.push_back(CmdIgniteHome + cfg.igniteHome);
+
+ if (cfg.springCfgPath.empty())
+ args.push_back(CmdSpringCfgUrl + cfg.springCfgPath);
+
+ if (cfg.jvmLibPath.empty())
+ args.push_back(CmdJvmLib + cfg.jvmLibPath);
+
+ if (cfg.jvmClassPath.empty())
+ args.push_back(CmdJvmClasspath + cfg.jvmClassPath);
+
+ if (cfg.jvmOpts.empty())
+ {
+ for (StringList::const_iterator i = cfg.jvmOpts.begin(); i != cfg.jvmOpts.end(); ++i)
+ args.push_back(CmdJvmOpt + *i);
+ }
+
+ args.push_back(CmdJvmMinMem + LongToString(cfg.jvmInitMem));
+ args.push_back(CmdJvmMaxMem + LongToString(cfg.jvmMaxMem));
+ }
+
+ /**
+ * Convert arguments to configuration.
+ *
+ * @param cfg Output configuration.
+ * @param args Input arguments.
+ */
+ void Configure(ignite::IgniteConfiguration& cfg, const StringList& src)
+ {
+ using ignite::common::util::ParseInt;
+
+ StringList jvmOpts;
+
+ for (StringList::const_iterator i = src.begin(); i != src.end(); ++i)
+ {
+ const std::string& arg = *i;
+
+ std::string argLow = ToLower(arg);
+
+ if (argLow.find(CmdIgniteHome) == 0)
+ cfg.igniteHome = arg.substr(CmdIgniteHome.size());
+ else if (argLow.find(CmdSpringCfgUrl) == 0)
+ cfg.springCfgPath = arg.substr(CmdSpringCfgUrl.size());
+ else if (argLow.find(CmdJvmLib) == 0)
+ cfg.jvmLibPath = arg.substr(CmdJvmLib.size());
+ else if (argLow.find(CmdJvmClasspath) == 0)
+ cfg.jvmClassPath = arg.substr(CmdJvmClasspath.size());
+ else if (argLow.find(CmdJvmMinMem) == 0)
+ cfg.jvmInitMem = ParseInt(arg.substr(CmdJvmMinMem.size()));
+ else if (argLow.find(CmdJvmMaxMem) == 0)
+ cfg.jvmMaxMem = ParseInt(arg.substr(CmdJvmMaxMem.size()));
+ else if (argLow.find(CmdJvmOpt) == 0)
+ jvmOpts.push_back(arg.substr(CmdJvmOpt.size()));
+ else
+ {
+ std::cout << "WARNING: unknown argument \"" << arg << "\"."
+ << "Type --help for the list of supported arguments." << std::endl;
+ }
+ }
+
+ if (!jvmOpts.empty())
+ {
+ if (!cfg.jvmOpts.empty())
+ cfg.jvmOpts.swap(jvmOpts);
+ else
+ std::copy(jvmOpts.begin(), jvmOpts.end(), std::back_insert_iterator<StringList>(cfg.jvmOpts));
+ }
+ }
+}
+
+
+/**
+ * Prints help to standard output.
+ */
+void PrintHelp()
+{
+ std::cout << "Usage: ignite [-options]" << std::endl;
+ std::cout << std::endl;
+ std::cout << "Options:" << std::endl;
+ std::cout << "\t-igniteHome path to Ignite installation directory (if not provided IGNITE_HOME environment variable is used)" << std::endl;
+ std::cout << "\t-springConfigUrl path to spring configuration file (if not provided \"config/default-config.xml\" is used)" << std::endl;
+ std::cout << "\t-jvmLibPath path to JVM library (if not provided JAVA_HOME environment variable is used)" << std::endl;
+ std::cout << "\t-jvmClasspath classpath passed to JVM (enlist additional jar files here)" << std::endl;
+ std::cout << "\t-J<javaOption> JVM options passed to created JVM" << std::endl;
+ std::cout << "\t-jvmInitialMemoryMB Initial Java heap size, in megabytes. Maps to -Xms Java parameter. Defaults to 512." << std::endl;
+ std::cout << "\t-jvmMaxMemoryMB Maximum Java heap size, in megabytes. Maps to -Xmx Java parameter. Defaults to 1024." << std::endl;
+ std::cout << std::endl;
+ std::cout << "Examples:" << std::endl;
+ std::cout << "\tignite -J-Xms1024m -J-Xmx1024m -springConfigUrl=C:/woer/gg-test/my-test-gg-confignative.xml" << std::endl;
+ std::cout << "\tignite -igniteHome=c:/apache-ignite -jvmClasspath=libs/myLib1.jar;libs/myLib2.jar" << std::endl;
+ std::cout << "\tignite -jvmInitialMemoryMB=1024 -jvmMaxMemoryMB=4096" << std::endl;
+ std::cout << std::endl;
+}
+
+/**
+ * Application entry point.
+ */
+int main(int argc, const char* argv[])
+{
+ // Help commands.
+ StringSet Help;
+ Help.insert("/help");
+ Help.insert("-help");
+ Help.insert("--help");
+
+ StringList args;
+ std::copy(argv + 1, argv + argc, std::back_insert_iterator<StringList>(args));
+
+ try
+ {
+ // Check for special cases.
+ if (!args.empty())
+ {
+ using ignite::common::util::ToLower;
+
+ std::string first = ToLower(args.front());
+
+ if (Help.find(first) != Help.end())
+ {
+ PrintHelp();
+
+ return 0;
+ }
+ }
+
+ // Pick application configuration.
+ ignite::IgniteConfiguration cfg;
+
+ // Pick command line arguments.
+ config::Configure(cfg, args);
+
+ ignite::Ignite ignite = ignite::Ignition::Start(cfg);
+
+ ignite::impl::IgniteImpl *igniteImpl = ignite::impl::IgniteImpl::GetFromProxy(ignite);
+
+ if (igniteImpl)
+ {
+ ignite::common::java::JniContext* context = igniteImpl->GetContext();
+ if (context)
+ {
+ context->DestroyJvm();
+ }
+ }
+ }
+ catch (ignite::IgniteError& e)
+ {
+ std::cout << "ERROR: " << e.GetText() << std::endl;
+
+ return -1;
+ }
+ catch (std::exception& e)
+ {
+ std::cout << "ERROR: " << e.what() << std::endl;
+
+ return -2;
+ }
+ return 0;
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/40978109/modules/platforms/cpp/project/vs/ignite.sln
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/project/vs/ignite.sln b/modules/platforms/cpp/project/vs/ignite.sln
index 4a2ec29..c573606 100644
--- a/modules/platforms/cpp/project/vs/ignite.sln
+++ b/modules/platforms/cpp/project/vs/ignite.sln
@@ -9,6 +9,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "..\..\core\project\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core-test", "..\..\core-test\project\vs\core-test.vcxproj", "{133A22DB-FD60-44B9-B5E3-6CBB3EA5ABF0}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ignite", "..\..\ignite\project\vs\ignite.vcxproj", "{69688B4D-3EE0-43F5-A1C6-29B5D2DDE949}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -41,6 +43,14 @@ Global
{133A22DB-FD60-44B9-B5E3-6CBB3EA5ABF0}.Release|Win32.Build.0 = Release|Win32
{133A22DB-FD60-44B9-B5E3-6CBB3EA5ABF0}.Release|x64.ActiveCfg = Release|x64
{133A22DB-FD60-44B9-B5E3-6CBB3EA5ABF0}.Release|x64.Build.0 = Release|x64
+ {69688B4D-3EE0-43F5-A1C6-29B5D2DDE949}.Debug|Win32.ActiveCfg = Debug|Win32
+ {69688B4D-3EE0-43F5-A1C6-29B5D2DDE949}.Debug|Win32.Build.0 = Debug|Win32
+ {69688B4D-3EE0-43F5-A1C6-29B5D2DDE949}.Debug|x64.ActiveCfg = Debug|x64
+ {69688B4D-3EE0-43F5-A1C6-29B5D2DDE949}.Debug|x64.Build.0 = Debug|x64
+ {69688B4D-3EE0-43F5-A1C6-29B5D2DDE949}.Release|Win32.ActiveCfg = Release|Win32
+ {69688B4D-3EE0-43F5-A1C6-29B5D2DDE949}.Release|Win32.Build.0 = Release|Win32
+ {69688B4D-3EE0-43F5-A1C6-29B5D2DDE949}.Release|x64.ActiveCfg = Release|x64
+ {69688B4D-3EE0-43F5-A1C6-29B5D2DDE949}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
[05/17] ignite git commit: IGNITE-1655: Decoupled Date and Timestamp
in Java.
Posted by ag...@apache.org.
IGNITE-1655: Decoupled Date and Timestamp in Java.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f8b18ccd
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f8b18ccd
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f8b18ccd
Branch: refs/heads/ignite-950-new
Commit: f8b18ccd4b3fb90d8910cffd8476b42bfe9b980a
Parents: f65a53e
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Fri Oct 23 12:34:21 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Oct 23 12:34:21 2015 +0300
----------------------------------------------------------------------
.../portable/GridPortableMarshaller.java | 6 +
.../portable/PortableClassDescriptor.java | 69 +++++---
.../internal/portable/PortableContext.java | 59 +------
.../portable/PortableMetaDataCollector.java | 5 +
.../internal/portable/PortableReaderExImpl.java | 157 +++++++++++++------
.../ignite/internal/portable/PortableUtils.java | 28 ++--
.../internal/portable/PortableWriterExImpl.java | 93 +++++++----
.../portable/builder/PortableBuilderReader.java | 52 ++++--
.../CacheObjectPortableProcessorImpl.java | 4 +
.../platform/PlatformContextImpl.java | 9 +-
.../transactions/PlatformTransactions.java | 5 +-
.../marshaller/portable/PortableMarshaller.java | 22 ---
.../ignite/portable/PortableRawReader.java | 6 +
.../ignite/portable/PortableRawWriter.java | 6 +
.../apache/ignite/portable/PortableReader.java | 7 +
.../portable/PortableTypeConfiguration.java | 19 ---
.../apache/ignite/portable/PortableWriter.java | 7 +
.../GridPortableBuilderAdditionalSelfTest.java | 65 +++++++-
.../portable/GridPortableBuilderSelfTest.java | 50 +++++-
.../GridPortableMarshallerSelfTest.java | 47 +-----
.../mutabletest/GridPortableTestClasses.java | 9 ++
.../Apache.Ignite.Benchmarks/Model/TestModel.cs | 8 +-
.../Portable/PortableApiSelfTest.cs | 26 +--
.../Portable/PortableSelfTest.cs | 66 ++------
.../Apache.Ignite.Core/Events/EventBase.cs | 2 +-
.../Impl/Cluster/ClusterMetricsImpl.cs | 6 +-
.../Portable/Metadata/PortableMetadataImpl.cs | 8 +-
.../Impl/Portable/PortableBuilderImpl.cs | 12 +-
.../Impl/Portable/PortableReaderImpl.cs | 46 ++----
.../Impl/Portable/PortableReflectiveRoutines.cs | 12 +-
.../Portable/PortableReflectiveSerializer.cs | 2 +-
.../Impl/Portable/PortableSystemHandlers.cs | 58 ++-----
.../Impl/Portable/PortableUtils.cs | 91 +++--------
.../Impl/Portable/PortableWriterImpl.cs | 28 ++--
.../Impl/Transactions/TransactionMetricsImpl.cs | 4 +-
.../Portable/IPortableRawReader.cs | 26 +--
.../Portable/IPortableRawWriter.cs | 4 +-
.../Portable/IPortableReader.cs | 26 +--
.../Portable/IPortableWriter.cs | 4 +-
.../Portable/PortableTypeNames.cs | 10 +-
40 files changed, 592 insertions(+), 572 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
index 20e8693..6f16755 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/GridPortableMarshaller.java
@@ -132,6 +132,12 @@ public class GridPortableMarshaller {
/** */
public static final byte CLASS = 32;
+ /** Timestamp. */
+ public static final byte TIMESTAMP = 33;
+
+ /** Timestamp array. */
+ public static final byte TIMESTAMP_ARR = 34;
+
/** */
public static final byte NULL = (byte)101;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
index 05a7f13..0a9974e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableClassDescriptor.java
@@ -88,9 +88,6 @@ public class PortableClassDescriptor {
private final Method readResolveMtd;
/** */
- private final boolean useTs;
-
- /** */
private final Map<String, String> fieldsMeta;
/** */
@@ -113,7 +110,6 @@ public class PortableClassDescriptor {
* @param typeName Type name.
* @param idMapper ID mapper.
* @param serializer Serializer.
- * @param useTs Use timestamp flag.
* @param metaDataEnabled Metadata enabled flag.
* @param keepDeserialized Keep deserialized flag.
* @param registered Whether typeId has been successfully registered by MarshallerContext or not.
@@ -128,7 +124,6 @@ public class PortableClassDescriptor {
String typeName,
@Nullable PortableIdMapper idMapper,
@Nullable PortableSerializer serializer,
- boolean useTs,
boolean metaDataEnabled,
boolean keepDeserialized,
boolean registered,
@@ -143,7 +138,6 @@ public class PortableClassDescriptor {
this.typeId = typeId;
this.typeName = typeName;
this.serializer = serializer;
- this.useTs = useTs;
this.keepDeserialized = keepDeserialized;
this.registered = registered;
@@ -169,6 +163,7 @@ public class PortableClassDescriptor {
case STRING:
case UUID:
case DATE:
+ case TIMESTAMP:
case BYTE_ARR:
case SHORT_ARR:
case INT_ARR:
@@ -181,6 +176,7 @@ public class PortableClassDescriptor {
case STRING_ARR:
case UUID_ARR:
case DATE_ARR:
+ case TIMESTAMP_ARR:
case OBJ_ARR:
case COL:
case MAP:
@@ -280,13 +276,6 @@ public class PortableClassDescriptor {
}
/**
- * @return Use timestamp flag.
- */
- boolean isUseTimestamp() {
- return useTs;
- }
-
- /**
* @return Keep deserialized flag.
*/
boolean keepDeserialized() {
@@ -405,10 +394,12 @@ public class PortableClassDescriptor {
break;
case DATE:
- if (obj instanceof Timestamp)
- writer.doWriteTimestamp((Timestamp)obj);
- else
- writer.doWriteDate((Date)obj);
+ writer.doWriteDate((Date)obj);
+
+ break;
+
+ case TIMESTAMP:
+ writer.doWriteTimestamp((Timestamp)obj);
break;
@@ -472,6 +463,11 @@ public class PortableClassDescriptor {
break;
+ case TIMESTAMP_ARR:
+ writer.doWriteTimestampArray((Timestamp[]) obj);
+
+ break;
+
case OBJ_ARR:
writer.doWriteObjectArray((Object[])obj);
@@ -767,8 +763,10 @@ public class PortableClassDescriptor {
return Mode.STRING;
else if (cls == UUID.class)
return Mode.UUID;
- else if (cls == Timestamp.class || cls == Date.class)
+ else if (cls == Date.class)
return Mode.DATE;
+ else if (cls == Timestamp.class)
+ return Mode.TIMESTAMP;
else if (cls == byte[].class)
return Mode.BYTE_ARR;
else if (cls == short[].class)
@@ -793,6 +791,8 @@ public class PortableClassDescriptor {
return Mode.UUID_ARR;
else if (cls == Date[].class)
return Mode.DATE_ARR;
+ else if (cls == Timestamp[].class)
+ return Mode.TIMESTAMP_ARR;
else if (cls.isArray())
return cls.getComponentType().isEnum() ? Mode.ENUM_ARR : Mode.OBJ_ARR;
else if (cls == PortableObjectImpl.class)
@@ -927,10 +927,12 @@ public class PortableClassDescriptor {
break;
case DATE:
- if (val instanceof Timestamp)
- writer.writeTimestampField((Timestamp)val);
- else
- writer.writeDateField((Date)val);
+ writer.writeDateField((Date)val);
+
+ break;
+
+ case TIMESTAMP:
+ writer.writeTimestampField((Timestamp)val);
break;
@@ -994,6 +996,11 @@ public class PortableClassDescriptor {
break;
+ case TIMESTAMP_ARR:
+ writer.writeTimestampArrayField((Timestamp[]) val);
+
+ break;
+
case OBJ_ARR:
writer.writeObjectArrayField((Object[])val);
@@ -1111,7 +1118,12 @@ public class PortableClassDescriptor {
break;
case DATE:
- val = field.getType() == Timestamp.class ? reader.readTimestamp(id) : reader.readDate(id);
+ val = reader.readDate(id);
+
+ break;
+
+ case TIMESTAMP:
+ val = reader.readTimestamp(id);
break;
@@ -1175,6 +1187,11 @@ public class PortableClassDescriptor {
break;
+ case TIMESTAMP_ARR:
+ val = reader.readTimestampArray(id);
+
+ break;
+
case OBJ_ARR:
val = reader.readObjectArray(id);
@@ -1275,6 +1292,9 @@ public class PortableClassDescriptor {
DATE("Date"),
/** */
+ TIMESTAMP("Timestamp"),
+
+ /** */
BYTE_ARR("byte[]"),
/** */
@@ -1311,6 +1331,9 @@ public class PortableClassDescriptor {
DATE_ARR("Date[]"),
/** */
+ TIMESTAMP_ARR("Timestamp[]"),
+
+ /** */
OBJ_ARR("Object[]"),
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index c56fc8c..9c11ca8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -130,9 +130,6 @@ public class PortableContext implements Externalizable {
private Map<Integer, Boolean> metaEnabled = new HashMap<>(0);
/** */
- private Set<Integer> usingTs = new HashSet<>();
-
- /** */
private PortableMetaDataHandler metaHnd;
/** */
@@ -148,9 +145,6 @@ public class PortableContext implements Externalizable {
private boolean convertStrings;
/** */
- private boolean useTs;
-
- /** */
private boolean metaDataEnabled;
/** */
@@ -200,9 +194,9 @@ public class PortableContext implements Externalizable {
registerPredefinedType(String.class, GridPortableMarshaller.STRING);
registerPredefinedType(BigDecimal.class, GridPortableMarshaller.DECIMAL);
registerPredefinedType(Date.class, GridPortableMarshaller.DATE);
+ registerPredefinedType(Timestamp.class, GridPortableMarshaller.TIMESTAMP);
registerPredefinedType(UUID.class, GridPortableMarshaller.UUID);
// TODO: How to handle timestamp? It has the same ID in .Net.
- registerPredefinedType(Timestamp.class, GridPortableMarshaller.DATE);
registerPredefinedType(byte[].class, GridPortableMarshaller.BYTE_ARR);
registerPredefinedType(short[].class, GridPortableMarshaller.SHORT_ARR);
@@ -216,6 +210,7 @@ public class PortableContext implements Externalizable {
registerPredefinedType(String[].class, GridPortableMarshaller.STRING_ARR);
registerPredefinedType(UUID[].class, GridPortableMarshaller.UUID_ARR);
registerPredefinedType(Date[].class, GridPortableMarshaller.DATE_ARR);
+ registerPredefinedType(Timestamp[].class, GridPortableMarshaller.TIMESTAMP_ARR);
registerPredefinedType(Object[].class, GridPortableMarshaller.OBJ_ARR);
registerPredefinedType(ArrayList.class, 0);
@@ -250,7 +245,6 @@ public class PortableContext implements Externalizable {
return;
convertStrings = marsh.isConvertStringToBytes();
- useTs = marsh.isUseTimestamp();
metaDataEnabled = marsh.isMetaDataEnabled();
keepDeserialized = marsh.isKeepDeserialized();
@@ -263,7 +257,6 @@ public class PortableContext implements Externalizable {
configure(
marsh.getIdMapper(),
marsh.getSerializer(),
- marsh.isUseTimestamp(),
marsh.isMetaDataEnabled(),
marsh.isKeepDeserialized(),
marsh.getClassNames(),
@@ -274,7 +267,6 @@ public class PortableContext implements Externalizable {
/**
* @param globalIdMapper ID mapper.
* @param globalSerializer Serializer.
- * @param globalUseTs Use timestamp flag.
* @param globalMetaDataEnabled Metadata enabled flag.
* @param globalKeepDeserialized Keep deserialized flag.
* @param clsNames Class names.
@@ -284,7 +276,6 @@ public class PortableContext implements Externalizable {
private void configure(
PortableIdMapper globalIdMapper,
PortableSerializer globalSerializer,
- boolean globalUseTs,
boolean globalMetaDataEnabled,
boolean globalKeepDeserialized,
Collection<String> clsNames,
@@ -300,11 +291,11 @@ public class PortableContext implements Externalizable {
String pkgName = clsName.substring(0, clsName.length() - 2);
for (String clsName0 : classesInPackage(pkgName))
- descs.add(clsName0, idMapper, null, null, globalUseTs, globalMetaDataEnabled,
+ descs.add(clsName0, idMapper, null, null, globalMetaDataEnabled,
globalKeepDeserialized, true);
}
else // Regular single class
- descs.add(clsName, idMapper, null, null, globalUseTs, globalMetaDataEnabled,
+ descs.add(clsName, idMapper, null, null, globalMetaDataEnabled,
globalKeepDeserialized, true);
}
}
@@ -328,7 +319,6 @@ public class PortableContext implements Externalizable {
if (typeCfg.getSerializer() != null)
serializer = typeCfg.getSerializer();
- boolean useTs = typeCfg.isUseTimestamp() != null ? typeCfg.isUseTimestamp() : globalUseTs;
boolean metaDataEnabled = typeCfg.isMetaDataEnabled() != null ? typeCfg.isMetaDataEnabled() :
globalMetaDataEnabled;
boolean keepDeserialized = typeCfg.isKeepDeserialized() != null ? typeCfg.isKeepDeserialized() :
@@ -338,17 +328,17 @@ public class PortableContext implements Externalizable {
String pkgName = clsName.substring(0, clsName.length() - 2);
for (String clsName0 : classesInPackage(pkgName))
- descs.add(clsName0, idMapper, serializer, typeCfg.getAffinityKeyFieldName(), useTs,
+ descs.add(clsName0, idMapper, serializer, typeCfg.getAffinityKeyFieldName(),
metaDataEnabled, keepDeserialized, true);
}
else
- descs.add(clsName, idMapper, serializer, typeCfg.getAffinityKeyFieldName(), useTs,
+ descs.add(clsName, idMapper, serializer, typeCfg.getAffinityKeyFieldName(),
metaDataEnabled, keepDeserialized, false);
}
}
for (TypeDescriptor desc : descs.descriptors()) {
- registerUserType(desc.clsName, desc.idMapper, desc.serializer, desc.affKeyFieldName, desc.useTs,
+ registerUserType(desc.clsName, desc.idMapper, desc.serializer, desc.affKeyFieldName,
desc.metadataEnabled, desc.keepDeserialized);
}
}
@@ -505,7 +495,6 @@ public class PortableContext implements Externalizable {
clsName,
BASIC_CLS_ID_MAPPER,
null,
- useTs,
metaDataEnabled,
keepDeserialized,
true, /* registered */
@@ -552,7 +541,6 @@ public class PortableContext implements Externalizable {
typeName,
idMapper,
null,
- useTs,
metaDataEnabled,
keepDeserialized,
registered,
@@ -696,7 +684,6 @@ public class PortableContext implements Externalizable {
null,
false,
false,
- false,
true, /* registered */
true /* predefined */
);
@@ -714,7 +701,6 @@ public class PortableContext implements Externalizable {
* @param idMapper ID mapper.
* @param serializer Serializer.
* @param affKeyFieldName Affinity key field name.
- * @param useTs Use timestamp flag.
* @param metaDataEnabled Metadata enabled flag.
* @param keepDeserialized Keep deserialized flag.
* @throws PortableException In case of error.
@@ -724,7 +710,6 @@ public class PortableContext implements Externalizable {
PortableIdMapper idMapper,
@Nullable PortableSerializer serializer,
@Nullable String affKeyFieldName,
- boolean useTs,
boolean metaDataEnabled,
boolean keepDeserialized)
throws PortableException {
@@ -748,9 +733,6 @@ public class PortableContext implements Externalizable {
if (mappers.put(id, idMapper) != null)
throw new PortableException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
- if (useTs)
- usingTs.add(id);
-
String typeName = typeName(clsName);
typeMappers.put(typeName, idMapper);
@@ -768,7 +750,6 @@ public class PortableContext implements Externalizable {
typeName,
idMapper,
serializer,
- useTs,
metaDataEnabled,
keepDeserialized,
true, /* registered */
@@ -844,21 +825,6 @@ public class PortableContext implements Externalizable {
}
/**
- * @return Use timestamp flag.
- */
- public boolean isUseTimestamp() {
- return useTs;
- }
-
- /**
- * @param typeId Type ID.
- * @return If timestamp used.
- */
- public boolean isUseTimestamp(int typeId) {
- return usingTs.contains(typeId);
- }
-
- /**
* @return Whether to convert string to UTF8 bytes.
*/
public boolean isConvertString() {
@@ -989,7 +955,6 @@ public class PortableContext implements Externalizable {
* @param idMapper ID mapper.
* @param serializer Serializer.
* @param affKeyFieldName Affinity key field name.
- * @param useTs Use timestamp flag.
* @param metadataEnabled Metadata enabled flag.
* @param keepDeserialized Keep deserialized flag.
* @param canOverride Whether this descriptor can be override.
@@ -999,7 +964,6 @@ public class PortableContext implements Externalizable {
PortableIdMapper idMapper,
PortableSerializer serializer,
String affKeyFieldName,
- boolean useTs,
boolean metadataEnabled,
boolean keepDeserialized,
boolean canOverride)
@@ -1008,7 +972,6 @@ public class PortableContext implements Externalizable {
idMapper,
serializer,
affKeyFieldName,
- useTs,
metadataEnabled,
keepDeserialized,
canOverride);
@@ -1047,9 +1010,6 @@ public class PortableContext implements Externalizable {
/** Affinity key field name. */
private String affKeyFieldName;
- /** Use timestamp flag. */
- private boolean useTs;
-
/** Metadata enabled flag. */
private boolean metadataEnabled;
@@ -1066,19 +1026,17 @@ public class PortableContext implements Externalizable {
* @param idMapper ID mapper.
* @param serializer Serializer.
* @param affKeyFieldName Affinity key field name.
- * @param useTs Use timestamp flag.
* @param metadataEnabled Metadata enabled flag.
* @param keepDeserialized Keep deserialized flag.
* @param canOverride Whether this descriptor can be override.
*/
private TypeDescriptor(String clsName, PortableIdMapper idMapper, PortableSerializer serializer,
- String affKeyFieldName, boolean useTs, boolean metadataEnabled, boolean keepDeserialized,
+ String affKeyFieldName, boolean metadataEnabled, boolean keepDeserialized,
boolean canOverride) {
this.clsName = clsName;
this.idMapper = idMapper;
this.serializer = serializer;
this.affKeyFieldName = affKeyFieldName;
- this.useTs = useTs;
this.metadataEnabled = metadataEnabled;
this.keepDeserialized = keepDeserialized;
this.canOverride = canOverride;
@@ -1097,7 +1055,6 @@ public class PortableContext implements Externalizable {
idMapper = other.idMapper;
serializer = other.serializer;
affKeyFieldName = other.affKeyFieldName;
- useTs = other.useTs;
metadataEnabled = other.metadataEnabled;
keepDeserialized = other.keepDeserialized;
canOverride = other.canOverride;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java
index ae5fbf0..9a88bfb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableMetaDataCollector.java
@@ -197,6 +197,11 @@ class PortableMetaDataCollector implements PortableWriter {
}
/** {@inheritDoc} */
+ @Override public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws PortableException {
+ add(fieldName, Timestamp[].class);
+ }
+
+ /** {@inheritDoc} */
@Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws PortableException {
add(fieldName, Object[].class);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
index 015ed6c..5d1460c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableReaderExImpl.java
@@ -17,6 +17,21 @@
package org.apache.ignite.internal.portable;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.portable.streams.PortableHeapInputStream;
+import org.apache.ignite.internal.portable.streams.PortableInputStream;
+import org.apache.ignite.internal.util.GridEnumCache;
+import org.apache.ignite.internal.util.lang.GridMapEntry;
+import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.portable.PortableException;
+import org.apache.ignite.portable.PortableInvalidClassException;
+import org.apache.ignite.portable.PortableObject;
+import org.apache.ignite.portable.PortableRawReader;
+import org.apache.ignite.portable.PortableReader;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
import java.io.ByteArrayInputStream;
import java.io.EOFException;
import java.io.IOException;
@@ -38,21 +53,6 @@ import java.util.TreeSet;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.portable.streams.PortableHeapInputStream;
-import org.apache.ignite.internal.portable.streams.PortableInputStream;
-import org.apache.ignite.internal.util.GridEnumCache;
-import org.apache.ignite.internal.util.lang.GridMapEntry;
-import org.apache.ignite.internal.util.typedef.internal.SB;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.portable.PortableMarshaller;
-import org.apache.ignite.portable.PortableException;
-import org.apache.ignite.portable.PortableInvalidClassException;
-import org.apache.ignite.portable.PortableObject;
-import org.apache.ignite.portable.PortableRawReader;
-import org.apache.ignite.portable.PortableReader;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.ARR_LIST;
@@ -102,6 +102,8 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING_ARR;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.TREE_MAP;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.TREE_SET;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UNREGISTERED_TYPE_ID;
@@ -556,7 +558,7 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
if (flag == NULL)
return null;
- if (flag != DATE)
+ if (flag != TIMESTAMP)
throw new PortableException("Invalid flag value: " + flag);
return doReadTimestamp(false);
@@ -893,6 +895,32 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
* @return Value.
* @throws PortableException In case of error.
*/
+ @Nullable Timestamp[] readTimestampArray(int fieldId) throws PortableException {
+ off = fieldOffset(fieldId);
+
+ if (off >= 0) {
+ byte flag = doReadByte(false);
+
+ if (flag == NULL)
+ return null;
+
+ if (flag == HANDLE)
+ return readHandleField();
+
+ if (flag != TIMESTAMP_ARR)
+ throw new PortableException("Invalid flag value: " + flag);
+
+ return doReadTimestampArray(false);
+ }
+ else
+ return null;
+ }
+
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws PortableException In case of error.
+ */
@Nullable Object[] readObjectArray(int fieldId) throws PortableException {
off = fieldOffset(fieldId);
@@ -1318,7 +1346,7 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
if (flag == NULL)
return null;
- if (flag != DATE)
+ if (flag != TIMESTAMP)
throw new PortableException("Invalid flag value: " + flag);
return doReadTimestamp(true);
@@ -1544,6 +1572,11 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
}
/** {@inheritDoc} */
+ @Nullable @Override public Timestamp[] readTimestampArray(String fieldName) throws PortableException {
+ return readTimestampArray(fieldId(fieldName));
+ }
+
+ /** {@inheritDoc} */
@Nullable @Override public Date[] readDateArray() throws PortableException {
byte flag = doReadByte(true);
@@ -1557,6 +1590,19 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
}
/** {@inheritDoc} */
+ @Nullable @Override public Timestamp[] readTimestampArray() throws PortableException {
+ byte flag = doReadByte(true);
+
+ if (flag == NULL)
+ return null;
+
+ if (flag != TIMESTAMP_ARR)
+ throw new PortableException("Invalid flag value: " + flag);
+
+ return doReadTimestampArray(true);
+ }
+
+ /** {@inheritDoc} */
@Nullable @Override public Object[] readObjectArray(String fieldName) throws PortableException {
return readObjectArray(fieldId(fieldName));
}
@@ -1803,7 +1849,10 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
return doReadUuid(raw);
case DATE:
- return isUseTimestamp() ? doReadTimestamp(raw) : doReadDate(raw);
+ return doReadDate(raw);
+
+ case TIMESTAMP:
+ return doReadTimestamp(raw);
case BYTE_ARR:
return doReadByteArray(raw);
@@ -1841,6 +1890,9 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
case DATE_ARR:
return doReadDateArray(raw);
+ case TIMESTAMP_ARR:
+ return doReadTimestampArray(raw);
+
case OBJ_ARR:
return doReadObjectArray(raw, false);
@@ -2072,12 +2124,6 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
private Date doReadDate(boolean raw) {
long time = doReadLong(raw);
- // Skip remainder.
- if (raw)
- rawOff += 4;
- else
- off += 4;
-
return new Date(time);
}
@@ -2087,7 +2133,6 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
*/
private Timestamp doReadTimestamp(boolean raw) {
long time = doReadLong(raw);
-
int nanos = doReadInt(raw);
Timestamp ts = new Timestamp(time);
@@ -2225,7 +2270,12 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
break;
case DATE:
- obj = isUseTimestamp() ? doReadTimestamp(true) : doReadDate(true);
+ obj = doReadDate(true);
+
+ break;
+
+ case TIMESTAMP:
+ obj = doReadTimestamp(true);
break;
@@ -2289,6 +2339,11 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
break;
+ case TIMESTAMP_ARR:
+ obj = doReadTimestampArray(true);
+
+ break;
+
case OBJ_ARR:
obj = doReadObjectArray(true, true);
@@ -2361,26 +2416,6 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
}
/**
- * @return Use timestamp flag.
- * @throws PortableInvalidClassException If fails to find object type descriptor.
- */
- private boolean isUseTimestamp() throws PortableInvalidClassException {
- in.position(start);
-
- boolean dateObj = in.readByte() == DATE;
-
- if (!dateObj) {
- in.position(start + GridPortableMarshaller.TYPE_ID_POS);
-
- int typeId = in.readInt(start + GridPortableMarshaller.TYPE_ID_POS);
-
- return ctx.isUseTimestamp(typeId);
- }
-
- return ctx.isUseTimestamp();
- }
-
- /**
* @param raw Raw flag.
* @return Value.
*/
@@ -2698,6 +2733,36 @@ public class PortableReaderExImpl implements PortableReader, PortableRawReaderEx
/**
* @param raw Raw flag.
+ * @return Value.
+ * @throws PortableException In case of error.
+ */
+ private Timestamp[] doReadTimestampArray(boolean raw) throws PortableException {
+ int hPos = (raw ? rawOff : off) - 1;
+
+ int len = doReadInt(raw);
+
+ Timestamp[] arr = new Timestamp[len];
+
+ setHandler(arr, hPos);
+
+ for (int i = 0; i < len; i++) {
+ byte flag = doReadByte(raw);
+
+ if (flag == NULL)
+ arr[i] = null;
+ else {
+ if (flag != TIMESTAMP)
+ throw new PortableException("Invalid flag value: " + flag);
+
+ arr[i] = doReadTimestamp(raw);
+ }
+ }
+
+ return arr;
+ }
+
+ /**
+ * @param raw Raw flag.
* @param deep Deep flag.
* @return Value.
* @throws PortableException In case of error.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
index 10970a0..2140bee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableUtils.java
@@ -71,6 +71,8 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING_ARR;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID_ARR;
@@ -138,6 +140,7 @@ public class PortableUtils {
PLAIN_CLASS_TO_FLAG.put(String.class, GridPortableMarshaller.STRING);
PLAIN_CLASS_TO_FLAG.put(UUID.class, GridPortableMarshaller.UUID);
PLAIN_CLASS_TO_FLAG.put(Date.class, GridPortableMarshaller.DATE);
+ PLAIN_CLASS_TO_FLAG.put(Timestamp.class, GridPortableMarshaller.TIMESTAMP);
PLAIN_CLASS_TO_FLAG.put(byte[].class, GridPortableMarshaller.BYTE_ARR);
PLAIN_CLASS_TO_FLAG.put(short[].class, GridPortableMarshaller.SHORT_ARR);
@@ -151,6 +154,7 @@ public class PortableUtils {
PLAIN_CLASS_TO_FLAG.put(String[].class, GridPortableMarshaller.STRING_ARR);
PLAIN_CLASS_TO_FLAG.put(UUID[].class, GridPortableMarshaller.UUID_ARR);
PLAIN_CLASS_TO_FLAG.put(Date[].class, GridPortableMarshaller.DATE_ARR);
+ PLAIN_CLASS_TO_FLAG.put(Timestamp[].class, GridPortableMarshaller.TIMESTAMP_ARR);
for (Map.Entry<Class<?>, Byte> entry : PLAIN_CLASS_TO_FLAG.entrySet())
FLAG_TO_CLASS.put(entry.getValue(), entry.getKey());
@@ -166,9 +170,9 @@ public class PortableUtils {
for (byte b : new byte[] {
BYTE, SHORT, INT, LONG, FLOAT, DOUBLE,
- CHAR, BOOLEAN, DECIMAL, STRING, UUID, DATE,
+ CHAR, BOOLEAN, DECIMAL, STRING, UUID, DATE, TIMESTAMP,
BYTE_ARR, SHORT_ARR, INT_ARR, LONG_ARR, FLOAT_ARR, DOUBLE_ARR,
- CHAR_ARR, BOOLEAN_ARR, DECIMAL_ARR, STRING_ARR, UUID_ARR, DATE_ARR,
+ CHAR_ARR, BOOLEAN_ARR, DECIMAL_ARR, STRING_ARR, UUID_ARR, DATE_ARR, TIMESTAMP_ARR,
ENUM, ENUM_ARR, NULL}) {
PLAIN_TYPE_FLAG[b] = true;
@@ -252,10 +256,12 @@ public class PortableUtils {
break;
case DATE:
- if (val instanceof Timestamp)
- writer.doWriteTimestamp((Timestamp)val);
- else
- writer.doWriteDate((Date)val);
+ writer.doWriteDate((Date)val);
+
+ break;
+
+ case TIMESTAMP:
+ writer.doWriteTimestamp((Timestamp) val);
break;
@@ -319,6 +325,11 @@ public class PortableUtils {
break;
+ case TIMESTAMP_ARR:
+ writer.doWriteTimestampArray((Timestamp[])val);
+
+ break;
+
default:
throw new IllegalArgumentException("Can't write object with type: " + val.getClass());
}
@@ -369,7 +380,7 @@ public class PortableUtils {
* @return {@code true} if content of serialized array value cannot contain references to other object.
*/
public static boolean isPlainArrayType(int type) {
- return type >= BYTE_ARR && type <= DATE_ARR;
+ return (type >= BYTE_ARR && type <= DATE_ARR) || type == TIMESTAMP_ARR;
}
/**
@@ -377,9 +388,6 @@ public class PortableUtils {
* @return Portable field type.
*/
public static byte typeByClass(Class<?> cls) {
- if (Date.class.isAssignableFrom(cls))
- return DATE;
-
Byte type = PLAIN_CLASS_TO_FLAG.get(cls);
if (type != null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
index 3152c4b..a8a4295 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
@@ -17,13 +17,18 @@
package org.apache.ignite.internal.portable;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.portable.streams.PortableHeapOutputStream;
+import org.apache.ignite.internal.portable.streams.PortableOutputStream;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.portable.PortableException;
+import org.apache.ignite.portable.PortableRawWriter;
+import org.apache.ignite.portable.PortableWriter;
+import org.jetbrains.annotations.Nullable;
+
import java.io.IOException;
-import java.io.ObjectInputStream;
import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
@@ -32,15 +37,6 @@ import java.util.Date;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.portable.streams.PortableHeapOutputStream;
-import org.apache.ignite.internal.portable.streams.PortableOutputStream;
-import org.apache.ignite.internal.util.typedef.internal.A;
-import org.apache.ignite.portable.PortableException;
-import org.apache.ignite.portable.PortableRawWriter;
-import org.apache.ignite.portable.PortableWriter;
-import org.jetbrains.annotations.Nullable;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.BOOLEAN;
@@ -77,6 +73,8 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING_ARR;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.TOTAL_LEN_POS;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UNREGISTERED_TYPE_ID;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID;
@@ -506,22 +504,21 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
else {
doWriteByte(DATE);
doWriteLong(date.getTime());
- doWriteInt(0);
}
}
- /**
- * @param ts Timestamp.
- */
- public void doWriteTimestamp(@Nullable Timestamp ts) {
- if (ts == null)
- doWriteByte(NULL);
- else {
- doWriteByte(DATE);
- doWriteLong(ts.getTime());
- doWriteInt(ts.getNanos() % 1000000);
- }
- }
+ /**
+ * @param ts Timestamp.
+ */
+ public void doWriteTimestamp(@Nullable Timestamp ts) {
+ if (ts== null)
+ doWriteByte(NULL);
+ else {
+ doWriteByte(TIMESTAMP);
+ doWriteLong(ts.getTime());
+ doWriteInt(ts.getNanos() % 1000000);
+ }
+ }
/**
* @param obj Object.
@@ -751,6 +748,24 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
}
}
+ /**
+ * @param val Array of timestamps.
+ */
+ void doWriteTimestampArray(@Nullable Timestamp[] val) {
+ if (val == null)
+ doWriteByte(NULL);
+ else {
+ if (tryWriteAsHandle(val))
+ return;
+
+ doWriteByte(TIMESTAMP_ARR);
+ doWriteInt(val.length);
+
+ for (Timestamp ts : val)
+ doWriteTimestamp(ts);
+ }
+ }
+
/**
* @param val Array of objects.
* @throws PortableException In case of error.
@@ -1084,7 +1099,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
* @param val Value.
*/
void writeDateField(@Nullable Date val) {
- doWriteInt(val != null ? 13 : 1);
+ doWriteInt(val != null ? 9 : 1);
doWriteDate(val);
}
@@ -1242,6 +1257,17 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
/**
* @param val Value.
+ */
+ void writeTimestampArrayField(@Nullable Timestamp[] val) {
+ int lenPos = reserveAndMark(4);
+
+ doWriteTimestampArray(val);
+
+ writeDelta(lenPos);
+ }
+
+ /**
+ * @param val Value.
* @throws PortableException In case of error.
*/
void writeObjectArrayField(@Nullable Object[] val) throws PortableException {
@@ -1456,7 +1482,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
/** {@inheritDoc} */
@Override public void writeTimestamp(String fieldName, @Nullable Timestamp val) throws PortableException {
- writeFieldId(fieldName, DATE);
+ writeFieldId(fieldName, TIMESTAMP);
writeTimestampField(val);
}
@@ -1618,6 +1644,17 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
}
/** {@inheritDoc} */
+ @Override public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws PortableException {
+ writeFieldId(fieldName, TIMESTAMP_ARR);
+ writeTimestampArrayField(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeTimestampArray(@Nullable Timestamp[] val) throws PortableException {
+ doWriteTimestampArray(val);
+ }
+
+ /** {@inheritDoc} */
@Override public void writeObjectArray(String fieldName, @Nullable Object[] val) throws PortableException {
writeFieldId(fieldName, OBJ_ARR);
writeObjectArrayField(val);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
index 31a3c11..afa40a3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java
@@ -260,6 +260,11 @@ class PortableBuilderReader {
break;
case GridPortableMarshaller.DATE:
+ len = 8;
+
+ break;
+
+ case GridPortableMarshaller.TIMESTAMP:
len = 8 + 4;
break;
@@ -284,6 +289,7 @@ class PortableBuilderReader {
case GridPortableMarshaller.DECIMAL_ARR:
case GridPortableMarshaller.DATE_ARR:
+ case GridPortableMarshaller.TIMESTAMP_ARR:
case GridPortableMarshaller.OBJ_ARR:
case GridPortableMarshaller.ENUM_ARR:
case GridPortableMarshaller.UUID_ARR:
@@ -404,6 +410,7 @@ class PortableBuilderReader {
case GridPortableMarshaller.STRING:
case GridPortableMarshaller.UUID:
case GridPortableMarshaller.DATE:
+ case GridPortableMarshaller.TIMESTAMP:
return new PortablePlainLazyValue(this, pos, len);
case GridPortableMarshaller.BYTE_ARR:
@@ -416,6 +423,7 @@ class PortableBuilderReader {
case GridPortableMarshaller.BOOLEAN_ARR:
case GridPortableMarshaller.DECIMAL_ARR:
case GridPortableMarshaller.DATE_ARR:
+ case GridPortableMarshaller.TIMESTAMP_ARR:
case GridPortableMarshaller.UUID_ARR:
case GridPortableMarshaller.STRING_ARR:
case GridPortableMarshaller.ENUM_ARR:
@@ -554,6 +562,11 @@ class PortableBuilderReader {
break;
case GridPortableMarshaller.DATE:
+ plainLazyValLen = 8;
+
+ break;
+
+ case GridPortableMarshaller.TIMESTAMP:
plainLazyValLen = 8 + 4;
break;
@@ -626,18 +639,39 @@ class PortableBuilderReader {
pos += 8;
- if (ctx.isUseTimestamp()) {
- Timestamp ts = new Timestamp(time);
+ res[i] = new Date(time);
+ }
- ts.setNanos(ts.getNanos() + readInt());
+ return res;
+ }
- res[i] = ts;
- }
- else {
- res[i] = new Date(time);
+ case GridPortableMarshaller.TIMESTAMP_ARR: {
+ int size = readInt();
- pos += 4;
- }
+ Timestamp[] res = new Timestamp[size];
+
+ for (int i = 0; i < res.length; i++) {
+ byte flag = arr[pos++];
+
+ if (flag == GridPortableMarshaller.NULL)
+ continue;
+
+ if (flag != GridPortableMarshaller.TIMESTAMP)
+ throw new PortableException("Invalid flag value: " + flag);
+
+ long time = PRIM.readLong(arr, pos);
+
+ pos += 8;
+
+ int nano = PRIM.readInt(arr, pos);
+
+ pos += 4;
+
+ Timestamp ts = new Timestamp(time);
+
+ ts.setNanos(ts.getNanos() + nano);
+
+ res[i] = ts;
}
return res;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
index 1be5aea..7bf32cd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
@@ -118,6 +118,8 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.SHORT_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.STRING_ARR;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP;
+import static org.apache.ignite.internal.portable.GridPortableMarshaller.TIMESTAMP_ARR;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID_ARR;
@@ -190,6 +192,7 @@ public class CacheObjectPortableProcessorImpl extends IgniteCacheObjectProcessor
FIELD_TYPE_NAMES[DECIMAL] = "decimal";
FIELD_TYPE_NAMES[STRING] = "String";
FIELD_TYPE_NAMES[DATE] = "Date";
+ FIELD_TYPE_NAMES[TIMESTAMP] = "Timestamp";
FIELD_TYPE_NAMES[ENUM] = "Enum";
FIELD_TYPE_NAMES[OBJ] = "Object";
FIELD_TYPE_NAMES[PORTABLE_OBJ] = "Object";
@@ -207,6 +210,7 @@ public class CacheObjectPortableProcessorImpl extends IgniteCacheObjectProcessor
FIELD_TYPE_NAMES[DECIMAL_ARR] = "decimal[]";
FIELD_TYPE_NAMES[STRING_ARR] = "String[]";
FIELD_TYPE_NAMES[DATE_ARR] = "Date[]";
+ FIELD_TYPE_NAMES[TIMESTAMP_ARR] = "Timestamp[]";
FIELD_TYPE_NAMES[OBJ_ARR] = "Object[]";
FIELD_TYPE_NAMES[ENUM_ARR] = "Enum[]";
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
index 0999f6a..177a732 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java
@@ -73,6 +73,7 @@ import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.portable.PortableMetadata;
import org.jetbrains.annotations.Nullable;
+import java.sql.Timestamp;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
@@ -270,7 +271,7 @@ public class PlatformContextImpl implements PlatformContext {
writer.writeBoolean(true);
writer.writeLong(metrics.getLastUpdateTime());
- writer.writeDate(new Date(metrics.getLastUpdateTime()));
+ writer.writeTimestamp(new Timestamp(metrics.getLastUpdateTime()));
writer.writeInt(metrics.getMaximumActiveJobs());
writer.writeInt(metrics.getCurrentActiveJobs());
writer.writeFloat(metrics.getAverageActiveJobs());
@@ -318,8 +319,8 @@ public class PlatformContextImpl implements PlatformContext {
writer.writeLong(metrics.getNonHeapMemoryTotal());
writer.writeLong(metrics.getUpTime());
- writer.writeDate(new Date(metrics.getStartTime()));
- writer.writeDate(new Date(metrics.getNodeStartTime()));
+ writer.writeTimestamp(new Timestamp(metrics.getStartTime()));
+ writer.writeTimestamp(new Timestamp(metrics.getNodeStartTime()));
writer.writeInt(metrics.getCurrentThreadCount());
writer.writeInt(metrics.getMaximumThreadCount());
writer.writeLong(metrics.getTotalStartedThreadCount());
@@ -572,7 +573,7 @@ public class PlatformContextImpl implements PlatformContext {
writer.writeString(evt.message());
writer.writeInt(evt.type());
writer.writeString(evt.name());
- writer.writeDate(new Date(evt.timestamp()));
+ writer.writeTimestamp(new Timestamp(evt.timestamp()));
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
index 1d2c315..c143212 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/transactions/PlatformTransactions.java
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.processors.platform.transactions;
+import java.sql.Timestamp;
import java.util.Date;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;
@@ -245,8 +246,8 @@ public class PlatformTransactions extends PlatformAbstractTarget {
case OP_METRICS:
TransactionMetrics metrics = txs.metrics();
- writer.writeDate(new Date(metrics.commitTime()));
- writer.writeDate(new Date(metrics.rollbackTime()));
+ writer.writeTimestamp(new Timestamp(metrics.commitTime()));
+ writer.writeTimestamp(new Timestamp(metrics.rollbackTime()));
writer.writeInt(metrics.txCommits());
writer.writeInt(metrics.txRollbacks());
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
index 3f02c65..ea2e1cc 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
@@ -21,7 +21,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.ignite.IgniteCheckedException;
@@ -88,9 +87,6 @@ public class PortableMarshaller extends AbstractMarshaller {
/** Types. */
private Collection<PortableTypeConfiguration> typeCfgs;
- /** Use timestamp flag. */
- private boolean useTs = true;
-
/** Whether to convert string to bytes using UTF-8 encoding. */
private boolean convertString = true;
@@ -179,24 +175,6 @@ public class PortableMarshaller extends AbstractMarshaller {
}
/**
- * If {@code true} then date values converted to {@link Timestamp} on deserialization.
- * <p>
- * Default value is {@code true}.
- *
- * @return Flag indicating whether date values converted to {@link Timestamp} during unmarshalling.
- */
- public boolean isUseTimestamp() {
- return useTs;
- }
-
- /**
- * @param useTs Flag indicating whether date values converted to {@link Timestamp} during unmarshalling.
- */
- public void setUseTimestamp(boolean useTs) {
- this.useTs = useTs;
- }
-
- /**
* Gets strings must be converted to or from bytes using UTF-8 encoding.
* <p>
* Default value is {@code true}.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/portable/PortableRawReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableRawReader.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableRawReader.java
index 3bae2e1..4b3dc4c 100644
--- a/modules/core/src/main/java/org/apache/ignite/portable/PortableRawReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/portable/PortableRawReader.java
@@ -188,6 +188,12 @@ public interface PortableRawReader {
@Nullable public Date[] readDateArray() throws PortableException;
/**
+ * @return Timestamp array.
+ * @throws PortableException In case of error.
+ */
+ @Nullable public Timestamp[] readTimestampArray() throws PortableException;
+
+ /**
* @return Object array.
* @throws PortableException In case of error.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/portable/PortableRawWriter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableRawWriter.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableRawWriter.java
index 53f4f92..245f755 100644
--- a/modules/core/src/main/java/org/apache/ignite/portable/PortableRawWriter.java
+++ b/modules/core/src/main/java/org/apache/ignite/portable/PortableRawWriter.java
@@ -191,6 +191,12 @@ public interface PortableRawWriter {
* @param val Value to write.
* @throws PortableException In case of error.
*/
+ public void writeTimestampArray(@Nullable Timestamp[] val) throws PortableException;
+
+ /**
+ * @param val Value to write.
+ * @throws PortableException In case of error.
+ */
public void writeObjectArray(@Nullable Object[] val) throws PortableException;
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/portable/PortableReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableReader.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableReader.java
index 58f078d..f2b1cda 100644
--- a/modules/core/src/main/java/org/apache/ignite/portable/PortableReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/portable/PortableReader.java
@@ -222,6 +222,13 @@ public interface PortableReader {
/**
* @param fieldName Field name.
+ * @return Timestamp array.
+ * @throws PortableException In case of error.
+ */
+ @Nullable public Timestamp[] readTimestampArray(String fieldName) throws PortableException;
+
+ /**
+ * @param fieldName Field name.
* @return Object array.
* @throws PortableException In case of error.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/portable/PortableTypeConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableTypeConfiguration.java
index 5e6e09d..68f0514 100644
--- a/modules/core/src/main/java/org/apache/ignite/portable/PortableTypeConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/portable/PortableTypeConfiguration.java
@@ -41,9 +41,6 @@ public class PortableTypeConfiguration {
/** Serializer. */
private PortableSerializer serializer;
- /** Use timestamp flag. */
- private Boolean useTs;
-
/** Meta data enabled flag. */
private Boolean metaDataEnabled;
@@ -121,22 +118,6 @@ public class PortableTypeConfiguration {
}
/**
- * If {@code true} then date values converted to {@link Timestamp} during unmarshalling.
- *
- * @return Flag indicating whether date values converted to {@link Timestamp} during unmarshalling.
- */
- public Boolean isUseTimestamp() {
- return useTs;
- }
-
- /**
- * @param useTs Flag indicating whether date values converted to {@link Timestamp} during unmarshalling.
- */
- public void setUseTimestamp(Boolean useTs) {
- this.useTs = useTs;
- }
-
- /**
* Defines whether meta data is collected for this type. If provided, this value will override
* {@link PortableMarshaller#isMetaDataEnabled()} property.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/main/java/org/apache/ignite/portable/PortableWriter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/portable/PortableWriter.java b/modules/core/src/main/java/org/apache/ignite/portable/PortableWriter.java
index 0d7160f..99bd5c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/portable/PortableWriter.java
+++ b/modules/core/src/main/java/org/apache/ignite/portable/PortableWriter.java
@@ -225,6 +225,13 @@ public interface PortableWriter {
* @param val Value to write.
* @throws PortableException In case of error.
*/
+ public void writeTimestampArray(String fieldName, @Nullable Timestamp[] val) throws PortableException;
+
+ /**
+ * @param fieldName Field name.
+ * @param val Value to write.
+ * @throws PortableException In case of error.
+ */
public void writeObjectArray(String fieldName, @Nullable Object[] val) throws PortableException;
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
index 61ec714..d8eff6d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderAdditionalSelfTest.java
@@ -258,6 +258,24 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
/**
*
*/
+ public void testTimestampArrayModification() {
+ TestObjectAllTypes obj = new TestObjectAllTypes();
+
+ obj.tsArr = new Timestamp[] {new Timestamp(111222333), new Timestamp(222333444)};
+
+ PortableBuilderImpl mutObj = wrap(obj);
+
+ Timestamp[] arr = mutObj.getField("tsArr");
+ arr[0] = new Timestamp(333444555);
+
+ TestObjectAllTypes res = mutObj.build().deserialize();
+
+ Assert.assertArrayEquals(new Timestamp[] {new Timestamp(333444555), new Timestamp(222333444)}, res.tsArr);
+ }
+
+ /**
+ *
+ */
public void testUUIDArrayModification() {
TestObjectAllTypes obj = new TestObjectAllTypes();
@@ -1012,6 +1030,19 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
PortableBuilderImpl mutableObj = wrap(obj);
+ assertEquals(Date.class, mutableObj.getField("foo").getClass());
+ }
+
+ /**
+ *
+ */
+ public void testTimestampInObjectField() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ obj.foo = new Timestamp(100020003);
+
+ PortableBuilderImpl mutableObj = wrap(obj);
+
assertEquals(Timestamp.class, mutableObj.getField("foo").getClass());
}
@@ -1025,6 +1056,19 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
PortableBuilderImpl mutableObj = wrap(obj);
+ assertEquals(Date.class, ((List<?>)mutableObj.getField("foo")).get(0).getClass());
+ }
+
+ /**
+ *
+ */
+ public void testTimestampInCollection() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ obj.foo = Lists.newArrayList(new Timestamp(100020003));
+
+ PortableBuilderImpl mutableObj = wrap(obj);
+
assertEquals(Timestamp.class, ((List<?>)mutableObj.getField("foo")).get(0).getClass());
}
@@ -1037,7 +1081,7 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
PortableBuilderImpl mutableObj = wrap(obj);
- Date[] arr = {new Date()};
+ Date[] arr = { new Date() };
mutableObj.setField("foo", arr);
@@ -1050,6 +1094,25 @@ public class GridPortableBuilderAdditionalSelfTest extends GridCommonAbstractTes
/**
*
*/
+ @SuppressWarnings("AssertEqualsBetweenInconvertibleTypes")
+ public void testTimestampArrayOverride() {
+ TestObjectContainer obj = new TestObjectContainer();
+
+ PortableBuilderImpl mutableObj = wrap(obj);
+
+ Timestamp[] arr = { new Timestamp(100020003) };
+
+ mutableObj.setField("foo", arr);
+
+ TestObjectContainer res = mutableObj.build().deserialize();
+
+ assertEquals(Timestamp[].class, res.foo.getClass());
+ assertTrue(Objects.deepEquals(arr, res.foo));
+ }
+
+ /**
+ *
+ */
public void testChangeMap() {
AddressBook addrBook = new AddressBook();
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
index 7f23c1f..331d9dc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableBuilderSelfTest.java
@@ -18,10 +18,12 @@
package org.apache.ignite.internal.portable;
import java.math.BigDecimal;
+import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -133,7 +135,7 @@ public class GridPortableBuilderSelfTest extends GridCommonAbstractTest {
assertEquals("class".hashCode(), po.typeId());
assertEquals(100, po.hashCode());
- assertEquals((byte)1, po.<Byte>field("byteField").byteValue());
+ assertEquals((byte) 1, po.<Byte>field("byteField").byteValue());
}
/**
@@ -301,6 +303,25 @@ public class GridPortableBuilderSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
+ public void testDateField() throws Exception {
+ Date date = new Date();
+
+ assertEquals(date, builder("C").setField("d", date).build().<Date>field("d"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTimestampField() throws Exception {
+ Timestamp ts = new Timestamp(new Date().getTime());
+ ts.setNanos(1000);
+
+ assertEquals(ts, builder("C").setField("t", ts).build().<Timestamp>field("t"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testUuidField() throws Exception {
PortableBuilder builder = builder("Class");
@@ -506,6 +527,33 @@ public class GridPortableBuilderSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
+ public void testDateArrayField() throws Exception {
+ Date date1 = new Date();
+ Date date2 = new Date(date1.getTime() + 1000);
+
+ Date[] dateArr = new Date[] { date1, date2 };
+
+ assertTrue(Arrays.equals(dateArr, builder("C").setField("da", dateArr).build().<Date[]>field("da")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTimestampArrayField() throws Exception {
+ Timestamp ts1 = new Timestamp(new Date().getTime());
+ Timestamp ts2 = new Timestamp(new Date().getTime() + 1000);
+
+ ts1.setNanos(1000);
+ ts2.setNanos(2000);
+
+ Timestamp[] tsArr = new Timestamp[] { ts1, ts2 };
+
+ assertTrue(Arrays.equals(tsArr, builder("C").setField("ta", tsArr).build().<Timestamp[]>field("ta")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testUuidArrayField() throws Exception {
PortableBuilder builder = builder("Class");
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
index 7f1ca6b..2b29e4d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
@@ -196,15 +196,6 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
Date val = marshalUnmarshal(date);
assertEquals(date, val);
- assertEquals(Timestamp.class, val.getClass()); // With default configuration should unmarshal as Timestamp.
-
- PortableMarshaller marsh = new PortableMarshaller();
-
- marsh.setUseTimestamp(false);
-
- val = marshalUnmarshal(date, marsh);
-
- assertEquals(date, val);
assertEquals(Date.class, val.getClass());
}
@@ -443,16 +434,12 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
- public void testUseTimestampFlag() throws Exception {
+ public void testDateAndTimestampInSingleObject() throws Exception {
PortableTypeConfiguration cfg1 = new PortableTypeConfiguration(DateClass1.class.getName());
- PortableTypeConfiguration cfg2 = new PortableTypeConfiguration(DateClass2.class.getName());
-
- cfg2.setUseTimestamp(false);
-
PortableMarshaller marsh = new PortableMarshaller();
- marsh.setTypeConfigurations(Arrays.asList(cfg1, cfg2));
+ marsh.setTypeConfigurations(Arrays.asList(cfg1));
Date date = new Date();
Timestamp ts = new Timestamp(System.currentTimeMillis());
@@ -461,32 +448,16 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
obj1.date = date;
obj1.ts = ts;
- DateClass2 obj2 = new DateClass2();
- obj2.date = date;
- obj2.ts = ts;
-
PortableObject po1 = marshal(obj1, marsh);
assertEquals(date, po1.field("date"));
- assertEquals(Timestamp.class, po1.field("date").getClass());
+ assertEquals(Date.class, po1.field("date").getClass());
assertEquals(ts, po1.field("ts"));
-
- PortableObject po2 = marshal(obj2, marsh);
-
- assertEquals(date, po2.field("date"));
- assertEquals(Date.class, po2.field("date").getClass());
- assertEquals(new Date(ts.getTime()), po2.field("ts"));
- assertEquals(Date.class, po2.field("ts").getClass());
+ assertEquals(Timestamp.class, po1.field("ts").getClass());
obj1 = po1.deserialize();
assertEquals(date, obj1.date);
- assertEquals(Date.class, obj1.date.getClass());
assertEquals(ts, obj1.ts);
-
- obj2 = po2.deserialize();
- assertEquals(date, obj2.date);
- assertEquals(Date.class, obj2.date.getClass());
- assertEquals(ts, obj2.ts);
}
/**
@@ -3604,16 +3575,6 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest {
}
/**
- */
- private static class DateClass2 {
- /** */
- private Date date;
-
- /** */
- private Timestamp ts;
- }
-
- /**
*
*/
private static class NoPublicConstructor {
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
index e49514b..a2ae71f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/mutabletest/GridPortableTestClasses.java
@@ -24,6 +24,7 @@ import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.math.BigDecimal;
+import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -184,6 +185,9 @@ public class GridPortableTestClasses {
public Date date;
/** */
+ public Timestamp ts;
+
+ /** */
public byte[] bArr;
/** */
@@ -220,6 +224,9 @@ public class GridPortableTestClasses {
public Date[] dateArr;
/** */
+ public Timestamp[] tsArr;
+
+ /** */
public TestObjectEnum anEnum;
/** */
@@ -273,6 +280,7 @@ public class GridPortableTestClasses {
str = "abc";
uuid = new UUID(1, 1);
date = new Date(1000000);
+ ts = new Timestamp(100020003);
bArr = new byte[] {1, 2, 3};
sArr = new short[] {1, 2, 3};
@@ -287,6 +295,7 @@ public class GridPortableTestClasses {
uuidArr = new UUID[] {new UUID(1, 1), new UUID(2, 2)};
bdArr = new BigDecimal[] {new BigDecimal(1000), BigDecimal.TEN};
dateArr = new Date[] {new Date(1000000), new Date(200000)};
+ tsArr = new Timestamp[] {new Timestamp(100020003), new Timestamp(200030004)};
anEnum = TestObjectEnum.A;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
index 2685dec..c84b219 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Model/TestModel.cs
@@ -71,8 +71,8 @@ namespace Apache.Ignite.Benchmarks.Model
writer.WriteDoubleArray("DoubleArray", DoubleArray);
writer.WriteDecimal("Decimal", Decimal);
writer.WriteDecimalArray("DecimalArray", DecimalArray);
- writer.WriteDate("Date", Date);
- writer.WriteDateArray("DateArray", DateArray);
+ writer.WriteTimestamp("Date", Date);
+ writer.WriteTimestampArray("DateArray", DateArray);
writer.WriteString("String", String);
writer.WriteStringArray("StringArray", StringArray);
writer.WriteGuid("Guid", Guid);
@@ -100,8 +100,8 @@ namespace Apache.Ignite.Benchmarks.Model
DoubleArray = reader.ReadDoubleArray("DoubleArray");
Decimal = reader.ReadDecimal("Decimal");
DecimalArray = reader.ReadDecimalArray("DecimalArray");
- Date = reader.ReadDate("Date");
- DateArray = reader.ReadDateArray("DateArray");
+ Date = reader.ReadTimestamp("Date");
+ DateArray = reader.ReadTimestampArray("DateArray");
String = reader.ReadString("String");
StringArray = reader.ReadStringArray("StringArray");
Guid = reader.ReadObject<Guid>("Guid");
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
index 53e066d..bb1cf06 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableApiSelfTest.cs
@@ -801,17 +801,13 @@ namespace Apache.Ignite.Core.Tests.Portable
[Test]
public void TestStringDateGuidEnum()
{
- DateTime date = DateTime.Now.ToUniversalTime();
DateTime? nDate = DateTime.Now.ToUniversalTime();
- Guid guid = Guid.NewGuid();
Guid? nGuid = Guid.NewGuid();
IPortableObject portObj = _grid.GetPortables().GetBuilder(typeof(StringDateGuidEnum))
.SetField("fStr", "str")
- .SetField("fDate", date)
.SetField("fNDate", nDate)
- .SetField("fGuid", guid)
.SetField("fNGuid", nGuid)
.SetField("fEnum", TestEnum.One)
.SetField("fStrArr", new[] { "str" })
@@ -827,23 +823,19 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(typeof(StringDateGuidEnum).Name, meta.TypeName);
- Assert.AreEqual(10, meta.Fields.Count);
+ Assert.AreEqual(8, meta.Fields.Count);
Assert.AreEqual(PortableTypeNames.TypeNameString, meta.GetFieldTypeName("fStr"));
- Assert.AreEqual(PortableTypeNames.TypeNameDate, meta.GetFieldTypeName("fDate"));
- Assert.AreEqual(PortableTypeNames.TypeNameDate, meta.GetFieldTypeName("fNDate"));
- Assert.AreEqual(PortableTypeNames.TypeNameGuid, meta.GetFieldTypeName("fGuid"));
+ Assert.AreEqual(PortableTypeNames.TypeNameTimestamp, meta.GetFieldTypeName("fNDate"));
Assert.AreEqual(PortableTypeNames.TypeNameGuid, meta.GetFieldTypeName("fNGuid"));
Assert.AreEqual(PortableTypeNames.TypeNameEnum, meta.GetFieldTypeName("fEnum"));
Assert.AreEqual(PortableTypeNames.TypeNameArrayString, meta.GetFieldTypeName("fStrArr"));
- Assert.AreEqual(PortableTypeNames.TypeNameArrayDate, meta.GetFieldTypeName("fDateArr"));
+ Assert.AreEqual(PortableTypeNames.TypeNameArrayTimestamp, meta.GetFieldTypeName("fDateArr"));
Assert.AreEqual(PortableTypeNames.TypeNameArrayGuid, meta.GetFieldTypeName("fGuidArr"));
Assert.AreEqual(PortableTypeNames.TypeNameArrayEnum, meta.GetFieldTypeName("fEnumArr"));
Assert.AreEqual("str", portObj.GetField<string>("fStr"));
- Assert.AreEqual(date, portObj.GetField<DateTime>("fDate"));
Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
- Assert.AreEqual(guid, portObj.GetField<Guid>("fGuid"));
Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
Assert.AreEqual(TestEnum.One, portObj.GetField<TestEnum>("fEnum"));
Assert.AreEqual(new[] { "str" }, portObj.GetField<string[]>("fStrArr"));
@@ -854,9 +846,7 @@ namespace Apache.Ignite.Core.Tests.Portable
StringDateGuidEnum obj = portObj.Deserialize<StringDateGuidEnum>();
Assert.AreEqual("str", obj.FStr);
- Assert.AreEqual(date, obj.FDate);
Assert.AreEqual(nDate, obj.FnDate);
- Assert.AreEqual(guid, obj.FGuid);
Assert.AreEqual(nGuid, obj.FnGuid);
Assert.AreEqual(TestEnum.One, obj.FEnum);
Assert.AreEqual(new[] { "str" }, obj.FStrArr);
@@ -865,17 +855,13 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(new[] { TestEnum.One }, obj.FEnumArr);
// Overwrite.
- date = DateTime.Now.ToUniversalTime();
nDate = DateTime.Now.ToUniversalTime();
- guid = Guid.NewGuid();
nGuid = Guid.NewGuid();
portObj = _grid.GetPortables().GetBuilder(typeof(StringDateGuidEnum))
.SetField("fStr", "str2")
- .SetField("fDate", date)
.SetField("fNDate", nDate)
- .SetField("fGuid", guid)
.SetField("fNGuid", nGuid)
.SetField("fEnum", TestEnum.Two)
.SetField("fStrArr", new[] { "str2" })
@@ -888,9 +874,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(200, portObj.GetHashCode());
Assert.AreEqual("str2", portObj.GetField<string>("fStr"));
- Assert.AreEqual(date, portObj.GetField<DateTime>("fDate"));
Assert.AreEqual(nDate, portObj.GetField<DateTime?>("fNDate"));
- Assert.AreEqual(guid, portObj.GetField<Guid>("fGuid"));
Assert.AreEqual(nGuid, portObj.GetField<Guid?>("fNGuid"));
Assert.AreEqual(TestEnum.Two, portObj.GetField<TestEnum>("fEnum"));
Assert.AreEqual(new[] { "str2" }, portObj.GetField<string[]>("fStrArr"));
@@ -901,9 +885,7 @@ namespace Apache.Ignite.Core.Tests.Portable
obj = portObj.Deserialize<StringDateGuidEnum>();
Assert.AreEqual("str2", obj.FStr);
- Assert.AreEqual(date, obj.FDate);
Assert.AreEqual(nDate, obj.FnDate);
- Assert.AreEqual(guid, obj.FGuid);
Assert.AreEqual(nGuid, obj.FnGuid);
Assert.AreEqual(TestEnum.Two, obj.FEnum);
Assert.AreEqual(new[] { "str2" }, obj.FStrArr);
@@ -1460,9 +1442,7 @@ namespace Apache.Ignite.Core.Tests.Portable
public class StringDateGuidEnum
{
public string FStr;
- public DateTime FDate;
public DateTime? FnDate;
- public Guid FGuid;
public Guid? FnGuid;
public TestEnum FEnum;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
index f06bf43..62d52f6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Portable/PortableSelfTest.cs
@@ -498,17 +498,7 @@ namespace Apache.Ignite.Core.Tests.Portable
Assert.AreEqual(vals, newVals);
}
-
- /**
- * <summary>Check write of date.</summary>
- */
- [Test]
- public void TestWriteDate() {
- DateTime time = DateTime.Now.ToUniversalTime();
-
- Assert.AreEqual(_marsh.Unmarshal<DateTime>(_marsh.Marshal(time)), time);
- }
-
+
/// <summary>
/// Test object with dates.
/// </summary>
@@ -530,18 +520,12 @@ namespace Apache.Ignite.Core.Tests.Portable
DateTimeType otherObj = marsh.Unmarshal<DateTimeType>(marsh.Marshal(obj));
- Assert.AreEqual(obj.Loc, otherObj.Loc);
Assert.AreEqual(obj.Utc, otherObj.Utc);
- Assert.AreEqual(obj.LocNull, otherObj.LocNull);
Assert.AreEqual(obj.UtcNull, otherObj.UtcNull);
- Assert.AreEqual(obj.LocArr, otherObj.LocArr);
Assert.AreEqual(obj.UtcArr, otherObj.UtcArr);
- Assert.AreEqual(obj.LocRaw, otherObj.LocRaw);
Assert.AreEqual(obj.UtcRaw, otherObj.UtcRaw);
- Assert.AreEqual(obj.LocNullRaw, otherObj.LocNullRaw);
Assert.AreEqual(obj.UtcNullRaw, otherObj.UtcNullRaw);
- Assert.AreEqual(obj.LocArrRaw, otherObj.LocArrRaw);
Assert.AreEqual(obj.UtcArrRaw, otherObj.UtcArrRaw);
}
@@ -2059,22 +2043,16 @@ namespace Apache.Ignite.Core.Tests.Portable
/// </summary>
public class DateTimeType : IPortableMarshalAware
{
- public DateTime Loc;
public DateTime Utc;
- public DateTime? LocNull;
public DateTime? UtcNull;
- public DateTime?[] LocArr;
public DateTime?[] UtcArr;
- public DateTime LocRaw;
public DateTime UtcRaw;
- public DateTime? LocNullRaw;
public DateTime? UtcNullRaw;
- public DateTime?[] LocArrRaw;
public DateTime?[] UtcArrRaw;
/// <summary>
@@ -2083,63 +2061,45 @@ namespace Apache.Ignite.Core.Tests.Portable
/// <param name="now">Current local time.</param>
public DateTimeType(DateTime now)
{
- Loc = now;
Utc = now.ToUniversalTime();
- LocNull = Loc;
UtcNull = Utc;
- LocArr = new DateTime?[] { Loc };
UtcArr = new DateTime?[] { Utc };
- LocRaw = Loc;
UtcRaw = Utc;
- LocNullRaw = LocNull;
UtcNullRaw = UtcNull;
- LocArrRaw = new[] { LocArr[0] };
UtcArrRaw = new[] { UtcArr[0] };
}
/** <inheritDoc /> */
public void WritePortable(IPortableWriter writer)
{
- writer.WriteDate("loc", Loc);
- writer.WriteDate("utc", Utc);
- writer.WriteDate("locNull", LocNull);
- writer.WriteDate("utcNull", UtcNull);
- writer.WriteDateArray("locArr", LocArr);
- writer.WriteDateArray("utcArr", UtcArr);
+ writer.WriteTimestamp("utc", Utc);
+ writer.WriteTimestamp("utcNull", UtcNull);
+ writer.WriteTimestampArray("utcArr", UtcArr);
IPortableRawWriter rawWriter = writer.GetRawWriter();
- rawWriter.WriteDate(LocRaw);
- rawWriter.WriteDate(UtcRaw);
- rawWriter.WriteDate(LocNullRaw);
- rawWriter.WriteDate(UtcNullRaw);
- rawWriter.WriteDateArray(LocArrRaw);
- rawWriter.WriteDateArray(UtcArrRaw);
+ rawWriter.WriteTimestamp(UtcRaw);
+ rawWriter.WriteTimestamp(UtcNullRaw);
+ rawWriter.WriteTimestampArray(UtcArrRaw);
}
/** <inheritDoc /> */
public void ReadPortable(IPortableReader reader)
{
- Loc = reader.ReadDate("loc", true).Value;
- Utc = reader.ReadDate("utc", false).Value;
- LocNull = reader.ReadDate("loc", true).Value;
- UtcNull = reader.ReadDate("utc", false).Value;
- LocArr = reader.ReadDateArray("locArr", true);
- UtcArr = reader.ReadDateArray("utcArr", false);
+ Utc = reader.ReadTimestamp("utc").Value;
+ UtcNull = reader.ReadTimestamp("utc").Value;
+ UtcArr = reader.ReadTimestampArray("utcArr");
IPortableRawReader rawReader = reader.GetRawReader();
- LocRaw = rawReader.ReadDate(true).Value;
- UtcRaw = rawReader.ReadDate(false).Value;
- LocNullRaw = rawReader.ReadDate(true).Value;
- UtcNullRaw = rawReader.ReadDate(false).Value;
- LocArrRaw = rawReader.ReadDateArray(true);
- UtcArrRaw = rawReader.ReadDateArray(false);
+ UtcRaw = rawReader.ReadTimestamp().Value;
+ UtcNullRaw = rawReader.ReadTimestamp().Value;
+ UtcArrRaw = rawReader.ReadTimestampArray();
}
}
[07/17] ignite git commit: IGNITE-1572: .Net: Removed unnecessary
wrappers.
Posted by ag...@apache.org.
IGNITE-1572: .Net: Removed unnecessary wrappers.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9d67c20c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9d67c20c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9d67c20c
Branch: refs/heads/ignite-950-new
Commit: 9d67c20c852455e767c49588956f255cc9a0a317
Parents: f8b18cc
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Fri Oct 23 12:42:30 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Oct 23 12:42:30 2015 +0300
----------------------------------------------------------------------
.../Interop/TaskBenchmark.cs | 2 +-
.../Cache/CacheAbstractTest.cs | 25 +++-
.../Continuous/ContinuousQueryAbstractTest.cs | 2 +-
.../Compute/ComputeApiTest.cs | 4 +-
.../Compute/ComputeMultithreadedTest.cs | 4 +-
.../Compute/FailoverTaskSelfTest.cs | 2 +-
.../Compute/IgniteExceptionTaskSelfTest.cs | 11 +-
.../Compute/PortableTaskTest.cs | 60 +++++----
.../Compute/ResourceTaskTest.cs | 8 +-
.../Compute/TaskAdapterTest.cs | 4 +-
.../Compute/TaskResultTest.cs | 6 +-
.../Examples/PathUtil.cs | 1 -
.../IgniteManagerTest.cs | 1 -
.../Process/IgniteProcess.cs | 1 -
.../SerializationTest.cs | 4 +-
.../Apache.Ignite.Core.csproj | 2 -
.../Compute/ComputeJobAdapter.cs | 2 +-
.../Compute/ComputeJobResultPolicy.cs | 2 +-
.../Compute/ComputeTaskAdapter.cs | 4 +-
.../ComputeTaskNoResultCacheAttribute.cs | 2 +-
.../Apache.Ignite.Core/Compute/IComputeJob.cs | 4 +-
.../Compute/IComputeJobResult.cs | 25 ++--
.../Apache.Ignite.Core/Compute/IComputeTask.cs | 2 +-
.../Datastream/StreamTransformer.cs | 2 +-
.../Impl/Cache/CacheEntryFilterHolder.cs | 4 +-
.../Impl/Cache/CacheEntryProcessorHolder.cs | 8 +-
.../Cache/CacheEntryProcessorResultHolder.cs | 3 +-
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 13 +-
.../Continuous/ContinuousQueryFilterHolder.cs | 7 +-
.../Impl/Common/PortableResultWrapper.cs | 67 ----------
.../Closure/ComputeAbstractClosureTask.cs | 4 +-
.../Impl/Compute/Closure/ComputeActionJob.cs | 4 +-
.../Impl/Compute/Closure/ComputeFuncJob.cs | 10 +-
.../Compute/Closure/ComputeMultiClosureTask.cs | 2 +-
.../Impl/Compute/Closure/ComputeOutFuncJob.cs | 4 +-
.../Closure/ComputeReducingClosureTask.cs | 2 +-
.../Compute/Closure/ComputeSingleClosureTask.cs | 2 +-
.../Impl/Compute/ComputeFunc.cs | 4 +-
.../Impl/Compute/ComputeJob.cs | 4 +-
.../Impl/Compute/ComputeJobHolder.cs | 6 +-
.../Compute/ComputeJobResultGenericWrapper.cs | 15 ++-
.../Impl/Compute/ComputeJobResultImpl.cs | 15 ++-
.../Impl/Compute/ComputeOutFunc.cs | 4 +-
.../Impl/Compute/ComputeTaskHolder.cs | 20 +--
.../Impl/Datastream/StreamReceiverHolder.cs | 6 +-
.../Apache.Ignite.Core/Impl/Events/Events.cs | 4 +-
.../Impl/Events/RemoteListenEventFilter.cs | 3 +-
.../Impl/Messaging/MessageListenerHolder.cs | 4 +-
.../Impl/Portable/PortableMarshaller.cs | 3 -
.../PortableOrSerializableObjectHolder.cs | 64 ----------
.../Impl/Portable/PortableUtils.cs | 128 +------------------
.../Impl/Portable/SerializableObjectHolder.cs | 13 +-
.../Impl/Services/Services.cs | 4 +-
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 2 +-
.../Portable/IPortableBuilder.cs | 2 -
.../Compute/AverageSalaryTask.cs | 2 +-
56 files changed, 189 insertions(+), 424 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/TaskBenchmark.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/TaskBenchmark.cs b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/TaskBenchmark.cs
index 6a2585c..0312f95 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/TaskBenchmark.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Benchmarks/Interop/TaskBenchmark.cs
@@ -56,7 +56,7 @@ namespace Apache.Ignite.Benchmarks.Interop
}
/** <inheritDoc /> */
- public ComputeJobResultPolicy Result(IComputeJobResult<object> res, IList<IComputeJobResult<object>> rcvd)
+ public ComputeJobResultPolicy OnResult(IComputeJobResult<object> res, IList<IComputeJobResult<object>> rcvd)
{
return ComputeJobResultPolicy.Wait;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
index 94ec2d6..19ea37d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -21,7 +21,6 @@ namespace Apache.Ignite.Core.Tests.Cache
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
- using System.Runtime.Serialization;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -2828,6 +2827,22 @@ namespace Apache.Ignite.Core.Tests.Cache
}
[Test]
+ public void TestSerializableKeepPortable()
+ {
+ var cache = Cache<int, TestSerializableObject>();
+
+ var obj = new TestSerializableObject {Name = "Vasya", Id = 128};
+
+ cache.Put(1, obj);
+
+ var portableResult = cache.WithKeepPortable<int, IPortableObject>().Get(1);
+
+ var resultObj = portableResult.Deserialize<TestSerializableObject>();
+
+ Assert.AreEqual(obj, resultObj);
+ }
+
+ [Test]
public void TestInvoke()
{
TestInvoke(false);
@@ -2849,7 +2864,7 @@ namespace Apache.Ignite.Core.Tests.Cache
TestInvoke<NonSerializableCacheEntryProcessor>(async);
Assert.Fail();
}
- catch (SerializationException)
+ catch (PortableException)
{
// Expected
}
@@ -2884,7 +2899,7 @@ namespace Apache.Ignite.Core.Tests.Cache
AssertThrowsCacheEntryProcessorException(
() => cache.Invoke(key, new T {ThrowErrPortable = true}, arg));
AssertThrowsCacheEntryProcessorException(
- () => cache.Invoke(key, new T { ThrowErrNonSerializable = true }, arg), "SerializationException");
+ () => cache.Invoke(key, new T { ThrowErrNonSerializable = true }, arg), "PortableException");
}
private static void AssertThrowsCacheEntryProcessorException(Action action, string containsText = null)
@@ -2930,7 +2945,7 @@ namespace Apache.Ignite.Core.Tests.Cache
TestInvokeAll<NonSerializableCacheEntryProcessor>(async, i);
Assert.Fail();
}
- catch (SerializationException)
+ catch (PortableException)
{
// Expected
}
@@ -2978,7 +2993,7 @@ namespace Apache.Ignite.Core.Tests.Cache
TestInvokeAllException(cache, entries, new T { ThrowErrPortable = true, ThrowOnKey = errKey },
arg, errKey);
TestInvokeAllException(cache, entries, new T { ThrowErrNonSerializable = true, ThrowOnKey = errKey },
- arg, errKey, "SerializationException");
+ arg, errKey, "PortableException");
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
index e0dcdaa..c4d2b36 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
@@ -491,7 +491,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
}
else
{
- Assert.Throws<SerializationException>(() =>
+ Assert.Throws<PortableException>(() =>
{
using (cache1.QueryContinuous(qry))
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
index 4c451e7..b0388cd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeApiTest.cs
@@ -1153,7 +1153,7 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- public ComputeJobResultPolicy Result(IComputeJobResult<NetSimpleJobResult> res,
+ public ComputeJobResultPolicy OnResult(IComputeJobResult<NetSimpleJobResult> res,
IList<IComputeJobResult<NetSimpleJobResult>> rcvd)
{
return ComputeJobResultPolicy.Wait;
@@ -1162,7 +1162,7 @@ namespace Apache.Ignite.Core.Tests.Compute
/** <inheritDoc /> */
public NetSimpleTaskResult Reduce(IList<IComputeJobResult<NetSimpleJobResult>> results)
{
- return new NetSimpleTaskResult(results.Sum(res => res.Data().Res));
+ return new NetSimpleTaskResult(results.Sum(res => res.Data.Res));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs
index 5b6874f..b03d4a4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ComputeMultithreadedTest.cs
@@ -207,7 +207,7 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- public ComputeJobResultPolicy Result(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
+ public ComputeJobResultPolicy OnResult(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
{
return ComputeJobResultPolicy.Wait;
}
@@ -215,7 +215,7 @@ namespace Apache.Ignite.Core.Tests.Compute
/** <inheritDoc /> */
public int Reduce(IList<IComputeJobResult<int>> results)
{
- return results.Count == 0 ? 0 : results[0].Data();
+ return results.Count == 0 ? 0 : results[0].Data;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
index e46ec64..2bd8e3a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/FailoverTaskSelfTest.cs
@@ -161,7 +161,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
Assert.AreEqual(1, results.Count);
- return results[0].Data();
+ return results[0].Data;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
index 62f860d..31286fe 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/IgniteExceptionTaskSelfTest.cs
@@ -24,6 +24,7 @@ namespace Apache.Ignite.Core.Tests.Compute
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Compute;
+ using Apache.Ignite.Core.Portable;
using Apache.Ignite.Core.Resource;
using NUnit.Framework;
@@ -87,7 +88,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
Mode = ErrorMode.MapJobNotMarshalable;
- SerializationException e = ExecuteWithError() as SerializationException;
+ var e = ExecuteWithError() as PortableException;
Assert.IsNotNull(e);
}
@@ -435,13 +436,13 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- public ComputeJobResultPolicy Result(IComputeJobResult<object> res, IList<IComputeJobResult<object>> rcvd)
+ public ComputeJobResultPolicy OnResult(IComputeJobResult<object> res, IList<IComputeJobResult<object>> rcvd)
{
- if (res.Exception() != null)
- JobErrs.Add(res.Exception());
+ if (res.Exception != null)
+ JobErrs.Add(res.Exception);
else
{
- object res0 = res.Data();
+ object res0 = res.Data;
bool rmt = res0 is GoodJobResult ? ((GoodJobResult)res0).Rmt : ((BadJobResult)res0).Rmt;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
index 736aa61..c63b4f0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/PortableTaskTest.cs
@@ -46,11 +46,11 @@ namespace Apache.Ignite.Core.Tests.Compute
[Test]
public void TestPortableObjectInTask()
{
- IPortableObject taskArg = ToPortable(Grid1, new PortableTaskArgument(100));
+ var taskArg = new PortableWrapper {Item = ToPortable(Grid1, new PortableTaskArgument(100))};
TestTask task = new TestTask(Grid1, taskArg);
- IPortableObject res = Grid1.GetCompute().Execute(task, taskArg);
+ var res = Grid1.GetCompute().Execute(task, taskArg).Item;
Assert.NotNull(res);
@@ -78,46 +78,48 @@ namespace Apache.Ignite.Core.Tests.Compute
portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableTaskArgument)));
portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableTaskResult)));
portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableJob)));
+ portTypeCfgs.Add(new PortableTypeConfiguration(typeof(PortableWrapper)));
}
/// <summary>
/// Test task.
/// </summary>
- public class TestTask : ComputeTaskAdapter<IPortableObject, IPortableObject, IPortableObject>
+ class TestTask : ComputeTaskAdapter<PortableWrapper, PortableWrapper, PortableWrapper>
{
/** */
private readonly IIgnite _grid;
- private readonly IPortableObject _taskArgField;
+ private readonly PortableWrapper _taskArgField;
- public TestTask(IIgnite grid, IPortableObject taskArgField)
+ public TestTask(IIgnite grid, PortableWrapper taskArgField)
{
_grid = grid;
_taskArgField = taskArgField;
}
/** <inheritDoc /> */
- override public IDictionary<IComputeJob<IPortableObject>, IClusterNode> Map(IList<IClusterNode> subgrid, IPortableObject arg)
+ override public IDictionary<IComputeJob<PortableWrapper>, IClusterNode> Map(IList<IClusterNode> subgrid, PortableWrapper arg)
{
Assert.AreEqual(3, subgrid.Count);
Assert.NotNull(_grid);
- IPortableObject taskArg = arg;
+ var taskArg = arg;
CheckTaskArgument(taskArg);
CheckTaskArgument(_taskArgField);
- IDictionary<IComputeJob<IPortableObject>, IClusterNode> jobs = new Dictionary<IComputeJob<IPortableObject>, IClusterNode>();
+ var jobs = new Dictionary<IComputeJob<PortableWrapper>, IClusterNode>();
foreach (IClusterNode node in subgrid)
{
if (!Grid3Name.Equals(node.GetAttribute<string>("org.apache.ignite.ignite.name"))) // Grid3 does not have cache.
{
- PortableJob job = new PortableJob();
-
- job.Arg = ToPortable(_grid, new PortableJobArgument(200));
+ var job = new PortableJob
+ {
+ Arg = new PortableWrapper {Item = ToPortable(_grid, new PortableJobArgument(200))}
+ };
jobs.Add(job, node);
}
@@ -128,8 +130,12 @@ namespace Apache.Ignite.Core.Tests.Compute
return jobs;
}
- private void CheckTaskArgument(IPortableObject taskArg)
+ private void CheckTaskArgument(PortableWrapper arg)
{
+ Assert.IsNotNull(arg);
+
+ var taskArg = arg.Item;
+
Assert.IsNotNull(taskArg);
Assert.AreEqual(100, taskArg.GetField<int>("val"));
@@ -140,15 +146,15 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- override public IPortableObject Reduce(IList<IComputeJobResult<IPortableObject>> results)
+ override public PortableWrapper Reduce(IList<IComputeJobResult<PortableWrapper>> results)
{
Assert.NotNull(_grid);
Assert.AreEqual(2, results.Count);
- foreach (IComputeJobResult<IPortableObject> res in results)
+ foreach (var res in results)
{
- IPortableObject jobRes = res.Data();
+ var jobRes = res.Data.Item;
Assert.NotNull(jobRes);
@@ -159,7 +165,7 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(300, jobResObj.Val);
}
- return ToPortable(_grid, new PortableTaskResult(400));
+ return new PortableWrapper {Item = ToPortable(_grid, new PortableTaskResult(400))};
}
}
@@ -222,26 +228,31 @@ namespace Apache.Ignite.Core.Tests.Compute
/// <summary>
///
/// </summary>
- class PortableJob : IComputeJob<IPortableObject>
+ class PortableJob : IComputeJob<PortableWrapper>
{
[InstanceResource]
private IIgnite _grid = null;
/** */
- public IPortableObject Arg;
+ public PortableWrapper Arg;
/** <inheritDoc /> */
- public IPortableObject Execute()
+
+ public PortableWrapper Execute()
{
Assert.IsNotNull(Arg);
- Assert.AreEqual(200, Arg.GetField<int>("val"));
+ var arg = Arg.Item;
+
+ Assert.IsNotNull(arg);
- PortableJobArgument argObj = Arg.Deserialize<PortableJobArgument>();
+ Assert.AreEqual(200, arg.GetField<int>("val"));
+
+ PortableJobArgument argObj = arg.Deserialize<PortableJobArgument>();
Assert.AreEqual(200, argObj.Val);
- return ToPortable(_grid, new PortableJobResult(300));
+ return new PortableWrapper {Item = ToPortable(_grid, new PortableJobResult(300))};
}
public void Cancel()
@@ -249,5 +260,10 @@ namespace Apache.Ignite.Core.Tests.Compute
// No-op.
}
}
+
+ class PortableWrapper
+ {
+ public IPortableObject Item { get; set; }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
index 55bb9d0..da72c7b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/ResourceTaskTest.cs
@@ -100,7 +100,7 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- public ComputeJobResultPolicy Result(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
+ public ComputeJobResultPolicy OnResult(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
{
return ComputeJobResultPolicy.Wait;
}
@@ -108,7 +108,7 @@ namespace Apache.Ignite.Core.Tests.Compute
/** <inheritDoc /> */
public int Reduce(IList<IComputeJobResult<int>> results)
{
- return results.Sum(res => res.Data());
+ return results.Sum(res => res.Data);
}
}
@@ -509,12 +509,12 @@ namespace Apache.Ignite.Core.Tests.Compute
}
/** <inheritDoc /> */
- public ComputeJobResultPolicy Result(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
+ public ComputeJobResultPolicy OnResult(IComputeJobResult<int> res, IList<IComputeJobResult<int>> rcvd)
{
Assert.IsTrue(rcvd != null);
Assert.IsTrue(rcvd.Count == 0);
- _sum += res.Data();
+ _sum += res.Data;
return ComputeJobResultPolicy.Wait;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
index 7c4d52e..9b58268 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskAdapterTest.cs
@@ -132,7 +132,7 @@ namespace Apache.Ignite.Core.Tests.Compute
HashSet<Guid> nodes = new HashSet<Guid>();
foreach (var res in results) {
- Guid id = res.Data();
+ Guid id = res.Data;
Assert.NotNull(id);
@@ -168,7 +168,7 @@ namespace Apache.Ignite.Core.Tests.Compute
{
Assert.AreEqual(1, results.Count);
- Assert.IsTrue(results[0].Data());
+ Assert.IsTrue(results[0].Data);
return true;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
index 0073d47..7108f59 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Compute/TaskResultTest.cs
@@ -332,7 +332,7 @@ namespace Apache.Ignite.Core.Tests.Compute
var res = results[0];
- Assert.IsNull(res.Exception());
+ Assert.IsNull(res.Exception);
Assert.IsFalse(res.Cancelled);
@@ -340,11 +340,11 @@ namespace Apache.Ignite.Core.Tests.Compute
Assert.AreEqual(GridId(_gridName), res.NodeId);
- var job = res.Job();
+ var job = res.Job;
Assert.IsNotNull(job);
- return res.Data();
+ return res.Data;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs
index 9ac3530..a128b7d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Examples/PathUtil.cs
@@ -18,7 +18,6 @@
namespace Apache.Ignite.Core.Tests.Examples
{
using System.IO;
- using Apache.Ignite.Core.Impl;
/// <summary>
/// Grid path resolver.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteManagerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteManagerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteManagerTest.cs
index 590f0e6..2b73da9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteManagerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteManagerTest.cs
@@ -19,7 +19,6 @@ namespace Apache.Ignite.Core.Tests
{
using System;
using System.IO;
- using Apache.Ignite.Core.Impl;
using Apache.Ignite.Core.Impl.Common;
using NUnit.Framework;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcess.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcess.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcess.cs
index 2d9fbeb..4853d93 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcess.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Process/IgniteProcess.cs
@@ -23,7 +23,6 @@ namespace Apache.Ignite.Core.Tests.Process
using System.Linq;
using System.Text;
using System.Threading;
- using Apache.Ignite.Core.Impl;
using Apache.Ignite.Core.Impl.Common;
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
index e1a543e..07caaf3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
@@ -195,7 +195,7 @@ namespace Apache.Ignite.Core.Tests
return subgrid.ToDictionary(x => (IComputeJob<string>) new ToStringJob {Arg = arg}, x => x);
}
- public ComputeJobResultPolicy Result(IComputeJobResult<string> res, IList<IComputeJobResult<string>> rcvd)
+ public ComputeJobResultPolicy OnResult(IComputeJobResult<string> res, IList<IComputeJobResult<string>> rcvd)
{
return ComputeJobResultPolicy.Wait;
}
@@ -204,7 +204,7 @@ namespace Apache.Ignite.Core.Tests
{
var result = new SerializableXmlDoc();
- result.LoadXml(CombineStrings(results.Select(x => x.Data())));
+ result.LoadXml(CombineStrings(results.Select(x => x.Data)));
return result;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index be96fd9..f314c99 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -186,7 +186,6 @@
<Compile Include="Impl\Common\IFutureInternal.cs" />
<Compile Include="Impl\Common\IgniteHome.cs" />
<Compile Include="Impl\Common\LoadedAssembliesResolver.cs" />
- <Compile Include="Impl\Common\PortableResultWrapper.cs" />
<Compile Include="Impl\Common\TypeCaster.cs" />
<Compile Include="Impl\Compute\Closure\ComputeAbstractClosureTask.cs" />
<Compile Include="Impl\Compute\Closure\ComputeActionJob.cs" />
@@ -263,7 +262,6 @@
<Compile Include="Impl\Portable\PortableMarshaller.cs" />
<Compile Include="Impl\Portable\PortableMode.cs" />
<Compile Include="Impl\Portable\PortableObjectHandle.cs" />
- <Compile Include="Impl\Portable\PortableOrSerializableObjectHolder.cs" />
<Compile Include="Impl\Portable\PortableReaderExtensions.cs" />
<Compile Include="Impl\Portable\PortableReaderHandleDictionary.cs" />
<Compile Include="Impl\Portable\PortableReaderImpl.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeJobAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeJobAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeJobAdapter.cs
index a472b50..2a0ed4e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeJobAdapter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeJobAdapter.cs
@@ -114,7 +114,7 @@ namespace Apache.Ignite.Core.Compute
/// <returns>
/// Job execution result (possibly <c>null</c>). This result will be returned
/// in <see cref="IComputeJobResult{T}" /> object passed into
- /// <see cref="IComputeTask{A,T,R}.Result" />
+ /// <see cref="IComputeTask{TA,T,TR}.OnResult" />
/// on caller node.
/// </returns>
public abstract T Execute();
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeJobResultPolicy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeJobResultPolicy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeJobResultPolicy.cs
index 6fa0808..9807c37 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeJobResultPolicy.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeJobResultPolicy.cs
@@ -21,7 +21,7 @@ namespace Apache.Ignite.Core.Compute
/// <summary>
/// This enumeration provides different types of actions following the last received job result. See
- /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
+ /// <see cref="IComputeTask{TA,T,TR}.OnResult"/>
/// for more details.
/// </summary>
public enum ComputeJobResultPolicy
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
index 5965d2b..367947a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
@@ -42,10 +42,10 @@ namespace Apache.Ignite.Core.Compute
/// <param name="res">Received remote Ignite executable result.</param>
/// <param name="rcvd">All previously received results.</param>
/// <returns>Result policy that dictates how to process further upcoming job results.</returns>
- public virtual ComputeJobResultPolicy Result(IComputeJobResult<TJobRes> res,
+ public virtual ComputeJobResultPolicy OnResult(IComputeJobResult<TJobRes> res,
IList<IComputeJobResult<TJobRes>> rcvd)
{
- Exception err = res.Exception();
+ Exception err = res.Exception;
if (err != null)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskNoResultCacheAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskNoResultCacheAttribute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskNoResultCacheAttribute.cs
index a58aa87..b8a884d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskNoResultCacheAttribute.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskNoResultCacheAttribute.cs
@@ -23,7 +23,7 @@ namespace Apache.Ignite.Core.Compute
/// This attribute disables caching of task results when attached to <see cref="IComputeTask{A,T,R}"/>
/// instance. Use it when number of jobs within task grows too big, or jobs themselves are too large
/// to keep in memory throughout task execution. By default all results are cached and passed into
- /// <see cref="IComputeTask{A,T,R}.Result"/>
+ /// <see cref="IComputeTask{TA,T,TR}.OnResult"/>
/// and <see cref="IComputeTask{A,T,R}.Reduce"/> methods. When this
/// attribute is attached to a task class, then this list of job results will always be empty.
/// </summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs
index 684ff95..36f47d5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJob.cs
@@ -29,7 +29,7 @@ namespace Apache.Ignite.Core.Compute
/// <para />
/// Once job execution is complete, the return value will be sent back to parent task and will
/// be passed into
- /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
+ /// <see cref="IComputeTask{TA,T,TR}.OnResult"/>
/// method via <see cref="IComputeJobResult{T}"/> instance.
/// <para />
/// Ignite job implementation can be injected with <see cref="IIgnite"/> using
@@ -42,7 +42,7 @@ namespace Apache.Ignite.Core.Compute
/// </summary>
/// <returns>Job execution result (possibly <c>null</c>). This result will be returned
/// in <see cref="IComputeJobResult{T}"/> object passed into
- /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
+ /// <see cref="IComputeTask{TA,T,TR}.OnResult"/>
/// on caller node.</returns>
TRes Execute();
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs
index 6369eb5..e5c1c66 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeJobResult.cs
@@ -22,7 +22,7 @@ namespace Apache.Ignite.Core.Compute
/// <summary>
/// Job execution result which gets passed to
- /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
+ /// <see cref="IComputeTask{TA,T,TR}.OnResult"/>
/// method.
/// </summary>
public interface IComputeJobResult<out TRes>
@@ -33,41 +33,34 @@ namespace Apache.Ignite.Core.Compute
/// <para />
/// Note that if task is annotated with <see cref="ComputeTaskNoResultCacheAttribute"/>
/// attribute, then job results will not be cached and will be available only in
- /// <see cref="IComputeTask{A,T,R}.Result(IComputeJobResult{T}, IList{IComputeJobResult{T}})"/>
+ /// <see cref="IComputeTask{TA,T,TR}.OnResult"/>
/// method for every individual job, but not in
- /// <see cref="IComputeTask{A,T,R}.Reduce(IList{IComputeJobResult{T}})"/> method.
- ///
+ /// <see cref="IComputeTask{A,T,R}.Reduce(IList{IComputeJobResult{T}})"/> method.
/// </summary>
/// <returns>Data returned by job.</returns>
- TRes Data();
+ TRes Data { get; }
/// <summary>
/// Gets local instance of remote job produced this result.
/// </summary>
/// <returns></returns>
- IComputeJob<TRes> Job();
+ IComputeJob<TRes> Job { get; }
/// <summary>
/// Gets exception produced by execution of remote job, or <c>null</c> if no
/// exception was produced.
/// </summary>
- /// <returns>Exception or <c>null</c> in case of success.</returns>
- Exception Exception();
+ /// <value>Exception or <c>null</c> in case of success.</value>
+ Exception Exception { get; }
/// <summary>
/// ID of the node where actual job execution occurred.
/// </summary>
- Guid NodeId
- {
- get;
- }
+ Guid NodeId { get; }
/// <summary>
/// Whether the job was cancelled.
/// </summary>
- bool Cancelled
- {
- get;
- }
+ bool Cancelled { get; }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
index d3d7ccf..7677653 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/IComputeTask.cs
@@ -105,7 +105,7 @@ namespace Apache.Ignite.Core.Compute
/// <param name="rcvd">All previously received results. Note that if task class has
/// <see cref="ComputeTaskNoResultCacheAttribute"/> attribute, then this list will be empty.</param>
/// <returns>Result policy that dictates how to process further upcoming job results.</returns>
- ComputeJobResultPolicy Result(IComputeJobResult<TJobRes> res, IList<IComputeJobResult<TJobRes>> rcvd);
+ ComputeJobResultPolicy OnResult(IComputeJobResult<TJobRes> res, IList<IComputeJobResult<TJobRes>> rcvd);
/// <summary>
/// Reduces (or aggregates) results received so far into one compound result to be returned to
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
index d8b4620..cd3e5f6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Datastream/StreamTransformer.cs
@@ -67,7 +67,7 @@ namespace Apache.Ignite.Core.Datastream
w.WriteByte(StreamReceiverHolder.RcvTransformer);
- PortableUtils.WritePortableOrSerializable(w, _proc);
+ w.WriteObject(_proc);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
index 279979a..c01103e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryFilterHolder.cs
@@ -92,7 +92,7 @@ namespace Apache.Ignite.Core.Impl.Cache
{
var writer0 = (PortableWriterImpl)writer.GetRawWriter();
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, _pred));
+ writer0.WithDetach(w => w.WriteObject(_pred));
writer0.WriteBoolean(_keepPortable);
}
@@ -105,7 +105,7 @@ namespace Apache.Ignite.Core.Impl.Cache
{
var reader0 = (PortableReaderImpl)reader.GetRawReader();
- _pred = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+ _pred = reader0.ReadObject<object>();
_keepPortable = reader0.ReadBoolean();
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
index 8b30536..3f21b53 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorHolder.cs
@@ -105,8 +105,8 @@ namespace Apache.Ignite.Core.Impl.Cache
{
var writer0 = (PortableWriterImpl) writer.GetRawWriter();
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, _proc));
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, _arg));
+ writer0.WithDetach(w => w.WriteObject(_proc));
+ writer0.WithDetach(w => w.WriteObject(_arg));
}
/// <summary>
@@ -117,8 +117,8 @@ namespace Apache.Ignite.Core.Impl.Cache
{
var reader0 = (PortableReaderImpl) reader.GetRawReader();
- _proc = PortableUtils.ReadPortableOrSerializable<object>(reader0);
- _arg = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+ _proc = reader0.ReadObject<object>();
+ _arg = reader0.ReadObject<object>();
_processFunc = GetProcessFunc(_proc);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs
index 02928e9..a6641e1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheEntryProcessorResultHolder.cs
@@ -21,7 +21,6 @@ namespace Apache.Ignite.Core.Impl.Cache
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
- using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Portable;
using Apache.Ignite.Core.Impl.Portable.IO;
@@ -101,7 +100,7 @@ namespace Apache.Ignite.Core.Impl.Cache
else
{
writer.WriteByte((byte) MutableCacheEntryState.ErrPortable);
- writer.Write(new PortableResultWrapper(Error));
+ writer.Write(Error);
}
}
catch (Exception marshErr)
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index c689bb4..af230b3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -885,15 +885,10 @@ namespace Apache.Ignite.Core.Impl.Cache
/// <returns>Result.</returns>
private static T GetResultOrThrow<T>(object obj)
{
- var holder = obj as PortableResultWrapper;
+ var err = obj as Exception;
- if (holder != null)
- {
- var err = holder.Result as Exception;
-
- if (err != null)
- throw err as CacheEntryProcessorException ?? new CacheEntryProcessorException(err);
- }
+ if (err != null)
+ throw err as CacheEntryProcessorException ?? new CacheEntryProcessorException(err);
return obj == null ? default(T) : (T) obj;
}
@@ -939,7 +934,7 @@ namespace Apache.Ignite.Core.Impl.Cache
var clsName = item as string;
if (clsName == null)
- return new CacheEntryProcessorException((Exception) ((PortableResultWrapper) item).Result);
+ return new CacheEntryProcessorException((Exception) item);
var msg = Unmarshal<string>(inStream);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
index 5737ed3..a7cb245 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Query/Continuous/ContinuousQueryFilterHolder.cs
@@ -65,10 +65,9 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
/// <param name="writer">Writer.</param>
public void WritePortable(IPortableWriter writer)
{
- PortableWriterImpl rawWriter = (PortableWriterImpl) writer.GetRawWriter();
-
- PortableUtils.WritePortableOrSerializable(rawWriter, _filter);
+ var rawWriter = (PortableWriterImpl) writer.GetRawWriter();
+ rawWriter.WriteObject(_filter);
rawWriter.WriteBoolean(_keepPortable);
}
@@ -80,7 +79,7 @@ namespace Apache.Ignite.Core.Impl.Cache.Query.Continuous
{
var rawReader = (PortableReaderImpl) reader.GetRawReader();
- _filter = PortableUtils.ReadPortableOrSerializable<object>(rawReader);
+ _filter = rawReader.ReadObject<object>();
_keepPortable = rawReader.ReadBoolean();
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.cs
deleted file mode 100644
index c9fddf3..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/PortableResultWrapper.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Common
-{
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Portable;
-
- /// <summary>
- /// Simple wrapper over result to handle marshalling properly.
- /// </summary>
- internal class PortableResultWrapper : IPortableWriteAware
- {
- /** */
- private readonly object _result;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="PortableResultWrapper"/> class.
- /// </summary>
- /// <param name="reader">The reader.</param>
- public PortableResultWrapper(IPortableReader reader)
- {
- var reader0 = (PortableReaderImpl)reader.GetRawReader();
-
- _result = PortableUtils.ReadPortableOrSerializable<object>(reader0);
- }
-
- /// <summary>
- /// Constructor.
- /// </summary>
- /// <param name="res">Result.</param>
- public PortableResultWrapper(object res)
- {
- _result = res;
- }
-
- /// <summary>
- /// Result.
- /// </summary>
- public object Result
- {
- get { return _result; }
- }
-
- /** <inheritDoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- var writer0 = (PortableWriterImpl) writer.GetRawWriter();
-
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, Result));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs
index 1a772c2..286ae3a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs
@@ -60,9 +60,9 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
/// <returns>
/// Result policy that dictates how to process further upcoming job results.
/// </returns>
- public ComputeJobResultPolicy Result(IComputeJobResult<T> res, IList<IComputeJobResult<T>> rcvd)
+ public ComputeJobResultPolicy OnResult(IComputeJobResult<T> res, IList<IComputeJobResult<T>> rcvd)
{
- Exception err = res.Exception();
+ Exception err = res.Exception;
if (err != null)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
index cc5e29f..24f78b3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeActionJob.cs
@@ -65,7 +65,7 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
{
var writer0 = (PortableWriterImpl)writer.GetRawWriter();
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, _action));
+ writer0.WithDetach(w => w.WriteObject(_action));
}
/// <summary>
@@ -76,7 +76,7 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
{
var reader0 = (PortableReaderImpl)reader.GetRawReader();
- _action = PortableUtils.ReadPortableOrSerializable<IComputeAction>(reader0);
+ _action = reader0.ReadObject<IComputeAction>();
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
index 072fe76..5dcd3e8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeFuncJob.cs
@@ -67,8 +67,8 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
{
PortableWriterImpl writer0 = (PortableWriterImpl) writer.GetRawWriter();
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, _clo));
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, _arg));
+ writer0.WithDetach(w => w.WriteObject(_clo));
+ writer0.WithDetach(w => w.WriteObject(_arg));
}
/// <summary>
@@ -78,9 +78,9 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
public ComputeFuncJob(IPortableReader reader)
{
var reader0 = (PortableReaderImpl) reader.GetRawReader();
-
- _clo = PortableUtils.ReadPortableOrSerializable<IComputeFunc>(reader0);
- _arg = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+
+ _clo = reader0.ReadObject<IComputeFunc>();
+ _arg = reader0.ReadObject<object>();
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs
index dd57f6c..f26fe93 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeMultiClosureTask.cs
@@ -42,7 +42,7 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
/** <inheritDoc /> */
protected override ComputeJobResultPolicy Result0(IComputeJobResult<T> res)
{
- _res.Add(res.Data());
+ _res.Add(res.Data);
return ComputeJobResultPolicy.Wait;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
index 11ec157..1b671fd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeOutFuncJob.cs
@@ -62,14 +62,14 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
{
var writer0 = (PortableWriterImpl) writer.GetRawWriter();
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, _clo));
+ writer0.WithDetach(w => w.WriteObject(_clo));
}
public ComputeOutFuncJob(IPortableReader reader)
{
var reader0 = (PortableReaderImpl) reader.GetRawReader();
- _clo = PortableUtils.ReadPortableOrSerializable<IComputeOutFunc>(reader0);
+ _clo = reader0.ReadObject<IComputeOutFunc>();
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeReducingClosureTask.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeReducingClosureTask.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeReducingClosureTask.cs
index a84d7ce..8e2260e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeReducingClosureTask.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeReducingClosureTask.cs
@@ -43,7 +43,7 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
/** <inheritDoc /> */
protected override ComputeJobResultPolicy Result0(IComputeJobResult<T> res)
{
- return _rdc.Collect(res.Data()) ? ComputeJobResultPolicy.Wait : ComputeJobResultPolicy.Reduce;
+ return _rdc.Collect(res.Data) ? ComputeJobResultPolicy.Wait : ComputeJobResultPolicy.Reduce;
}
/** <inheritDoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeSingleClosureTask.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeSingleClosureTask.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeSingleClosureTask.cs
index 6e82c9b..20da4b6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeSingleClosureTask.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeSingleClosureTask.cs
@@ -32,7 +32,7 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
/** <inheritDoc /> */
protected override ComputeJobResultPolicy Result0(IComputeJobResult<T> res)
{
- _res = (TR) res.Data();
+ _res = (TR) res.Data;
// No more results are expected at this point, but we prefer not to alter regular
// task flow.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
index 4195120..f21d3da 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeFunc.cs
@@ -75,7 +75,7 @@ namespace Apache.Ignite.Core.Impl.Compute
{
var writer0 = (PortableWriterImpl)writer.GetRawWriter();
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, _func));
+ writer0.WithDetach(w => w.WriteObject(_func));
}
/// <summary>
@@ -86,7 +86,7 @@ namespace Apache.Ignite.Core.Impl.Compute
{
var reader0 = (PortableReaderImpl)reader.GetRawReader();
- _func = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+ _func = reader0.ReadObject<object>();
_invoker = DelegateTypeDescriptor.GetComputeFunc(_func.GetType());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
index 61cc4d8..eb8fee5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJob.cs
@@ -56,7 +56,7 @@ namespace Apache.Ignite.Core.Impl.Compute
{
var reader0 = (PortableReaderImpl)reader.GetRawReader();
- _job = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+ _job = reader0.ReadObject<object>();
DelegateTypeDescriptor.GetComputeJob(_job.GetType(), out _execute, out _cancel);
}
@@ -104,7 +104,7 @@ namespace Apache.Ignite.Core.Impl.Compute
{
var writer0 = (PortableWriterImpl)writer.GetRawWriter();
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, Job));
+ writer0.WithDetach(w => w.WriteObject(Job));
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
index ab41100..178937c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobHolder.cs
@@ -55,7 +55,7 @@ namespace Apache.Ignite.Core.Impl.Compute
_ignite = reader0.Marshaller.Ignite;
- _job = PortableUtils.ReadPortableOrSerializable<IComputeJob>(reader0);
+ _job = reader0.ReadObject<IComputeJob>();
}
/// <summary>
@@ -113,7 +113,7 @@ namespace Apache.Ignite.Core.Impl.Compute
try
{
// 3. Marshal results.
- PortableUtils.WriteWrappedInvocationResult(writer, success, res);
+ PortableUtils.WriteInvocationResult(writer, success, res);
}
finally
{
@@ -220,7 +220,7 @@ namespace Apache.Ignite.Core.Impl.Compute
{
PortableWriterImpl writer0 = (PortableWriterImpl) writer.GetRawWriter();
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, _job));
+ writer0.WithDetach(w => w.WriteObject(_job));
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultGenericWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultGenericWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultGenericWrapper.cs
index 8173f71..5654d96 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultGenericWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultGenericWrapper.cs
@@ -38,21 +38,24 @@ namespace Apache.Ignite.Core.Impl.Compute
}
/** <inheritdoc /> */
- public T Data()
+
+ public T Data
{
- return (T)_wrappedRes.Data();
+ get { return (T) _wrappedRes.Data; }
}
/** <inheritdoc /> */
- public Exception Exception()
+
+ public Exception Exception
{
- return _wrappedRes.Exception();
+ get { return _wrappedRes.Exception; }
}
/** <inheritdoc /> */
- public IComputeJob<T> Job()
+
+ public IComputeJob<T> Job
{
- return _wrappedRes.Job().Unwrap<object, T>();
+ get { return _wrappedRes.Job.Unwrap<object, T>(); }
}
/** <inheritdoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultImpl.cs
index a35bae0..fe5aedd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeJobResultImpl.cs
@@ -58,21 +58,24 @@ namespace Apache.Ignite.Core.Impl.Compute
}
/** <inheritDoc /> */
- public object Data()
+
+ public object Data
{
- return _data;
+ get { return _data; }
}
/** <inheritDoc /> */
- public Exception Exception()
+
+ public Exception Exception
{
- return _err;
+ get { return _err; }
}
/** <inheritDoc /> */
- public IComputeJob<object> Job()
+
+ public IComputeJob<object> Job
{
- return _job;
+ get { return _job; }
}
/** <inheritDoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
index 3b7e2b5..3746bbe 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeOutFunc.cs
@@ -79,7 +79,7 @@ namespace Apache.Ignite.Core.Impl.Compute
{
var writer0 = (PortableWriterImpl)writer.GetRawWriter();
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, _func));
+ writer0.WithDetach(w => w.WriteObject(_func));
}
/// <summary>
@@ -90,7 +90,7 @@ namespace Apache.Ignite.Core.Impl.Compute
{
var reader0 = (PortableReaderImpl)reader.GetRawReader();
- _func = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+ _func = reader0.ReadObject<object>();
_invoker = DelegateTypeDescriptor.GetComputeOutFunc(_func.GetType());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
index 552e0eb..ef27889 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/ComputeTaskHolder.cs
@@ -299,7 +299,7 @@ namespace Apache.Ignite.Core.Impl.Compute
{
object err;
- var data = PortableUtils.ReadWrappedInvocationResult(reader, out err);
+ var data = PortableUtils.ReadInvocationResult(reader, out err);
// 2. Process the result.
return (int) JobResult0(new ComputeJobResultImpl(data, (Exception) err, job.Job, nodeId.Value, cancelled));
@@ -364,15 +364,9 @@ namespace Apache.Ignite.Core.Impl.Compute
try
{
- if (reader.ReadBoolean())
- {
- PortableResultWrapper res = reader.ReadObject<PortableUserObject>()
- .Deserialize<PortableResultWrapper>();
-
- err = (Exception) res.Result;
- }
- else
- err = ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
+ err = reader.ReadBoolean()
+ ? reader.ReadObject<PortableUserObject>().Deserialize<Exception>()
+ : ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
}
catch (Exception e)
{
@@ -425,17 +419,17 @@ namespace Apache.Ignite.Core.Impl.Compute
ress0 = EmptyRes;
// 2. Invoke user code.
- var policy = _task.Result(new ComputeJobResultGenericWrapper<T>(res), ress0);
+ var policy = _task.OnResult(new ComputeJobResultGenericWrapper<T>(res), ress0);
// 3. Add result to the list only in case of success.
if (_resCache)
{
- var job = res.Job().Unwrap();
+ var job = res.Job.Unwrap();
if (!_resJobs.Add(job))
{
// Duplicate result => find and replace it with the new one.
- var oldRes = _ress.Single(item => item.Job() == job);
+ var oldRes = _ress.Single(item => item.Job == job);
_ress.Remove(oldRes);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
index 32cbc0b..4c72a90 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Datastream/StreamReceiverHolder.cs
@@ -54,8 +54,8 @@ namespace Apache.Ignite.Core.Impl.Datastream
{
var rcvType = reader.ReadByte();
- _rcv = PortableUtils.ReadPortableOrSerializable<object>(reader);
-
+ _rcv = reader.ReadObject<object>();
+
Debug.Assert(_rcv != null);
var type = _rcv.GetType();
@@ -98,7 +98,7 @@ namespace Apache.Ignite.Core.Impl.Datastream
else
{
w.WriteByte(RcvNormal);
- PortableUtils.WritePortableOrSerializable((PortableWriterImpl) writer, _rcv);
+ w.WriteObject(_rcv);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
index 6898a58..99ee2cd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
@@ -113,7 +113,7 @@ namespace Apache.Ignite.Core.Impl.Events
return DoOutInOp((int) Op.RemoteQuery,
writer =>
{
- writer.Write(new PortableOrSerializableObjectHolder(filter));
+ writer.Write(filter);
writer.WriteLong((long) (timeout == null ? 0 : timeout.Value.TotalMilliseconds));
@@ -155,7 +155,7 @@ namespace Apache.Ignite.Core.Impl.Events
writer.WriteBoolean(remoteFilter != null);
if (remoteFilter != null)
- writer.Write(new PortableOrSerializableObjectHolder(remoteFilter));
+ writer.Write(remoteFilter);
WriteEventTypes(types, writer);
},
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
index f8e2f95..cd04c66 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
@@ -21,7 +21,6 @@ namespace Apache.Ignite.Core.Impl.Events
using System.Diagnostics;
using Apache.Ignite.Core.Events;
using Apache.Ignite.Core.Impl.Common;
- using Apache.Ignite.Core.Impl.Portable;
using Apache.Ignite.Core.Impl.Portable.IO;
/// <summary>
@@ -74,7 +73,7 @@ namespace Apache.Ignite.Core.Impl.Events
var reader = marsh.StartUnmarshal(stream);
- var pred = reader.ReadObject<PortableOrSerializableObjectHolder>().Item;
+ var pred = reader.ReadObject<object>();
var func = DelegateTypeDescriptor.GetEventFilter(pred.GetType());
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
index 412a84e..dc6585c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessageListenerHolder.cs
@@ -154,7 +154,7 @@ namespace Apache.Ignite.Core.Impl.Messaging
{
var writer0 = (PortableWriterImpl)writer.GetRawWriter();
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, Filter));
+ writer0.WithDetach(w => w.WriteObject(Filter));
}
/// <summary>
@@ -165,7 +165,7 @@ namespace Apache.Ignite.Core.Impl.Messaging
{
var reader0 = (PortableReaderImpl)reader.GetRawReader();
- _filter = PortableUtils.ReadPortableOrSerializable<object>(reader0);
+ _filter = reader0.ReadObject<object>();
_invoker = GetInvoker(_filter);
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
index 6499946..2848df1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableMarshaller.cs
@@ -23,7 +23,6 @@ namespace Apache.Ignite.Core.Impl.Portable
using System.Linq;
using Apache.Ignite.Core.Impl.Cache;
using Apache.Ignite.Core.Impl.Cache.Query.Continuous;
- using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Compute;
using Apache.Ignite.Core.Impl.Compute.Closure;
using Apache.Ignite.Core.Impl.Datastream;
@@ -505,7 +504,6 @@ namespace Apache.Ignite.Core.Impl.Portable
{
AddSystemType(PortableUtils.TypeNativeJobHolder, w => new ComputeJobHolder(w));
AddSystemType(PortableUtils.TypeComputeJobWrapper, w => new ComputeJobWrapper(w));
- AddSystemType(PortableUtils.TypePortableJobResHolder, w => new PortableResultWrapper(w));
AddSystemType(PortableUtils.TypeIgniteProxy, w => new IgniteProxy());
AddSystemType(PortableUtils.TypeComputeOutFuncJob, w => new ComputeOutFuncJob(w));
AddSystemType(PortableUtils.TypeComputeOutFuncWrapper, w => new ComputeOutFuncWrapper(w));
@@ -517,7 +515,6 @@ namespace Apache.Ignite.Core.Impl.Portable
AddSystemType(PortableUtils.TypeCacheEntryProcessorHolder, w => new CacheEntryProcessorHolder(w));
AddSystemType(PortableUtils.TypeCacheEntryPredicateHolder, w => new CacheEntryFilterHolder(w));
AddSystemType(PortableUtils.TypeMessageListenerHolder, w => new MessageListenerHolder(w));
- AddSystemType(PortableUtils.TypePortableOrSerializableHolder, w => new PortableOrSerializableObjectHolder(w));
AddSystemType(PortableUtils.TypeStreamReceiverHolder, w => new StreamReceiverHolder(w));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableOrSerializableObjectHolder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableOrSerializableObjectHolder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableOrSerializableObjectHolder.cs
deleted file mode 100644
index d2a2928..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableOrSerializableObjectHolder.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Portable
-{
- using Apache.Ignite.Core.Portable;
-
- /// <summary>
- /// Wraps portable/serializable item in a portable.
- /// </summary>
- internal class PortableOrSerializableObjectHolder : IPortableWriteAware
- {
- /** */
- private readonly object _item;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="SerializableObjectHolder"/> class.
- /// </summary>
- /// <param name="item">The item to wrap.</param>
- public PortableOrSerializableObjectHolder(object item)
- {
- _item = item;
- }
-
- /// <summary>
- /// Gets or sets the item to wrap.
- /// </summary>
- public object Item
- {
- get { return _item; }
- }
-
- /** <inheritDoc /> */
- public void WritePortable(IPortableWriter writer)
- {
- var writer0 = (PortableWriterImpl)writer.GetRawWriter();
-
- writer0.WithDetach(w => PortableUtils.WritePortableOrSerializable(w, Item));
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="PortableOrSerializableObjectHolder"/> class.
- /// </summary>
- /// <param name="reader">The reader.</param>
- public PortableOrSerializableObjectHolder(IPortableReader reader)
- {
- _item = PortableUtils.ReadPortableOrSerializable<object>((PortableReaderImpl)reader.GetRawReader());
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9d67c20c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
index e9ef369..dd72a8c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
@@ -29,6 +29,7 @@ namespace Apache.Ignite.Core.Impl.Portable
using System.Runtime.Serialization.Formatters.Binary;
using System.Security.Policy;
using System.Text;
+
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Portable.IO;
using Apache.Ignite.Core.Portable;
@@ -167,9 +168,6 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Type: native job holder. */
public const byte TypeNativeJobHolder = 77;
- /** Type: native job result holder. */
- public const byte TypePortableJobResHolder = 76;
-
/** Type: Ignite proxy. */
public const byte TypeIgniteProxy = 74;
@@ -1672,102 +1670,6 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/// <summary>
- /// Write object which is not necessary portable.
- /// </summary>
- /// <param name="writer">Writer.</param>
- /// <param name="obj">Object.</param>
- public static void WritePortableOrSerializable<T>(PortableWriterImpl writer, T obj)
- {
- if (writer.IsPortable(obj))
- {
- writer.WriteBoolean(true);
-
- writer.WriteObject(obj);
- }
- else
- {
- writer.WriteBoolean(false);
-
- WriteSerializable(writer, obj);
- }
- }
-
- /// <summary>
- /// Writes a serializable object.
- /// </summary>
- /// <param name="writer">Writer.</param>
- /// <param name="obj">Object.</param>
- public static void WriteSerializable<T>(PortableWriterImpl writer, T obj)
- {
- new BinaryFormatter().Serialize(new PortableStreamAdapter(writer.Stream), obj);
- }
-
- /// <summary>
- /// Read object which is not necessary portable.
- /// </summary>
- /// <param name="reader">Reader.</param>
- /// <returns>Object.</returns>
- public static T ReadPortableOrSerializable<T>(PortableReaderImpl reader)
- {
- return reader.ReadBoolean()
- ? reader.ReadObject<T>()
- : ReadSerializable<T>(reader);
- }
-
- /// <summary>
- /// Reads a serializable object.
- /// </summary>
- /// <param name="reader">Reader.</param>
- /// <returns>Object.</returns>
- public static T ReadSerializable<T>(PortableReaderImpl reader)
- {
- return (T) new BinaryFormatter().Deserialize(new PortableStreamAdapter(reader.Stream), null);
- }
-
- /// <summary>
- /// Writes wrapped invocation result.
- /// </summary>
- /// <param name="writer">Writer.</param>
- /// <param name="success">Success flag.</param>
- /// <param name="res">Result.</param>
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
- public static void WriteWrappedInvocationResult(PortableWriterImpl writer, bool success, object res)
- {
- var pos = writer.Stream.Position;
-
- try
- {
- if (success)
- writer.WriteBoolean(true);
- else
- {
- writer.WriteBoolean(false); // Call failed.
- writer.WriteBoolean(true); // Exception serialized sucessfully.
- }
-
- writer.Write(new PortableResultWrapper(res));
- }
- catch (Exception marshErr)
- {
- // Failed to serialize result, fallback to plain string.
- writer.Stream.Seek(pos, SeekOrigin.Begin);
-
- writer.WriteBoolean(false); // Call failed.
- writer.WriteBoolean(false); // Cannot serialize result or exception.
-
- if (success)
- {
- writer.WriteString("Call completed successfully, but result serialization failed [resultType=" +
- res.GetType().Name + ", serializationErrMsg=" + marshErr.Message + ']');
- }
- else
- {
- writer.WriteString("Call completed with error, but error serialization failed [errType=" +
- res.GetType().Name + ", serializationErrMsg=" + marshErr.Message + ']');
- }
- }
- }
- /// <summary>
/// Writes invocation result.
/// </summary>
/// <param name="writer">Writer.</param>
@@ -1812,27 +1714,6 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/// <summary>
- /// Reads wrapped invocation result.
- /// </summary>
- /// <param name="reader">Reader.</param>
- /// <param name="err">Error.</param>
- /// <returns>Result.</returns>
- public static object ReadWrappedInvocationResult(PortableReaderImpl reader, out object err)
- {
- err = null;
-
- if (reader.ReadBoolean())
- return reader.ReadObject<PortableResultWrapper>().Result;
-
- if (reader.ReadBoolean())
- err = (Exception) reader.ReadObject<PortableResultWrapper>().Result;
- else
- err = ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
-
- return null;
- }
-
- /// <summary>
/// Reads invocation result.
/// </summary>
/// <param name="reader">Reader.</param>
@@ -1845,10 +1726,9 @@ namespace Apache.Ignite.Core.Impl.Portable
if (reader.ReadBoolean())
return reader.ReadObject<object>();
- if (reader.ReadBoolean())
- err = reader.ReadObject<object>();
- else
- err = ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
+ err = reader.ReadBoolean()
+ ? reader.ReadObject<object>()
+ : ExceptionUtils.GetException(reader.ReadString(), reader.ReadString());
return null;
}
[11/17] ignite git commit: IGNITE-1652: .Net async API reworked.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
index 99ee2cd..800ed13 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/Events.cs
@@ -22,8 +22,8 @@ namespace Apache.Ignite.Core.Impl.Events
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Events;
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Handle;
@@ -36,18 +36,19 @@ namespace Apache.Ignite.Core.Impl.Events
/// <summary>
/// Ignite events.
/// </summary>
- internal class Events : PlatformTarget, IEvents
+ internal sealed class Events : PlatformTarget, IEvents
{
/// <summary>
/// Opcodes.
/// </summary>
- protected enum Op
+ private enum Op
{
RemoteQuery = 1,
RemoteListen = 2,
StopRemoteListen = 3,
WaitForLocal = 4,
LocalQuery = 5,
+ // ReSharper disable once UnusedMember.Local
RecordLocal = 6,
EnableLocal = 8,
DisableLocal = 9,
@@ -58,54 +59,59 @@ namespace Apache.Ignite.Core.Impl.Events
private readonly Dictionary<object, Dictionary<int, LocalHandledEventFilter>> _localFilters
= new Dictionary<object, Dictionary<int, LocalHandledEventFilter>>();
- /** Grid. */
- protected readonly Ignite Ignite;
+ /** Cluster group. */
+ private readonly IClusterGroup _clusterGroup;
+
+ /** Async instance. */
+ private readonly Lazy<Events> _asyncInstance;
/// <summary>
- /// Initializes a new instance of the <see cref="Events"/> class.
+ /// Initializes a new instance of the <see cref="Events" /> class.
/// </summary>
/// <param name="target">Target.</param>
/// <param name="marsh">Marshaller.</param>
/// <param name="clusterGroup">Cluster group.</param>
- public Events(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup clusterGroup)
+ public Events(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup clusterGroup)
: base(target, marsh)
{
Debug.Assert(clusterGroup != null);
- ClusterGroup = clusterGroup;
+ _clusterGroup = clusterGroup;
- Ignite = (Ignite) clusterGroup.Ignite;
+ _asyncInstance = new Lazy<Events>(() => new Events(this));
}
- /** <inheritDoc /> */
- public virtual IEvents WithAsync()
+ /// <summary>
+ /// Initializes a new async instance.
+ /// </summary>
+ /// <param name="events">The events.</param>
+ private Events(Events events) : base(UU.EventsWithAsync(events.Target), events.Marshaller)
{
- return new EventsAsync(UU.EventsWithAsync(Target), Marshaller, ClusterGroup);
+ _clusterGroup = events.ClusterGroup;
}
/** <inheritDoc /> */
- public virtual bool IsAsync
+ public IClusterGroup ClusterGroup
{
- get { return false; }
+ get { return _clusterGroup; }
}
- /** <inheritDoc /> */
- public virtual IFuture GetFuture()
+ /** */
+ private Ignite Ignite
{
- throw IgniteUtils.GetAsyncModeDisabledException();
+ get { return (Ignite) ClusterGroup.Ignite; }
}
- /** <inheritDoc /> */
- public virtual IFuture<TResult> GetFuture<TResult>()
+ /// <summary>
+ /// Gets the asynchronous instance.
+ /// </summary>
+ private Events AsyncInstance
{
- throw IgniteUtils.GetAsyncModeDisabledException();
+ get { return _asyncInstance.Value; }
}
/** <inheritDoc /> */
- public IClusterGroup ClusterGroup { get; private set; }
-
- /** <inheritDoc /> */
- public virtual ICollection<T> RemoteQuery<T>(IEventFilter<T> filter, TimeSpan? timeout = null, params int[] types)
+ public ICollection<T> RemoteQuery<T>(IEventFilter<T> filter, TimeSpan? timeout = null, params int[] types)
where T : IEvent
{
IgniteArgumentCheck.NotNull(filter, "filter");
@@ -123,6 +129,16 @@ namespace Apache.Ignite.Core.Impl.Events
}
/** <inheritDoc /> */
+ public Task<ICollection<T>> RemoteQueryAsync<T>(IEventFilter<T> filter, TimeSpan? timeout = null,
+ params int[] types) where T : IEvent
+ {
+ AsyncInstance.RemoteQuery(filter, timeout, types);
+
+ return GetFuture((futId, futTyp) => UU.TargetListenFutureForOperation(AsyncInstance.Target, futId, futTyp,
+ (int) Op.RemoteQuery), convertFunc: ReadEvents<T>).Task;
+ }
+
+ /** <inheritDoc /> */
public ICollection<T> RemoteQuery<T>(IEventFilter<T> filter, TimeSpan? timeout = null,
IEnumerable<int> types = null) where T : IEvent
{
@@ -130,7 +146,14 @@ namespace Apache.Ignite.Core.Impl.Events
}
/** <inheritDoc /> */
- public virtual Guid? RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
+ public Task<ICollection<T>> RemoteQueryAsync<T>(IEventFilter<T> filter, TimeSpan? timeout = null,
+ IEnumerable<int> types = null) where T : IEvent
+ {
+ return RemoteQueryAsync(filter, timeout, TypesToArray(types));
+ }
+
+ /** <inheritDoc /> */
+ public Guid? RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types)
where T : IEvent
{
@@ -171,7 +194,7 @@ namespace Apache.Ignite.Core.Impl.Events
}
/** <inheritDoc /> */
- public virtual void StopRemoteListen(Guid opId)
+ public void StopRemoteListen(Guid opId)
{
DoOutOp((int) Op.StopRemoteListen, writer =>
{
@@ -186,13 +209,25 @@ namespace Apache.Ignite.Core.Impl.Events
}
/** <inheritDoc /> */
+ public Task<IEvent> WaitForLocalAsync(params int[] types)
+ {
+ return WaitForLocalAsync<IEvent>(null, types);
+ }
+
+ /** <inheritDoc /> */
public IEvent WaitForLocal(IEnumerable<int> types)
{
return WaitForLocal(TypesToArray(types));
}
/** <inheritDoc /> */
- public virtual T WaitForLocal<T>(IEventFilter<T> filter, params int[] types) where T : IEvent
+ public Task<IEvent> WaitForLocalAsync(IEnumerable<int> types)
+ {
+ return WaitForLocalAsync<IEvent>(null, TypesToArray(types));
+ }
+
+ /** <inheritDoc /> */
+ public T WaitForLocal<T>(IEventFilter<T> filter, params int[] types) where T : IEvent
{
long hnd = 0;
@@ -208,12 +243,46 @@ namespace Apache.Ignite.Core.Impl.Events
}
/** <inheritDoc /> */
+ public Task<T> WaitForLocalAsync<T>(IEventFilter<T> filter, params int[] types) where T : IEvent
+ {
+ long hnd = 0;
+
+ try
+ {
+ AsyncInstance.WaitForLocal0(filter, ref hnd, types);
+
+ var fut = GetFuture((futId, futTyp) => UU.TargetListenFutureForOperation(AsyncInstance.Target, futId,
+ futTyp, (int) Op.WaitForLocal), convertFunc: reader => (T) EventReader.Read<IEvent>(reader));
+
+ if (filter != null)
+ {
+ // Dispose handle as soon as future ends.
+ fut.Task.ContinueWith(x => Ignite.HandleRegistry.Release(hnd));
+ }
+
+ return fut.Task;
+ }
+ catch (Exception)
+ {
+ Ignite.HandleRegistry.Release(hnd);
+ throw;
+ }
+
+ }
+
+ /** <inheritDoc /> */
public T WaitForLocal<T>(IEventFilter<T> filter, IEnumerable<int> types) where T : IEvent
{
return WaitForLocal(filter, TypesToArray(types));
}
/** <inheritDoc /> */
+ public Task<T> WaitForLocalAsync<T>(IEventFilter<T> filter, IEnumerable<int> types) where T : IEvent
+ {
+ return WaitForLocalAsync(filter, TypesToArray(types));
+ }
+
+ /** <inheritDoc /> */
public ICollection<IEvent> LocalQuery(params int[] types)
{
return DoOutInOp((int) Op.LocalQuery,
@@ -325,7 +394,7 @@ namespace Apache.Ignite.Core.Impl.Events
/// <param name="types">Types of the events to wait for.
/// If not provided, all events will be passed to the filter.</param>
/// <returns>Ignite event.</returns>
- protected T WaitForLocal0<T>(IEventFilter<T> filter, ref long handle, params int[] types) where T : IEvent
+ private T WaitForLocal0<T>(IEventFilter<T> filter, ref long handle, params int[] types) where T : IEvent
{
if (filter != null)
handle = Ignite.HandleRegistry.Allocate(new LocalEventFilter
@@ -357,7 +426,7 @@ namespace Apache.Ignite.Core.Impl.Events
/// <typeparam name="T">Event type.</typeparam>
/// <param name="reader">Reader.</param>
/// <returns>Resulting list or null.</returns>
- private List<T> ReadEvents<T>(IPortableStream reader) where T : IEvent
+ private ICollection<T> ReadEvents<T>(IPortableStream reader) where T : IEvent
{
return ReadEvents<T>(Marshaller.StartUnmarshal(reader));
}
@@ -368,7 +437,7 @@ namespace Apache.Ignite.Core.Impl.Events
/// <typeparam name="T">Event type.</typeparam>
/// <param name="portableReader">Reader.</param>
/// <returns>Resulting list or null.</returns>
- protected static List<T> ReadEvents<T>(PortableReaderImpl portableReader) where T : IEvent
+ private static ICollection<T> ReadEvents<T>(PortableReaderImpl portableReader) where T : IEvent
{
var count = portableReader.GetRawReader().ReadInt();
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs
deleted file mode 100644
index 461f2ae..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventsAsync.cs
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Events
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Threading;
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Events;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Impl.Unmanaged;
- using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
- /// <summary>
- /// Async Ignite events.
- /// </summary>
- [SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")]
- internal class EventsAsync : Events
- {
- /** */
- private readonly ThreadLocal<int> _lastAsyncOp = new ThreadLocal<int>(() => OpNone);
-
- /** */
- private readonly ThreadLocal<IFuture> _curFut = new ThreadLocal<IFuture>();
-
- /// <summary>
- /// Initializes a new instance of the <see cref="Events"/> class.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <param name="marsh">Marshaller.</param>
- /// <param name="clusterGroup">Cluster group.</param>
- public EventsAsync(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup clusterGroup)
- : base(target, marsh, clusterGroup)
- {
- // No-op.
- }
-
- /** <inheritdoc /> */
- public override ICollection<T> RemoteQuery<T>(IEventFilter<T> filter, TimeSpan? timeout = null,
- params int[] types)
- {
- _lastAsyncOp.Value = (int) Op.RemoteQuery;
-
- var result = base.RemoteQuery(filter, timeout, types);
-
- // Result is a List<T> so we can't create proper converter later in GetFuture call from user.
- // ReSharper disable once RedundantTypeArgumentsOfMethod (otherwise won't compile in VS2010 / TC)
- _curFut.Value = GetFuture<List<T>>((futId, futTyp) => UU.TargetListenFutureForOperation(Target, futId, futTyp,
- (int) Op.RemoteQuery), convertFunc: ReadEvents<T>);
-
- return result;
- }
-
- /** <inheritdoc /> */
- public override Guid? RemoteListen<T>(int bufSize = 1, TimeSpan? interval = null, bool autoUnsubscribe = true,
- IEventFilter<T> localListener = null, IEventFilter<T> remoteFilter = null, params int[] types)
- {
- _lastAsyncOp.Value = (int) Op.RemoteListen;
- _curFut.Value = null;
-
- return base.RemoteListen(bufSize, interval, autoUnsubscribe, localListener, remoteFilter, types);
- }
-
- /** <inheritdoc /> */
- public override void StopRemoteListen(Guid opId)
- {
- _lastAsyncOp.Value = (int) Op.StopRemoteListen;
- _curFut.Value = null;
-
- base.StopRemoteListen(opId);
- }
-
- /** <inheritdoc /> */
- public override T WaitForLocal<T>(IEventFilter<T> filter, params int[] types)
- {
- _lastAsyncOp.Value = (int) Op.WaitForLocal;
-
- long hnd = 0;
-
- try
- {
- var result = WaitForLocal0(filter, ref hnd, types);
-
- if (filter != null)
- {
- // Dispose handle as soon as future ends.
- var fut = GetFuture<T>();
-
- _curFut.Value = fut;
-
- fut.Listen(() => Ignite.HandleRegistry.Release(hnd));
- }
- else
- _curFut.Value = null;
-
- return result;
- }
- catch (Exception)
- {
- Ignite.HandleRegistry.Release(hnd);
- throw;
- }
- }
-
- /** <inheritdoc /> */
- public override IEvents WithAsync()
- {
- return this;
- }
-
- /** <inheritdoc /> */
- public override bool IsAsync
- {
- get { return true; }
- }
-
- /** <inheritdoc /> */
- public override IFuture GetFuture()
- {
- return GetFuture<object>();
- }
-
- /** <inheritdoc /> */
- public override IFuture<T> GetFuture<T>()
- {
- if (_curFut.Value != null)
- {
- var fut = _curFut.Value;
- _curFut.Value = null;
- return (IFuture<T>) fut;
- }
-
- Func<PortableReaderImpl, T> converter = null;
-
- if (_lastAsyncOp.Value == (int) Op.WaitForLocal)
- converter = reader => (T) EventReader.Read<IEvent>(reader);
-
- return GetFuture((futId, futTyp) => UU.TargetListenFutureForOperation(Target, futId, futTyp, _lastAsyncOp.Value),
- convertFunc: converter);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
index 2ed7a75..30c6b66 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -353,9 +353,7 @@ namespace Apache.Ignite.Core.Impl
/// </returns>
public ICache<TK, TV> Cache<TK, TV>(IUnmanagedTarget nativeCache, bool keepPortable = false)
{
- var cacheImpl = new CacheImpl<TK, TV>(this, nativeCache, _marsh, false, keepPortable, false, false);
-
- return new CacheProxyImpl<TK, TV>(cacheImpl);
+ return new CacheImpl<TK, TV>(this, nativeCache, _marsh, false, keepPortable, false, false);
}
/** <inheritdoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index 7588945..532c19d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -415,14 +415,5 @@ namespace Apache.Ignite.Core.Impl
return res;
}
-
- /// <summary>
- /// Gets the asynchronous mode disabled exception.
- /// </summary>
- /// <returns>Asynchronous mode disabled exception.</returns>
- public static InvalidOperationException GetAsyncModeDisabledException()
- {
- return new InvalidOperationException("Asynchronous mode is disabled");
- }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
index de94c74..df7d6ff 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/Messaging.cs
@@ -22,8 +22,8 @@ namespace Apache.Ignite.Core.Impl.Messaging
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Collections;
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Portable;
@@ -57,6 +57,15 @@ namespace Apache.Ignite.Core.Impl.Messaging
/** Grid */
private readonly Ignite _ignite;
+
+ /** Async instance. */
+ private readonly Lazy<Messaging> _asyncInstance;
+
+ /** Async flag. */
+ private readonly bool _isAsync;
+
+ /** Cluster group. */
+ private readonly IClusterGroup _clusterGroup;
/// <summary>
/// Initializes a new instance of the <see cref="Messaging" /> class.
@@ -69,15 +78,40 @@ namespace Apache.Ignite.Core.Impl.Messaging
{
Debug.Assert(prj != null);
- ClusterGroup = prj;
+ _clusterGroup = prj;
_ignite = (Ignite) prj.Ignite;
+
+ _asyncInstance = new Lazy<Messaging>(() => new Messaging(this));
+ }
+
+ /// <summary>
+ /// Initializes a new async instance.
+ /// </summary>
+ /// <param name="messaging">The messaging.</param>
+ private Messaging(Messaging messaging) : base(UU.MessagingWithASync(messaging.Target), messaging.Marshaller)
+ {
+ _isAsync = true;
+ _ignite = messaging._ignite;
+ _clusterGroup = messaging.ClusterGroup;
}
/** <inheritdoc /> */
- public IClusterGroup ClusterGroup { get; private set; }
+ public IClusterGroup ClusterGroup
+ {
+ get { return _clusterGroup; }
+ }
+
+ /// <summary>
+ /// Gets the asynchronous instance.
+ /// </summary>
+ private Messaging AsyncInstance
+ {
+ get { return _asyncInstance.Value; }
+ }
/** <inheritdoc /> */
+
public void Send(object message, object topic = null)
{
IgniteArgumentCheck.NotNull(message, "message");
@@ -189,21 +223,22 @@ namespace Apache.Ignite.Core.Impl.Messaging
{
Guid id = Guid.Empty;
- DoOutInOp((int) Op.RemoteListen, writer =>
- {
- writer.Write(filter0);
- writer.WriteLong(filterHnd);
- writer.Write(topic);
- },
- input =>
- {
- var id0 = Marshaller.StartUnmarshal(input).GetRawReader().ReadGuid();
+ DoOutInOp((int) Op.RemoteListen,
+ writer =>
+ {
+ writer.Write(filter0);
+ writer.WriteLong(filterHnd);
+ writer.Write(topic);
+ },
+ input =>
+ {
+ var id0 = Marshaller.StartUnmarshal(input).GetRawReader().ReadGuid();
- Debug.Assert(IsAsync || id0.HasValue);
+ Debug.Assert(_isAsync || id0.HasValue);
- if (id0.HasValue)
- id = id0.Value;
- });
+ if (id0.HasValue)
+ id = id0.Value;
+ });
return id;
}
@@ -216,36 +251,28 @@ namespace Apache.Ignite.Core.Impl.Messaging
}
/** <inheritdoc /> */
- public void StopRemoteListen(Guid opId)
+ public Task<Guid> RemoteListenAsync<T>(IMessageListener<T> listener, object topic = null)
{
- DoOutOp((int) Op.StopRemoteListen, writer =>
- {
- writer.WriteGuid(opId);
- });
- }
+ AsyncInstance.RemoteListen(listener, topic);
- /** <inheritdoc /> */
- public virtual IMessaging WithAsync()
- {
- return new MessagingAsync(UU.MessagingWithASync(Target), Marshaller, ClusterGroup);
+ return AsyncInstance.GetTask<Guid>();
}
/** <inheritdoc /> */
- public virtual bool IsAsync
+ public void StopRemoteListen(Guid opId)
{
- get { return false; }
+ DoOutOp((int) Op.StopRemoteListen, writer =>
+ {
+ writer.WriteGuid(opId);
+ });
}
/** <inheritdoc /> */
- public virtual IFuture GetFuture()
+ public Task StopRemoteListenAsync(Guid opId)
{
- throw IgniteUtils.GetAsyncModeDisabledException();
- }
+ AsyncInstance.StopRemoteListen(opId);
- /** <inheritdoc /> */
- public virtual IFuture<TResult> GetFuture<TResult>()
- {
- throw IgniteUtils.GetAsyncModeDisabledException();
+ return AsyncInstance.GetTask();
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.cs
deleted file mode 100644
index e899d4e..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Messaging/MessagingAsync.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Messaging
-{
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Impl.Unmanaged;
- using Apache.Ignite.Core.Messaging;
- using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
- /// <summary>
- /// Async messaging implementation.
- /// </summary>
- internal class MessagingAsync : Messaging
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="MessagingAsync" /> class.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <param name="marsh">Marshaller.</param>
- /// <param name="prj">Cluster group.</param>
- public MessagingAsync(IUnmanagedTarget target, PortableMarshaller marsh,
- IClusterGroup prj) : base(target, marsh, prj)
- {
- // No-op.
- }
-
- /** <inheritdoc /> */
- public override IMessaging WithAsync()
- {
- return this;
- }
-
- /** <inheritdoc /> */
- public override bool IsAsync
- {
- get { return true; }
- }
-
- /** <inheritdoc /> */
- public override IFuture GetFuture()
- {
- return GetFuture<object>();
- }
-
- /** <inheritdoc /> */
- public override IFuture<T> GetFuture<T>()
- {
- return GetFuture<T>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp));
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
index 6d0a324..49b57a5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/PlatformTarget.cs
@@ -22,8 +22,7 @@ namespace Apache.Ignite.Core.Impl
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
- using Apache.Ignite.Core.Cache;
- using Apache.Ignite.Core.Common;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Memory;
using Apache.Ignite.Core.Impl.Portable;
@@ -631,7 +630,7 @@ namespace Apache.Ignite.Core.Impl
/// <param name="keepPortable">Keep portable flag, only applicable to object futures. False by default.</param>
/// <param name="convertFunc">The function to read future result from stream.</param>
/// <returns>Created future.</returns>
- protected IFuture<T> GetFuture<T>(Action<long, int> listenAction, bool keepPortable = false,
+ protected Future<T> GetFuture<T>(Action<long, int> listenAction, bool keepPortable = false,
Func<PortableReaderImpl, T> convertFunc = null)
{
var futType = FutureType.Object;
@@ -652,6 +651,22 @@ namespace Apache.Ignite.Core.Impl
return fut;
}
+ /// <summary>
+ /// Creates a task to listen for the last async op.
+ /// </summary>
+ protected Task GetTask()
+ {
+ return GetTask<object>();
+ }
+
+ /// <summary>
+ /// Creates a task to listen for the last async op.
+ /// </summary>
+ protected Task<T> GetTask<T>()
+ {
+ return GetFuture<T>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp)).Task;
+ }
+
#endregion
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
index ac65807f..fe1a146 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
@@ -22,8 +22,8 @@ namespace Apache.Ignite.Core.Impl.Services
using System.Diagnostics;
using System.Linq;
using System.Reflection;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Portable;
using Apache.Ignite.Core.Impl.Unmanaged;
@@ -33,7 +33,7 @@ namespace Apache.Ignite.Core.Impl.Services
/// <summary>
/// Services implementation.
/// </summary>
- internal class Services : PlatformTarget, IServices
+ internal sealed class Services : PlatformTarget, IServices
{
/** */
private const int OpDeploy = 1;
@@ -54,10 +54,13 @@ namespace Apache.Ignite.Core.Impl.Services
private readonly IClusterGroup _clusterGroup;
/** Invoker portable flag. */
- protected readonly bool KeepPortable;
+ private readonly bool _keepPortable;
/** Server portable flag. */
- protected readonly bool SrvKeepPortable;
+ private readonly bool _srvKeepPortable;
+
+ /** Async instance. */
+ private readonly Lazy<Services> _asyncInstance;
/// <summary>
/// Initializes a new instance of the <see cref="Services" /> class.
@@ -74,74 +77,87 @@ namespace Apache.Ignite.Core.Impl.Services
Debug.Assert(clusterGroup != null);
_clusterGroup = clusterGroup;
- KeepPortable = keepPortable;
- SrvKeepPortable = srvKeepPortable;
+ _keepPortable = keepPortable;
+ _srvKeepPortable = srvKeepPortable;
+
+ _asyncInstance = new Lazy<Services>(() => new Services(this));
}
- /** <inheritDoc /> */
- public virtual IServices WithKeepPortable()
+ /// <summary>
+ /// Initializes a new async instance.
+ /// </summary>
+ /// <param name="services">The services.</param>
+ private Services(Services services) : base(UU.ServicesWithAsync(services.Target), services.Marshaller)
{
- if (KeepPortable)
- return this;
-
- return new Services(Target, Marshaller, _clusterGroup, true, SrvKeepPortable);
+ _clusterGroup = services.ClusterGroup;
+ _keepPortable = services._keepPortable;
+ _srvKeepPortable = services._srvKeepPortable;
}
/** <inheritDoc /> */
- public virtual IServices WithServerKeepPortable()
+ public IServices WithKeepPortable()
{
- if (SrvKeepPortable)
+ if (_keepPortable)
return this;
- return new Services(UU.ServicesWithServerKeepPortable(Target), Marshaller, _clusterGroup, KeepPortable, true);
+ return new Services(Target, Marshaller, _clusterGroup, true, _srvKeepPortable);
}
/** <inheritDoc /> */
- public virtual IServices WithAsync()
+ public IServices WithServerKeepPortable()
{
- return new ServicesAsync(UU.ServicesWithAsync(Target), Marshaller, _clusterGroup, KeepPortable, SrvKeepPortable);
+ if (_srvKeepPortable)
+ return this;
+
+ return new Services(UU.ServicesWithServerKeepPortable(Target), Marshaller, _clusterGroup, _keepPortable, true);
}
/** <inheritDoc /> */
- public virtual bool IsAsync
+ public IClusterGroup ClusterGroup
{
- get { return false; }
+ get { return _clusterGroup; }
}
- /** <inheritDoc /> */
- public virtual IFuture GetFuture()
+ /// <summary>
+ /// Gets the asynchronous instance.
+ /// </summary>
+ private Services AsyncInstance
{
- throw new InvalidOperationException("Asynchronous mode is disabled");
+ get { return _asyncInstance.Value; }
}
/** <inheritDoc /> */
- public virtual IFuture<TResult> GetFuture<TResult>()
+ public void DeployClusterSingleton(string name, IService service)
{
- throw new InvalidOperationException("Asynchronous mode is disabled");
+ IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+ IgniteArgumentCheck.NotNull(service, "service");
+
+ DeployMultiple(name, service, 1, 1);
}
/** <inheritDoc /> */
- public IClusterGroup ClusterGroup
+ public Task DeployClusterSingletonAsync(string name, IService service)
{
- get { return _clusterGroup; }
+ AsyncInstance.DeployClusterSingleton(name, service);
+
+ return AsyncInstance.GetTask();
}
/** <inheritDoc /> */
- public void DeployClusterSingleton(string name, IService service)
+ public void DeployNodeSingleton(string name, IService service)
{
IgniteArgumentCheck.NotNullOrEmpty(name, "name");
IgniteArgumentCheck.NotNull(service, "service");
- DeployMultiple(name, service, 1, 1);
+ DeployMultiple(name, service, 0, 1);
}
/** <inheritDoc /> */
- public void DeployNodeSingleton(string name, IService service)
+ public Task DeployNodeSingletonAsync(string name, IService service)
{
- IgniteArgumentCheck.NotNullOrEmpty(name, "name");
- IgniteArgumentCheck.NotNull(service, "service");
+ AsyncInstance.DeployNodeSingleton(name, service);
- DeployMultiple(name, service, 0, 1);
+ return AsyncInstance.GetTask();
}
/** <inheritDoc /> */
@@ -163,6 +179,14 @@ namespace Apache.Ignite.Core.Impl.Services
}
/** <inheritDoc /> */
+ public Task DeployKeyAffinitySingletonAsync<TK>(string name, IService service, string cacheName, TK affinityKey)
+ {
+ AsyncInstance.DeployKeyAffinitySingleton(name, service, cacheName, affinityKey);
+
+ return AsyncInstance.GetTask();
+ }
+
+ /** <inheritDoc /> */
public void DeployMultiple(string name, IService service, int totalCount, int maxPerNodeCount)
{
IgniteArgumentCheck.NotNullOrEmpty(name, "name");
@@ -178,6 +202,14 @@ namespace Apache.Ignite.Core.Impl.Services
}
/** <inheritDoc /> */
+ public Task DeployMultipleAsync(string name, IService service, int totalCount, int maxPerNodeCount)
+ {
+ AsyncInstance.DeployMultiple(name, service, totalCount, maxPerNodeCount);
+
+ return AsyncInstance.GetTask();
+ }
+
+ /** <inheritDoc /> */
public void Deploy(ServiceConfiguration configuration)
{
IgniteArgumentCheck.NotNull(configuration, "configuration");
@@ -199,6 +231,14 @@ namespace Apache.Ignite.Core.Impl.Services
}
/** <inheritDoc /> */
+ public Task DeployAsync(ServiceConfiguration configuration)
+ {
+ AsyncInstance.Deploy(configuration);
+
+ return AsyncInstance.GetTask();
+ }
+
+ /** <inheritDoc /> */
public void Cancel(string name)
{
IgniteArgumentCheck.NotNullOrEmpty(name, "name");
@@ -207,17 +247,33 @@ namespace Apache.Ignite.Core.Impl.Services
}
/** <inheritDoc /> */
+ public Task CancelAsync(string name)
+ {
+ AsyncInstance.Cancel(name);
+
+ return AsyncInstance.GetTask();
+ }
+
+ /** <inheritDoc /> */
public void CancelAll()
{
UU.ServicesCancelAll(Target);
}
/** <inheritDoc /> */
+ public Task CancelAllAsync()
+ {
+ AsyncInstance.CancelAll();
+
+ return AsyncInstance.GetTask();
+ }
+
+ /** <inheritDoc /> */
public ICollection<IServiceDescriptor> GetServiceDescriptors()
{
return DoInOp(OpDescriptors, stream =>
{
- var reader = Marshaller.StartUnmarshal(stream, KeepPortable);
+ var reader = Marshaller.StartUnmarshal(stream, _keepPortable);
var size = reader.ReadInt();
@@ -310,7 +366,7 @@ namespace Apache.Ignite.Core.Impl.Services
{
return DoOutInOp(OpInvokeMethod,
writer => ServiceProxySerializer.WriteProxyMethod(writer, method, args),
- stream => ServiceProxySerializer.ReadInvocationResult(stream, Marshaller, KeepPortable), proxy.Target);
+ stream => ServiceProxySerializer.ReadInvocationResult(stream, Marshaller, _keepPortable), proxy.Target);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServicesAsync.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServicesAsync.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServicesAsync.cs
deleted file mode 100644
index 860de45..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServicesAsync.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Services
-{
- using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl.Portable;
- using Apache.Ignite.Core.Impl.Unmanaged;
- using Apache.Ignite.Core.Services;
- using UU = Apache.Ignite.Core.Impl.Unmanaged.UnmanagedUtils;
-
- /// <summary>
- /// Async services implementation.
- /// </summary>
- internal class ServicesAsync : Services
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="ServicesAsync" /> class.
- /// </summary>
- /// <param name="target">Target.</param>
- /// <param name="marsh">Marshaller.</param>
- /// <param name="clusterGroup">Cluster group.</param>
- /// <param name="keepPortable">Portable flag.</param>
- /// <param name="srvKeepPortable">Server portable flag.</param>
- public ServicesAsync(IUnmanagedTarget target, PortableMarshaller marsh, IClusterGroup clusterGroup,
- bool keepPortable, bool srvKeepPortable)
- : base(target, marsh, clusterGroup, keepPortable, srvKeepPortable)
- {
- // No-op
- }
-
- /** <inheritDoc /> */
- public override bool IsAsync
- {
- get { return true; }
- }
-
- /** <inheritDoc /> */
- public override IServices WithKeepPortable()
- {
- if (KeepPortable)
- return this;
-
- return new ServicesAsync(Target, Marshaller, ClusterGroup, true, SrvKeepPortable);
- }
-
- /** <inheritDoc /> */
- public override IServices WithServerKeepPortable()
- {
- if (SrvKeepPortable)
- return this;
-
- return new ServicesAsync(Target, Marshaller, ClusterGroup, KeepPortable, true);
- }
-
- /** <inheritDoc /> */
- public override IServices WithAsync()
- {
- return this;
- }
-
- /** <inheritDoc /> */
- public override IFuture GetFuture()
- {
- return GetFuture<object>();
- }
-
- /** <inheritDoc /> */
- public override IFuture<T> GetFuture<T>()
- {
- return GetFuture<T>((futId, futTyp) => UU.TargetListenFuture(Target, futId, futTyp));
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/AsyncTransaction.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/AsyncTransaction.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/AsyncTransaction.cs
deleted file mode 100644
index 82d1d55..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/AsyncTransaction.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl.Transactions
-{
- using System;
- using System.Threading;
- using Apache.Ignite.Core.Common;
-
- /// <summary>
- /// Grid async transaction facade.
- /// </summary>
- internal class AsyncTransaction : Transaction
- {
- /** */
- private readonly ThreadLocal<IFuture> _curFut = new ThreadLocal<IFuture>();
-
- /// <summary>
- /// Initializes a new instance of the <see cref="AsyncTransaction"/> class.
- /// </summary>
- /// <param name="tx">The tx to wrap.</param>
- public AsyncTransaction(TransactionImpl tx) : base(tx)
- {
- // No-op.
- }
-
- /** <inheritDoc /> */
- public override bool IsAsync
- {
- get { return true; }
- }
-
- /** <inheritDoc /> */
- public override IFuture<TResult> GetFuture<TResult>()
- {
- return GetFuture() as IFuture<TResult>;
- }
-
- /** <inheritDoc /> */
- public override IFuture GetFuture()
- {
- var fut = _curFut.Value;
-
- if (fut == null)
- throw new InvalidOperationException("Asynchronous operation not started.");
-
- _curFut.Value = null;
-
- return fut;
- }
-
- /** <inheritDoc /> */
- public override void Commit()
- {
- _curFut.Value = Tx.GetFutureOrError(() => Tx.CommitAsync());
- }
-
- /** <inheritDoc /> */
- public override void Rollback()
- {
- _curFut.Value = Tx.GetFutureOrError(() => Tx.RollbackAsync());
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs
index 35dad92..595300c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/Transaction.cs
@@ -19,16 +19,16 @@ namespace Apache.Ignite.Core.Impl.Transactions
{
using System;
using System.Diagnostics.CodeAnalysis;
- using Apache.Ignite.Core.Common;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Transactions;
/// <summary>
/// Ignite transaction facade.
/// </summary>
- internal class Transaction : ITransaction
+ internal sealed class Transaction : ITransaction
{
/** */
- protected readonly TransactionImpl Tx;
+ private readonly TransactionImpl _tx;
/// <summary>
/// Initializes a new instance of the <see cref="Transaction" /> class.
@@ -36,7 +36,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
/// <param name="tx">The tx to wrap.</param>
public Transaction(TransactionImpl tx)
{
- Tx = tx;
+ _tx = tx;
}
/** <inheritDoc /> */
@@ -44,115 +44,103 @@ namespace Apache.Ignite.Core.Impl.Transactions
Justification = "There is no finalizer.")]
public void Dispose()
{
- Tx.Dispose();
- }
-
- /** <inheritDoc /> */
- public ITransaction WithAsync()
- {
- return new AsyncTransaction(Tx);
- }
-
- /** <inheritDoc /> */
- public virtual bool IsAsync
- {
- get { return false; }
- }
-
- /** <inheritDoc /> */
- public virtual IFuture GetFuture()
- {
- throw IgniteUtils.GetAsyncModeDisabledException();
- }
-
- /** <inheritDoc /> */
- public virtual IFuture<TResult> GetFuture<TResult>()
- {
- throw IgniteUtils.GetAsyncModeDisabledException();
+ _tx.Dispose();
}
/** <inheritDoc /> */
public Guid NodeId
{
- get { return Tx.NodeId; }
+ get { return _tx.NodeId; }
}
/** <inheritDoc /> */
public long ThreadId
{
- get { return Tx.ThreadId; }
+ get { return _tx.ThreadId; }
}
/** <inheritDoc /> */
public DateTime StartTime
{
- get { return Tx.StartTime; }
+ get { return _tx.StartTime; }
}
/** <inheritDoc /> */
public TransactionIsolation Isolation
{
- get { return Tx.Isolation; }
+ get { return _tx.Isolation; }
}
/** <inheritDoc /> */
public TransactionConcurrency Concurrency
{
- get { return Tx.Concurrency; }
+ get { return _tx.Concurrency; }
}
/** <inheritDoc /> */
public TransactionState State
{
- get { return Tx.State; }
+ get { return _tx.State; }
}
/** <inheritDoc /> */
public TimeSpan Timeout
{
- get { return Tx.Timeout; }
+ get { return _tx.Timeout; }
}
/** <inheritDoc /> */
public bool IsRollbackOnly
{
- get { return Tx.IsRollbackOnly; }
+ get { return _tx.IsRollbackOnly; }
}
/** <inheritDoc /> */
public bool SetRollbackonly()
{
- return Tx.SetRollbackOnly();
+ return _tx.SetRollbackOnly();
+ }
+
+ /** <inheritDoc /> */
+ public void Commit()
+ {
+ _tx.Commit();
+ }
+
+ /** <inheritDoc /> */
+ public Task CommitAsync()
+ {
+ return _tx.GetTask(() => _tx.CommitAsync());
}
/** <inheritDoc /> */
- public virtual void Commit()
+ public void Rollback()
{
- Tx.Commit();
+ _tx.Rollback();
}
/** <inheritDoc /> */
- public virtual void Rollback()
+ public Task RollbackAsync()
{
- Tx.Rollback();
+ return _tx.GetTask(() => _tx.RollbackAsync());
}
/** <inheritDoc /> */
public void AddMeta<TV>(string name, TV val)
{
- Tx.AddMeta(name, val);
+ _tx.AddMeta(name, val);
}
/** <inheritDoc /> */
public TV Meta<TV>(string name)
{
- return Tx.Meta<TV>(name);
+ return _tx.Meta<TV>(name);
}
/** <inheritDoc /> */
public TV RemoveMeta<TV>(string name)
{
- return Tx.RemoveMeta<TV>(name);
+ return _tx.RemoveMeta<TV>(name);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs
index 3d1e57d..d32cd3d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionImpl.cs
@@ -20,8 +20,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
using System;
using System.Globalization;
using System.Threading;
- using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl.Common;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Transactions;
/// <summary>
@@ -336,34 +335,26 @@ namespace Apache.Ignite.Core.Impl.Transactions
/// <summary>
/// Commits tx in async mode.
/// </summary>
- internal IFuture CommitAsync()
+ internal Task CommitAsync()
{
lock (this)
{
ThrowIfClosed();
- var fut = _txs.CommitAsync(this);
-
- CloseWhenComplete(fut);
-
- return fut;
+ return CloseWhenComplete(_txs.CommitAsync(this));
}
}
/// <summary>
/// Rolls tx back in async mode.
/// </summary>
- internal IFuture RollbackAsync()
+ internal Task RollbackAsync()
{
lock (this)
{
ThrowIfClosed();
- var fut = _txs.RollbackAsync(this);
-
- CloseWhenComplete(fut);
-
- return fut;
+ return CloseWhenComplete(_txs.RollbackAsync(this));
}
}
@@ -391,7 +382,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
/// <summary>
/// Gets a value indicating whether this transaction is closed.
/// </summary>
- internal bool IsClosed
+ private bool IsClosed
{
get { return _state != null; }
}
@@ -406,26 +397,26 @@ namespace Apache.Ignite.Core.Impl.Transactions
}
/// <summary>
- /// Creates a future via provided factory if IsClosed is false; otherwise, return a future with an error.
+ /// Creates a task via provided factory if IsClosed is false; otherwise, return a task with an error.
/// </summary>
- internal IFuture GetFutureOrError(Func<IFuture> operationFactory)
+ internal Task GetTask(Func<Task> operationFactory)
{
lock (this)
{
- return IsClosed ? GetExceptionFuture() : operationFactory();
+ return IsClosed ? GetExceptionTask() : operationFactory();
}
}
/// <summary>
- /// Gets the future that throws an exception.
+ /// Gets the task that throws an exception.
/// </summary>
- private IFuture GetExceptionFuture()
+ private Task GetExceptionTask()
{
- var fut = new Future<object>();
-
- fut.OnError(GetClosedException());
-
- return fut;
+ var tcs = new TaskCompletionSource<object>();
+
+ tcs.SetException(GetClosedException());
+
+ return tcs.Task;
}
/// <summary>
@@ -449,11 +440,11 @@ namespace Apache.Ignite.Core.Impl.Transactions
}
/// <summary>
- /// Closes this transaction upon future completion.
+ /// Closes this transaction upon task completion.
/// </summary>
- private void CloseWhenComplete(IFuture fut)
+ private Task CloseWhenComplete(Task task)
{
- fut.Listen(Close);
+ return task.ContinueWith(x => Close());
}
/** <inheritdoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
index f2bc0f6..3305ba1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
@@ -18,7 +18,7 @@
namespace Apache.Ignite.Core.Impl.Transactions
{
using System;
- using Apache.Ignite.Core.Common;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Impl.Portable;
using Apache.Ignite.Core.Impl.Unmanaged;
using Apache.Ignite.Core.Portable;
@@ -177,17 +177,17 @@ namespace Apache.Ignite.Core.Impl.Transactions
/// <summary>
/// Commits tx in async mode.
/// </summary>
- internal IFuture CommitAsync(TransactionImpl tx)
+ internal Task CommitAsync(TransactionImpl tx)
{
- return GetFuture<object>((futId, futTyp) => UU.TransactionsCommitAsync(Target, tx.Id, futId));
+ return GetFuture<object>((futId, futTyp) => UU.TransactionsCommitAsync(Target, tx.Id, futId)).Task;
}
/// <summary>
/// Rolls tx back in async mode.
/// </summary>
- internal IFuture RollbackAsync(TransactionImpl tx)
+ internal Task RollbackAsync(TransactionImpl tx)
{
- return GetFuture<object>((futId, futTyp) => UU.TransactionsRollbackAsync(Target, tx.Id, futId));
+ return GetFuture<object>((futId, futTyp) => UU.TransactionsRollbackAsync(Target, tx.Id, futId)).Task;
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
index 9d986ec..54cfe28 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedCallbacks.cs
@@ -292,7 +292,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
IUnmanagedTarget cb0 = null;
if ((long) cb != 0)
- cb0 = new UnmanagedNonReleaseableTarget(_ctx.NativeContext, cb);
+ cb0 = new UnmanagedNonReleaseableTarget(_ctx, cb);
using (PlatformMemoryStream stream = IgniteManager.Memory.Get(memPtr).GetStream())
{
@@ -618,7 +618,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
portableReceiver.Deserialize<StreamReceiverHolder>();
if (receiver != null)
- receiver.Receive(_ignite, new UnmanagedNonReleaseableTarget(_ctx.NativeContext, cache), stream,
+ receiver.Receive(_ignite, new UnmanagedNonReleaseableTarget(_ctx, cache), stream,
keepPortable != 0);
}
});
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedNonReleaseableTarget.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedNonReleaseableTarget.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedNonReleaseableTarget.cs
index fe2de77..d044c5f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedNonReleaseableTarget.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedNonReleaseableTarget.cs
@@ -17,7 +17,6 @@
namespace Apache.Ignite.Core.Impl.Unmanaged
{
- using System;
using System.Diagnostics.CodeAnalysis;
/// <summary>
@@ -26,7 +25,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
internal unsafe class UnmanagedNonReleaseableTarget : IUnmanagedTarget
{
/** Context. */
- private readonly void* _ctx;
+ private readonly UnmanagedContext _ctx;
/** Target. */
private readonly void* _target;
@@ -36,7 +35,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
/// </summary>
/// <param name="ctx">Context.</param>
/// <param name="target">Target.</param>
- public UnmanagedNonReleaseableTarget(void* ctx, void* target)
+ public UnmanagedNonReleaseableTarget(UnmanagedContext ctx, void* target)
{
_ctx = ctx;
_target = target;
@@ -45,7 +44,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
/** <inheritdoc /> */
public void* Context
{
- get { return _ctx; }
+ get { return _ctx.NativeContext; }
}
/** <inheritdoc /> */
@@ -57,7 +56,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
/** <inheritdoc /> */
public IUnmanagedTarget ChangeTarget(void* target)
{
- throw new NotSupportedException();
+ return new UnmanagedTarget(_ctx, target);
}
/** <inheritdoc /> */
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
index de2b0d9..53bf680 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Messaging/IMessaging.cs
@@ -19,8 +19,8 @@ namespace Apache.Ignite.Core.Messaging
{
using System;
using System.Collections;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
/// <summary>
/// Provides functionality for topic-based message exchange among nodes defined by <see cref="IClusterGroup"/>.
@@ -29,7 +29,7 @@ namespace Apache.Ignite.Core.Messaging
/// <para/>
/// All members are thread-safe and may be used concurrently from multiple threads.
/// </summary>
- public interface IMessaging : IAsyncSupport<IMessaging>
+ public interface IMessaging
{
/// <summary>
/// Gets the cluster group to which this instance belongs.
@@ -95,14 +95,34 @@ namespace Apache.Ignite.Core.Messaging
/// <returns>
/// Operation ID that can be passed to <see cref="StopRemoteListen"/> method to stop listening.
/// </returns>
- [AsyncSupported]
Guid RemoteListen<T>(IMessageListener<T> listener, object topic = null);
/// <summary>
+ /// Adds a message listener for a given topic to all nodes in the cluster group (possibly including
+ /// this node if it belongs to the cluster group as well). This means that any node within this cluster
+ /// group can send a message for a given topic and all nodes within the cluster group will receive
+ /// listener notifications.
+ /// </summary>
+ /// <param name="listener">
+ /// Predicate that is called on each received message. If predicate returns false,
+ /// then it will be unsubscribed from any further notifications.
+ /// </param>
+ /// <param name="topic">Topic to unsubscribe from.</param>
+ /// <returns>
+ /// Operation ID that can be passed to <see cref="StopRemoteListen"/> method to stop listening.
+ /// </returns>
+ Task<Guid> RemoteListenAsync<T>(IMessageListener<T> listener, object topic = null);
+
+ /// <summary>
/// Unregisters all listeners identified with provided operation ID on all nodes in the cluster group.
/// </summary>
/// <param name="opId">Operation ID that was returned from <see cref="RemoteListen{T}"/> method.</param>
- [AsyncSupported]
void StopRemoteListen(Guid opId);
+
+ /// <summary>
+ /// Unregisters all listeners identified with provided operation ID on all nodes in the cluster group.
+ /// </summary>
+ /// <param name="opId">Operation ID that was returned from <see cref="RemoteListen{T}"/> method.</param>
+ Task StopRemoteListenAsync(Guid opId);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Services/IServices.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Services/IServices.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Services/IServices.cs
index ec1a044..da7394f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Services/IServices.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Services/IServices.cs
@@ -19,13 +19,13 @@ namespace Apache.Ignite.Core.Services
{
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+ using System.Threading.Tasks;
using Apache.Ignite.Core.Cluster;
- using Apache.Ignite.Core.Common;
/// <summary>
/// Defines functionality to deploy distributed services in the Ignite.
/// </summary>
- public interface IServices : IAsyncSupport<IServices>
+ public interface IServices
{
/// <summary>
/// Gets the cluster group to which this instance belongs.
@@ -47,21 +47,43 @@ namespace Apache.Ignite.Core.Services
/// </summary>
/// <param name="name">Service name.</param>
/// <param name="service">Service instance.</param>
- [AsyncSupported]
void DeployClusterSingleton(string name, IService service);
/// <summary>
+ /// Deploys a cluster-wide singleton service. Ignite guarantees that there is always
+ /// one instance of the service in the cluster. In case if Ignite node on which the service
+ /// was deployed crashes or stops, Ignite will automatically redeploy it on another node.
+ /// However, if the node on which the service is deployed remains in topology, then the
+ /// service will always be deployed on that node only, regardless of topology changes.
+ /// <para />
+ /// Note that in case of topology changes, due to network delays, there may be a temporary situation
+ /// when a singleton service instance will be active on more than one node (e.g. crash detection delay).
+ /// </summary>
+ /// <param name="name">Service name.</param>
+ /// <param name="service">Service instance.</param>
+ Task DeployClusterSingletonAsync(string name, IService service);
+
+ /// <summary>
/// Deploys a per-node singleton service. Ignite guarantees that there is always
/// one instance of the service running on each node. Whenever new nodes are started
/// within the underlying cluster group, Ignite will automatically deploy one instance of
- /// the service on every new node.
+ /// the service on every new node.
/// </summary>
/// <param name="name">Service name.</param>
/// <param name="service">Service instance.</param>
- [AsyncSupported]
void DeployNodeSingleton(string name, IService service);
/// <summary>
+ /// Deploys a per-node singleton service. Ignite guarantees that there is always
+ /// one instance of the service running on each node. Whenever new nodes are started
+ /// within the underlying cluster group, Ignite will automatically deploy one instance of
+ /// the service on every new node.
+ /// </summary>
+ /// <param name="name">Service name.</param>
+ /// <param name="service">Service instance.</param>
+ Task DeployNodeSingletonAsync(string name, IService service);
+
+ /// <summary>
/// Deploys one instance of this service on the primary node for a given affinity key.
/// Whenever topology changes and primary node assignment changes, Ignite will always
/// make sure that the service is undeployed on the previous primary node and deployed
@@ -75,10 +97,25 @@ namespace Apache.Ignite.Core.Services
/// <param name="cacheName">Name of the cache on which affinity for key should be calculated, null for
/// default cache.</param>
/// <param name="affinityKey">Affinity cache key.</param>
- [AsyncSupported]
void DeployKeyAffinitySingleton<TK>(string name, IService service, string cacheName, TK affinityKey);
/// <summary>
+ /// Deploys one instance of this service on the primary node for a given affinity key.
+ /// Whenever topology changes and primary node assignment changes, Ignite will always
+ /// make sure that the service is undeployed on the previous primary node and deployed
+ /// on the new primary node.
+ /// <para />
+ /// Note that in case of topology changes, due to network delays, there may be a temporary situation
+ /// when a service instance will be active on more than one node (e.g. crash detection delay).
+ /// </summary>
+ /// <param name="name">Service name.</param>
+ /// <param name="service">Service instance.</param>
+ /// <param name="cacheName">Name of the cache on which affinity for key should be calculated, null for
+ /// default cache.</param>
+ /// <param name="affinityKey">Affinity cache key.</param>
+ Task DeployKeyAffinitySingletonAsync<TK>(string name, IService service, string cacheName, TK affinityKey);
+
+ /// <summary>
/// Deploys multiple instances of the service on the grid. Ignite will deploy a
/// maximum amount of services equal to <paramref name="totalCount" /> parameter making sure that
/// there are no more than <paramref name="maxPerNodeCount" /> service instances running
@@ -90,18 +127,36 @@ namespace Apache.Ignite.Core.Services
/// <param name="service">Service instance.</param>
/// <param name="totalCount">Maximum number of deployed services in the grid, 0 for unlimited.</param>
/// <param name="maxPerNodeCount">Maximum number of deployed services on each node, 0 for unlimited.</param>
- [AsyncSupported]
void DeployMultiple(string name, IService service, int totalCount, int maxPerNodeCount);
/// <summary>
+ /// Deploys multiple instances of the service on the grid. Ignite will deploy a
+ /// maximum amount of services equal to <paramref name="totalCount" /> parameter making sure that
+ /// there are no more than <paramref name="maxPerNodeCount" /> service instances running
+ /// on each node. Whenever topology changes, Ignite will automatically rebalance
+ /// the deployed services within cluster to make sure that each node will end up with
+ /// about equal number of deployed instances whenever possible.
+ /// </summary>
+ /// <param name="name">Service name.</param>
+ /// <param name="service">Service instance.</param>
+ /// <param name="totalCount">Maximum number of deployed services in the grid, 0 for unlimited.</param>
+ /// <param name="maxPerNodeCount">Maximum number of deployed services on each node, 0 for unlimited.</param>
+ Task DeployMultipleAsync(string name, IService service, int totalCount, int maxPerNodeCount);
+
+ /// <summary>
/// Deploys instances of the service in the Ignite according to provided configuration.
/// </summary>
/// <param name="configuration">Service configuration.</param>
- [AsyncSupported]
void Deploy(ServiceConfiguration configuration);
/// <summary>
- /// Cancels service deployment. If a service with specified name was deployed on the grid,
+ /// Deploys instances of the service in the Ignite according to provided configuration.
+ /// </summary>
+ /// <param name="configuration">Service configuration.</param>
+ Task DeployAsync(ServiceConfiguration configuration);
+
+ /// <summary>
+ /// Cancels service deployment. If a service with specified name was deployed on the grid,
/// then <see cref="IService.Cancel"/> method will be called on it.
/// <para/>
/// Note that Ignite cannot guarantee that the service exits from <see cref="IService.Execute"/>
@@ -109,19 +164,36 @@ namespace Apache.Ignite.Core.Services
/// make sure that the service code properly reacts to cancellations.
/// </summary>
/// <param name="name">Name of the service to cancel.</param>
- [AsyncSupported]
void Cancel(string name);
/// <summary>
+ /// Cancels service deployment. If a service with specified name was deployed on the grid,
+ /// then <see cref="IService.Cancel"/> method will be called on it.
+ /// <para/>
+ /// Note that Ignite cannot guarantee that the service exits from <see cref="IService.Execute"/>
+ /// method whenever <see cref="IService.Cancel"/> is called. It is up to the user to
+ /// make sure that the service code properly reacts to cancellations.
+ /// </summary>
+ /// <param name="name">Name of the service to cancel.</param>
+ Task CancelAsync(string name);
+
+ /// <summary>
/// Cancels all deployed services.
/// <para/>
- /// Note that depending on user logic, it may still take extra time for a service to
+ /// Note that depending on user logic, it may still take extra time for a service to
/// finish execution, even after it was cancelled.
/// </summary>
- [AsyncSupported]
void CancelAll();
/// <summary>
+ /// Cancels all deployed services.
+ /// <para/>
+ /// Note that depending on user logic, it may still take extra time for a service to
+ /// finish execution, even after it was cancelled.
+ /// </summary>
+ Task CancelAllAsync();
+
+ /// <summary>
/// Gets metadata about all deployed services.
/// </summary>
/// <returns>Metadata about all deployed services.</returns>
@@ -173,7 +245,7 @@ namespace Apache.Ignite.Core.Services
/// </summary>
/// <returns>Instance with portable mode enabled.</returns>
IServices WithKeepPortable();
-
+
/// <summary>
/// Returns an instance with server-side portable mode enabled.
/// Service method arguments will be kept in portable form.
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/Apache.Ignite.Core/Transactions/ITransaction.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Transactions/ITransaction.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Transactions/ITransaction.cs
index e85d577..22a1ee1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Transactions/ITransaction.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Transactions/ITransaction.cs
@@ -19,7 +19,7 @@ namespace Apache.Ignite.Core.Transactions
{
using System;
using System.Collections.Generic;
- using Apache.Ignite.Core.Common;
+ using System.Threading.Tasks;
/// <summary>
/// Grid cache transaction.
@@ -115,7 +115,7 @@ namespace Apache.Ignite.Core.Transactions
/// </code>
/// </example>
/// </summary>
- public interface ITransaction : IDisposable, IAsyncSupport<ITransaction>
+ public interface ITransaction : IDisposable
{
/// <summary>
/// ID of the node on which this transaction started.
@@ -196,16 +196,24 @@ namespace Apache.Ignite.Core.Transactions
/// <summary>
/// Commits this transaction.
/// </summary>
- [AsyncSupported]
void Commit();
/// <summary>
+ /// Commits this transaction.
+ /// </summary>
+ Task CommitAsync();
+
+ /// <summary>
/// Rolls back this transaction.
/// </summary>
- [AsyncSupported]
void Rollback();
/// <summary>
+ /// Rolls back this transaction.
+ /// </summary>
+ Task RollbackAsync();
+
+ /// <summary>
/// Adds a new metadata.
/// </summary>
/// <param name="name">Metadata name.</param>
http://git-wip-us.apache.org/repos/asf/ignite/blob/cc1aa533/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
index e23d615..270d147 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/CrossPlatformExample.cs
@@ -118,15 +118,13 @@ namespace Apache.Ignite.Examples.Datagrid
/// Gets entry put by Java client. In order for entry to be in cache, Java client example
/// must be run before this example.
/// </summary>
- /// <param name="Ignite">Ignite instance.</param>
+ /// <param name="ignite">Ignite instance.</param>
private static void GetFromJava(IIgnite ignite)
{
var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
- .WithKeepPortable<int, IPortableObject>().WithAsync();
-
- cache.Get(KeyJava);
+ .WithKeepPortable<int, IPortableObject>();
- var orgPortable = cache.GetFuture<IPortableObject>().ToTask().Result;
+ var orgPortable = cache.GetAsync(KeyJava).Result;
if (orgPortable == null)
{
@@ -149,11 +147,9 @@ namespace Apache.Ignite.Examples.Datagrid
private static void GetFromCpp(IIgnite ignite)
{
var cache = ignite.GetOrCreateCache<int, IPortableObject>(CacheName)
- .WithKeepPortable<int, IPortableObject>().WithAsync();
-
- cache.Get(KeyCpp);
+ .WithKeepPortable<int, IPortableObject>();
- var orgPortable = cache.GetFuture<IPortableObject>().Get();
+ var orgPortable = cache.GetAsync(KeyCpp).Result;
Console.WriteLine();
[04/17] ignite git commit: IGNITE-1655: Decoupled Date and Timestamp
in Java.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
index 96f94ad..62ab1a6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
@@ -69,7 +69,7 @@ namespace Apache.Ignite.Core.Events
_type = r.ReadInt();
_name = r.ReadString();
- var timestamp = r.ReadDate();
+ var timestamp = r.ReadTimestamp();
Debug.Assert(timestamp.HasValue);
_timestamp = timestamp.Value;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
index 81a9a5a..9d86311 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cluster/ClusterMetricsImpl.cs
@@ -35,7 +35,7 @@ namespace Apache.Ignite.Core.Impl.Cluster
{
LastUpdateTimeRaw = reader.ReadLong();
- var lastUpdateTime = reader.ReadDate();
+ var lastUpdateTime = reader.ReadTimestamp();
Debug.Assert(lastUpdateTime.HasValue);
LastUpdateTime = lastUpdateTime.Value;
@@ -86,11 +86,11 @@ namespace Apache.Ignite.Core.Impl.Cluster
NonHeapMemoryTotal = reader.ReadLong();
Uptime = reader.ReadLong();
- var startTime = reader.ReadDate();
+ var startTime = reader.ReadTimestamp();
Debug.Assert(startTime.HasValue);
StartTime = startTime.Value;
- var nodeStartTime = reader.ReadDate();
+ var nodeStartTime = reader.ReadTimestamp();
Debug.Assert(nodeStartTime.HasValue);
NodeStartTime = nodeStartTime.Value;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
index 4031d17..7037c6f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/Metadata/PortableMetadataImpl.cs
@@ -71,8 +71,8 @@ namespace Apache.Ignite.Core.Impl.Portable.Metadata
return PortableTypeNames.TypeNameString;
case PortableUtils.TypeGuid:
return PortableTypeNames.TypeNameGuid;
- case PortableUtils.TypeDate:
- return PortableTypeNames.TypeNameDate;
+ case PortableUtils.TypeTimestamp:
+ return PortableTypeNames.TypeNameTimestamp;
case PortableUtils.TypeEnum:
return PortableTypeNames.TypeNameEnum;
case PortableUtils.TypePortable:
@@ -100,8 +100,8 @@ namespace Apache.Ignite.Core.Impl.Portable.Metadata
return PortableTypeNames.TypeNameArrayString;
case PortableUtils.TypeArrayGuid:
return PortableTypeNames.TypeNameArrayGuid;
- case PortableUtils.TypeArrayDate:
- return PortableTypeNames.TypeNameArrayDate;
+ case PortableUtils.TypeArrayTimestamp:
+ return PortableTypeNames.TypeNameArrayTimestamp;
case PortableUtils.TypeArrayEnum:
return PortableTypeNames.TypeNameArrayEnum;
case PortableUtils.TypeArray:
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
index 3241c1c..ac7a957 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableBuilderImpl.cs
@@ -96,16 +96,12 @@ namespace Apache.Ignite.Core.Impl.Portable
TypeIds[typeof(string[])] = PortableUtils.TypeArrayString;
// 3. Guid.
- TypeIds[typeof(Guid)] = PortableUtils.TypeGuid;
TypeIds[typeof(Guid?)] = PortableUtils.TypeGuid;
- TypeIds[typeof(Guid[])] = PortableUtils.TypeArrayGuid;
TypeIds[typeof(Guid?[])] = PortableUtils.TypeArrayGuid;
// 4. Date.
- TypeIds[typeof(DateTime)] = PortableUtils.TypeDate;
- TypeIds[typeof(DateTime?)] = PortableUtils.TypeDate;
- TypeIds[typeof(DateTime[])] = PortableUtils.TypeArrayDate;
- TypeIds[typeof(DateTime?[])] = PortableUtils.TypeArrayDate;
+ TypeIds[typeof(DateTime?)] = PortableUtils.TypeTimestamp;
+ TypeIds[typeof(DateTime?[])] = PortableUtils.TypeArrayTimestamp;
}
/// <summary>
@@ -632,7 +628,7 @@ namespace Apache.Ignite.Core.Impl.Portable
break;
- case PortableUtils.TypeDate:
+ case PortableUtils.TypeTimestamp:
TransferBytes(inStream, outStream, 12);
break;
@@ -680,7 +676,7 @@ namespace Apache.Ignite.Core.Impl.Portable
case PortableUtils.TypeArrayDecimal:
case PortableUtils.TypeArrayString:
case PortableUtils.TypeArrayGuid:
- case PortableUtils.TypeArrayDate:
+ case PortableUtils.TypeArrayTimestamp:
case PortableUtils.TypeArrayEnum:
case PortableUtils.TypeArray:
int arrLen = inStream.ReadInt();
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
index 6e06007..2d50499 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReaderImpl.cs
@@ -323,53 +323,29 @@ namespace Apache.Ignite.Core.Impl.Portable
}
/** <inheritdoc /> */
- public DateTime? ReadDate(string fieldName)
+ public DateTime? ReadTimestamp(string fieldName)
{
- return ReadDate(fieldName, false);
+ return ReadField(fieldName, PortableUtils.ReadTimestamp);
}
/** <inheritdoc /> */
- public DateTime? ReadDate(string fieldName, bool local)
+ public DateTime? ReadTimestamp()
{
- return ReadField(fieldName, r => PortableUtils.ReadDate(r, local));
+ return Read(PortableUtils.ReadTimestamp);
}
-
- /** <inheritdoc /> */
- public DateTime? ReadDate()
- {
- return ReadDate(false);
- }
-
+
/** <inheritdoc /> */
- public DateTime? ReadDate(bool local)
+ public DateTime?[] ReadTimestampArray(string fieldName)
{
- return Read(r => PortableUtils.ReadDate(r, local));
+ return ReadField(fieldName, PortableUtils.ReadTimestampArray);
}
-
- /** <inheritdoc /> */
- public DateTime?[] ReadDateArray(string fieldName)
- {
- return ReadDateArray(fieldName, false);
- }
-
+
/** <inheritdoc /> */
- public DateTime?[] ReadDateArray(string fieldName, bool local)
+ public DateTime?[] ReadTimestampArray()
{
- return ReadField(fieldName, r => PortableUtils.ReadDateArray(r, local));
+ return Read(PortableUtils.ReadTimestampArray);
}
-
- /** <inheritdoc /> */
- public DateTime?[] ReadDateArray()
- {
- return ReadDateArray(false);
- }
-
- /** <inheritdoc /> */
- public DateTime?[] ReadDateArray(bool local)
- {
- return Read(r => PortableUtils.ReadDateArray(r, local));
- }
-
+
/** <inheritdoc /> */
public string ReadString(string fieldName)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
index 261a172..d79cc0b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveRoutines.cs
@@ -256,8 +256,8 @@ namespace Apache.Ignite.Core.Impl.Portable
}
else if (elemType == typeof(DateTime?))
{
- writeAction = GetWriter<DateTime?[]>(field, (f, w, o) => w.WriteDateArray(f, o));
- readAction = GetReader(field, (f, r) => r.ReadDateArray(f));
+ writeAction = GetWriter<DateTime?[]>(field, (f, w, o) => w.WriteTimestampArray(f, o));
+ readAction = GetReader(field, (f, r) => r.ReadTimestampArray(f));
}
else if (elemType.IsEnum)
{
@@ -310,13 +310,13 @@ namespace Apache.Ignite.Core.Impl.Portable
}
else if (type == typeof(DateTime))
{
- writeAction = GetWriter<DateTime>(field, (f, w, o) => w.WriteDate(f, o));
- readAction = GetReader(field, (f, r) => r.ReadDate(f));
+ writeAction = GetWriter<DateTime>(field, (f, w, o) => w.WriteTimestamp(f, o));
+ readAction = GetReader(field, (f, r) => r.ReadTimestamp(f));
}
else if (nullable && nullableType == typeof(DateTime))
{
- writeAction = GetWriter<DateTime?>(field, (f, w, o) => w.WriteDate(f, o));
- readAction = GetReader(field, (f, r) => r.ReadDate(f));
+ writeAction = GetWriter<DateTime?>(field, (f, w, o) => w.WriteTimestamp(f, o));
+ readAction = GetReader(field, (f, r) => r.ReadTimestamp(f));
}
else if (type.IsEnum)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs
index 3dff691..849230e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableReflectiveSerializer.cs
@@ -33,7 +33,7 @@ namespace Apache.Ignite.Core.Impl.Portable
/// zone. It means that this difference will be different as you change time zones.
/// To overcome this discrepancy Ignite always converts .Net date to UTC form
/// before serializing and allows user to decide whether to deserialize them
- /// in UTC or local form using <c>ReadDate(..., true/false)</c> methods in
+ /// in UTC or local form using <c>ReadTimestamp(..., true/false)</c> methods in
/// <see cref="IPortableReader"/> and <see cref="IPortableRawReader"/>.
/// This serializer always read dates in UTC form. It means that if you have
/// local date in any field/property, it will be implicitly converted to UTC
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
index ff3fb85..ed2e9ea 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableSystemHandlers.cs
@@ -66,7 +66,7 @@ namespace Apache.Ignite.Core.Impl.Portable
ReadHandlers[PortableUtils.TypeDecimal] = new PortableSystemReader<decimal?>(PortableUtils.ReadDecimal);
// 2. Date.
- ReadHandlers[PortableUtils.TypeDate] = new PortableSystemReader<DateTime?>(s => PortableUtils.ReadDate(s, false));
+ ReadHandlers[PortableUtils.TypeTimestamp] = new PortableSystemReader<DateTime?>(PortableUtils.ReadTimestamp);
// 3. String.
ReadHandlers[PortableUtils.TypeString] = new PortableSystemReader<string>(PortableUtils.ReadString);
@@ -104,8 +104,8 @@ namespace Apache.Ignite.Core.Impl.Portable
new PortableSystemReader<decimal?[]>(PortableUtils.ReadDecimalArray);
// 6. Date array.
- ReadHandlers[PortableUtils.TypeArrayDate] =
- new PortableSystemReader<DateTime?[]>(s => PortableUtils.ReadDateArray(s, false));
+ ReadHandlers[PortableUtils.TypeArrayTimestamp] =
+ new PortableSystemReader<DateTime?[]>(PortableUtils.ReadTimestampArray);
// 7. String array.
ReadHandlers[PortableUtils.TypeArrayString] = new PortableSystemTypedArrayReader<string>();
@@ -162,7 +162,7 @@ namespace Apache.Ignite.Core.Impl.Portable
private static PortableSystemWriteDelegate FindWriteHandler(Type type)
{
// 1. Well-known types.
- if (type == typeof (string))
+ if (type == typeof(string))
return WriteString;
if (type == typeof(decimal))
return WriteDecimal;
@@ -210,18 +210,14 @@ namespace Apache.Ignite.Core.Impl.Portable
if (elemType == typeof(ulong))
return WriteUlongArray;
// Special types.
- else if (elemType == typeof (decimal?))
+ if (elemType == typeof (decimal?))
return WriteDecimalArray;
if (elemType == typeof(string))
return WriteStringArray;
-// else if (elemType == typeof(DateTime))
-// return WriteDateArray;
if (elemType == typeof(DateTime?))
- return WriteNullableDateArray;
-// else if (elemType == typeof(Guid))
-// return WriteGuidArray;
+ return WriteTimestampArray;
if (elemType == typeof(Guid?))
- return WriteNullableGuidArray;
+ return WriteGuidArray;
// Enums.
if (elemType.IsEnum)
return WriteEnumArray;
@@ -299,9 +295,9 @@ namespace Apache.Ignite.Core.Impl.Portable
/// <param name="obj">Value.</param>
private static void WriteDate(PortableWriterImpl ctx, object obj)
{
- ctx.Stream.WriteByte(PortableUtils.TypeDate);
+ ctx.Stream.WriteByte(PortableUtils.TypeTimestamp);
- PortableUtils.WriteDate((DateTime)obj, ctx.Stream);
+ PortableUtils.WriteTimestamp((DateTime)obj, ctx.Stream);
}
/// <summary>
@@ -483,29 +479,17 @@ namespace Apache.Ignite.Core.Impl.Portable
PortableUtils.WriteDecimalArray((decimal?[])obj, ctx.Stream);
}
-
- /// <summary>
- /// Write date array.
- /// </summary>
- /// <param name="ctx">Context.</param>
- /// <param name="obj">Value.</param>
- private static void WriteDateArray(PortableWriterImpl ctx, object obj)
- {
- ctx.Stream.WriteByte(PortableUtils.TypeArrayDate);
-
- PortableUtils.WriteDateArray((DateTime[])obj, ctx.Stream);
- }
-
+
/// <summary>
/// Write nullable date array.
/// </summary>
/// <param name="ctx">Context.</param>
/// <param name="obj">Value.</param>
- private static void WriteNullableDateArray(PortableWriterImpl ctx, object obj)
+ private static void WriteTimestampArray(PortableWriterImpl ctx, object obj)
{
- ctx.Stream.WriteByte(PortableUtils.TypeArrayDate);
+ ctx.Stream.WriteByte(PortableUtils.TypeArrayTimestamp);
- PortableUtils.WriteDateArray((DateTime?[])obj, ctx.Stream);
+ PortableUtils.WriteTimestampArray((DateTime?[])obj, ctx.Stream);
}
/// <summary>
@@ -519,25 +503,13 @@ namespace Apache.Ignite.Core.Impl.Portable
PortableUtils.WriteStringArray((string[])obj, ctx.Stream);
}
-
- /// <summary>
- /// Write GUID array.
- /// </summary>
- /// <param name="ctx">Context.</param>
- /// <param name="obj">Value.</param>
- private static void WriteGuidArray(PortableWriterImpl ctx, object obj)
- {
- ctx.Stream.WriteByte(PortableUtils.TypeArrayGuid);
-
- PortableUtils.WriteGuidArray((Guid[])obj, ctx.Stream);
- }
-
+
/// <summary>
/// Write nullable GUID array.
/// </summary>
/// <param name="ctx">Context.</param>
/// <param name="obj">Value.</param>
- private static void WriteNullableGuidArray(PortableWriterImpl ctx, object obj)
+ private static void WriteGuidArray(PortableWriterImpl ctx, object obj)
{
ctx.Stream.WriteByte(PortableUtils.TypeArrayGuid);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
index 26cf5b5..e9ef369 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableUtils.cs
@@ -105,7 +105,7 @@ namespace Apache.Ignite.Core.Impl.Portable
public const byte TypeGuid = 10;
/** Type: date. */
- public const byte TypeDate = 11;
+ public const byte TypeTimestamp = 33;
/** Type: unsigned byte array. */
public const byte TypeArrayByte = 12;
@@ -141,7 +141,7 @@ namespace Apache.Ignite.Core.Impl.Portable
public const byte TypeArrayGuid = 21;
/** Type: date array. */
- public const byte TypeArrayDate = 22;
+ public const byte TypeArrayTimestamp = 34;
/** Type: object array. */
public const byte TypeArray = 23;
@@ -212,6 +212,9 @@ namespace Apache.Ignite.Core.Impl.Portable
/** Type: stream receiver holder. */
public const byte TypeStreamReceiverHolder = 94;
+ /** Type: DateTime. */
+ public const byte TypeDateTime = 95;
+
/** Collection: custom. */
public const byte CollectionCustom = 0;
@@ -621,7 +624,7 @@ namespace Apache.Ignite.Core.Impl.Portable
* <param name="val">Date.</param>
* <param name="stream">Stream.</param>
*/
- public static void WriteDate(DateTime val, IPortableStream stream)
+ public static void WriteTimestamp(DateTime val, IPortableStream stream)
{
long high;
int low;
@@ -638,37 +641,20 @@ namespace Apache.Ignite.Core.Impl.Portable
* <param name="local">Local flag.</param>
* <returns>Date</returns>
*/
- public static DateTime? ReadDate(IPortableStream stream, bool local)
+ public static DateTime? ReadTimestamp(IPortableStream stream)
{
long high = stream.ReadLong();
int low = stream.ReadInt();
- return ToDotNetDate(high, low, local);
- }
-
- /// <summary>
- /// Write date array.
- /// </summary>
- /// <param name="vals">Values.</param>
- /// <param name="stream">Stream.</param>
- public static void WriteDateArray(DateTime[] vals, IPortableStream stream)
- {
- stream.WriteInt(vals.Length);
-
- foreach (DateTime val in vals)
- {
- stream.WriteByte(TypeDate);
-
- WriteDate(val, stream);
- }
+ return new DateTime(JavaDateTicks + high * TimeSpan.TicksPerMillisecond + low / 100, DateTimeKind.Utc);
}
-
+
/// <summary>
/// Write nullable date array.
/// </summary>
/// <param name="vals">Values.</param>
/// <param name="stream">Stream.</param>
- public static void WriteDateArray(DateTime?[] vals, IPortableStream stream)
+ public static void WriteTimestampArray(DateTime?[] vals, IPortableStream stream)
{
stream.WriteInt(vals.Length);
@@ -676,9 +662,9 @@ namespace Apache.Ignite.Core.Impl.Portable
{
if (val.HasValue)
{
- stream.WriteByte(TypeDate);
+ stream.WriteByte(TypeTimestamp);
- WriteDate(val.Value, stream);
+ WriteTimestamp(val.Value, stream);
}
else
stream.WriteByte(HdrNull);
@@ -1008,24 +994,7 @@ namespace Apache.Ignite.Core.Impl.Portable
return *(Guid*) (&dotnetGuid);
}
-
- /// <summary>
- /// Write GUID array.
- /// </summary>
- /// <param name="vals">Values.</param>
- /// <param name="stream">Stream.</param>
- public static void WriteGuidArray(Guid[] vals, IPortableStream stream)
- {
- stream.WriteInt(vals.Length);
-
- foreach (Guid val in vals)
- {
- stream.WriteByte(TypeGuid);
-
- WriteGuid(val, stream);
- }
- }
-
+
/// <summary>
/// Write GUID array.
/// </summary>
@@ -1125,20 +1094,19 @@ namespace Apache.Ignite.Core.Impl.Portable
return vals;
}
- /**
- * <summary>Read DateTime array.</summary>
- * <param name="stream">Stream.</param>
- * <param name="local">Local flag.</param>
- * <returns>Array.</returns>
- */
- public static DateTime?[] ReadDateArray(IPortableStream stream, bool local)
+ /// <summary>
+ /// Read timestamp array.
+ /// </summary>
+ /// <param name="stream">Stream.</param>
+ /// <returns>Timestamp array.</returns>
+ public static DateTime?[] ReadTimestampArray(IPortableStream stream)
{
int len = stream.ReadInt();
DateTime?[] vals = new DateTime?[len];
for (int i = 0; i < len; i++)
- vals[i] = stream.ReadByte() == HdrNull ? null : ReadDate(stream, local);
+ vals[i] = stream.ReadByte() == HdrNull ? null : ReadTimestamp(stream);
return vals;
}
@@ -1460,7 +1428,7 @@ namespace Apache.Ignite.Core.Impl.Portable
case TypeDecimal:
case TypeString:
case TypeGuid:
- case TypeDate:
+ case TypeTimestamp:
case TypeEnum:
case TypeArrayByte:
case TypeArrayShort:
@@ -1473,7 +1441,7 @@ namespace Apache.Ignite.Core.Impl.Portable
case TypeArrayDecimal:
case TypeArrayString:
case TypeArrayGuid:
- case TypeArrayDate:
+ case TypeArrayTimestamp:
case TypeArrayEnum:
case TypeArray:
case TypeCollection:
@@ -1912,21 +1880,6 @@ namespace Apache.Ignite.Core.Impl.Portable
low = (int)(diff % TimeSpan.TicksPerMillisecond) * 100;
}
- /**
- * <summary>Convert Java ticks to date.</summary>
- * <param name="high">High part (milliseconds).</param>
- * <param name="low">Low part (nanoseconds).</param>
- * <param name="local">Whether the time should be treaten as local.</param>
- * <returns>Date.</returns>
- */
- private static DateTime ToDotNetDate(long high, int low, bool local)
- {
- DateTime res =
- new DateTime(JavaDateTicks + high * TimeSpan.TicksPerMillisecond + low / 100, DateTimeKind.Utc);
-
- return local ? res.ToLocalTime() : res;
- }
-
/// <summary>
/// Read additional configuration from the stream.
/// </summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
index b75292f..d5fb6ec 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Portable/PortableWriterImpl.cs
@@ -610,9 +610,9 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Date value.</param>
- public void WriteDate(string fieldName, DateTime? val)
+ public void WriteTimestamp(string fieldName, DateTime? val)
{
- WriteFieldId(fieldName, PU.TypeDate);
+ WriteFieldId(fieldName, PU.TypeTimestamp);
if (val == null)
WriteNullField();
@@ -620,8 +620,8 @@ namespace Apache.Ignite.Core.Impl.Portable
{
_stream.WriteInt(PU.LengthTypeId + 12);
- _stream.WriteByte(PortableUtils.TypeDate);
- PortableUtils.WriteDate(val.Value, _stream);
+ _stream.WriteByte(PortableUtils.TypeTimestamp);
+ PortableUtils.WriteTimestamp(val.Value, _stream);
}
}
@@ -629,14 +629,14 @@ namespace Apache.Ignite.Core.Impl.Portable
/// Write date value.
/// </summary>
/// <param name="val">Date value.</param>
- public void WriteDate(DateTime? val)
+ public void WriteTimestamp(DateTime? val)
{
if (val == null)
WriteNullRawField();
else
{
- _stream.WriteByte(PortableUtils.TypeDate);
- PortableUtils.WriteDate(val.Value, _stream);
+ _stream.WriteByte(PortableUtils.TypeTimestamp);
+ PortableUtils.WriteTimestamp(val.Value, _stream);
}
}
@@ -645,9 +645,9 @@ namespace Apache.Ignite.Core.Impl.Portable
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Date array.</param>
- public void WriteDateArray(string fieldName, DateTime?[] val)
+ public void WriteTimestampArray(string fieldName, DateTime?[] val)
{
- WriteFieldId(fieldName, PU.TypeDate);
+ WriteFieldId(fieldName, PU.TypeTimestamp);
if (val == null)
WriteNullField();
@@ -655,8 +655,8 @@ namespace Apache.Ignite.Core.Impl.Portable
{
int pos = SkipFieldLength();
- _stream.WriteByte(PortableUtils.TypeArrayDate);
- PortableUtils.WriteDateArray(val, _stream);
+ _stream.WriteByte(PortableUtils.TypeArrayTimestamp);
+ PortableUtils.WriteTimestampArray(val, _stream);
WriteFieldLength(_stream, pos);
}
@@ -666,14 +666,14 @@ namespace Apache.Ignite.Core.Impl.Portable
/// Write date array.
/// </summary>
/// <param name="val">Date array.</param>
- public void WriteDateArray(DateTime?[] val)
+ public void WriteTimestampArray(DateTime?[] val)
{
if (val == null)
WriteNullRawField();
else
{
- _stream.WriteByte(PortableUtils.TypeArrayDate);
- PortableUtils.WriteDateArray(val, _stream);
+ _stream.WriteByte(PortableUtils.TypeArrayTimestamp);
+ PortableUtils.WriteTimestampArray(val, _stream);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
index 4b15150..8afc36b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionMetricsImpl.cs
@@ -33,11 +33,11 @@ namespace Apache.Ignite.Core.Impl.Transactions
/// <param name="reader">The reader.</param>
public TransactionMetricsImpl(IPortableRawReader reader)
{
- var commitTime = reader.ReadDate();
+ var commitTime = reader.ReadTimestamp();
Debug.Assert(commitTime.HasValue);
CommitTime = commitTime.Value;
- var rollbackTime = reader.ReadDate();
+ var rollbackTime = reader.ReadTimestamp();
Debug.Assert(rollbackTime.HasValue);
RollbackTime = rollbackTime.Value;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
index f0408a8..1c30aad 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawReader.cs
@@ -134,31 +134,17 @@ namespace Apache.Ignite.Core.Portable
decimal?[] ReadDecimalArray();
/// <summary>
- /// Read date value in UTC form. Shortcut for <c>ReadDate(false)</c>.
+ /// Read date value in UTC form. Shortcut for <c>ReadTimestamp(false)</c>.
/// </summary>
/// <returns>Date value.</returns>
- DateTime? ReadDate();
-
- /// <summary>
- /// Read date value.
- /// </summary>
- /// <param name="local">Whether to read date in local (<c>true</c>) or UTC (<c>false</c>) form.</param>
- /// <returns></returns>
- DateTime? ReadDate(bool local);
-
- /// <summary>
- /// Read date array in UTC form. Shortcut for <c>ReadDateArray(false)</c>.
- /// </summary>
- /// <returns>Date array.</returns>
- DateTime?[] ReadDateArray();
-
+ DateTime? ReadTimestamp();
+
/// <summary>
- /// Read date array.
+ /// Read date array in UTC form. Shortcut for <c>ReadTimestampArray(false)</c>.
/// </summary>
- /// <param name="local">Whether to read date array in local (<c>true</c>) or UTC (<c>false</c>) form.</param>
/// <returns>Date array.</returns>
- DateTime?[] ReadDateArray(bool local);
-
+ DateTime?[] ReadTimestampArray();
+
/// <summary>
/// Read string value.
/// </summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
index 71b0c07..fcd449c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableRawWriter.cs
@@ -137,13 +137,13 @@ namespace Apache.Ignite.Core.Portable
/// Write date value.
/// </summary>
/// <param name="val">Date value.</param>
- void WriteDate(DateTime? val);
+ void WriteTimestamp(DateTime? val);
/// <summary>
/// Write date array.
/// </summary>
/// <param name="val">Date array.</param>
- void WriteDateArray(DateTime?[] val);
+ void WriteTimestampArray(DateTime?[] val);
/// <summary>
/// Write string value.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
index 03702d3..7797ba2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableReader.cs
@@ -170,34 +170,18 @@ namespace Apache.Ignite.Core.Portable
decimal?[] ReadDecimalArray(string fieldName);
/// <summary>
- /// Read named date value in UTC form. Shortcut for <c>ReadDate(fieldName, false)</c>.
+ /// Read named date value in UTC form.
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <returns>Date value.</returns>
- DateTime? ReadDate(string fieldName);
-
- /// <summary>
- /// Read named date value.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <param name="local">Whether to read date in local (<c>true</c>) or UTC (<c>false</c>) form.</param>
- /// <returns>Date vaule.</returns>
- DateTime? ReadDate(string fieldName, bool local);
-
- /// <summary>
- /// Read named date array in UTC form. Shortcut for <c>ReadDateArray(fieldName, false)</c>.
- /// </summary>
- /// <param name="fieldName">Field name.</param>
- /// <returns>Date array.</returns>
- DateTime?[] ReadDateArray(string fieldName);
-
+ DateTime? ReadTimestamp(string fieldName);
+
/// <summary>
- /// Read named date array.
+ /// Read named date array in UTC form.
/// </summary>
/// <param name="fieldName">Field name.</param>
- /// <param name="local">Whether to read date in local (<c>true</c>) or UTC (<c>false</c>) form.</param>
/// <returns>Date array.</returns>
- DateTime?[] ReadDateArray(string fieldName, bool local);
+ DateTime?[] ReadTimestampArray(string fieldName);
/// <summary>
/// Read named string value.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
index 6e5d680..c7b8e11 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/IPortableWriter.cs
@@ -156,14 +156,14 @@ namespace Apache.Ignite.Core.Portable
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Date value.</param>
- void WriteDate(string fieldName, DateTime? val);
+ void WriteTimestamp(string fieldName, DateTime? val);
/// <summary>
/// Write named date array.
/// </summary>
/// <param name="fieldName">Field name.</param>
/// <param name="val">Date array.</param>
- void WriteDateArray(string fieldName, DateTime?[] val);
+ void WriteTimestampArray(string fieldName, DateTime?[] val);
/// <summary>
/// Write named string value.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f8b18ccd/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableTypeNames.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableTypeNames.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableTypeNames.cs
index ed792c3..14d9da9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableTypeNames.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Portable/PortableTypeNames.cs
@@ -55,9 +55,12 @@ namespace Apache.Ignite.Core.Portable
/** Type name: UUID. */
public const string TypeNameGuid = "UUID";
- /** Type name: Date. */
+ /** Type name: date. */
public const string TypeNameDate = "Date";
+ /** Type name: timestamp. */
+ public const string TypeNameTimestamp = "Timestamp";
+
/** Type name: Enum. */
public const string TypeNameEnum = "Enum";
@@ -97,9 +100,12 @@ namespace Apache.Ignite.Core.Portable
/** Type name: UUID array. */
public const string TypeNameArrayGuid = "UUID[]";
- /** Type name: Date array. */
+ /** Type name: timestamp array. */
public const string TypeNameArrayDate = "Date[]";
+ /** Type name: timestamp array. */
+ public const string TypeNameArrayTimestamp = "Timestamp[]";
+
/** Type name: Enum array. */
public const string TypeNameArrayEnum = "Enum[]";