Beispiel #1
0
  protected void _handleMergeRequest(
      Address sender, MergeId merge_id, Collection<? extends Address> mbrs) throws Exception {
    boolean success = matchMergeId(merge_id) || setMergeId(null, merge_id);
    if (!success)
      throw new Exception(
          "merge " + this.merge_id + " is already in progress, received merge-id=" + merge_id);

    /* Clears the view handler queue and discards all JOIN/LEAVE/MERGE requests until after the MERGE  */
    // gms.getViewHandler().suspend();
    if (log.isTraceEnabled())
      log.trace(
          gms.local_addr
              + ": got merge request from "
              + sender
              + ", merge_id="
              + merge_id
              + ", mbrs="
              + mbrs);

    // merge the membership of the current view with mbrs
    List<Address> members = new LinkedList<Address>();
    if (mbrs
        != null) { // didn't use a set because we didn't want to change the membership order at this
      // time (although not incorrect)
      for (Address mbr : mbrs) {
        if (!members.contains(mbr)) members.add(mbr);
      }
    }

    ViewId tmp_vid = gms.getViewId();
    if (tmp_vid != null) tmp_vid = tmp_vid.copy();
    if (tmp_vid == null) throw new Exception("view ID is null; cannot return merge response");

    View view = new View(tmp_vid, new ArrayList<Address>(members));

    // [JGRP-524] - FLUSH and merge: flush doesn't wrap entire merge process
    // [JGRP-770] - Concurrent startup of many channels doesn't stabilize
    // [JGRP-700] - FLUSH: flushing should span merge

    /*if flush is in stack, let this coordinator flush its cluster island */
    if (gms.flushProtocolInStack && !gms.startFlush(view)) throw new Exception("flush failed");

    // we still need to fetch digests from all members, and not just return our own digest
    // (https://issues.jboss.org/browse/JGRP-948)
    Digest digest = fetchDigestsFromAllMembersInSubPartition(members, merge_id);
    if (digest == null || digest.size() == 0)
      throw new Exception(
          "failed fetching digests from subpartition members; dropping merge response");

    sendMergeResponse(sender, view, digest, merge_id);
  }
Beispiel #2
0
  /**
   * Get the view and digest and send back both (MergeData) in the form of a MERGE_RSP to the
   * sender. If a merge is already in progress, send back a MergeData with the merge_rejected field
   * set to true.
   *
   * @param sender The address of the merge leader
   * @param merge_id The merge ID
   * @param mbrs The set of members from which we expect responses
   */
  public void handleMergeRequest(
      Address sender, MergeId merge_id, Collection<? extends Address> mbrs) {
    boolean success = matchMergeId(merge_id) || setMergeId(null, merge_id);
    if (!success) {
      if (log.isWarnEnabled()) log.warn(gms.local_addr + ": merge is already in progress");
      sendMergeRejectedResponse(sender, merge_id);
      return;
    }

    /* Clears the view handler queue and discards all JOIN/LEAVE/MERGE requests until after the MERGE  */
    gms.getViewHandler().suspend(merge_id);
    if (log.isDebugEnabled())
      log.debug(
          gms.local_addr
              + ": got merge request from "
              + sender
              + ", merge_id="
              + merge_id
              + ", mbrs="
              + mbrs);

    // merge the membership of the current view with mbrs
    List<Address> members = new LinkedList<Address>();
    if (mbrs
        != null) { // didn't use a set because we didn't want to change the membership order at this
                   // time (although not incorrect)
      for (Address mbr : mbrs) {
        if (!members.contains(mbr)) members.add(mbr);
      }
    }

    ViewId tmp_vid = gms.view_id != null ? gms.view_id.copy() : null;
    if (tmp_vid == null) {
      log.warn("view ID is null; cannot return merge response");
      sendMergeRejectedResponse(sender, merge_id);
      return;
    }
    View view = new View(tmp_vid, new Vector<Address>(members));

    // [JGRP-524] - FLUSH and merge: flush doesn't wrap entire merge process
    // [JGRP-770] - Concurrent startup of many channels doesn't stabilize
    // [JGRP-700] - FLUSH: flushing should span merge

    /*if flush is in stack, let this coordinator flush its cluster island */
    boolean successfulFlush = gms.startFlush(view);
    if (!successfulFlush) {
      sendMergeRejectedResponse(sender, merge_id);
      if (log.isWarnEnabled())
        log.warn(
            gms.local_addr
                + ": flush failed; sending merge rejected message to "
                + sender
                + ", merge_id="
                + merge_id);
      cancelMerge(merge_id);
      return;
    }
    Digest digest = fetchDigestsFromAllMembersInSubPartition(members);
    if (digest.size() == 0) {
      log.error("failed fetching digests from subpartition members; dropping merge response");
      return;
    }
    sendMergeResponse(sender, view, digest, merge_id);
  }