/// <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 (_cacheStopped != null) { _cache.CacheStopped -= _cacheStopped; _cacheStopped = null; } if (this._hashmapChanged != null) { this._cache.HashmapChanged -= this._hashmapChanged; _hashmapChanged = null; } if (_nodeJoined != null) { _cache.MemberJoined -= _nodeJoined; _nodeJoined = null; } if (_nodeLeft != null) { _cache.MemberLeft -= _nodeLeft; _nodeLeft = null; } }
/// <summary> /// Constructor. /// </summary> /// <param name="parent"></param> /// <param name="nCache"></param> internal InprocCacheEventsListener(CacheEventsListenerBase parent, Alachisoft.NCache.Caching.Cache nCache) { _listener = parent; _nCache = nCache; _itemAdded = new ItemAddedCallback(this.OnItemAdded); _itemUpdated = new ItemUpdatedCallback(this.OnItemUpdated); _itemRemoved = new ItemRemovedCallback(this.OnItemRemoved); _cacheCleared = new Alachisoft.NCache.Caching.CacheClearedCallback(this.OnCacheCleared); _customNotification = new Alachisoft.NCache.Caching.CustomNotificationCallback(this.OnCustomNotification); _cacheStopped = new Alachisoft.NCache.Caching.CacheStoppedCallback(this.OnCacheStopped); _queryChanged = new ActiveQueryCallback(this.OnActiveQueryChanged); _pollRequested = OnPollNotified; _nCache.ItemAdded += _itemAdded; _nCache.ItemUpdated += _itemUpdated; _nCache.ItemRemoved += _itemRemoved; _nCache.CacheCleared += _cacheCleared; _nCache.CustomNotif += _customNotification; _nCache.CacheStopped += _cacheStopped; _customRemoveCallback = new CustomRemoveCallback(this.OnCustomRemoveCallback); _customUpdateCallback = new CustomUpdateCallback(this.OnCustomUpdateCallback); _nCache.CustomRemoveCallbackNotif += _customRemoveCallback; _nCache.CustomUpdateCallbackNotif += _customUpdateCallback; _nCache.ActiveQueryCallbackNotif += _queryChanged; }
/// <summary> /// Start a cache and provide call backs /// </summary> /// <param name="cahcheID"></param> /// <param name="propertyString"></param> /// <param name="itemAdded"></param> /// <param name="itemRemoved"></param> /// <param name="itemUpdated"></param> /// <param name="cacheCleared"></param> /// <returns></returns> /// <exception cref="ArgumentNullException">cacheId is a null reference (Nothing in Visual Basic).</exception> public void StartCache(string cacheId, string partitionId, ItemAddedCallback itemAdded, ItemRemovedCallback itemRemoved, ItemUpdatedCallback itemUpdated, CacheClearedCallback cacheCleared, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate, bool twoPhaseInitialization) { ManagementCommand command = GetManagementCommand(ManagementUtil.MethodName.StartCache, 7); command.Parameters.AddParameter(cacheId); command.Parameters.AddParameter(partitionId); command.Parameters.AddParameter(null); command.Parameters.AddParameter(null); command.Parameters.AddParameter(null); command.Parameters.AddParameter(null); command.Parameters.AddParameter(null); command.Parameters.AddParameter(null); command.Parameters.AddParameter(twoPhaseInitialization); ExecuteCommandOnCacehServer(command); }
/// <summary> /// Creates a cache object by reading in cofiguration parameters from a .NET XML file. /// </summary> /// <param name="configFileName">Name and/or path of the configuration file.</param> /// <param name="configSection">Name and/or ID of the section in the configuration file.</param> /// <param name="itemAdded">item added handler</param> /// <param name="itemRemoved">item removed handler</param> /// <param name="itemUpdated">item updated handler</param> /// <param name="cacheMiss">cache miss handler</param> /// <param name="cacheCleared">cache cleared handler</param> /// <returns>return the Cache object</returns> static public Cache CreateFromXmlConfig(string configFileName, string configSection, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate) { ConfigReader xmlReader = new XmlConfigReader(configFileName, configSection); return CreateFromProperties(xmlReader.Properties,customRemove,customUpdate); }
/// <summary> /// Creates a cache object by parsing configuration string passed as parameter. /// </summary> /// <param name="propertyString">property string provided by the user </param> /// <param name="itemAdded">item added handler</param> /// <param name="itemRemoved">item removed handler</param> /// <param name="itemUpdated">item updated handler</param> /// <param name="cacheMiss">cache miss handler</param> /// <param name="cacheCleared">cache cleared handler</param> /// <returns>return the Cache object</returns> static public Cache CreateFromPropertyString(string propertyString, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate) { ConfigReader propReader = new PropsConfigReader(propertyString); return(CreateFromProperties(propReader.Properties, customRemove, customUpdate)); }
/// <summary> /// Creates a cache object by reading in cofiguration parameters from a .NET XML file. /// </summary> /// <param name="configFileName">Name and/or path of the configuration file.</param> /// <param name="configSection">Name and/or ID of the section in the configuration file.</param> /// <param name="itemAdded">item added handler</param> /// <param name="itemRemoved">item removed handler</param> /// <param name="itemUpdated">item updated handler</param> /// <param name="cacheMiss">cache miss handler</param> /// <param name="cacheCleared">cache cleared handler</param> /// <returns>return the Cache object</returns> static public Cache CreateFromXmlConfig(string configFileName, string configSection, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate) { ConfigReader xmlReader = new XmlConfigReader(configFileName, configSection); return(CreateFromProperties(xmlReader.Properties, customRemove, customUpdate)); }
public override void StartCache(string cacheId, ItemAddedCallback itemAdded, ItemRemovedCallback itemRemoved, ItemUpdatedCallback itemUpdated, CacheClearedCallback cacheCleared, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate) { StartCache(cacheId, null, itemAdded, itemRemoved, itemUpdated, cacheCleared, customRemove, customUpdate, false); }
public override void StartCache(string cacheId, string partitionId, ItemAddedCallback itemAdded, ItemRemovedCallback itemRemoved, ItemUpdatedCallback itemUpdated, CacheClearedCallback cacheCleared, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate, bool twoPhaseInitialization) { if (cacheId == null) { throw new ArgumentNullException("cacheId"); } ContainCacheProcess = true; LeasedCache cache = null; _rwLock.AcquireWriterLock(Timeout.Infinite); try { try { LoadConfiguration(cacheId); } catch (Exception e) { string msg = String.Format("CacheServer failed to load configuration, Error {0}", e.Message); AppUtil.LogEvent(msg, EventLogEntryType.Warning); ContainCacheProcess = false; } cacheInfo = GetCacheInfo(cacheId.ToLower()); if (cacheInfo != null) { cache = cacheInfo.Cache; } try { StartCacheInstance(cache, cacheInfo, itemAdded, itemRemoved, itemUpdated, cacheCleared, customRemove, customUpdate, twoPhaseInitialization); AppUtil.LogEvent(_cacheserver, "\"" + cacheId + "\"" + " started successfully.", EventLogEntryType.Information, EventCategories.Information, EventID.CacheStart); } catch (Exception e) { AppUtil.LogEvent(_cacheserver, "\"" + cacheId + "\" can not be started.\n" + e.ToString(), System.Diagnostics.EventLogEntryType.Error, EventCategories.Error, EventID.CacheStartError); ContainCacheProcess = false; throw; } } finally { _rwLock.ReleaseWriterLock(); } }
private void StartCacheInstance(LeasedCache cache, CacheInfo cacheInfo, ItemAddedCallback itemAdded, ItemRemovedCallback itemRemoved, ItemUpdatedCallback itemUpdated, CacheClearedCallback cacheCleared, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate, bool twoPhaseInitialization) { if (cache != null) { if (itemAdded != null) { cache.ItemAdded += itemAdded; } if (itemRemoved != null) { cache.ItemRemoved += itemRemoved; } if (itemUpdated != null) { cache.ItemUpdated += itemUpdated; } if (cacheCleared != null) { cache.CacheCleared += cacheCleared; } if (customRemove != null) { cache.CustomRemoveCallbackNotif += customRemove; } if (customUpdate != null) { cache.CustomUpdateCallbackNotif += customUpdate; } if (!cache.IsRunning) { cacheInfo.SyncConfiguration(); cache.StartInstance(Renderer, twoPhaseInitialization); #if COMMUNITY if (InstrumentCache.OnCacheStarted != null) { InstrumentCache.OnCacheStarted(cache.Name); } #endif } } else { throw new Runtime.Exceptions.ManagementException("Specified cacheId is not registered"); } }
/// <summary> /// Internal method that actually creates the cache. A HashMap containing the config parameters /// is passed to this method. /// </summary> /// <param name="propertyTable">contains the properties provided by the user in the for of Hashtable</param> /// <param name="itemAdded">item added handler</param> /// <param name="itemRemoved">item removed handler</param> /// <param name="itemUpdated">item updated handler</param> /// <param name="cacheMiss">cache miss handler</param> /// <param name="cacheCleared">cache cleared handler</param> /// <returns>return the Cache object</returns> static private Cache CreateFromProperties(IDictionary properties, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate) { return(CreateFromProperties(properties, null, customRemove, customUpdate, false, false)); }
/// <summary> /// Creates a cache object by parsing configuration string passed as parameter. /// </summary> /// <param name="propertyString">property string provided by the user </param> /// <param name="itemAdded">item added handler</param> /// <param name="itemRemoved">item removed handler</param> /// <param name="itemUpdated">item updated handler</param> /// <param name="cacheMiss">cache miss handler</param> /// <param name="cacheCleared">cache cleared handler</param> /// <returns>return the Cache object</returns> static public Cache CreateFromPropertyString(string propertyString, ItemAddedCallback itemAdded, ItemRemovedCallback itemRemoved, ItemUpdatedCallback itemUpdated, CacheClearedCallback cacheCleared, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate) { ConfigReader propReader = new PropsConfigReader(propertyString); return(CreateFromProperties(propReader.Properties, itemAdded, itemRemoved, itemUpdated, cacheCleared, customRemove, customUpdate)); }
private void StartCacheInstance(LeasedCache cache, CacheInfo cacheInfo, ItemAddedCallback itemAdded, ItemRemovedCallback itemRemoved, ItemUpdatedCallback itemUpdated, CacheClearedCallback cacheCleared, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate, bool twoPhaseInitialization) { if (cache != null) { if (itemAdded != null) { cache.ItemAdded += itemAdded; } if (itemRemoved != null) { cache.ItemRemoved += itemRemoved; } if (itemUpdated != null) { cache.ItemUpdated += itemUpdated; } if (cacheCleared != null) { cache.CacheCleared += cacheCleared; } if (customRemove != null) { cache.CustomRemoveCallbackNotif += customRemove; } if (customUpdate != null) { cache.CustomUpdateCallbackNotif += customUpdate; } if (!cache.IsRunning) { cacheInfo.SyncConfiguration(); cache.StartInstance(Renderer, twoPhaseInitialization); if (InstrumentCache.OnCacheStarted != null) { InstrumentCache.OnCacheStarted(cache.Name); } } } else { throw new Runtime.Exceptions.ManagementException(ErrorCodes.CacheInit.CACHE_ID_NOT_REGISTERED, ErrorMessages.GetErrorMessage(ErrorCodes.CacheInit.CACHE_ID_NOT_REGISTERED)); } }
/// <summary> /// Initialize the cache instance. /// </summary> internal NCache(string cacheId, bool isDotNetClient, ClientManager client, string licenceInfo) { this._cacheId = cacheId; this._isDotNetClient = isDotNetClient; this._client = client; this._licenceCode = licenceInfo; try { _cache = CacheProvider.Provider.GetCacheInstanceIgnoreReplica(cacheId); } catch (Exception) { throw; } if (_cache == null) { throw new Exception("Cache is not registered"); } if (!_cache.IsRunning) { throw new Exception("Cache is not running"); } _onItemUpdatedCallback = new CustomUpdateCallback(CustomUpdate); _cache.CustomUpdateCallbackNotif += _onItemUpdatedCallback; _onItemRemoveCallback = new CustomRemoveCallback(CustomRemove); _cache.CustomRemoveCallbackNotif += _onItemRemoveCallback; 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); } _cache.ClientsInvalidated += new ClientsInvalidatedCallback(OnClientsInvalidated); _cache.OnClientConnected(client.ClientID, cacheId); }
/// <summary> /// Internal method that actually creates the cache. A HashMap containing the config parameters /// is passed to this method. /// </summary> /// <param name="propertyTable">contains the properties provided by the user in the for of Hashtable</param> /// <param name="itemAdded">item added handler</param> /// <param name="itemRemoved">item removed handler</param> /// <param name="itemUpdated">item updated handler</param> /// <param name="cacheMiss">cache miss handler</param> /// <param name="cacheCleared">cache cleared handler</param> /// <returns>return the Cache object</returns> static private Cache CreateFromProperties(IDictionary properties, CacheServerConfig config, ItemAddedCallback itemAdded, ItemRemovedCallback itemRemoved, ItemUpdatedCallback itemUpdated, CacheClearedCallback cacheCleared, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate, string userId, string password, bool isStartingAsMirror, bool twoPhaseInitialization) { Cache cache = new Cache(); cache.Configuration = config; if (itemAdded != null) { cache.ItemAdded += itemAdded; } if (itemRemoved != null) { cache.ItemRemoved += itemRemoved; } if (itemUpdated != null) { cache.ItemUpdated += itemUpdated; } if (cacheCleared != null) { cache.CacheCleared += cacheCleared; } if (customRemove != null) { cache.CustomRemoveCallbackNotif += customRemove; } if (customUpdate != null) { cache.CustomUpdateCallbackNotif += customUpdate; } cache.Initialize(properties, true, isStartingAsMirror, twoPhaseInitialization); return(cache); }
/// <summary> /// Internal method that actually creates the cache. A HashMap containing the config parameters /// is passed to this method. /// </summary> /// <param name="propertyTable">contains the properties provided by the user in the for of Hashtable</param> /// <param name="itemAdded">item added handler</param> /// <param name="itemRemoved">item removed handler</param> /// <param name="itemUpdated">item updated handler</param> /// <param name="cacheMiss">cache miss handler</param> /// <param name="cacheCleared">cache cleared handler</param> /// <returns>return the Cache object</returns> static private Cache CreateFromProperties(IDictionary properties, ItemAddedCallback itemAdded, ItemRemovedCallback itemRemoved, ItemUpdatedCallback itemUpdated, CacheClearedCallback cacheCleared, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate) { Cache cache = new Cache(); if (itemAdded != null) { cache.ItemAdded += itemAdded; } if (itemRemoved != null) { cache.ItemRemoved += itemRemoved; } if (itemUpdated != null) { cache.ItemUpdated += itemUpdated; } if (cacheCleared != null) { cache.CacheCleared += cacheCleared; } if (customRemove != null) { cache.CustomRemoveCallbackNotif += customRemove; } if (customUpdate != null) { cache.CustomUpdateCallbackNotif += customUpdate; } cache.Initialize(properties, true); return(cache); }
/// <summary> /// Internal method that actually creates the cache. A HashMap containing the config parameters /// is passed to this method. /// </summary> /// <param name="propertyTable">contains the properties provided by the user in the for of Hashtable</param> /// <param name="itemAdded">item added handler</param> /// <param name="itemRemoved">item removed handler</param> /// <param name="itemUpdated">item updated handler</param> /// <param name="cacheMiss">cache miss handler</param> /// <param name="cacheCleared">cache cleared handler</param> /// <returns>return the Cache object</returns> static private Cache CreateFromProperties(IDictionary properties, CacheServerConfig config, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate, bool isStartingAsMirror, bool twoPhaseInitialization) { Cache cache = new Cache(); cache.Configuration = config; if (customRemove != null) { cache.CustomRemoveCallbackNotif += customRemove; } if (customUpdate != null) { cache.CustomUpdateCallbackNotif += customUpdate; } cache.Initialize(properties, true, isStartingAsMirror, twoPhaseInitialization); return(cache); }
/// <summary> /// Internal method that actually creates the cache. A HashMap containing the config parameters /// is passed to this method. /// </summary> /// <param name="propertyTable">contains the properties provided by the user in the for of Hashtable</param> /// <param name="itemAdded">item added handler</param> /// <param name="itemRemoved">item removed handler</param> /// <param name="itemUpdated">item updated handler</param> /// <param name="cacheMiss">cache miss handler</param> /// <param name="cacheCleared">cache cleared handler</param> /// <returns>return the Cache object</returns> static private Cache CreateFromProperties(IDictionary properties, ItemAddedCallback itemAdded, ItemRemovedCallback itemRemoved, ItemUpdatedCallback itemUpdated, CacheClearedCallback cacheCleared, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate, string userId, string password) { return(CreateFromProperties(properties, null, itemAdded, itemRemoved, itemUpdated, cacheCleared, customRemove, customUpdate, userId, password, false, false)); }
/// <summary> /// Constructor. /// </summary> /// <param name="parent"></param> /// <param name="nCache"></param> internal CacheEventsListener(Cache.CacheEventsListener parent, Alachisoft.NCache.Caching.Cache nCache) { _listener = parent; _nCache = nCache; _customRemoveCallback = new CustomRemoveCallback(this.OnCustomRemoveCallback); _customUpdateCallback = new CustomUpdateCallback(this.OnCustomUpdateCallback); _nCache.CustomRemoveCallbackNotif += _customRemoveCallback; _nCache.CustomUpdateCallbackNotif += _customUpdateCallback; }
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; }
/// <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; } }
/// <summary> /// Initialize the cache instance. /// </summary> internal NCache(string cacheId, ClientManager client) { this._cacheId = cacheId; this._client = client; try { _cache = CacheProvider.Provider.GetCacheInstanceIgnoreReplica(cacheId); } catch (Exception) { throw; } if (_cache == null) throw new Exception("Cache is not registered"); if (!_cache.IsRunning) throw new Exception("Cache is not running"); _onItemUpdatedCallback = new CustomUpdateCallback(CustomUpdate); _cache.CustomUpdateCallbackNotif += _onItemUpdatedCallback; _onItemRemoveCallback = new CustomRemoveCallback(CustomRemove); _cache.CustomRemoveCallbackNotif += _onItemRemoveCallback; 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); _cache.ClientsInvalidated += new ClientsInvalidatedCallback(OnClientsInvalidated); _cache.OnClientConnected(client.ClientID, cacheId); }
/// <summary> /// Internal method that actually creates the cache. A HashMap containing the config parameters /// is passed to this method. /// </summary> /// <param name="propertyTable">contains the properties provided by the user in the for of Hashtable</param> /// <param name="itemAdded">item added handler</param> /// <param name="itemRemoved">item removed handler</param> /// <param name="itemUpdated">item updated handler</param> /// <param name="cacheMiss">cache miss handler</param> /// <param name="cacheCleared">cache cleared handler</param> /// <returns>return the Cache object</returns> static private Cache CreateFromProperties(IDictionary properties, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate) { return CreateFromProperties(properties, null, customRemove, customUpdate, false, false); }
/// <summary> /// Internal method that actually creates the cache. A HashMap containing the config parameters /// is passed to this method. /// </summary> /// <param name="propertyTable">contains the properties provided by the user in the for of Hashtable</param> /// <param name="itemAdded">item added handler</param> /// <param name="itemRemoved">item removed handler</param> /// <param name="itemUpdated">item updated handler</param> /// <param name="cacheMiss">cache miss handler</param> /// <param name="cacheCleared">cache cleared handler</param> /// <returns>return the Cache object</returns> static private Cache CreateFromProperties(IDictionary properties, CacheServerConfig config, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate, bool isStartingAsMirror, bool twoPhaseInitialization) { Cache cache = new Cache(); cache.Configuration = config; if (customRemove != null) cache.CustomRemoveCallbackNotif += customRemove; if (customUpdate != null) cache.CustomUpdateCallbackNotif += customUpdate; cache.Initialize(properties, true, isStartingAsMirror,twoPhaseInitialization); return cache; }
/// <summary> /// Creates a cache object by parsing configuration string passed as parameter. /// </summary> /// <param name="propertyString">property string provided by the user </param> /// <param name="itemAdded">item added handler</param> /// <param name="itemRemoved">item removed handler</param> /// <param name="itemUpdated">item updated handler</param> /// <param name="cacheMiss">cache miss handler</param> /// <param name="cacheCleared">cache cleared handler</param> /// <returns>return the Cache object</returns> static public Cache CreateFromPropertyString(string propertyString, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate) { ConfigReader propReader = new PropsConfigReader(propertyString); return CreateFromProperties(propReader.Properties, customRemove,customUpdate); }