public override void StopCacheInstance(string cacheName, CacheInfo cacheInfo, CacheServer.CacheStopReason reason) { LeasedCache cache = cacheInfo.Cache; if (cache != null && cache.Name == cacheName) { if (cache.IsRunning) { if (!cache.VerifyNodeShutDown()) { throw new Runtime.Exceptions.ManagementException("Graceful shutdown is already in progress..."); } if (reason.Equals(CacheStopReason.Expired)) { cache.NCacheLog.CriticalInfo("NCache license has expired on this machine. Stopping cache..."); } cache.Stop(); if (cacheInfo != null) { cacheInfo.SyncConfiguration(); } if (InstrumentCache.OnCacheStopped != null) { InstrumentCache.OnCacheStopped(cache.Name); } } } else { throw new Runtime.Exceptions.ManagementException(ErrorCodes.CacheInit.CACHE_ID_NOT_REGISTERED, ErrorMessages.GetErrorMessage(ErrorCodes.CacheInit.CACHE_ID_NOT_REGISTERED)); } }
public override void StopCacheInstance(string cacheName, CacheInfo cacheInfo, CacheStopReason reason) { LeasedCache cache = cacheInfo.Cache; if (cache != null && cache.Name == cacheName) { if (cache.IsRunning) { if (reason.Equals(CacheStopReason.Expired)) { cache.NCacheLog.CriticalInfo("NCache license has expired on this machine. Stopping cache..."); } cache.Stop(); if (cacheInfo != null) { cacheInfo.SyncConfiguration(); } //instrumentation Code #if COMMUNITY if (InstrumentCache.OnCacheStopped != null) { InstrumentCache.OnCacheStopped(cache.Name); } #endif } } else { throw new Runtime.Exceptions.ManagementException("Specified cacheId is not registered"); } }
public override void StopCache(string cacheId, string partitionId) { if (cacheId == null) { throw new ArgumentNullException("cacheId"); } LeasedCache cache = null; _rwLock.AcquireWriterLock(Timeout.Infinite); try ///For a finally {...} { if (cacheInfo != null) { cache = cacheInfo.Cache; } if (cache != null) { try { StopCacheInstance(cache.Name, cacheInfo, CacheServer.CacheStopReason.Stoped); } catch (Exception e) { 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"); } }
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 StopCache(CacheServer.CacheStopReason cacheStopReason) { if (cacheInfo != null) { LeasedCache cache = cacheInfo.Cache; if (cache != null) { StopCacheInstance(cache.Name, cacheInfo, cacheStopReason); } } }
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)); } }
public override void StartCachePhase2(string cacheId) { _rwLock.AcquireWriterLock(Timeout.Infinite); try { LeasedCache cache = GetCacheInstance(cacheId.ToLower(), null) as LeasedCache; if (cache != null) { cache.StartInstancePhase2(); } } finally { _rwLock.ReleaseWriterLock(); } }
public override StatusInfo GetCacheStatus(string cacheId, string partitionId) { StatusInfo status = new StatusInfo(); if (cacheInfo != null && cacheInfo.Cache.Name.ToLower().Equals(cacheId.ToLower())) { LeasedCache cache = cacheInfo.Cache; if (cache != null) { if (cache.IsRunning) { status.Status = CacheStatus.Running; } status.IsCoordinator = cache.IsCoordinator; } } return(status); }
private void StartCacheInstance(LeasedCache cache, CacheInfo cacheInfo, bool twoPhaseInitialization) { if (cache != null) { if (!cache.IsRunning) { cacheInfo.SyncConfiguration(); cache.StartInstance(Renderer, twoPhaseInitialization); if (InstrumentCache.OnCacheStarted != null) { InstrumentCache.OnCacheStarted(cache.Name); } } } else { throw new Runtime.Exceptions.ManagementException("Specified cacheId is not registered"); } }
public new StatusInfo GetCacheStatus(string cacheId, string partitionId) { StatusInfo status = new StatusInfo(); if (cacheInfo != null && cacheInfo.Cache.Name.ToLower().Equals(cacheId.ToLower())) { LeasedCache cache = cacheInfo.Cache; if (cache != null) { if (cache.IsRunning) { status.Status = CacheStatus.Running; } #if !(DEVELOPMENT || CLIENT) status.IsCoordinator = cache.IsCoordinator; #endif } } return(status); }
public override void StopCacheInstance(string cacheName, CacheInfo cacheInfo, CacheServer.CacheStopReason reason) { LeasedCache cache = cacheInfo.Cache; if (cache != null && cache.Name == cacheName) { if (cache.IsRunning) { cache.Stop(); if (cacheInfo != null) { cacheInfo.SyncConfiguration(); } InstrumentCache.OnCacheStopped(cache.Name); } } else { throw new Runtime.Exceptions.ManagementException("Specified cacheId is not registered"); } }