예제 #1
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="info"></param>
 protected NodeInfo(NodeInfo info)
 {
     this._address = info._address == null ? null : info._address.Clone() as Address;
     this._rendererAddress = info._rendererAddress != null ? info._rendererAddress.Clone() as Address : null;
     this._stats = info._stats == null ? null:info._stats.Clone() as CacheStatistics;
     this._status = info._status;
     this._subgroupName = info._subgroupName;
     this._isInproc = info._isInproc;
     this._dataAffinity = info._dataAffinity == null ? null : info._dataAffinity.Clone() as DataAffinity;
     _isStartedAsMirror = info.IsStartedAsMirror;
     if(info._connectedClients != null)
     {
         lock(info._connectedClients.SyncRoot) 
             this._connectedClients = info._connectedClients.Clone() as ArrayList;
     }
 }
예제 #2
0
        /// <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;

        }
예제 #3
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or 
        /// resetting unmanaged resources.
        /// </summary>
        public override void Dispose()
        {
            _stats = null;

            base.Dispose();
        }
예제 #4
0
		/// <summary>
		/// Copy constructor.
		/// </summary>
		/// <param name="stat"></param>
		protected CacheStatistics(CacheStatistics stat)
		{
            lock (stat)
			{
				this._className = stat._className;
				this._perfInst = stat._perfInst;
				this._upTime = stat._upTime;
				this._count = stat._count;
				this._hiCount = stat._hiCount;
				this._maxCount = stat._maxCount;
                this._maxSize = stat._maxSize;
				this._hitCount = stat._hitCount;
				this._missCount = stat._missCount;
                this._localBuckets = stat._localBuckets != null ? stat._localBuckets.Clone() as HashVector : null;
			}
		}
예제 #5
0
 public static void WriteCacheStatistics(CompactWriter writer, CacheStatistics stats)
 {
     byte isNull = 1;
     if (stats == null)
         writer.Write(isNull);
     else
     {
         isNull = 0;
         writer.Write(isNull);
         stats.Serialize(writer);
     }
     return;
 }  		
예제 #6
0
 public static CacheStatistics ReadCacheStatistics(CompactReader reader)
 {
     byte isNull = reader.ReadByte();
     if (isNull == 1)
         return null;
     CacheStatistics newStats = new CacheStatistics();
     newStats.Deserialize(reader);
     return newStats;
 }
예제 #7
0
        /// <summary>
        /// Combines the collected statistics of the nodes, in a replicated environment.
        /// </summary>
        /// <returns></returns>
        public static CacheStatistics CombineReplicatedStatistics(ClusterCacheStatistics s)
        {
            CacheStatistics stats = new CacheStatistics();
            if (s.Nodes == null) return stats;

            for (int i = 0; i < s.Nodes.Count; i++)
            {
                NodeInfo info = s.Nodes[i] as NodeInfo;
                if (info == null || info.Statistics == null) continue;

                stats.HitCount += info.Statistics.HitCount;
                stats.MissCount += info.Statistics.MissCount;
            }

            stats.UpdateCount(s.LocalNode.Statistics.Count);
            stats.MaxCount = s.LocalNode.Statistics.MaxCount;
            stats.MaxSize = s.LocalNode.Statistics.MaxSize;
            stats.SessionCount = s.LocalNode.Statistics.SessionCount;
            return stats;
        }
예제 #8
0
        /// <summary>
        /// Combines the collected statistics of the nodes, in a partitioned environment.
        /// </summary>
        /// <returns></returns>
        public static CacheStatistics CombinePartitionStatistics(ClusterCacheStatistics s)
        {
            CacheStatistics stats = new CacheStatistics();
            if (s.Nodes == null) return stats;

            bool zeroSeen = false;
            for (int i = 0; i < s.Nodes.Count; i++)
            {
                NodeInfo info = s.Nodes[i] as NodeInfo;
                if (info == null || info.Statistics == null) continue;

                stats.HitCount += info.Statistics.HitCount;
                stats.MissCount += info.Statistics.MissCount;
                stats.UpdateCount(stats.Count + info.Statistics.Count);
                stats.MaxCount += info.Statistics.MaxCount;
                if (info.Statistics.MaxCount == 0)
                    zeroSeen = true;
            }

            stats.MaxSize = s.LocalNode.Statistics.MaxSize;

            if (zeroSeen)
                stats.MaxCount = 0;
            return stats;
        }
예제 #9
0
 public void Deserialize(CompactReader reader)
 {
     _address = Address.ReadAddress(reader);
     _subgroupName = reader.ReadObject() as string;
     _stats = CacheStatistics.ReadCacheStatistics(reader);
     _status = new BitSet(reader.ReadByte());
     _dataAffinity = DataAffinity.ReadDataAffinity(reader);
     _connectedClients = (ArrayList)reader.ReadObject();
     _isInproc = reader.ReadBoolean();
     _rendererAddress = Address.ReadAddress(reader);
     _isStartedAsMirror = reader.ReadBoolean();
 }
예제 #10
0
파일: Main.cs 프로젝트: christrotter/NCache
        static private void PrintCacheInfo(CacheStatistics statistics, string partId, string cacheName, bool isRunning)
        {

            CacheStatistics s = statistics;
            string schemeName = s.ClassName.ToLower(CultureInfo.CurrentCulture);
            string running = isRunning ? "Running" : "Stopped";

            Console.WriteLine("{0,-20} {1,-15} {2,-30} {3,-5}", cacheName, partId, schemeName, running);
        }
예제 #11
0
파일: Main.cs 프로젝트: christrotter/NCache
        static private void PrintDetailedCacheInfo(CacheStatistics statistics, string partId, bool printConf, bool xmlSyntax, bool isRunning, string cacheName, String configString)
        {
            CacheStatistics s = statistics;
            long MaxSize = 0;
            string schemeName = s.ClassName.ToLower(CultureInfo.CurrentCulture);
            bool running = isRunning;

            Console.WriteLine("Cache-ID:       {0}", cacheName);

            if (partId != null && partId != string.Empty)
                Console.WriteLine("Partition-ID:   {0}", partId);

            Console.WriteLine("Scheme:         {0}", schemeName);
            Console.WriteLine("Status:         {0}", isRunning ? "Running" : "Stopped");
            if (running)
            {
                if (s is ClusterCacheStatistics)
                {
                    System.Text.StringBuilder nodes = new System.Text.StringBuilder();

                    ClusterCacheStatistics cs = s as ClusterCacheStatistics;
                   
                    Console.WriteLine("Cluster size:   {0}", cs.Nodes.Count);

                    MaxSize = (cs.LocalNode.Statistics.MaxSize / 1024) / 1024;

                    
                    foreach (NodeInfo n in cs.Nodes)
                    {
                        nodes.Append("                ").Append(n.Address).Append("\n");
                    }
                    Console.Write("{0}", nodes.ToString());

                    if (partId != null && partId != string.Empty)
                    {
                        if (cs.SubgroupNodes != null && cs.SubgroupNodes.Contains(partId.ToLower()))
                        {
                            nodes = new System.Text.StringBuilder();
                            ArrayList groupNodes = cs.SubgroupNodes[partId.ToLower()] as ArrayList;
                            Console.WriteLine("Partition size: {0}", groupNodes.Count);
                            
                            foreach (Address address in groupNodes)
                            {
                                nodes.Append("                ").Append(address).Append("\n");
                            }
                        }
                        Console.Write("{0}", nodes.ToString());
                    }
                }
                Console.WriteLine("UpTime:         {0}", s.UpTime);

                if (s.MaxSize != 0)
                    Console.WriteLine("Capacity:       {0} MB", ((s.MaxSize / 1024) / 1024));
                else
                    Console.WriteLine("Capacity:       {0} MB", MaxSize);

                Console.WriteLine("Count:          {0}", s.Count);
            }
            if (printConf)
            {
                try
                {
                    if (xmlSyntax)
                    {
                        PropsConfigReader pr = new PropsConfigReader(configString);
                        Console.WriteLine("Configuration:\n{0}", ConfigReader.ToPropertiesXml(pr.Properties, true));
                    }
                    else
                    {
                        Console.WriteLine("Configuration:\n{0}", configString);
                    }
                }
                catch (ConfigurationException) { }
            }
            Console.WriteLine("");
        }