Exemplo n.º 1
0
 public String dumpQueue() {
   StringBuilder sb = new StringBuilder();
   List v = queue.values();
   for (Iterator it = v.iterator(); it.hasNext(); ) {
     sb.append(it.next() + "\n");
   }
   return sb.toString();
 }
Exemplo n.º 2
0
  public void channelConnected(Channel channel) {

    synchronized (additionalChannelListeners) {
      for (Iterator i = additionalChannelListeners.iterator(); i.hasNext(); ) {
        ChannelListener l = (ChannelListener) i.next();
        try {
          l.channelConnected(channel);
        } catch (Throwable t) {
          log.warn("channel listener failed", t);
        }
      }
    }
  }
Exemplo n.º 3
0
    protected synchronized void handleView(List<Address> members) {
      if (current_owner != null && !members.contains(current_owner.getAddress())) {
        Owner tmp = current_owner;
        setOwner(null);
        if (log.isDebugEnabled())
          log.debug("unlocked \"" + lock_name + "\" because owner " + tmp + " left");
      }

      for (Iterator<Request> it = queue.iterator(); it.hasNext(); ) {
        Request req = it.next();
        if (!members.contains(req.owner.getAddress())) it.remove();
      }

      for (Iterator<Owner> it = condition.queue.iterator(); it.hasNext(); ) {
        Owner own = it.next();
        if (!members.contains(own.getAddress())) {
          it.remove();
        }
      }

      processQueue();
    }
Exemplo n.º 4
0
 /**
  * Removes all members from a given view which don't have us in their view
  * (https://jira.jboss.org/browse/JGRP-1061). Example:
  *
  * <pre>
  * A: AB
  * B: AB
  * C: ABC
  * </pre>
  *
  * becomes
  *
  * <pre>
  * A: AB
  * B: AB
  * C: C // A and B don't have C in their views
  * </pre>
  *
  * @param map A map of members and their associated views
  */
 public static void sanitizeViews(Map<Address, View> map) {
   if (map == null) return;
   for (Map.Entry<Address, View> entry : map.entrySet()) {
     Address key = entry.getKey();
     List<Address> members = new ArrayList<Address>(entry.getValue().getMembers());
     boolean modified = false;
     for (Iterator<Address> it = members.iterator(); it.hasNext(); ) {
       Address val = it.next();
       if (val.equals(key)) // we can always talk to ourself !
       continue;
       View view = map.get(val);
       final Collection<Address> tmp_mbrs = view != null ? view.getMembers() : null;
       if (tmp_mbrs != null && !tmp_mbrs.contains(key)) {
         it.remove();
         modified = true;
       }
     }
     if (modified) {
       View old_view = entry.getValue();
       entry.setValue(new View(old_view.getVid(), members));
     }
   }
 }
Exemplo n.º 5
0
 protected void removeRequest(Type type, Owner owner) {
   for (Iterator<Request> it = queue.iterator(); it.hasNext(); ) {
     Request req = it.next();
     if (req.type == type && req.owner.equals(owner)) it.remove();
   }
 }