Exemplo n.º 1
0
 internal virtual void OnMemberLeft(Address mbr, NodeIdentity identity)
 {
     if (_existingMembers != null && _existingMembers.Contains(mbr))
     {
         _existingMembers.Remove(mbr);
     }
 }
Exemplo n.º 2
0
 internal virtual void OnMemberJoined(Address mbr, NodeIdentity identity)
 {
     if (_existingMembers != null && !_existingMembers.Contains(mbr))
     {
         _existingMembers.Add(mbr);
     }
 }
Exemplo n.º 3
0
        internal override void OnMemberLeft(Address mbr, NodeIdentity identity)
        {
            PartNodeInfo partNodeInfo = new PartNodeInfo(mbr, identity.SubGroupName, false);

            _existingMembers.Remove(partNodeInfo.NodeAddress);
            _subGroupMap.Remove(partNodeInfo.NodeAddress);

            ArrayList    groupNodes = (ArrayList)_partitionNodesInfo[partNodeInfo.SubGroup];
            PartNodeInfo coordinator;

            if (groupNodes != null)
            {
                if (groupNodes.Contains(partNodeInfo))
                {
                    groupNodes.Remove(partNodeInfo);
                    if (groupNodes.Count > 0)
                    {
                        coordinator = (PartNodeInfo)groupNodes[0];
                        coordinator.IsCoordinator = true;
                        if (!_existingMembers.Contains(coordinator.NodeAddress))
                        {
                            _existingMembers.Add(coordinator.NodeAddress);
                        }
                    }
                    else
                    {
                        _partitionNodesInfo.Remove(partNodeInfo.SubGroup);
                    }
                }
            }
        }
Exemplo n.º 4
0
        internal override void OnMemberJoined(Address mbr, NodeIdentity identity)
        {
            ArrayList    partitionNodes;
            PartNodeInfo partNodeInfo = new PartNodeInfo(mbr, identity.SubGroupName, false);

            //assuming existing members doesnot contain the newly added member.
            if (!_partitionNodesInfo.ContainsKey(partNodeInfo.SubGroup))
            {
                partitionNodes             = new ArrayList();
                partNodeInfo.IsCoordinator = true;
                partitionNodes.Add(partNodeInfo);
                _subGroupMap[partNodeInfo.NodeAddress] = partNodeInfo.SubGroup;
                _partitionNodesInfo.Add(partNodeInfo.SubGroup, partitionNodes);
                base.OnMemberJoined(mbr, identity);
            }
            else
            {
                partitionNodes = (ArrayList)_partitionNodesInfo[partNodeInfo.SubGroup];
                if (!partitionNodes.Contains(partNodeInfo))
                {
                    partitionNodes.Add(partNodeInfo);
                    _subGroupMap[partNodeInfo.NodeAddress] = partNodeInfo.SubGroup;
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Authenticate the client and see if it is allowed to join the list of valid members.
 /// </summary>
 /// <param name="address"></param>
 /// <param name="identity"></param>
 /// <returns>true if the node is valid and belongs to the scheme's cluster</returns>
 public override bool AuthenticateNode(Address address, NodeIdentity identity)
 {
     try
     {
         if (identity == null || !(identity is Identity))
         {
             Context.NCacheLog.Warn("MirrorCacheBase.AuthenticateNode()", "A non-recognized node attempted to join cluster -> " + address);
             return(false);
         }
         return(true);
     }
     catch (Exception)
     {
     }
     return(false);
 }
Exemplo n.º 6
0
        /// <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>
        internal virtual int OnMemberJoined(Address address, NodeIdentity identity)
        {
            if (identity.SubGroupName != _groupid)
            {
                return(-1);
            }

            NCacheLog.Warn("SubCluster.OnMemberJoined()", "Memeber " + address + " added to sub-cluster " + _groupid);

            _members.Add(address);
            if (identity.HasStorage && !identity.IsStartedAsMirror)
            {
                _servers.Add(address);
            }
            return(_members.Count);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Authenticate the client and see if it is allowed to join the list of valid members.
 /// </summary>
 /// <param name="address"></param>
 /// <param name="identity"></param>
 /// <returns>true if the node is valid and belongs to the scheme's cluster</returns>
 public override bool AuthenticateNode(Address address, NodeIdentity identity)
 {
     try
     {
         if (identity == null || !(identity is Identity))
         {
             Context.NCacheLog.Warn("ReplicatedCacheBase.AuthenticateNode()", "A non-recognized node attempted to join cluster -> " + address);
             return false;
         }
         return true;
     }
     catch (Exception)
     {
     }
     return false;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Called when an existing member leaves the group.
        /// </summary>
        /// <param name="address">address of the joining member</param>
        /// <returns>true if the node left successfuly</returns>
        public virtual bool OnMemberLeft(Address address, NodeIdentity identity)
        {
            if (Context.NCacheLog.IsInfoEnabled) Context.NCacheLog.Info("ClusterCacheBase.OnMemberLeft()", "Member left: " + address);

            // we don't have any non-routable expiration thus no NodeExpiration.
            //// Add the leaving node in the list of left nodes.
            
            if (_context.ExpiryMgr != null)
            {
                if (_cluster.IsCoordinator)
                {
                    _context.ExpiryMgr.IsCoordinatorNode = true;
                }
            }
            lock (_wbQueueTransferCorresponders.SyncRoot)
            {
                if (_wbQueueTransferCorresponders.Contains(address))
                {
                    _wbQueueTransferCorresponders.Remove(address);
                }
            }

            return true;
        }
Exemplo n.º 9
0
 /// <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 virtual bool OnMemberJoined(Address address, NodeIdentity identity)
 {
     return true;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Authenticate the client and see if it is allowed to join the list of valid members.
 /// </summary>
 /// <param name="address"></param>
 /// <param name="identity"></param>
 /// <returns>true if the node is valid and belongs to the scheme's cluster</returns>
 public virtual bool AuthenticateNode(Address address, NodeIdentity identity)
 {
     return true;
 }
Exemplo n.º 11
0
        protected virtual void InitializeCluster(IDictionary properties,
        string channelName,
        string domain,
        NodeIdentity identity,
        bool twoPhaseInitialization, bool isPor)
        {
            if (properties == null)
                throw new ArgumentNullException("properties");

            try
            {
                _cluster = new ClusterService(_context, this, this);
                _cluster.ClusterEventsListener = _clusterListener;
                _cluster.Initialize(properties, channelName, domain, identity, twoPhaseInitialization, isPor);
            }
            catch (Exception e)
            {
                Dispose();
                throw new ConfigurationException("Configuration Error: " + e.ToString(), e);
            }
        }
Exemplo n.º 12
0
        public void Initialize(IDictionary properties, string channelName,
            string domain, NodeIdentity identity,
            bool twoPhaseInitialization,bool isPor)
        {
            if (properties == null)
                throw new ArgumentNullException("properties");
            
            try
            {
                if (properties.Contains("op-timeout"))
                {
                    long val = Convert.ToInt64(properties["op-timeout"]);
                    if (val < 60) val = 60;
                    val = val * 1000;
                    Timeout = val;
                }
                if (properties.Contains("notification-priority"))
                {
                    string priority = Convert.ToString(properties["notification-priority"]);
                    if (priority.ToLower() == "normal")
                        _eventPriority = Priority.Normal;
                }

                IDictionary clusterProps = properties["cluster"] as IDictionary;
                string channelProps = ConfigHelper.GetClusterPropertyString(clusterProps, Timeout, isPor);

                string name = channelName != null? channelName.ToLower(): null ;
                if (clusterProps.Contains("group-id"))
                    name = Convert.ToString(clusterProps["group-id"]);
                if (clusterProps.Contains("sub-group-id"))
                {
                    _subgroupid = Convert.ToString(clusterProps["sub-group-id"]);
                    if (_subgroupid != null) _subgroupid = _subgroupid.ToLower();
                    identity.SubGroupName = _subgroupid;
                }
                // =======================================
                else
                    _subgroupid = name;
                // =======================================
                    this.PopulateClusterNodes(new Hashtable(clusterProps));

                if (name != null) name = name.ToLower();
                if (_subgroupid != null) _subgroupid = _subgroupid.ToLower();
                //A property or indexer may not be passed as an out or ref parameter.
                _channel = new GroupChannel(channelProps, _context.NCacheLog);

                Hashtable config = new Hashtable();
                config["additional_data"] = CompactBinaryFormatter.ToByteBuffer(identity, _context.SerializationContext);
                _channel.down(new Event(Event.CONFIG, config));

                _msgDisp = new MsgDispatcher(_channel, this, this, this, this, false, true);
                _channel.connect(name + domain, _subgroupid, identity.IsStartedAsMirror,twoPhaseInitialization);
                localIp = LocalAddress.IpAddress.ToString();
                _msgDisp.start();
            }
            catch (Exception e)
            {
                Dispose();
                throw new ConfigurationException("Configuration Error: " + e.ToString(), e);
            }
        }
Exemplo n.º 13
0
 internal virtual void OnMemberJoined(Address mbr, NodeIdentity identity)
 {
     if (_existingMembers != null && !_existingMembers.Contains(mbr))
     {
         _existingMembers.Add(mbr);
     }
 }
Exemplo n.º 14
0
        /// <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>
        private bool OnMemberJoined(Address address, NodeIdentity identity, ArrayList joiningNowList)
        {
            try
            {
                if (!AuthenticateNode(address, identity))
                {
                    NCacheLog.Warn("ClusterService.OnMemberJoined()", "A non-server attempted to join cluster -> " + address);
                    _validMembers.Remove(address);
                    _servers.Remove(address);
                    return false;
                }

                SubCluster group = null;
                if (identity.HasStorage && identity.SubGroupName != null)
                {
                    lock (_subgroups.SyncRoot)
                    {
                        group = GetSubCluster(identity.SubGroupName);
                        if (group == null)
                        {
                            if (NCacheLog.IsInfoEnabled) NCacheLog.Info("ClusterService.OnMemberJoined()", "Formed new sub-cluster -> " + identity.SubGroupName);
                            group = new SubCluster(identity.SubGroupName, this);
                            _subgroups[identity.SubGroupName] = group;
                        }
                        group.OnMemberJoined(address, identity);
                    }
                }
                bool joined = _participant.OnMemberJoined(address, identity);
                if (!joined && group != null)
                {
                    group.OnMemberLeft(address, _distributionPolicyMbr.BucketsOwnershipMap);
                }
                
                if (joined)
                {
                    NCacheLog.CriticalInfo("ClusterService.OnMemberJoined()", "Member joined: " + address);

                    Address renderer = new Address(identity.RendererAddress, identity.RendererPort);

                    string mirrorExplaination = identity.IsStartedAsMirror ? " (replica)" : "";

                    if (joiningNowList.Contains(address) && !_context.IsStartedAsMirror && !address.Equals(LocalAddress))
                    {
                        AppUtil.LogEvent(_cacheserver, "Node \"" + address + mirrorExplaination + "\" has joined to \"" + _context.CacheRoot.Name + "\".", System.Diagnostics.EventLogEntryType.Information, EventCategories.Information, EventID.NodeJoined);
                    }

                    if (!_membersRenders.Contains(address))
                    {
                        _membersRenders.Add(address, renderer);

                        if (_listener != null && !identity.IsStartedAsMirror)
                        {
                            _listener.OnMemberJoined(address, renderer);
                        }
                    }
                }

                return joined;
            }
            catch (Exception exception)
            {
                NCacheLog.Error("ClusterService.OnMemberJoined", exception.ToString());
            }
            return false;
        }
Exemplo n.º 15
0
        /// <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;
        }
Exemplo n.º 16
0
        /// <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>
        internal virtual int OnMemberJoined(Address address, NodeIdentity identity)
        {
            if (identity.SubGroupName != _groupid)
            {
                return -1;
            }

            NCacheLog.Warn("SubCluster.OnMemberJoined()",   "Memeber " + address + " added to sub-cluster " + _groupid);

            _members.Add(address);
            if (identity.HasStorage && !identity.IsStartedAsMirror)
                _servers.Add(address);
            return _members.Count;
        }
Exemplo n.º 17
0
        /// <summary>
        /// Called when an existing member leaves the group.
        /// </summary>
        /// <param name="address">address of the joining member</param>
        /// <returns>true if the node left successfuly</returns>
        public override bool OnMemberLeft(Address address, NodeIdentity identity)
        {
            if (!base.OnMemberLeft(address, identity))
                return false;

            NodeInfo info = _stats.GetNode(address as Address);
            _stats.Nodes.Remove(info);

            //remove into the list of other servers.
            _otherServers.Remove(address);

            if (!info.IsInproc)
            {
                RemoveServerInformation(address, identity.RendererPort);

                if (_clientsMgr != null)
                {
                    _clientsMgr.OnMemberLeft(address);
                }
            }

            if (Context.NCacheLog.IsInfoEnabled) Context.NCacheLog.Info("ReplicatedCache.OnMemberLeft()", "Replica Removed: " + address);
            return true;
        }
Exemplo n.º 18
0
        /// <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;
        }
Exemplo n.º 19
0
 internal virtual void OnMemberLeft(Address mbr, NodeIdentity identity)
 {
     if (_existingMembers != null && _existingMembers.Contains(mbr))
     {
         _existingMembers.Remove(mbr);
     }
 }
Exemplo n.º 20
0
        /// <summary>
        /// Called when an existing member leaves the group.
        /// </summary>
        /// <param name="address">address of the joining member</param>
        /// <returns>true if the node left successfuly</returns>
        private bool OnMemberLeft(Address address, NodeIdentity identity)
        {
            if (_validMembers.Contains(address))
            {
                NCacheLog.CriticalInfo("ClusterService.OnMemberLeft()", "Member left: " + address);
                if (identity.HasStorage && identity.SubGroupName != null)
                {
                    lock (_subgroups.SyncRoot)
                    {
                        SubCluster group = GetSubCluster(identity.SubGroupName);
                        if (group != null)
                        {
                            if (group.OnMemberLeft(address, _distributionPolicyMbr.BucketsOwnershipMap) < 1)
                            {
                                if (NCacheLog.IsInfoEnabled) NCacheLog.Info("ClusterService.OnMemberLeft()",   "Destroyed sub-cluster -> " + identity.SubGroupName);
                                _subgroups.Remove(identity.SubGroupName);
                            }
                        }
                    }
                }
                //muds:
                if (_membersRenders.Contains(address))
                {
                    Address renderer = (Address)_membersRenders[address];
                    _membersRenders.Remove(address);

                    if (_listener != null && !identity.IsStartedAsMirror) // invisible replica's don't raise events.
                        _listener.OnMemberLeft(address, renderer);
                }

                string mirrorExplaination = identity.IsStartedAsMirror ? " (replica)" : "";

                if (!_context.IsStartedAsMirror)
                {
                    AppUtil.LogEvent(_cacheserver, "Node \"" + address + mirrorExplaination + "\" has left \"" + _context.CacheRoot.Name + "\".", System.Diagnostics.EventLogEntryType.Warning, EventCategories.Warning, EventID.NodeLeft);
                }

                return _participant.OnMemberLeft(address, identity);
            }
            return false;
        }
Exemplo n.º 21
0
 /// <summary>
 /// Authenticate the client and see if it is allowed to join the list of valid members.
 /// </summary>
 /// <param name="address"></param>
 /// <param name="identity"></param>
 /// <returns>true if the node is valid and belongs to the scheme's cluster</returns>
 private bool AuthenticateNode(Address address, NodeIdentity identity)
 {
     return _participant.AuthenticateNode(address, identity);
 }
Exemplo n.º 22
0
        /// <summary>
        /// Called when an existing member leaves the group.
        /// </summary>
        /// <param name="address">address of the joining member</param>
        /// <returns>true if the node left successfuly</returns>
        public override bool OnMemberLeft(Address address, NodeIdentity identity)
        {
            if (!base.OnMemberLeft(address, identity))
                return false;

            NodeInfo info = _stats.GetNode(address as Address);
            _stats.Nodes.Remove(info);
            _distributionMgr.OnMemberLeft(address, identity);



            //muds:
            if (_stats.DatagroupsAtPartition.Contains(address))
            {
                ArrayList datagroups = (ArrayList) _stats.DatagroupsAtPartition[address];
                if (datagroups != null && datagroups.Count > 0)
                {
                    IEnumerator ie = datagroups.GetEnumerator();
                    while (ie.MoveNext())
                    {
                        if (_stats.PartitionsHavingDatagroup.Contains(ie.Current))
                        {
                            ArrayList nodeList = (ArrayList) _stats.PartitionsHavingDatagroup[ie.Current];
                            if (nodeList != null)
                            {
                                if (nodeList.Contains(address))
                                    nodeList.Remove(address);
                            }
                        }
                    }
                }
                _stats.DatagroupsAtPartition.Remove(address);
            }

            //muds:
            UpdateLocalBuckets();

            if (_corresponders != null)
            {
                StateTxfrCorresponder cor = _corresponders[address] as StateTxfrCorresponder;
                if (cor != null)
                {
                    cor.Dispose();
                    _corresponders.Remove(address);
                }
            }
            if (!info.IsInproc)
                RemoveServerInformation(address, identity.RendererPort);

            if (NCacheLog.IsInfoEnabled)
                NCacheLog.Info("PartitionedCache.OnMemberLeft()", "Partition shrunk: " + address);
            return true;
        }