/// <summary>
		/// Copy constructor.
		/// </summary>
		/// <param name="stat"></param>
		protected ClusterCacheStatistics(ClusterCacheStatistics stat):base(stat)
		{
			lock(stat)
			{
				this._groupName = stat._groupName;
				this._channelType = stat._channelType;
				this._memberCount = stat._memberCount;
				this._serverCount = stat._serverCount;
				this._otherCount = stat._otherCount;
				this._localNode = stat._localNode == null ? null:stat._localNode.Clone() as NodeInfo;
				if(stat._nodeInfos != null)
				{
					this._nodeInfos = new ArrayList(stat._nodeInfos.Count);
					for(int i=0; i<stat._nodeInfos.Count; i++)
					{
						this._nodeInfos.Add(((NodeInfo)stat._nodeInfos[i]).Clone() as NodeInfo);
					}
				}
                if (stat.ClusterDataAffinity != null)
                    this.ClusterDataAffinity = (ArrayList)stat.ClusterDataAffinity.Clone();

				if (stat.PartitionsHavingDatagroup != null)
					this.PartitionsHavingDatagroup = (Hashtable)stat.PartitionsHavingDatagroup.Clone();

				if (stat.DatagroupsAtPartition != null)
					this.DatagroupsAtPartition = (Hashtable)stat.DatagroupsAtPartition.Clone();

                if (stat.SubgroupNodes != null)
                    this.SubgroupNodes = (Hashtable)stat.SubgroupNodes.Clone();

			}
		}
Example #2
0
		/// <summary>
		/// Return the next node in call balacing order that is fully functional.
		/// </summary>
		/// <returns></returns>
		NodeInfo IActivityDistributor.SelectNode(ClusterCacheStatistics clusterStats, object hint)
		{
			ArrayList memberInfos = clusterStats.Nodes;
			lock (memberInfos.SyncRoot)
			{
				int maxtries = memberInfos.Count;
				NodeInfo info = null;
				do
				{
					info = (NodeInfo)memberInfos[_lastServ % memberInfos.Count];
					_lastServ = ++_lastServ % memberInfos.Count;
					if (info.Status.IsAnyBitSet(NodeStatus.Running))
					{
						return info;
					}
					maxtries--;
				}
				while (maxtries > 0);
			}
			return null;
		}
Example #3
0
        /// <summary>
        /// Copy constructor.
        /// </summary>
        /// <param name="stat"></param>
        protected ClusterCacheStatistics(ClusterCacheStatistics stat) : base(stat)
        {
            lock (stat)
            {
                this._groupName   = stat._groupName;
                this._channelType = stat._channelType;
                this._memberCount = stat._memberCount;
                this._serverCount = stat._serverCount;
                this._otherCount  = stat._otherCount;
                this._localNode   = stat._localNode == null ? null:stat._localNode.Clone() as NodeInfo;
                if (stat._nodeInfos != null)
                {
                    this._nodeInfos = new ArrayList(stat._nodeInfos.Count);
                    for (int i = 0; i < stat._nodeInfos.Count; i++)
                    {
                        this._nodeInfos.Add(((NodeInfo)stat._nodeInfos[i]).Clone() as NodeInfo);
                    }
                }
                if (stat.ClusterDataAffinity != null)
                {
                    this.ClusterDataAffinity = (ArrayList)stat.ClusterDataAffinity.Clone();
                }

                if (stat.PartitionsHavingDatagroup != null)
                {
                    this.PartitionsHavingDatagroup = (Hashtable)stat.PartitionsHavingDatagroup.Clone();
                }

                if (stat.DatagroupsAtPartition != null)
                {
                    this.DatagroupsAtPartition = (Hashtable)stat.DatagroupsAtPartition.Clone();
                }

                if (stat.SubgroupNodes != null)
                {
                    this.SubgroupNodes = (Hashtable)stat.SubgroupNodes.Clone();
                }
            }
        }
Example #4
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or 
        /// resetting unmanaged resources.
        /// </summary>
        public override void Dispose()
        {
            if (_nodeInformationTable != null)
            {
                lock (_nodeInformationTable.SyncRoot) _nodeInformationTable.Clear();
            }

            _statusLatch.Clear();
            if (_cluster != null)
            {
                _cluster.Dispose();
                _cluster = null;
            }

            _stats = null;
            base.Dispose();
        }
Example #5
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();

        }
Example #6
0
 /// <summary>
 /// Initializing the cluster_stats object for WMI
 /// </summary>
 /// <param name="stats"></param>
 /// <param name="Name"></param>
 internal void postInstrumentatedData(ClusterCacheStatistics stats, string Name)
 {
     if (Name.IndexOf("_BK_NODE") != -1)
     {
         Name = Name.Remove(Name.IndexOf("_BK_"), Name.Length - Name.IndexOf("_BK_"));
     }
 }
Example #7
0
 public virtual CacheStatistics CombineClusterStatistics(ClusterCacheStatistics s)
 {
     return null;
 }
Example #8
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;
        }
Example #9
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;
        }
 public override CacheStatistics CombineClusterStatistics(ClusterCacheStatistics s)
 {
     CacheStatistics c = ClusterHelper.CombineReplicatedStatistics(s);
     return c;
 }
 public override CacheStatistics CombineClusterStatistics(ClusterCacheStatistics s)
 {
     CacheStatistics c = ClusterHelper.CombinePartitionStatistics(s);
     return c;
 }