You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/10/27 15:59:30 UTC
[1/9] ignite git commit: IGNITE-1644: Correct DateTime serialization.
Repository: ignite
Updated Branches:
refs/heads/ignite-1770 67e62fc7b -> 91b8d2e8e
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);
}
}
[5/9] ignite git commit: IGNITE-1652: .Net async API reworked.
Posted by vo...@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;
}
}
[2/9] ignite git commit: IGNITE-1644: Correct DateTime serialization.
Posted by vo...@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-1770
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.
[7/9] ignite git commit: IGNITE-1652: .Net async API reworked.
Posted by vo...@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-1770
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" />
[9/9] ignite git commit: Merge branch 'ignite-1282' into ignite-1770
Posted by vo...@apache.org.
Merge branch 'ignite-1282' into ignite-1770
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/91b8d2e8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/91b8d2e8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/91b8d2e8
Branch: refs/heads/ignite-1770
Commit: 91b8d2e8e42f77bdd2429692a9d05fed0ce48a2f
Parents: 67e62fc 54c44b8
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Oct 27 18:00:06 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Oct 27 18:00:06 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 +
.../Apache.Ignite.Benchmarks.csproj | 7 +
.../Apache.Ignite.Benchmarks.snk | Bin 0 -> 596 bytes
.../Interop/GetAsyncBenchmark.cs | 6 +-
.../Interop/PutAsyncBenchmark.cs | 6 +-
.../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 | 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 +-
.../Portable/PortableApiSelfTest.cs | 60 ++-
.../Portable/PortableSelfTest.cs | 42 +-
.../Services/ServicesAsyncWrapper.cs | 90 ++--
.../Apache.Ignite.Core.csproj | 20 +-
.../Apache.Ignite.Core/Apache.Ignite.Core.snk | Bin 0 -> 596 bytes
.../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/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 +-
.../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 +-
.../Portable/IPortableBuilder.cs | 235 +++++++++
.../Properties/AssemblyInfo.cs | 4 +-
.../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
100 files changed, 3574 insertions(+), 3130 deletions(-)
----------------------------------------------------------------------
[4/9] ignite git commit: IGNITE-1652: .Net async API reworked.
Posted by vo...@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();
[6/9] ignite git commit: IGNITE-1652: .Net async API reworked.
Posted by vo...@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>
[8/9] ignite git commit: IGNITE-1677: Signed .Net project.
Posted by vo...@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-1770
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
[3/9] ignite git commit: IGNITE-1467: Created standalone CPP
application.
Posted by vo...@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-1770
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