Пример #1
0
  @Override
  public void viewAccepted(View newView) {
    log.debugf("New view accepted: %s", newView);
    List<org.jgroups.Address> newMembers = newView.getMembers();
    if (newMembers == null || newMembers.isEmpty()) {
      log.debugf("Received null or empty member list from JGroups channel: " + newView);
      return;
    }

    List<Address> oldMembers = members;
    // we need a defensive copy anyway
    members = fromJGroupsAddressList(newMembers);

    // Now that we have a view, figure out if we are the isCoordinator
    coordinator = fromJGroupsAddress(newView.getCreator());
    isCoordinator = coordinator != null && coordinator.equals(getAddress());

    // Wake up any threads that are waiting to know about who the isCoordinator is
    // do it before the notifications, so if a listener throws an exception we can still start
    channelConnectedLatch.countDown();

    // now notify listeners - *after* updating the isCoordinator. - JBCACHE-662
    boolean hasNotifier = notifier != null;
    if (hasNotifier) {
      Notify n;
      if (newView instanceof MergeView) {
        if (log.isInfoEnabled()) log.receivedMergedView(newView);
        n = new NotifyMerge();
      } else {
        if (log.isInfoEnabled()) log.receivedClusterView(newView);
        n = new NotifyViewChange();
      }

      n.emitNotification(oldMembers, newView);
    }
  }