/// <summary> /// Constructor: Deserialises the information and recreates the instance. /// </summary> /// <param name="info">Standard <c>SerializationInfo</c> object</param> /// <param name="ctxt">Standard <c>StreamingContext</c> object</param> public GmsHeader(SerializationInfo info, StreamingContext ctxt) { type = info.GetInt32("type"); //merge_rejected = info.GetBoolean("merge_rejected"); view = (View)info.GetValue("view", typeof(object)); mbr = (Address)info.GetValue("mbr", typeof(object)); join_rsp = (JoinRsp)info.GetValue("join_rsp", typeof(object)); digest = (Digest)info.GetValue("digest", typeof(object)); }
/// <summary> /// Not implemented by Coord GMS /// </summary> /// <param name="join_rsp"></param> public override void handleJoinResponse(JoinRsp join_rsp) { wrongMethod("handleJoinResponse"); }
/// <summary> /// Not implemented by Participant GMS /// </summary> /// <param name="join_rsp"></param> public override void handleJoinResponse(JoinRsp join_rsp) { wrongMethod("handleJoinResponse"); }
/// <summary> /// Constructor /// </summary> /// <param name="type">Type of GMS Header</param> /// <param name="join_rsp">JoinRsp associated with type</param> public GmsHeader(int type, JoinRsp join_rsp) { this.type=type; this.join_rsp=join_rsp; }
/// <summary> /// Not implemented by Client GMS /// </summary> /// <param name="join_rsp"></param> public override void handleJoinResponse(JoinRsp join_rsp) { join_promise.setResult(join_rsp); // will wake up join() method }
/// <summary> /// Constructor /// </summary> /// <param name="type">Type of GMS Header</param> /// <param name="join_rsp">JoinRsp associated with type</param> public GmsHeader(int type, JoinRsp join_rsp) { this.type = type; this.join_rsp = join_rsp; }
/// <summary> /// Process response to join request /// </summary> /// <param name="join_rsp">Response to Join request</param> public abstract void handleJoinResponse(JoinRsp join_rsp);
/// <remarks> /// Determines the coordinator and sends a unicast /// handleJoin() message to it. The coordinator returns a JoinRsp and then broadcasts the new view, which /// contains a message digest and the current membership (including the joiner). The joiner is then /// supposed to install the new view and the digest and starts accepting mcast messages. Previous /// mcast messages were discarded as we were not a member.<p> /// If successful, impl is changed to an instance of ParticipantGmsImpl. /// Otherwise, we continue trying to send join() messages to the coordinator, /// until we succeed (or there is no member in the group. In this case, we create our own singleton group). /// <p>When GMS.disable_initial_coord is set to true, then we won't become coordinator on receiving an initial /// membership of 0, but instead will retry (forever) until we get an initial membership of > 0.</p> /// </p> /// </remarks> /// <summary> /// Joins this process to a group. /// </summary> /// <param name="mbr">The local Address of the process</param> public override void join(Address mbr) { Address coord = null; Digest tmp_digest = null; JoinRsp rsp = null; while (true) { findInitialMembers(); if (Trace.trace) { Trace.info("ClientGmsImpl.join()", "initial_mbrs are " + initial_mbrs); } if (initial_mbrs.Count == 0) { if (gms.disable_initial_coord) { if (Trace.trace) { Trace.info("ClientGmsImpl.join()", "received an initial membership of 0, but " + "cannot become coordinator (disable_initial_coord=" + gms.disable_initial_coord + "), will retry fetching the initial membership"); } continue; } if (Trace.trace) { Trace.info("ClientGmsImpl.join()", "no initial members discovered: " + "creating group as first member"); } becomeSingletonMember(mbr); return; } coord = determineCoord(initial_mbrs); if (coord == null) { if (Trace.trace) { Trace.error("ClientGmsImpl.join()", "could not determine coordinator " + "from responses " + initial_mbrs); } continue; } try { if (Trace.trace) { Trace.info("ClientGmsImpl.join()", "sending handleJoin(" + mbr + ") to " + coord); } sendJoinMessage(coord, mbr); rsp = (JoinRsp)join_promise.getResult(gms.join_timeout); if (rsp == null) { if (Trace.trace) { Trace.warn("ClientGmsImpl.join()", "handleJoin(" + mbr + ") failed, retrying"); } } else { // 1. Install digest tmp_digest = rsp.getDigest(); if (tmp_digest != null) { tmp_digest.incrementHighSeqno(coord); if (Trace.trace) { Trace.info("ClientGmsImpl.join()", "digest is " + tmp_digest); } gms.setDigest(tmp_digest); } else if (Trace.trace) { Trace.error("ClientGmsImpl.join()", "digest of JOIN response is null"); } // 2. Install view if (Trace.trace) { Trace.info("ClientGmsImpl.join()", "[" + gms.local_addr + "]: JoinRsp=" + rsp.getView() + " [size=" + rsp.getView().size() + "]\n\n"); } if (rsp.getView() != null) { if (!installView(rsp.getView())) { if (Trace.trace) { Trace.error("ClientGmsImpl.join()", "view installation failed, " + "retrying to join group"); } continue; } gms.passUp(new Event(Event.BECOME_SERVER)); gms.passDown(new Event(Event.BECOME_SERVER)); return; } else if (Trace.trace) { Trace.error("ClientGmsImpl.join()", "view of JOIN response is null"); } } } catch (Exception e) { Trace.info("ClientGmsImpl.join()", "exception=" + e.ToString() + ", retrying"); } Thread.Sleep((int)gms.join_retry_timeout); } // end while }