Example #1
0
        public void StopCacheInstance(string cache, CacheInfo cacheInfo, CacheStopReason reason)
        {
            ManagementCommand command = GetManagementCommand(ManagementUtil.MethodName.StopCacheInstance);

            command.Parameters.AddParameter(cache);
            command.Parameters.AddParameter(cacheInfo);
            command.Parameters.AddParameter(reason);

            ExecuteCommandOnCacehServer(command);
        }
Example #2
0
 private void StopCache(CacheStopReason cacheStopReason)
 {
     if (cacheInfo != null)
     {
         LeasedCache cache = cacheInfo.Cache;
         if (cache != null)
         {
             StopCacheInstance(cache.Name, cacheInfo, cacheStopReason);
         }
     }
 }
Example #3
0
        private static void StopCacheInstance(ArrayList caches, ArrayList cacheInfos, CacheStopReason reason)
        {
            if (caches != null && caches.Count > 0)
            {
                for (int i = 0; i < caches.Count; i++)
                {
                    LeasedCache cache = caches[i] as LeasedCache;
                    CacheInfo cacheInfo = cacheInfos[i] as CacheInfo;

                    if (cache.IsRunning)
                    {
                        if(reason == CacheStopReason.Expired)
                            cache.NCacheLog.CriticalInfo("NCache license has expired on this machine. Stopping cache...");
                        cache.StopInstance();
                        cacheInfo.SyncConfiguration();

                        //instrumentation Code

                    }
                }
            }
            else
                throw new Runtime.Exceptions.ManagementException("Specified cache name is not registered");
        }
Example #4
0
 private static void StopAllCaches(CacheStopReason reason)
 {
     ArrayList caches = new ArrayList();
     ArrayList cacheInfos = new ArrayList();
     foreach(DictionaryEntry de in s_caches)
     {
         //CacheInfo should not be null
         if (de.Value != null)
         {
             caches.Add(((de.Value) as CacheInfo).Cache);
             cacheInfos.Add(de.Value);
         }
     }
     StopCacheInstance(caches, cacheInfos, reason);
 }
Example #5
0
        private void StopCache(string cacheId, string partitionId, CacheStopReason stopReason)
        {
            if (cacheId == null) throw new ArgumentNullException("cacheId");
            ArrayList cacheInfos = null;
            ArrayList caches = null;
            CacheInfo cacheInfo = null;
            LeasedCache cache = null;

            _rwLock.AcquireWriterLock(Timeout.Infinite);
            try ///For a finally {...}
            {

                cacheInfo = GetCacheInfo(cacheId.ToLower());
                if (cacheInfo != null)
                {
                    cache = cacheInfo.Cache;
                }
                if (cache != null)
                {
                    if (caches == null)
                        caches = new ArrayList();

                    if (cacheInfos == null)
                        cacheInfos = new ArrayList();

                    caches.Add(cache);
                    cacheInfos.Add(cacheInfo);
                }

                try
                {

                    StopCacheInstance(caches, cacheInfos, stopReason);
                    AppUtil.LogEvent(_cacheserver, "\"" + cacheId + "\"" + " stopped successfully.", EventLogEntryType.Information, EventCategories.Information, EventID.CacheStop);

                }
                catch (Exception e)
                {

                    AppUtil.LogEvent(_cacheserver, "\"" + cacheId + "\" can not be stopped.\n" + e.ToString(), System.Diagnostics.EventLogEntryType.Error, EventCategories.Error, EventID.CacheStopError);

                    throw;
                }
            }
            finally
            {
                _rwLock.ReleaseWriterLock();
            }
        }
Example #6
0
        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");
            }
        }