Example #1
0
 public virtual void handleIsClusterInStateTransfer(Address sender)
 {
     Message msg = new Message(sender, null, new byte[0]);
     GMS.HDR hdr = new GMS.HDR(GMS.HDR.IS_NODE_IN_STATE_TRANSFER_RSP);
     gms.Stack.NCacheLog.Debug("gmsImpl.handleIsClusterInStateTransfer", "(state transfer request) sender: " + sender + " ->" + isInStateTransfer);
     hdr.arg = isInStateTransfer;
     msg.putHeader(HeaderType.GMS,hdr);
     gms.passDown(new Event(Event.MSG,msg,Alachisoft.NCache.Common.Enum.Priority.Critical));
 }
Example #2
0
		internal virtual void  sendLeaveMessage(Address coord, Address mbr)
		{
			Message msg = new Message(coord, null, null);
			GMS.HDR hdr = new GMS.HDR(GMS.HDR.LEAVE_REQ, mbr);

            msg.putHeader(HeaderType.GMS, hdr);
			gms.passDown(new Event(Event.MSG, msg));
        }
Example #3
0
        internal virtual void sendJoinMessage(Address coord, Address mbr, string subGroup_name, bool isStartedAsMirror)
        {
            
            Message msg;
            GMS.HDR hdr;

            msg = new Message(coord, null, null);
            hdr = new GMS.HDR(GMS.HDR.JOIN_REQ, mbr, subGroup_name, isStartedAsMirror);
            hdr.GMSId = gms.unique_id;
            msg.putHeader(HeaderType.GMS, hdr);
            gms.passDown(new Event(Event.MSG_URGENT, msg, Priority.Critical));
        }
Example #4
0
 /// <summary>
 /// Informs the coodinator about the nodes to which this node can not establish connection
 /// on receiving the first view.Only the node who has most recently joined the cluster
 /// should inform the coodinator other nodes will neglect this event.
 /// </summary>
 /// <param name="nodes"></param>
 public override void handleConnectionFailure(System.Collections.ArrayList nodes)
 {
     if (nodes != null && nodes.Count > 0)
     {
         if (gms.Stack.NCacheLog.IsInfoEnabled) gms.Stack.NCacheLog.Info("ParticipantGmsImp.handleConnectionFailure", "informing coordinator about connection failure with [" + Global.CollectionToString(nodes) + "]");
         GMS.HDR header = new GMS.HDR(GMS.HDR.CAN_NOT_CONNECT_TO);
         header.nodeList = nodes;
         Message msg = new Message(gms.determineCoordinator(),null,new byte[0]);
         msg.putHeader(HeaderType.GMS,header);
         gms.passDown(new Event(Event.MSG,msg,Priority.Critical));
     }
     
 }
Example #5
0
        public override void handleNodeRejoining(Address node)
        {
            if (node != null)
            {
                if (gms.Stack.NCacheLog.IsInfoEnabled) gms.Stack.NCacheLog.Info("ParticipantGmsImpl.handleNodeRejoining", "I should inform coordinator about node rejoining with " + node);

                if (gms.members.contains(node))
                {
                    //inform coordinator about the node rejoining in the cluster.
                    GMS.HDR header = new GMS.HDR(GMS.HDR.INFORM_NODE_REJOINING, node);
                    Message rejoiningMsg = new Message(gms.determineCoordinator(), null, new byte[0]);
                    rejoiningMsg.putHeader(HeaderType.GMS, header);
                    gms.passDown(new Event(Event.MSG, rejoiningMsg, Priority.Critical));
                }
            }
        }
Example #6
0
        private void sendMemberLeftNotificationToCoordinator(Address suspected,Address coordinator)
        {
            if (gms.Stack.NCacheLog.IsInfoEnabled) gms.Stack.NCacheLog.Info("ParticipantGmsImp.sendMemberLeftNotification", "informing coordinator about abnormal connection breakage with " + suspected);

            GMS.HDR hdr = new GMS.HDR(GMS.HDR.CONNECTION_BROKEN, suspected);
            Message nodeLeftMsg = new Message(coordinator, null, new byte[0]);
            nodeLeftMsg.putHeader(HeaderType.GMS, hdr);
            gms.passDown(new Event(Event.MSG, nodeLeftMsg, Priority.Critical));
        }
Example #7
0
        public override void handleConnectedNodesRequest(Address src,int reqId)
        {
            if (gms.determineCoordinator().Equals(src))
            {
                ArrayList mbrs = gms.members.Members;
                ArrayList suspected = suspected_mbrs.Clone() as ArrayList;

                foreach (Address suspect in suspected_mbrs)
                {
                    mbrs.Remove(suspect);
                }

                if (gms.Stack.NCacheLog.IsInfoEnabled) gms.Stack.NCacheLog.Info("ParticipantGmsImp.handleConnectedNodesRequest    " + gms.local_addr + " --> " + Global.ArrayListToString(mbrs));

                Message rspMsg = new Message(src,null,new byte[0]);
                GMS.HDR hdr = new GMS.HDR(GMS.HDR.CONNECTED_NODES_RESPONSE,(Object)reqId);
                hdr.nodeList = mbrs;
                rspMsg.putHeader(HeaderType.GMS,hdr);
                gms.passDown(new Event(Event.MSG,rspMsg,Priority.Critical));
            }
        }
Example #8
0
        internal virtual void sendMergeCancelledMessage(System.Collections.ArrayList coords, object merge_id)
        {
            Message msg;
            GMS.HDR hdr;
            Address coord;

            if (coords == null || merge_id == null)
            {
                gms.Stack.NCacheLog.Error("coords or merge_id == null");
                return;
            }
            for (int i = 0; i < coords.Count; i++)
            {
                coord = (Address)coords[i];
                msg = new Message(coord, null, null);
                hdr = new GMS.HDR(GMS.HDR.CANCEL_MERGE);
                hdr.merge_id = merge_id;
                msg.putHeader(HeaderType.GMS, hdr);
                gms.passDown(new Event(Event.MSG, msg));
            }
        }
Example #9
0
        internal virtual void sendSpeicalJoinMessage(Address mbr, ArrayList dests)
        {
            Message msg;
            GMS.HDR hdr;

            msg = new Message(null, null, new byte[0]);
            msg.Dests = dests;
            hdr = new GMS.HDR(GMS.HDR.SPECIAL_JOIN_REQUEST, mbr);
            hdr.GMSId = gms.unique_id;
            msg.putHeader(HeaderType.GMS, hdr);
            gms.passDown(new Event(Event.MSG_URGENT, msg, Priority.Critical));
        }
Example #10
0
        /// <summary> Send back a response containing view and digest to sender</summary>
        internal virtual void sendMergeResponse(Address sender, View view, Digest digest)
        {
            Message msg = new Message(sender, null, null);
            GMS.HDR hdr = new GMS.HDR(GMS.HDR.MERGE_RSP);
            hdr.merge_id = merge_id;
            hdr.view = view;
            hdr.digest = digest;
            msg.putHeader(HeaderType.GMS, hdr);

            gms.Stack.NCacheLog.Debug("response=" + hdr);

            gms.passDown(new Event(Event.MSG, msg));
        }
Example #11
0
        internal virtual void sendMergeRejectedResponse(Address sender)
        {
            Message msg = new Message(sender, null, null);
            GMS.HDR hdr = new GMS.HDR(GMS.HDR.MERGE_RSP);
            hdr.merge_rejected = true;
            hdr.merge_id = merge_id;
            msg.putHeader(HeaderType.GMS, hdr);

            gms.Stack.NCacheLog.Debug("response=" + hdr);

            gms.passDown(new Event(Event.MSG, msg));
        }
Example #12
0
        /// <summary> Sends the new view and digest to all subgroup coordinors in coords. Each coord will in turn
        /// <ol>
        /// <li>cast the new view and digest to all the members of its subgroup (MergeView)
        /// <li>on reception of the view, if it is a MergeView, each member will set the digest and install
        /// the new view
        /// </ol>
        /// </summary>
        internal virtual void sendMergeView(System.Collections.ArrayList coords, MergeData combined_merge_data)
        {
            Message msg;
            GMS.HDR hdr;
            Address coord;
            View v;
            Digest d;

            if (coords == null || combined_merge_data == null)
                return;
            v = combined_merge_data.view;
            d = combined_merge_data.digest;
            if (v == null || d == null)
            {
                gms.Stack.NCacheLog.Error("view or digest is null, cannot send consolidated merge view/digest");
                return;
            }

            for (int i = 0; i < coords.Count; i++)
            {
                coord = (Address)coords[i];
                msg = new Message(coord, null, null);
                hdr = new GMS.HDR(GMS.HDR.INSTALL_MERGE_VIEW);
                hdr.view = v;
                hdr.digest = d;
                hdr.merge_id = merge_id;
                msg.putHeader(HeaderType.GMS, hdr);
                gms.passDown(new Event(Event.MSG, msg));
            }
        }
Example #13
0
        /// <summary> Sends a MERGE_REQ to all coords and populates a list of MergeData (in merge_rsps). Returns after coords.size()
        /// response have been received, or timeout msecs have elapsed (whichever is first).<p>
        /// If a subgroup coordinator rejects the MERGE_REQ (e.g. because of participation in a different merge),
        /// <em>that member will be removed from coords !</em>
        /// </summary>
        /// <param name="coords">A list of Addresses of subgroup coordinators (inluding myself)
        /// </param>
        /// <param name="timeout">Max number of msecs to wait for the merge responses from the subgroup coords
        /// </param>
        internal virtual void getMergeDataFromSubgroupCoordinators(System.Collections.ArrayList coords, long timeout)
        {
            Message msg;
            GMS.HDR hdr;
            Address coord;
            long curr_time, time_to_wait = 0, end_time;
            int num_rsps_expected = 0;

            if (coords == null || coords.Count <= 1)
            {
                gms.Stack.NCacheLog.Error("CoordGmsImpl.getMergeDataFromSubgroupCoordinator", "coords == null or size <= 1");
                return;
            }

            lock (merge_rsps.SyncRoot)
            {
                merge_rsps.Clear();

                gms.Stack.NCacheLog.Debug("sending MERGE_REQ to " + Global.CollectionToString(coords));
                for (int i = 0; i < coords.Count; i++)
                {
                    coord = (Address)coords[i];

                    if (gms.local_addr != null && gms.local_addr.Equals(coord))
                    {
                        merge_rsps.Add(getMergeResponse(gms.local_addr, merge_id));
                        continue;
                    }

                    msg = new Message(coord, null, null);
                    hdr = new GMS.HDR(GMS.HDR.MERGE_REQ);
                    hdr.mbr = gms.local_addr;
                    hdr.merge_id = merge_id;
                    msg.putHeader(HeaderType.GMS, hdr);
                    gms.passDown(new Event(Event.MSG, msg));
                }

                // wait until num_rsps_expected >= num_rsps or timeout elapsed
                num_rsps_expected = coords.Count;
                curr_time = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
                end_time = curr_time + timeout;
                while (end_time > curr_time)
                {
                    time_to_wait = end_time - curr_time;

                    gms.Stack.NCacheLog.Debug("waiting for " + time_to_wait + " msecs for merge responses");
                    if (merge_rsps.Count < num_rsps_expected)
                    {
                        try
                        {
                            System.Threading.Monitor.Wait(merge_rsps.SyncRoot, TimeSpan.FromMilliseconds(time_to_wait));
                        }
                        catch (System.Exception ex)
                        {
                            gms.Stack.NCacheLog.Error("CoordGmsImpl.getMergeDataFromSubgroupCoordinators()", ex.ToString());
                        }
                    }

                    // SAL:
                    if (time_to_wait < 0)
                    {
                        gms.Stack.NCacheLog.Fatal("[Timeout]CoordGmsImpl.getMergeDataFromSubgroupCoordinators:" + time_to_wait);
                    }

                    gms.Stack.NCacheLog.Debug("num_rsps_expected=" + num_rsps_expected + ", actual responses=" + merge_rsps.Count);

                    if (merge_rsps.Count >= num_rsps_expected)
                        break;
                    curr_time = (System.DateTime.Now.Ticks - 621355968000000000) / 10000;
                }
            }
        }
Example #14
0
        public void AskToLeaveCluster(Address leavingMember, string urGmsId)
        {
            if (gms.Stack.NCacheLog.IsInfoEnabled) gms.Stack.NCacheLog.Info("CoodGmsImpl.AskToLeaveCluster", leavingMember + " is requested to leave the cluster");

            Message msg = new Message(leavingMember, null, new byte[0]);
            GMS.HDR  hdr =  new GMS.HDR(GMS.HDR.LEAVE_CLUSTER, gms.local_addr);
            hdr.arg = urGmsId;
            msg.putHeader(HeaderType.GMS,hdr);
            gms.passDown(new Event(Event.MSG, msg, Priority.Critical)); ;
        }
Example #15
0
 public override void handleInformNodeRejoining(Address sender, Address node)
 {
     if (node != null)
     {
         if (gms.Stack.NCacheLog.IsInfoEnabled) gms.Stack.NCacheLog.Info("CoordinatorGmsImpl.handleInformNodeRejoining", sender.ToString() + " informed about rejoining with " + node);
         if (gms.members.contains(node))
         {
             ViewId viewId = gms.GetNextViewId();
             GMS.HDR header = new GMS.HDR(GMS.HDR.RESET_ON_NODE_REJOINING, node);
             header.view = new View(viewId, gms.members.Clone() as ArrayList);
             header.view.CoordinatorGmsId = gms.unique_id;
             Message rejoiningMsg = new Message(null, null, new byte[0]);
             rejoiningMsg.putHeader(HeaderType.GMS, header);
             gms.passDown(new Event(Event.MSG, rejoiningMsg, Priority.Critical));
         }
     }
 }
Example #16
0
        internal virtual void SendCheckClusterHealth(Address destination, Address coord)
        {
            
            Message msg;
            GMS.HDR hdr;

            msg = new Message(destination, null, null);
            hdr = new GMS.HDR(GMS.HDR.RE_CHECK_CLUSTER_HEALTH, coord);
            hdr.GMSId = gms.unique_id;
            msg.putHeader(HeaderType.GMS, hdr);
            gms.passDown(new Event(Event.MSG_URGENT, msg, Priority.Critical));
        }