コード例 #1
0
ファイル: ClusterStats.cs プロジェクト: nonomal/NCache
        /// <summary>
        /// Called each time a node lefts the cluster
        /// </summary>
        /// <param name="NodeName">Name of the Node</param>
        public void MemberLeft(string port, string nodeName, bool fireEvent)
        {
            //lock (this._syncPoint)
            //{
            try
            {
                if (this._inprocInstances.Contains(nodeName.Trim() + "." + port))
                {
                    nodeName = nodeName.Trim() + "." + port;
                    this._inprocInstances.Remove(nodeName);
                    this._nodes.Remove(nodeName);//remove the inproc instance from nodes too
                }
                if (_runningNodes.IndexOf(nodeName.Trim()) != -1)
                {
                    _runningNodes.Remove(nodeName.Trim());
                    NodeRemoved nodeRemoved = new NodeRemoved(this.ClusterName, nodeName.Trim());

                    /* Commented to stop posting on WMI */
                    if (fireEvent)
                    {
                        nodeRemoved.Fire();
                    }
                }
            }
            catch { }
            //}
        }
コード例 #2
0
ファイル: ClusterStats.cs プロジェクト: nonomal/NCache
        public void MemberLeft(string port, string nodeName, string subGroupName, bool fireEvent, bool isInproc)
        {
            try
            {
                if (isInproc)
                {
                    nodeName = nodeName.Trim() + "." + port;
                    string previousInstances = this._inprocPorInstances[subGroupName] as string;
                    if (previousInstances != null && previousInstances != string.Empty && previousInstances.Trim() != nodeName)
                    {
                        previousInstances = previousInstances.Replace(nodeName, "").Replace(",,", ",").TrimEnd(',');
                    }
                    else
                    {
                        this._inprocPorInstances.Remove(subGroupName);
                    }
                    for (int i = 0; i < this._porNodes.Count; i++)
                    {
                        string porInstances = this._porNodes[i] as string;
                        if (porInstances.IndexOf(subGroupName) != -1)
                        {
                            porInstances      = porInstances.Replace(nodeName, "").Replace(",,", ",").TrimEnd(',');
                            this._porNodes[i] = porInstances;
                            break;
                        }
                    }
                }
                if (this._porRunningNodeList.Contains(subGroupName))
                {
                    string nodeRemoved = (string)this._porRunningNodeList[subGroupName];
                    if (nodeRemoved.IndexOf(nodeName.Trim() + ",") != -1)
                    {
                        this._runningNodes[this._runningNodes.IndexOf(nodeRemoved)] = nodeRemoved.Replace(nodeName + ",", "");
                        this._porRunningNodeList[subGroupName] = nodeRemoved.Replace(nodeName + ",", "");
                    }
                    else if (nodeRemoved.IndexOf("," + nodeName.Trim()) != -1)
                    {
                        this._runningNodes[this._runningNodes.IndexOf(nodeRemoved)] = nodeRemoved.Replace("," + nodeName.Trim(), "");
                        this._porRunningNodeList[subGroupName] = nodeRemoved.Replace("," + nodeName.Trim(), "");
                    }

                    else if (nodeRemoved.IndexOf(nodeName) != -1)
                    {
                        this._runningNodes[this._runningNodes.IndexOf(nodeRemoved)] = nodeRemoved.Replace(nodeName.Trim(), "");
                        this._porRunningNodeList[subGroupName] = nodeRemoved.Replace(nodeName.Trim(), "");
                    }

                    if (!_doNotPublish && fireEvent)
                    {
                        NodeRemoved nodeRemovedevent = new NodeRemoved(this.ClusterName, nodeName.Trim());
                        nodeRemovedevent.Fire();
                    }
                }
            }
            catch { }
        }