Esempio n. 1
0
        public void TestEnableDisable()
        {
            var events = _grid1.Events();

            Assert.AreEqual(0, events.GetEnabledEvents().Length);

            Assert.IsFalse(EventType.EvtsCache.Any(events.IsEnabled));

            events.EnableLocal(EventType.EvtsCache);

            Assert.AreEqual(EventType.EvtsCache, events.GetEnabledEvents());

            Assert.IsTrue(EventType.EvtsCache.All(events.IsEnabled));

            events.EnableLocal(EventType.EvtsTaskExecution);

            events.DisableLocal(EventType.EvtsCache);

            Assert.AreEqual(EventType.EvtsTaskExecution, events.GetEnabledEvents());
        }
Esempio n. 2
0
 /** <inheritdoc /> */
 public IEvents Events()
 {
     return(_ignite.Events());
 }
Esempio n. 3
0
        public void TestRemoteListen(
            [Values(true, false)] bool async,
            [Values(true, false)] bool portable,
            [Values(true, false)] bool autoUnsubscribe)
        {
            foreach (var g in _grids)
            {
                g.Events().EnableLocal(EventType.EvtsJobExecution);
                g.Events().EnableLocal(EventType.EvtsTaskExecution);
            }

            var events = _grid1.Events();

            var expectedType = EventType.EvtJobStarted;

            var remoteFilter = portable
                ?  (IEventFilter <IEvent>) new RemoteEventPortableFilter(expectedType)
                :  new RemoteEventFilter(expectedType);

            var localListener = EventsTestHelper.GetListener();

            if (async)
            {
                events = events.WithAsync();
            }

            var listenId = events.RemoteListen(localListener: localListener, remoteFilter: remoteFilter,
                                               autoUnsubscribe: autoUnsubscribe);

            if (async)
            {
                listenId = events.GetFuture <Guid>().Get();
            }

            CheckSend(3, typeof(JobEvent), expectedType);

            _grid3.Events().DisableLocal(EventType.EvtsJobExecution);

            CheckSend(2, typeof(JobEvent), expectedType);

            events.StopRemoteListen(listenId);

            if (async)
            {
                events.GetFuture().Get();
            }

            CheckNoEvent();

            // Check unsubscription with listener
            events.RemoteListen(localListener: localListener, remoteFilter: remoteFilter,
                                autoUnsubscribe: autoUnsubscribe);

            if (async)
            {
                events.GetFuture <Guid>().Get();
            }

            CheckSend(2, typeof(JobEvent), expectedType);

            EventsTestHelper.ListenResult = false;

            CheckSend(1, typeof(JobEvent), expectedType);  // one last event

            CheckNoEvent();
        }