ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [14/50] [abbrv] ignite git commit: IGNITE-5605 .NET: Inject resources into remote event filters
Date Fri, 07 Jul 2017 09:37:15 GMT
IGNITE-5605 .NET: Inject resources into remote event filters


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

Branch: refs/heads/master
Commit: f9f13cf083b481f004531710ec3835afdf5b7cef
Parents: b67b8c4
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Wed Jul 5 12:59:43 2017 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Wed Jul 5 12:59:43 2017 +0300

----------------------------------------------------------------------
 .../Apache.Ignite.Core.Tests/EventsTest.cs       | 19 ++++++++++++++-----
 .../Impl/Events/RemoteListenEventFilter.cs       |  3 +++
 2 files changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f9f13cf0/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 7578475..c05511c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
@@ -17,6 +17,8 @@
 
 // ReSharper disable MemberCanBePrivate.Global
 // ReSharper disable UnusedParameter.Global
+// ReSharper disable UnusedAutoPropertyAccessor.Local
+// ReSharper disable UnusedAutoPropertyAccessor.Global
 #pragma warning disable 618
 namespace Apache.Ignite.Core.Tests
 {
@@ -33,6 +35,7 @@ namespace Apache.Ignite.Core.Tests
     using Apache.Ignite.Core.Events;
     using Apache.Ignite.Core.Impl;
     using Apache.Ignite.Core.Impl.Events;
+    using Apache.Ignite.Core.Resource;
     using Apache.Ignite.Core.Tests.Compute;
     using NUnit.Framework;
 
@@ -360,14 +363,14 @@ namespace Apache.Ignite.Core.Tests
                 if (i > 3)
                 {
                     // Filter
-                    waitTask = getWaitTask(new EventFilter<IEvent>(e => e.Type ==
EventType.TaskReduced), new int[0]);
+                    waitTask = getWaitTask(new LocalEventFilter<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(new EventFilter<IEvent>(e => e.Type ==
EventType.TaskReduced),
+                    waitTask = getWaitTask(new LocalEventFilter<IEvent>(e => e.Type
== EventType.TaskReduced),
                         new[] {EventType.TaskReduced});
 
                     Assert.IsTrue(waitTask.Wait(timeout));
@@ -868,7 +871,7 @@ namespace Apache.Ignite.Core.Tests
         /// <returns>New instance of event listener.</returns>
         public static IEventListener<IEvent> GetListener()
         {
-            return new EventFilter<IEvent>(Listen);
+            return new LocalEventFilter<IEvent>(Listen);
         }
 
         /// <summary>
@@ -917,7 +920,7 @@ namespace Apache.Ignite.Core.Tests
     /// Test event filter.
     /// </summary>
     [Serializable]
-    public class EventFilter<T> : IEventFilter<T>, IEventListener<T> where
T : IEvent
+    public class LocalEventFilter<T> : IEventFilter<T>, IEventListener<T>
where T : IEvent
     {
         /** */
         private readonly Func<T, bool> _invoke;
@@ -926,7 +929,7 @@ namespace Apache.Ignite.Core.Tests
         /// Initializes a new instance of the <see cref="RemoteListenEventFilter"/>
class.
         /// </summary>
         /// <param name="invoke">The invoke delegate.</param>
-        public EventFilter(Func<T, bool> invoke)
+        public LocalEventFilter(Func<T, bool> invoke)
         {
             _invoke = invoke;
         }
@@ -960,6 +963,10 @@ namespace Apache.Ignite.Core.Tests
         /** */
         private readonly int _type;
 
+        /** */
+        [InstanceResource]
+        public IIgnite Ignite { get; set; }
+
         public RemoteEventFilter(int type)
         {
             _type = type;
@@ -968,6 +975,8 @@ namespace Apache.Ignite.Core.Tests
         /** <inheritdoc /> */
         public bool Invoke(IEvent evt)
         {
+            Assert.IsNotNull(Ignite);
+
             return evt.Type == _type;
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/f9f13cf0/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
index 31bfff1..2e0b66c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/RemoteListenEventFilter.cs
@@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Impl.Events
     using Apache.Ignite.Core.Events;
     using Apache.Ignite.Core.Impl.Binary.IO;
     using Apache.Ignite.Core.Impl.Common;
+    using Apache.Ignite.Core.Impl.Resource;
 
     /// <summary>
     /// Event filter/listener holder for RemoteListen.
@@ -75,6 +76,8 @@ namespace Apache.Ignite.Core.Impl.Events
 
                 var pred = reader.ReadObject<object>();
 
+                ResourceProcessor.Inject(pred, grid);
+
                 var func = DelegateTypeDescriptor.GetEventFilter(pred.GetType());
 
                 return new RemoteListenEventFilter(grid, evt => func(pred, evt));


Mime
View raw message