Beispiel #1
0
    /**
     * @param views Guaranteed to be non-null and to have >= 2 members, or else this thread would
     *     not be started
     */
    public synchronized void start(Map<Address, View> views) {
      if (thread == null || thread.isAlive()) {
        this.coords.clear();

        // now remove all members which don't have us in their view, so RPCs won't block (e.g.
        // FLUSH)
        // https://jira.jboss.org/browse/JGRP-1061
        sanitizeViews(views);

        // Add all different coordinators of the views into the hashmap and sets their members:
        Collection<Address> coordinators = Util.determineMergeCoords(views);
        for (Address coord : coordinators) {
          View view = views.get(coord);
          if (view != null) this.coords.put(coord, new ArrayList<Address>(view.getMembers()));
        }

        // For the merge participants which are not coordinator, we simply add them, and the
        // associated
        // membership list consists only of themselves
        Collection<Address> merge_participants = Util.determineMergeParticipants(views);
        merge_participants.removeAll(coordinators);
        for (Address merge_participant : merge_participants) {
          Collection<Address> tmp = new ArrayList<Address>();
          tmp.add(merge_participant);
          coords.putIfAbsent(merge_participant, tmp);
        }

        thread = gms.getThreadFactory().newThread(this, "MergeTask");
        thread.setDaemon(true);
        thread.start();
      }
    }
Beispiel #2
0
  @SuppressWarnings("unchecked")
  private static void check(final int num_expected_msgs, Collection<Integer>... lists) {
    for (Collection<Integer> list : lists) {
      System.out.println("list: " + list);
    }

    for (Collection<Integer> list : lists) {
      Collection<Integer> missing = new TreeSet<Integer>();
      if (list.size() != num_expected_msgs) {
        for (int i = 0; i < num_expected_msgs; i++) missing.add(i);

        missing.removeAll(list);
        assert list.size() == num_expected_msgs
            : "expected "
                + num_expected_msgs
                + " elements, but got "
                + list.size()
                + " (list="
                + list
                + "), missing="
                + missing;
      }
    }
  }
Beispiel #3
0
 public void receive(Message msg) {
   Integer val = (Integer) msg.getObject();
   msgs.add(val);
 }
Beispiel #4
0
 public void receive(Message msg) {
   Integer val = (Integer) msg.getObject();
   System.out.println(name + ": <-- " + val);
   msgs.add(val);
 }