/// <summary> /// Constructor. /// </summary> /// <param name="parent"></param> /// <param name="nCache"></param> internal InprocCacheAsyncEventsListener(CacheAsyncEventsListenerBase parent, Alachisoft.NCache.Caching.Cache nCache) { _parent = parent; _nCache = nCache; _asyncOperationCompleted = new AsyncOperationCompletedCallback(this.OnAsyncOperationCompleted); _nCache.AsyncOperationCompleted += _asyncOperationCompleted; _dsUpdatedCallback = new DataSourceUpdatedCallback(this.OnDSUpdated); _nCache.DataSourceUpdated += _dsUpdatedCallback; }
/// <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; } }
internal NCache(string cacheId, bool isDotNetClient, ClientManager client, string licenceInfo, string userId, string password, byte[] userIdBinary, byte[] paswordBinary, Runtime.Caching.ClientInfo clientInfo) { this._cacheId = cacheId; this._isDotNetClient = isDotNetClient; this._client = client; this._licenceCode = licenceInfo; _cache = CacheProvider.Provider.GetCacheInstanceIgnoreReplica(cacheId); if (_cache == null) { throw new Exception("Cache is not registered"); } if (!_cache.IsRunning) { throw new Exception("Cache is not running"); } EventHelper.EventDataFormat = _cache.SocketServerDataService; #if !CLIENT if (_cache.CacheType.Equals("mirror-server") && !_cache.IsCoordinator) { throw new OperationNotSupportedException("Cannot connect to Passive Node in Mirror Cluster."); } #endif _onItemUpdatedCallback = new CustomUpdateCallback(CustomUpdate); _cache.CustomUpdateCallbackNotif += _onItemUpdatedCallback; _onItemRemoveCallback = new CustomRemoveCallback(CustomRemove); _cache.CustomRemoveCallbackNotif += _onItemRemoveCallback; _pollRequestCallback = new Caching.PollRequestCallback(PollRequest); _cache.PollRequestCallbackNotif += _pollRequestCallback; if (SocketServer.Logger.IsErrorLogsEnabled) { SocketServer.Logger.NCacheLog.Error(_cacheserver + ".ctor", "Registering cache stopped event for " + _client.ClientID); } _cacheStopped = new CacheStoppedCallback(OnCacheStopped); _cache.CacheStopped += _cacheStopped; if (SocketServer.Logger.IsErrorLogsEnabled) { SocketServer.Logger.NCacheLog.Error(_cacheserver + ".ctor", "Cache stopped event registered for " + _client.ClientID); } _asyncOperationCallback = new AsyncOperationCompletedCallback(AsyncOperationCompleted); _cache.AsyncOperationCompleted += _asyncOperationCallback; _cacheBecomeActive = new CacheBecomeActiveCallback(OnCacheBecomeActive); _cache.CacheBecomeActive += _cacheBecomeActive; _configModified = new ConfigurationModified(OnConfigModified); _cache.ConfigurationModified += _configModified; _onCompactTypeModifiedCallback = new CompactTypeModifiedCallback(CompactTypesModified); _cache.CompactTypeModified += _onCompactTypeModifiedCallback; _blockClientActivity = new BlockClientActivity(BlockClientActivity); _cache.BlockActivity += this._blockClientActivity; _unblockClientActivity = new UnBlockClientActivity(UnBlockClientActivity); _cache.UnBlockActivity += this._unblockClientActivity; _operationModeChanged += new OperationModeChangedCallback(OperationModeChanged); _cache.OperationModeChanged += _operationModeChanged; }