/** Manage the triggering of the events */
  @SuppressWarnings("unchecked")
  public void trigger(int type, GroupCommEventArgs l) {
    switch (type) {
      case Constants.JOINREMOVELIST:
        TSet start = (TSet) l.remove(0);
        TSet stop = (TSet) l.remove(0);

        Iterator itStart = start.iterator();
        while (itStart.hasNext()) {
          RPT2PTCallParameters jparams =
              new RPT2PTCallParameters(
                  (PID) itStart.next(), new TBoolean(true), new TBoolean(false));

          rpt2pt.call(jparams, null);
        }

        Iterator itStop = stop.iterator();
        while (itStop.hasNext()) {
          RPT2PTCallParameters jparams =
              new RPT2PTCallParameters(
                  (PID) itStop.next(), new TBoolean(false), new TBoolean(false));

          rpt2pt.call(jparams, null);
        }

        break;

      case Constants.PT2PTSEND:
        Transportable message = l.remove(0);
        PID ppid = (PID) l.remove(0);
        TBoolean promisc = (TBoolean) l.remove(0);
        RPT2PTCallParameters rparams = new RPT2PTCallParameters(ppid, promisc, new TBoolean(true));

        rpt2pt.call(rparams, new Message(message, rpt2ptListener));
        break;

      case Constants.ADELIVER:
        GroupCommMessage gm = (GroupCommMessage) l.remove(0);
        Message dmessage = new Message(gm);
        PID apid = (PID) l.remove(0);
        AbcastResponseParameters infos = new AbcastResponseParameters(apid);

        abcast.response(infos, dmessage);
        break;

      case Constants.PROPOSE:
        TList group = (TList) l.remove(0);
        Transportable cmessage = l.remove(0);
        TLong id = (TLong) l.remove(0);
        ConsensusCallParameters cparams =
            new ConsensusCallParameters(group, new ConsensusID(id, this.pValue));

        consensus.call(cparams, new Message(cmessage, consensusListener));
        break;
      default:
        throw new RuntimeException("Unknow event triggered : " + type);
    }
  }
  private synchronized void timeout(Object o) {
    GroupCommEventArgs ga = new GroupCommEventArgs();
    final Transportable key = (Transportable) o;

    if (!timers.containsKey(key))
      // Timer already canceled
      return;

    ga.add(key);
    handlers.handleTimeout(ga);
  }
  public synchronized void init() {
    try {
      GroupCommEventArgs initev = new GroupCommEventArgs();
      initev.addLast(stack.getGroup());
      handlers.handleInit(initev);
    } catch (Exception ex) {
      throw new RuntimeException("ProtocolFastAbcast: handleInit: " + ex.getMessage());
    }

    super.init();
  }