コード例 #1
0
ファイル: DatasourceMgr.cs プロジェクト: fabrimaciel/colosoft
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="cacheName">Nome do cache.</param>
 /// <param name="properties">Hash com as propriedades de configuração.</param>
 /// <param name="context">Contexto de execução.</param>
 /// <param name="timeout"></param>
 public DatasourceMgr(string cacheName, IDictionary properties, CacheRuntimeContext context, long timeout)
 {
     _cacheName = cacheName;
     _context   = context;
     _queue     = new Dictionary <object, IAsyncTask>();
     this.Initialize(properties, timeout);
 }
コード例 #2
0
ファイル: CacheBase.cs プロジェクト: usamabintariq/NCache
 /// <summary>
 /// Overloaded constructor. Takes the listener as parameter.
 /// </summary>
 /// <param name="listener">listener of Cache events.</param>
 public CacheBase(IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context)
 {
     _context        = context;
     _listener       = listener;
     _syncObj        = new ReaderWriterLock();
     _KeyLockManager = new KeyLockManager <object>(LockRecursionPolicy.SupportsRecursion);
 }
コード例 #3
0
ファイル: LocalCache.cs プロジェクト: christrotter/NCache
        /// <summary>
        /// Overloaded constructor. Takes the properties as a map.
        /// </summary>
        /// <param name="cacheSchemes">collection of cache schemes (config properties).</param>
        /// <param name="properties">properties collection for this cache.</param>
        /// <param name="listener">cache events listener</param>
        /// <param name="timeSched">scheduler to use for periodic tasks</param>
        public LocalCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context)

            : base(properties, parentCache, listener, context)
        {
            _stats.ClassName = "local-cache";
            Initialize(cacheClasses, properties);
        }
コード例 #4
0
 public WriteThruProviderManager(string cacheName, IDictionary properties, CacheRuntimeContext context, int timeout, string providerName)
 {
     _context    = context;
     _cacheName  = cacheName;
     _myProvider = providerName;
     this.Initialize(properties);
 }
コード例 #5
0
 internal virtual void ResetVariant(CacheRuntimeContext context)
 {
     if (this.IsVariant)
     {
         Reset(context);
     }
 }
コード例 #6
0
ファイル: CPUUsageCollector.cs プロジェクト: yongwuhou/NCache
 internal CPUUsageCollector(ResourceAtribute attribute, CacheRuntimeContext cacheRuntimeContext) : base(attribute, cacheRuntimeContext)
 {
     try
     {
         CouneterName = "% Processor Time";
         Name         = "CPU Usage";
         if (!ServiceConfiguration.PublishCountersToCacheHost)
         {
             InitializeCounter();
         }
         else
         {
             InitiliazeCPUNETCORE();
         }
         processrs = Environment.ProcessorCount;
         if (processrs <= 0)
         {
             processrs = 1;
         }
         SetThresholds();
     }
     catch (Exception ex)
     {
     }
 }
コード例 #7
0
        /// <summary>
        /// Overloaded constructor. Takes the properties as a map.
        /// </summary>
        /// <param name="cacheSchemes">collection of cache schemes (config properties).</param>
        /// <param name="properties">properties collection for this cache.</param>
        /// <param name="listener">cache events listener</param>
        /// <param name="timeSched">scheduler to use for periodic tasks</param>
        public IndexedLocalCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context)
            : base(cacheClasses, parentCache, properties, listener, context)
        {
            IDictionary props = null;
            if (properties.Contains("indexes"))
            {
                props = properties["indexes"] as IDictionary;
            }

            _queryIndexManager = new QueryIndexManager(props, this, _context.CacheRoot.Name);
            if (!_queryIndexManager.Initialize()) _queryIndexManager = null;


            //+Numan16122014
            _cacheStore.ISizableQueryIndexManager = _queryIndexManager;            
            _cacheStore.ISizableEvictionIndexManager = _evictionPolicy;
            _cacheStore.ISizableExpirationIndexManager = _context.ExpiryMgr;

            _stats.MaxCount = _cacheStore.MaxCount;
            _stats.MaxSize = _cacheStore.MaxSize;

            //+Numan16122014

            if (_context.PerfStatsColl != null)
            {
                if (_queryIndexManager != null)
                    _context.PerfStatsColl.SetQueryIndexSize(_queryIndexManager.IndexInMemorySize);                
            }
        }
コード例 #8
0
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="properties">Propriedades de configuração.</param>
 /// <param name="context">Contexto de execução.</param>
 public ExpirationManager(IDictionary properties, CacheRuntimeContext context)
 {
     _context = context;
     _logger  = context.Logger;
     this.Initialize(properties);
     _sleepInterval    = ServiceConfiguration.ExpirationBulkRemoveDelay;
     _removeThreshhold = ServiceConfiguration.ExpirationBulkRemoveSize;
 }
コード例 #9
0
        internal AsyncItemReplicator(CacheRuntimeContext context, TimeSpan interval)
        {
            _bulkKeysToReplicate = ServiceConfiguration.BulkItemsToReplicate;

            this._context  = context;
            this._interval = interval;
            _queue         = new OptimizedQueue(context);
        }
コード例 #10
0
 public bool IsExpired(CacheRuntimeContext context)
 {
     if (_hint != null)
     {
         return(_hint.DetermineExpiration(context));
     }
     return(false);
 }
コード例 #11
0
ファイル: KeyDependecy.cs プロジェクト: fabrimaciel/colosoft
 /// <summary>
 /// Determina a expiração para o contexto.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 internal override bool DetermineExpiration(CacheRuntimeContext context)
 {
     if (_startAfter.CompareTo(CachingUtils.DiffSeconds(DateTime.Now)) > 0)
     {
         return(false);
     }
     return(base.HasExpired);
 }
コード例 #12
0
 public DSWriteBehindOperation(CacheRuntimeContext context, Object key, CacheEntry entry, OpCode opcode, string providerName, long operationDelay, string taskId, string source, WriteBehindAsyncProcessor.TaskState taskState) :
     base(context, key, entry, opcode, providerName)
 {
     this._taskId        = taskId;
     this._state         = taskState;
     this._source        = source;
     this._delayInterval = operationDelay;
 }
コード例 #13
0
        internal AsyncItemReplicator(CacheRuntimeContext context, TimeSpan interval)
        {
                        if (System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.BulkItemsToReplicate"] != null)
            { _bulkKeysToReplicate = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.BulkItemsToReplicate"]); }

            this._context = context;
            this._interval = interval;
        }
コード例 #14
0
 /// <summary>
 /// Overloaded constructor
 /// Initializes the object based on the properties specified in configuration
 /// </summary>
 /// <param name="properties">properties collection for this cache.</param>
 public WriteThruProviderMgr(string cacheName, IDictionary properties, CacheRuntimeContext context, long operationDelay, string providerName)
 {
     _cacheName      = cacheName;
     _context        = context;
     _operationDelay = operationDelay;
     _myProvider     = providerName;
     Initialize(properties);
 }
コード例 #15
0
ファイル: KeyDependency.cs プロジェクト: wangchengqun/NCache
        /// <summary>
        /// virtual method that returns true when the expiration has taken place, returns
        /// false otherwise.
        /// </summary>
        internal override bool DetermineExpiration(CacheRuntimeContext context)
        {
            if (_startAfter.CompareTo(DateTime.Now) > 0)
            {
                return(false);
            }

            return(HasExpired);
        }
コード例 #16
0
 /// <summary>
 /// Resets the value of the hint. Called by the Cache manager upon a successful HIT.
 /// </summary>
 internal virtual bool Reset(CacheRuntimeContext context)
 {
     _bits &= ~EXPIRED;
     if (_ncacheLog == null)
     {
         _ncacheLog = context.NCacheLog;
     }
     return(true);
 }
コード例 #17
0
 public DSWriteOperation(CacheRuntimeContext context, Object key, CacheEntry entry, OpCode opcode, string providerName)
 {
     this._key          = key;
     this._entry        = entry;
     this._opCode       = opcode;
     this._providerName = providerName;
     this._cacheId      = context.SerializationContext;
     this._context      = context;
 }
コード例 #18
0
 internal NosDBDependencyListener(string key, string connString, string queryString,
                                  CacheRuntimeContext context, ExpirationHintType hintType, int timeOut = 0, IDictionary cmdParams = null)
     : base(
         key, connString, queryString, context.ExpiryMgr.NotifBasedDepManager,
         context.ExpiryMgr.NotifBasedDepManager, context.NCacheLog, hintType)
 {
     _cmdParams = cmdParams;
     _timeout   = timeOut;
 }
コード例 #19
0
 internal NotificationBasedDependencyManager(CacheRuntimeContext context)
 {
     _context         = context;
     _listeners       = new Hashtable();
     _silentListeners = new Hashtable();
     _dbConPool       = new DbConnectionPool(_context.NCacheLog);
     _asyncDepChange  = new AsyncOnDepenencyChange(this);
     _asyncDepChange.Start();
 }
コード例 #20
0
            internal YukonDependencyListener(string key, string connString, string queryString, CacheRuntimeContext context, ExpirationHintType hintType, CommandType cmdType, IDictionary cmdParams)
                : base(key, connString, queryString, context.ExpiryMgr.NotifBasedDepManager, context.ExpiryMgr.NotifBasedDepManager, context.NCacheLog, hintType)
            {
                _cmdParams = cmdParams;
                _cmdType   = cmdType;
                _context   = context;

                _notifBasedDepManager = _context.ExpiryMgr.NotifBasedDepManager;
            }
コード例 #21
0
ファイル: IdleExpiration.cs プロジェクト: christrotter/NCache
		/// <summary>
		/// virtual method that returns true when the expiration has taken place, returns 
		/// false otherwise.
		/// </summary>
		internal override bool DetermineExpiration(CacheRuntimeContext context)
		{ 
			if(HasExpired) 
				return true;

            if (SortKey.CompareTo(AppUtil.DiffSeconds(DateTime.Now)) < 0)
                this.NotifyExpiration(this, null);
			return HasExpired;
		}
コード例 #22
0
        internal AsyncItemReplicator(CacheRuntimeContext context, TimeSpan interval)
        {
            if (System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.BulkItemsToReplicate"] != null)
            {
                _bulkKeysToReplicate = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["NCacheServer.BulkItemsToReplicate"]);
            }

            this._context  = context;
            this._interval = interval;
        }
コード例 #23
0
 public CacheInputProvider(CacheBase source, QueryFilter filter, CacheRuntimeContext context)
 {
     this.queryFilter = filter;
     this.inputSource = source;
     this.context     = context;
     if (this.context != null)
     {
         this.serializationContext = this.context.SerializationContext;
     }
 }
コード例 #24
0
        internal Subscriptions(string clientId, string subscriptionId, SubscriptionPolicyType subscriptionPolicy, long expirationTime, CacheRuntimeContext context, SubscriptionType subscriptionType = SubscriptionType.Subscriber)
        {
            _clientId           = clientId;
            _subscriptionPolicy = subscriptionPolicy;
            _context            = context;
            _expiration         = IdleExpiration.Create(null, new TimeSpan(expirationTime));

            _subscriptionType = subscriptionType;
            _expirationTime   = expirationTime;
        }
コード例 #25
0
 /// <summary>
 /// Reset dependency settings
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 internal override bool Reset(CacheRuntimeContext context)
 {
     base.Reset(context);
     // todo add manager code for handling NosDB dependency
     _notifBasedDepManager = context.ExpiryMgr.NotifBasedDepManager;
     if (_notifBasedDepManager != null)
     {
         return(_notifBasedDepManager.Add(CacheKey, _conStr, _queryStr, context.IsDbSyncCoordinator, _hintType, CommandType.Text, _cmdParams, _timeOut));// initialize if this node is DbSyncCoordinator
     }
     return(false);
 }
コード例 #26
0
ファイル: FixedExpiration.cs プロジェクト: javithalion/NCache
		/// <summary>
		/// virtual method that returns true when the expiration has taken place, returns 
		/// false otherwise.
		/// </summary>
		internal override bool DetermineExpiration(CacheRuntimeContext context)
		{ 
			if(HasExpired) 
				return true;

            if (_absoluteTime < AppUtil.DiffSeconds(DateTime.Now))
                this.NotifyExpiration(this, null);


			return HasExpired;
		}
コード例 #27
0
 /// <summary>
 /// Resets only the variant ExpirationHints.
 /// </summary>
 internal override void ResetVariant(CacheRuntimeContext context)
 {
     for (int i = 0; i < _hints.Count; i++)
     {
         ExpirationHint hint = (ExpirationHint)_hints[i];
         if (hint.IsVariant)
         {
             hint.Reset(context);
         }
     }
 }
コード例 #28
0
        /// <summary>
        /// Overloaded Constructor
        /// </summary>
        /// <param name="timeSched"></param>
        public ExpirationManager(IDictionary properties, CacheRuntimeContext context)
        {
            _context   = context;
            _ncacheLog = context.NCacheLog;

            Initialize(properties);

            //new way to do this...
            _sleepInterval    = ServiceConfiguration.ExpirationBulkRemoveDelay;
            _removeThreshhold = ServiceConfiguration.ExpirationBulkRemoveSize;
        }
コード例 #29
0
 public void Execute(CacheBase cache, CacheRuntimeContext context, long count)
 {
     Sync.AcquireWriterLock(Timeout.Infinite);
     try
     {
         _evctPolicy.Execute(cache,context, count);
     }
     finally
     {
         Sync.ReleaseWriterLock();
     }
 }
コード例 #30
0
 public void Execute(CacheBase cache, CacheRuntimeContext context, long count)
 {
     Sync.AcquireWriterLock(Timeout.Infinite);
     try
     {
         _evctPolicy.Execute(cache, context, count);
     }
     finally
     {
         Sync.ReleaseWriterLock();
     }
 }
コード例 #31
0
 /// <summary>
 /// Determina a expiração.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 internal override bool DetermineExpiration(CacheRuntimeContext context)
 {
     if (base.HasExpired)
     {
         return(true);
     }
     if (this.SortKey.CompareTo(CachingUtils.DiffSeconds(DateTime.Now)) < 0)
     {
         base.NotifyExpiration(this, null);
     }
     return(base.HasExpired);
 }
コード例 #32
0
 /// <summary>
 /// Determina a data de expiração.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 internal override bool DetermineExpiration(CacheRuntimeContext context)
 {
     if (base.HasExpired)
     {
         return(true);
     }
     if (_absoluteTime < CachingUtils.DiffSeconds(DateTime.Now))
     {
         base.NotifyExpiration(this, null);
     }
     return(base.HasExpired);
 }
コード例 #33
0
        /// <summary>
        /// Resets both the contained ExpirationHints.
        /// </summary>
        internal override bool Reset(CacheRuntimeContext context)
        {
            bool flag = base.Reset(context);

            for (int i = 0; i < _hints.Count; i++)
            {
                if (((ExpirationHint)_hints[i]).Reset(context))
                {
                    flag = true;
                }
            }
            return(flag);
        }
コード例 #34
0
ファイル: DependencyHint.cs プロジェクト: yongwuhou/NCache
 /// <summary>
 /// virtual method that returns true when the expiration has taken place, returns 
 /// false otherwise.
 /// </summary>
 internal override bool DetermineExpiration(CacheRuntimeContext context)
 { 
     if (_startAfter.CompareTo(DateTime.Now) > 0)
     {
         return false;
     }
     if(!HasExpired)
     {
         if(HasChanged)
             NotifyExpiration(this, null);
     }
     return HasExpired;
 }
コード例 #35
0
 /// <summary>
 /// Reset dependency settings
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 internal override bool Reset(CacheRuntimeContext context)
 {
     base.Reset(context);
     _cdbSyncManager       = context.ExpiryMgr.CacheDbSyncManager;
     _notifBasedDepManager = context.ExpiryMgr.NotifBasedDepManager;
     if (_notifBasedDepManager != null)
     {
         return(_notifBasedDepManager.Add(CacheKey, _conStr, _queryStr, context.IsDbSyncCoordinator, _hintType, _cmdType, _cmdParams, 0));// initialize if this node is DbSyncCoordinator
     }
     else
     {
         return(false);
     }
 }
コード例 #36
0
        /// <summary>
        /// Overloaded Constructor
        /// </summary>
        /// <param name="timeSched"></param>
        public ExpirationManager(IDictionary properties, CacheRuntimeContext context)
        {
            _context   = context;
            _ncacheLog = context.NCacheLog;

            Initialize(properties);
            _cdbSyncMgr = new CacheDbSyncManager(_ncacheLog);
            _cdbSyncMgr.GetCacheID(context.CacheRoot.Name);

            _notifBasedDepMgr = new NotificationBasedDependencyManager(_context);

            _sleepInterval    = ServiceConfiguration.ExpirationBulkRemoveDelay;
            _removeThreshhold = ServiceConfiguration.ExpirationBulkRemoveSize;
        }
コード例 #37
0
        /// <summary>
        /// Overloaded Constructor
        /// </summary>
        /// <param name="timeSched"></param>
        public ExpirationManager(IDictionary properties, CacheRuntimeContext context)
        {
            _context = context;
			_ncacheLog = context.NCacheLog;
            
            Initialize(properties);

            //muds:
            //new way to do this...
            _sleepInterval = Convert.ToInt32(ServiceConfiguration.ExpirationBulkRemoveDelay);
            _removeThreshhold = Convert.ToInt32(ServiceConfiguration.ExpirationBulkRemoveSize);           
        }
コード例 #38
0
ファイル: ExpirationHint.cs プロジェクト: javithalion/NCache
		/// <summary>
		/// Resets the value of the hint. Called by the Cache manager upon a successful HIT.
		/// </summary>
		internal virtual bool Reset(CacheRuntimeContext context)
		{
			_bits &= ~EXPIRED;
            if (_ncacheLog == null)
                _ncacheLog = context.NCacheLog;
			//return false;
            return true;
		}
コード例 #39
0
 public HashedOverflowCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context, bool logEntries)
     : base(cacheClasses, parentCache, properties, listener, context)
 {
     _logMgr = new OpLogManager(logEntries, context);
     _logEntries = logEntries;
 }
コード例 #40
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="cacheClasses"></param>
 /// <param name="properties"></param>
 /// <param name="listener"></param>
 /// <param name="context"></param>
 /// <param name="clusterListener"></param>
 /// <param name="userId"></param>
 /// <param name="password"></param>
 public ReplicatedServerCache(IDictionary cacheClasses, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context, IClusterEventsListener clusterListener)
     : base(properties, listener, context, clusterListener)
 {
     _stats.ClassName = "replicated-server";
 }
コード例 #41
0
ファイル: ExpirationHint.cs プロジェクト: javithalion/NCache
 internal virtual void ResetVariant(CacheRuntimeContext context)
 {
     if (this.IsVariant)
     {
         Reset(context);
     }
 }
コード例 #42
0
ファイル: CacheBase.cs プロジェクト: christrotter/NCache
        /// <summary>
        /// Overloaded constructor. Takes the listener as parameter.
        /// </summary>
        /// <param name="listener">listener of Cache events.</param>
        public CacheBase(IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context)
        {
            _context = context;
            _listener = listener;
            _syncObj = new ReaderWriterLock();

        }
コード例 #43
0
        /// <summary>
        /// Overloaded Constructor
        /// </summary>
        /// <param name="timeSched"></param>
        public ExpirationManager(IDictionary properties, CacheRuntimeContext context)
        {
            _context = context;
			_ncacheLog = context.NCacheLog;
            
            Initialize(properties);

            //muds:
            //new way to do this...
            _sleepInterval = Convert.ToInt32(ServiceConfiguration.ExpirationBulkRemoveDelay);
            _removeThreshhold = Convert.ToInt32(ServiceConfiguration.ExpirationBulkRemoveSize);
            if (System.Configuration.ConfigurationSettings.AppSettings.Get("NCacheServer.EnableGCCollection") != null)
            {
                _allowExplicitGCCollection = Convert.ToBoolean(System.Configuration.ConfigurationSettings.AppSettings.Get("NCacheServer.EnableGCCollection"));
            }
        }
コード例 #44
0
 /// <summary>
 /// Overloaded constructor. Takes the listener as parameter.
 /// </summary>
 /// <param name="listener">listener of Cache events.</param>
 public ReplicatedCacheBase(IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context, IClusterEventsListener clusterListener)
     : base(properties, listener, context, clusterListener)
 {
 }
コード例 #45
0
 /// <summary>
 /// Overloaded constructor. Takes the properties as a map.
 /// </summary>
 /// <param name="cacheSchemes">collection of cache schemes (config properties).</param>
 /// <param name="properties">properties collection for this cache.</param>
 /// <param name="listener">cache events listener</param>
 /// <param name="timeSched">scheduler to use for periodic tasks</param>
 public IndexedOverflowCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context)
     : base( cacheClasses, parentCache, properties, listener, context)
 {
 }
コード例 #46
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="cacheSchemes">collection of cache schemes (config properties).</param>
 /// <param name="properties">properties collection for this cache.</param>
 /// <param name="listener">cache events listener</param>
 public ReplicatedServerCache(IDictionary cacheClasses, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context)
     : base(properties, listener, context)
 {
     _stats.ClassName = "replicated-server";
     Initialize(cacheClasses, properties);
 }
コード例 #47
0
ファイル: ExpirationHint.cs プロジェクト: javithalion/NCache
 /// <summary>
 /// Override this method for hints that should be reinitialized when they are moved to another partition.
 /// </summary>
 /// <param name="context">CacheRuntimeContex for required contextual information.</param>
 /// <returns>True if reinitialization was successfull.</returns>
 internal virtual bool ReInitializeHint(CacheRuntimeContext context)
 {
     return false;
 }
コード例 #48
0
        /// <summary>
        /// Overloaded constructor. Takes the listener as parameter.
        /// </summary>
        /// <param name="listener">listener of Cache events.</param>
        public ClusterCacheBase(IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context, IClusterEventsListener clusterListener)
            : base(properties, listener, context)
        {
            this._nodeInformationTable = Hashtable.Synchronized(new Hashtable(10));

            _stats = new ClusterCacheStatistics();
            _stats.InstanceName = _context.PerfStatsColl.InstanceName;

            _clusterListener = clusterListener;

            _nodeName = Environment.MachineName.ToLower();

        }
コード例 #49
0
ファイル: ClusterService.cs プロジェクト: javithalion/NCache
        /// <summary>
        /// Overloaded constructor. Takes the listener as parameter.
        /// </summary>
        /// <param name="listener">listener of Cache events.</param>
        public ClusterService(CacheRuntimeContext context, IClusterParticipant part, IDistributionPolicyMember distributionMbr, IClusterEventsListener listener)
        {
            _context = context;
            _participant = part;
            _distributionPolicyMbr = distributionMbr;
            _asynHandler = new ClusterOperationSynchronizer(this);
            _listener = listener;

        }
コード例 #50
0
ファイル: ClusterService.cs プロジェクト: javithalion/NCache
        /// <summary>
        /// Overloaded constructor. Takes the listener as parameter.
        /// </summary>
        /// <param name="listener">listener of Cache events.</param>
        public ClusterService(CacheRuntimeContext context, IClusterParticipant part, IDistributionPolicyMember distributionMbr)
        {
            _context = context;
            _ncacheLog = context.NCacheLog;
            
            _participant = part;
            _distributionPolicyMbr = distributionMbr;

           

            _asynHandler = new ClusterOperationSynchronizer(this);
        }
コード例 #51
0
ファイル: LocalCacheBase.cs プロジェクト: christrotter/NCache
        /// <summary>
        /// Overloaded constructor. Takes the listener as parameter.
        /// </summary>
        /// <param name="properties"></param>
        /// <param name="listener"></param>
        /// <param name="timeSched"></param>
        /// <param name="asyncProcessor"></param>
        /// <param name="expiryMgr"></param>
        /// <param name="perfStatsColl"></param>
        public LocalCacheBase(IDictionary properties, CacheBase parentCache, ICacheEventsListener listener, CacheRuntimeContext context

)
            : base(properties, listener, context)
        {

            if (System.Configuration.ConfigurationSettings.AppSettings.Get("preparedQueryTableSize") != null)
            {
                _preparedQueryTableSize = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings.Get("preparedQueryTableSize"));
            }
            if (System.Configuration.ConfigurationSettings.AppSettings.Get("preparedQueryEvictionPercentage") != null)
            {
                _preparedQueryEvictionPercentage = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings.Get("preparedQueryEvictionPercentage"));
            }

            _stats = new CacheStatistics();

            _stats.InstanceName = _context.PerfStatsColl.InstanceName;

            _parentCache = parentCache;

        }
コード例 #52
0
ファイル: ExpirationHint.cs プロジェクト: javithalion/NCache
		/// <summary>
		/// virtual method that returns true when the expiration has taken place, returns 
		/// false otherwise.
		/// </summary>
		internal virtual bool DetermineExpiration(CacheRuntimeContext context)
		{ 
			return HasExpired;
		}
コード例 #53
0
ファイル: ExpirationHint.cs プロジェクト: javithalion/NCache
 /// <summary>
 /// virtual method that returns true when the expiration has taken place, returns
 /// false otherwise. Used only for those hints that are validated at the time of Get
 /// operation on the cache.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 internal virtual bool CheckExpired(CacheRuntimeContext context)
 {
     return false;
 }
コード例 #54
0
 public HashedLocalCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context, bool logEntries)
     : base(cacheClasses, parentCache, properties, listener, context)
 {
     _logMgr = new OpLogManager(logEntries, context);
     _stats.LocalBuckets = new HashVector();
 }
コード例 #55
0
 public bool IsExpired(CacheRuntimeContext context)
 {
     if (_hint != null) return _hint.DetermineExpiration(context);
     return false;
 }
コード例 #56
0
ファイル: OpLogManager.cs プロジェクト: javithalion/NCache
 public OpLogManager(bool logEnteries, CacheRuntimeContext context)
 {
     _logEnteries = logEnteries;
     _ncacheLog = context.NCacheLog;
     
 }
コード例 #57
0
        void IEvictionPolicy.Execute(CacheBase cache, CacheRuntimeContext context, long evictSize)
        {
          
            ILogger NCacheLog = cache.Context.NCacheLog;
            
            if (NCacheLog.IsInfoEnabled) NCacheLog.Info("LocalCache.Evict()", "Cache Size: {0}" + cache.Count.ToString());

             //if user has updated the values in configuration file then new values will be reloaded.
            _sleepInterval = Convert.ToInt32(ServiceConfiguration.EvictionBulkRemoveDelay);
            _removeThreshhold = Convert.ToInt32(ServiceConfiguration.EvictionBulkRemoveSize);
            DateTime startTime = DateTime.Now;
            ArrayList selectedKeys = this.GetSelectedKeys(cache, (long)Math.Ceiling(evictSize * _ratio));
            DateTime endTime = DateTime.Now;

            if (NCacheLog.IsInfoEnabled) NCacheLog.Info("LocalCache.Evict()", String.Format("Time Span for {0} Items: " + (endTime - startTime), selectedKeys.Count));

            startTime = DateTime.Now;

            Cache rootCache = context.CacheRoot;

            ArrayList keysTobeRemoved = new ArrayList();
            ArrayList dependentItems = new ArrayList();
            ArrayList removedItems = null;

            IEnumerator e = selectedKeys.GetEnumerator();

            int removedThreshhold = _removeThreshhold/300;
            int remIteration = 0;
            while (e.MoveNext())
            {
                object key = e.Current;
                if (key == null) continue;

                keysTobeRemoved.Add(key);

                if (keysTobeRemoved.Count % 300 == 0)
                {
                    try
                    {
                        OperationContext priorityEvictionOperationContext = new OperationContext();
                        priorityEvictionOperationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                        removedItems = cache.RemoveSync(keysTobeRemoved.ToArray(), ItemRemoveReason.Underused, false, priorityEvictionOperationContext) as ArrayList;

                        context.PerfStatsColl.IncrementEvictPerSecStatsBy(keysTobeRemoved.Count);
                    }
                    catch (Exception ex)
                    {
                        NCacheLog.Error("PriorityEvictionPolicy.Execute", "an error occured while removing items. Error " + ex.ToString());
                    }
                    keysTobeRemoved.Clear();
                    if (removedItems != null && removedItems.Count > 0)
                    {
                        dependentItems.AddRange(removedItems);
                    }
                    
                    remIteration++;
                    if (remIteration >= removedThreshhold)
                    {
                        //put some delay so that user operations are not affected.
                        System.Threading.Thread.Sleep(_sleepInterval*1000);
                        remIteration = 0;
                    }
                }
            }

            if (keysTobeRemoved.Count > 0)
            {
                try
                {
                    OperationContext priorityEvictionOperationContext = new OperationContext();
                    priorityEvictionOperationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                    removedItems = cache.RemoveSync(keysTobeRemoved.ToArray(), ItemRemoveReason.Underused, false, priorityEvictionOperationContext) as ArrayList;

                    context.PerfStatsColl.IncrementEvictPerSecStatsBy(keysTobeRemoved.Count);
                    if (removedItems != null && removedItems.Count > 0)
                    {
                        dependentItems.AddRange(removedItems);
                    }
                }
                catch (Exception ex)
                {
                    NCacheLog.Error("PriorityEvictionPolicy.Execute", "an error occured while removing items. Error " + ex.ToString());
                }
            }

            if (dependentItems.Count > 0)
            {
                ArrayList removableList = new ArrayList();
                if (rootCache != null)
                {
                    foreach (object depenentItme in dependentItems)
                    {
                        if (depenentItme == null) continue;
                        removableList.Add(depenentItme);
                        if (removableList.Count % 100 == 0)
                        {
                            try
                            {
                                OperationContext priorityEvictionOperationContext = new OperationContext();
                                priorityEvictionOperationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                                rootCache.CascadedRemove(removableList.ToArray(), ItemRemoveReason.Underused, true, priorityEvictionOperationContext);

                                context.PerfStatsColl.IncrementEvictPerSecStatsBy(removableList.Count);
                            }
                            catch (Exception exc)
                            {
                                NCacheLog.Error("PriorityEvictionPolicy.Execute", "an error occured while removing dependent items. Error " + exc.ToString());

                            }
                            removableList.Clear();
                        }

                    }
                    if (removableList.Count > 0)
                    {
                        try
                        {
                            OperationContext priorityEvictionOperationContext = new OperationContext();
                            priorityEvictionOperationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                            rootCache.CascadedRemove(removableList.ToArray(), ItemRemoveReason.Underused, true, priorityEvictionOperationContext);

                            context.PerfStatsColl.IncrementEvictPerSecStatsBy(removableList.Count);
                        }
                        catch (Exception exc)
                        {
                            NCacheLog.Error("PriorityEvictionPolicy.Execute", "an error occured while removing dependent items. Error " + exc.ToString());

                        }
                        removableList.Clear();
                    }
                }
            }
            return;

        }
コード例 #58
0
 /// <summary>
 /// Overloaded constructor. Takes the listener as parameter.
 /// </summary>
 /// <param name="listener">listener of Cache events.</param>
 public PartitionedCacheBase(IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context)
     : base(properties, listener, context)
 {
 }
コード例 #59
0
ファイル: IdleExpiration.cs プロジェクト: christrotter/NCache
		/// <summary>
		/// Resets the time to live counter. 
		/// </summary>
		internal override bool Reset(CacheRuntimeContext context)
		{
            _lastTimeStamp = AppUtil.DiffSeconds(DateTime.Now);
			return base.Reset(context);
		}
コード例 #60
0
ファイル: OverflowCache.cs プロジェクト: christrotter/NCache
		/// <summary>
		/// Overloaded constructor. Takes the properties as a map.
		/// </summary>
		/// <param name="cacheSchemes">collection of cache schemes (config properties).</param>
		/// <param name="properties">properties collection for this cache.</param>
		/// <param name="listener">listener for the cache</param>
		/// <param name="timeSched">scheduler to use for periodic tasks</param>
        public OverflowCache(IDictionary cacheClasses, CacheBase parentCache, IDictionary properties, ICacheEventsListener listener, CacheRuntimeContext context)
            : base(properties, parentCache, listener, context)
		{
			_stats.ClassName = "overflow-cache";
			Initialize(cacheClasses, properties);

			CacheStatistics pstat = _primary.Statistics, sstat = _secondary.Statistics;
			if(pstat.MaxCount == 0 || sstat.MaxCount == 0)
				_stats.MaxCount = 0;
			else
				_stats.MaxCount = pstat.MaxCount + sstat.MaxCount;
		}