/// <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(); } }
/// <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; } }
/// <summary> /// Called when a new member joins the group. /// </summary> /// <param name="address">address of the joining member</param> /// <param name="identity">additional identity information</param> /// <returns>true if the node joined successfuly</returns> public override bool OnMemberJoined(Address address, NodeIdentity identity) { if (!base.OnMemberJoined(address, identity) || !((Identity)identity).HasStorage) return false; NodeInfo info = new NodeInfo(address as Address); if (identity.RendererAddress != null) info.RendererAddress = new Address(identity.RendererAddress, identity.RendererPort); info.IsInproc = identity.RendererPort == 0; info.SubgroupName = identity.SubGroupName; _stats.Nodes.Add(info); if (LocalAddress.CompareTo(address) == 0) { _stats.LocalNode = info; } else { lock (_nodesInStateTransfer) { if (!_nodesInStateTransfer.Contains(address)) _nodesInStateTransfer.Add(address); } //add into the list of other servers. if (!_otherServers.Contains(address)) _otherServers.Add(address); } if (!info.IsInproc) { AddServerInformation(address, identity.RendererPort, info.ConnectedClients.Count); if (_clientsMgr != null) { _clientsMgr.OnMemberJoined(address); } } if (Context.NCacheLog.IsInfoEnabled) Context.NCacheLog.Info("ReplicatedCache.OnMemberJoined()", "Replication increased: " + address); return true; }
public override void Deserialize(CompactReader reader) { base.Deserialize(reader); _groupName = reader.ReadObject() as string; _channelType = reader.ReadObject() as string; _memberCount = reader.ReadInt32(); _serverCount = reader.ReadInt32(); _otherCount = reader.ReadInt32(); _localNode = NodeInfo.ReadNodeInfo(reader); _nodeInfos = (ArrayList)reader.ReadObject(); }
public void UpdateBucketStats(NodeInfo localNode) { try { Sync.AcquireWriterLock(Timeout.Infinite); if (localNode == null) return; if (_bucketsStats == null) _bucketsStats = new Hashtable(); if (localNode.Statistics != null && localNode.Statistics.LocalBuckets != null) { IDictionary bucketStats = localNode.Statistics.LocalBuckets.Clone() as IDictionary; if (bucketStats != null) { IDictionaryEnumerator ide = bucketStats.GetEnumerator(); while (ide.MoveNext()) { //muds: //see if this node is the permanent owner of the bucket //otherwise its quite possible that we override the //stats of the bucket from the temporary owner. HashMapBucket bucket = (HashMapBucket)_installedHashMap[(int)ide.Key]; if (bucket.PermanentAddress.Equals(localNode.Address)) { BucketStatistics stats = ide.Value as BucketStatistics; _bucketsStats[ide.Key] = ide.Value; } else { } } } if (NCacheLog.IsInfoEnabled) NCacheLog.Info("DistributionMgr.UpdateBucketStats()", "bucketStats = " + _bucketsStats == null ? "null" : _bucketsStats.Count.ToString()); } } catch (Exception e) { if (NCacheLog.IsErrorEnabled) NCacheLog.Error("DistributionMgr.UpdateBucketStats()", e.ToString()); } finally { Sync.ReleaseWriterLock(); } }
/// <summary> /// Called when a new member joins the group. /// </summary> /// <param name="address">address of the joining member</param> /// <param name="identity">additional identity information</param> /// <returns>true if the node joined successfuly</returns> public override bool OnMemberJoined(Address address, NodeIdentity identity) { if (!base.OnMemberJoined(address, identity) || !((Identity) identity).HasStorage) return false; NodeInfo info = new NodeInfo(address as Address); if (identity.RendererAddress != null) info.RendererAddress = new Address(identity.RendererAddress, identity.RendererPort); info.IsInproc = identity.RendererPort == 0; info.SubgroupName = identity.SubGroupName; _stats.Nodes.Add(info); _distributionMgr.OnMemberJoined(address, identity); if (LocalAddress.CompareTo(address) == 0) { UpdateLocalBuckets(); _stats.LocalNode = info; if (_dataAffinity != null) { DataGrouping.DataAffinity da = new DataGrouping.DataAffinity(_dataAffinity); _stats.LocalNode.DataAffinity = da; if (da.AllBindedGroups != null) { IEnumerator ie = da.AllBindedGroups.GetEnumerator(); while (ie.MoveNext()) { if (!_stats.ClusterDataAffinity.Contains(ie.Current)) { _stats.ClusterDataAffinity.Add(ie.Current); } if (_stats.PartitionsHavingDatagroup.Contains(ie.Current)) { ArrayList nodeList = (ArrayList) _stats.PartitionsHavingDatagroup[ie.Current]; if (!nodeList.Contains(address)) { nodeList.Add(address); } } else { ArrayList nodeList = new ArrayList(); nodeList.Add(address); _stats.PartitionsHavingDatagroup[ie.Current] = nodeList; } } if (!_stats.DatagroupsAtPartition.Contains(address)) { _stats.DatagroupsAtPartition[address] = da.Groups; } } _dataAffinity = null; } } if (!info.IsInproc) AddServerInformation(address, identity.RendererPort, info.ConnectedClients.Count); if (NCacheLog.IsInfoEnabled) NCacheLog.Info("PartitionedCache.OnMemberJoined()", "Partition extended: " + address); return true; }
public static void WriteNodeInfo(CompactWriter writer, NodeInfo nodeInfo) { byte isNull = 1; if (nodeInfo == null) writer.Write(isNull); else { isNull = 0; writer.Write(isNull); nodeInfo.Serialize(writer); } return; }
public static NodeInfo ReadNodeInfo(CompactReader reader) { byte isNull = reader.ReadByte(); if (isNull == 1) return null; NodeInfo newInfo = new NodeInfo(); newInfo.Deserialize(reader); return newInfo; }