Beispiel #1
0
        /// <summary>
        /// Unregister the callbacks registered with cache
        /// </summary>

        private void UnRegisterNotifications()
        {
            if (_onItemUpdatedCallback != null)
            {
                _cache.CustomUpdateCallbackNotif -= _onItemUpdatedCallback;
                _onItemUpdatedCallback            = null;
            }
            if (_onItemRemoveCallback != null)
            {
                _cache.CustomRemoveCallbackNotif -= _onItemRemoveCallback;
                _onItemRemoveCallback             = null;
            }
            if (_pollRequestCallback != null)
            {
                _cache.PollRequestCallbackNotif -= _pollRequestCallback;
                _pollRequestCallback             = null;
            }

            if (_cacheCleared != null)
            {
                _cache.CacheCleared -= _cacheCleared;
                _cacheCleared        = null;
            }
            if (_cacheStopped != null)
            {
                _cache.CacheStopped -= _cacheStopped;
                _cacheStopped        = null;
            }
            if (_onCompactTypeModifiedCallback != null)
            {
                _cache.CompactTypeModified    -= _onCompactTypeModifiedCallback;
                _onCompactTypeModifiedCallback = null;
            }

            if (_asyncOperationCallback != null)
            {
                _cache.AsyncOperationCompleted -= _asyncOperationCallback;
                _asyncOperationCallback         = null;
            }
            if (_dsUpdatedCallback != null)
            {
                _cache.DataSourceUpdated -= _dsUpdatedCallback;
                _dsUpdatedCallback        = null;
            }

            if (_itemAdded != null)
            {
                _cache.ItemAdded -= _itemAdded;
                _itemAdded        = null;
                lock (sync_lock_AddDataFilter)
                {
                    ItemAddedFilter = EventDataFilter.None;
                    _addSeq         = -1;
                }
            }
            if (_itemUpdated != null)
            {
                _cache.ItemUpdated -= _itemUpdated;
                _itemUpdated        = null;
                lock (sync_lock_UpdateDataFilter)
                {
                    ItemUpdatedFilter = EventDataFilter.None;
                    _updateSeq        = -1;
                }
            }
            if (_itemRemoved != null)
            {
                _cache.ItemRemoved -= _itemRemoved;
                _itemRemoved        = null;
                lock (sync_lock_RemoveDataFilter)
                {
                    ItemRemovedFilter = EventDataFilter.None;
                    _removeSeq        = -1;
                }
            }

            if (_customNotif != null)
            {
                _cache.CustomNotif -= _customNotif;
                _customNotif        = null;
            }

            if (_nodeJoined != null)
            {
                _cache.MemberJoined -= _nodeJoined;
                _nodeJoined          = null;
            }
            if (_nodeLeft != null)
            {
                _cache.MemberLeft -= _nodeLeft;
                _nodeLeft          = null;
            }
            if (_cacheBecomeActive != null)
            {
                _cache.CacheBecomeActive -= _cacheBecomeActive;
                _cacheBecomeActive        = null;
            }
            if (_configModified != null)
            {
                _cache.ConfigurationModified -= _configModified;
                _configModified = null;
            }

#if !DEVELOPMENT
            if (this._hashmapChanged != null)
            {
                this._cache.HashmapChanged -= this._hashmapChanged;
                _hashmapChanged             = null;
            }
#endif

            if (_operationModeChanged != null)
            {
                _cache.OperationModeChanged -= _operationModeChanged;
                _operationModeChanged        = null;
            }
            if (this._blockClientActivity != null)
            {
                this._cache.BlockActivity -= this._blockClientActivity;
                _blockClientActivity       = null;
            }

            if (this._unblockClientActivity != null)
            {
                this._cache.UnBlockActivity -= this._unblockClientActivity;
                _unblockClientActivity       = null;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Register callbacks with cache.
        /// </summary>
        /// <param name="type"></param>
        public void RegisterNotification(NotificationsType type)
        {
            switch (type)
            {
            case NotificationsType.RegAddNotif:
                if (_itemAdded == null)
                {
                    _itemAdded        = new ItemAddedCallback(ItemAdded);
                    _cache.ItemAdded += _itemAdded;
                }
                break;

            case NotificationsType.RegUpdateNotif:
                if (_itemUpdated == null)
                {
                    _itemUpdated        = new ItemUpdatedCallback(ItemUpdated);
                    _cache.ItemUpdated += _itemUpdated;
                }
                break;

            case NotificationsType.RegRemoveNotif:
                if (_itemRemoved == null)
                {
                    _itemRemoved        = new ItemRemovedCallback(ItemRemoved);
                    _cache.ItemRemoved += _itemRemoved;
                }
                break;

            case NotificationsType.RegClearNotif:
                if (_cacheCleared == null)
                {
                    _cacheCleared        = new CacheClearedCallback(CacheCleared);
                    _cache.CacheCleared += _cacheCleared;
                }
                break;

            case NotificationsType.RegCustomNotif:
                if (_customNotif == null)
                {
                    _customNotif        = new CustomNotificationCallback(CustomNotification);
                    _cache.CustomNotif += _customNotif;
                }
                break;

            case NotificationsType.RegNodeJoinedNotif:
                if (_nodeJoined == null)
                {
                    _nodeJoined          = new NodeJoinedCallback(NodeJoined);
                    _cache.MemberJoined += _nodeJoined;
                }
                break;

            case NotificationsType.RegNodeLeftNotif:
                if (_nodeLeft == null)
                {
                    _nodeLeft          = new NodeLeftCallback(NodeLeft);
                    _cache.MemberLeft += _nodeLeft;
                }
                break;

            case NotificationsType.RegCacheStoppedNotif:

                _cacheStopped        = new CacheStoppedCallback(OnCacheStopped);
                _cache.CacheStopped += _cacheStopped;
                this._cacheStoppedEventRegistered = true;
                break;



#if !DEVELOPMENT
            case NotificationsType.RegHashmapChangedNotif:
                if (this._hashmapChanged == null)
                {
                    this._hashmapChanged        = new HashmapChangedCallback(HashmapChanged);
                    this._cache.HashmapChanged += this._hashmapChanged;
                }
                break;
#endif
            case NotificationsType.UnregAddNotif:
                if (_itemAdded != null)
                {
                    _cache.ItemAdded -= _itemAdded;
                    _itemAdded        = null;
                    lock (sync_lock_AddDataFilter)
                    {
                        ItemAddedFilter = EventDataFilter.None;
                        _addSeq         = -1;
                    }
                }
                break;

            case NotificationsType.UnregUpdateNotif:
                if (_itemUpdated != null)
                {
                    _cache.ItemUpdated -= _itemUpdated;
                    _itemUpdated        = null;
                    lock (sync_lock_UpdateDataFilter = -1)
                    {
                        ItemUpdatedFilter = EventDataFilter.None;
                        _updateSeq        = -1;
                    }
                }
                break;

            case NotificationsType.UnregRemoveNotif:
                if (_itemRemoved != null)
                {
                    _cache.ItemRemoved -= _itemRemoved;
                    _itemRemoved        = null;
                    lock (sync_lock_RemoveDataFilter)
                    {
                        ItemRemovedFilter = EventDataFilter.None;
                        _removeSeq        = -1;
                    }
                }
                break;

            case NotificationsType.UnregClearNotif:
                if (_cacheCleared != null)
                {
                    _cache.CacheCleared -= _cacheCleared;
                    _cacheCleared        = null;
                }
                break;

            case NotificationsType.UnregCustomNotif:
                if (_customNotif != null)
                {
                    _cache.CustomNotif -= _customNotif;
                    _customNotif        = null;
                }
                break;

            case NotificationsType.UnregNodeJoinedNotif:
                if (_nodeJoined != null)
                {
                    _cache.MemberJoined -= _nodeJoined;
                    _nodeJoined          = null;
                }
                break;



            case NotificationsType.UnregNodeLeftNotif:
                if (_nodeLeft != null)
                {
                    _cache.MemberLeft -= _nodeLeft;
                    _nodeLeft          = null;
                }
                break;

            case NotificationsType.UnregCacheStoppedNotif:
                this._cacheStoppedEventRegistered = false;
                break;


#if !DEVELOPMENT
            case NotificationsType.UnregHashmapChangedNotif:
                if (this._hashmapChanged != null)
                {
                    this._cache.HashmapChanged -= this._hashmapChanged;
                    this._hashmapChanged        = null;
                }
                break;
#endif
            }
        }