/**
   * Caller by the layer above this layer. Usually we just put this Message into the send queue and
   * let one or more worker threads handle it. A worker thread then removes the Message from the
   * send queue, performs a conversion and adds the modified Message to the send queue of the layer
   * below it, by calling Down).
   */
  public Object down(Event evt) {
    Message msg;
    Address dest_addr;

    switch (evt.getType()) {
      case Event.MSG:
        if (done) {
          break;
        }
        msg = (Message) evt.getArg();
        dest_addr = msg.getDest();
        if (dest_addr == null) num_msgs++;
        if (num_msgs >= expected_msgs) {
          stop = System.currentTimeMillis();
          synchronized (this) {
            done = true;
            this.notifyAll();
          }
          if (log.isInfoEnabled())
            log.info("all done (num_msgs=" + num_msgs + ", expected_msgs=" + expected_msgs);
        }
        break;

      case Event.CONNECT:
        return null;
    }

    if (getDownProtocol() != null) return down_prot.down(evt);
    return null;
  }
 public Object up(Event evt) {
   Message msg;
   Address dest_addr;
   switch (evt.getType()) {
     case Event.MSG:
       if (done) {
         if (log.isWarnEnabled()) log.warn("all done (discarding msg)");
         break;
       }
       msg = (Message) evt.getArg();
       dest_addr = msg.getDest();
       if (dest_addr == null) num_msgs++;
       if (num_msgs >= expected_msgs) {
         stop = System.currentTimeMillis();
         synchronized (this) {
           done = true;
           this.notifyAll();
         }
         if (log.isInfoEnabled())
           log.info("all done (num_msgs=" + num_msgs + ", expected_msgs=" + expected_msgs);
       } else {
         return up_prot.up(evt);
       }
   }
   return up_prot.up(evt);
 }
Exemple #3
0
 protected Object handleDownEvent(Event evt) {
     Object ret=super.handleDownEvent(evt);
     if(evt.getType() == Event.VIEW_CHANGE) {
         Set<Address> physical_mbrs=new HashSet<Address>();
         for(Address addr: members) {
             PhysicalAddress physical_addr=getPhysicalAddressFromCache(addr);
             if(physical_addr != null)
                 physical_mbrs.add(physical_addr);
         }
         retainAll(physical_mbrs); // remove all connections from the ConnectionTable which are not members
     }
     return ret;
 }