예제 #1
0
  /** @param view */
  private void handleView(View view) {

    log.debug(
        "Replicating view to all channels view "
            + view.view_id
            + " with size "
            + view.vs.addresses.length);
    //	    System.out.println("Multiplexer: Replicating view to all channels view "+view.view_id+"
    // with size "+view.vs.addresses.length);

    view.vs.version = "MULTI";
    vs = view.vs;

    Iterator<Channel> it = channels.keySet().iterator();
    for (; it.hasNext(); ) {
      Channel c = it.next();
      if (!c.equals(view.getChannel())) {
        try {
          //	          System.out.println("Multiplexer: sending to "+c.getChannelID());
          View copy = new View(view.vs, view.ls, c, view.getDir(), this);
          copy.setPriority(copy.getPriority() + 1);
          copy.go();
        } catch (AppiaEventException e2) {
          e2.printStackTrace();
        }
      }
    }

    try {
      //          System.out.println("Multiplexer: sending to "+view.getChannel().getChannelID());
      view.go();
    } catch (AppiaEventException e1) {
      e1.printStackTrace();
    }

    // dump pending events
    if (!pendingEvents.isEmpty()) {
      Iterator<GroupSendableEvent> eventIt = pendingEvents.iterator();
      while (eventIt.hasNext()) {
        GroupSendableEvent ev = eventIt.next();
        if (ev.view_id.equals(vs.id)) {
          eventIt.remove();
          try {
            ev.go();
          } catch (AppiaEventException e) {
            e.printStackTrace();
          }
        } else break;
      }
    }
  }
예제 #2
0
  /** @param event */
  private void handleEchoEvent(EchoEvent echo) {
    if (echo.getEvent() instanceof BlockOk) {
      log.debug(
          "Replicating EchoEvent to all channels. Echo received on Channel: "
              + echo.getChannel().getChannelID());
      blockOkCounter = 0;

      BlockOk blockok = (BlockOk) echo.getEvent();

      Iterator<Channel> it = channels.keySet().iterator();
      for (; it.hasNext(); ) {
        Channel c = it.next();
        if (!c.equals(echo.getChannel())) {
          try {
            EchoEvent copy =
                new EchoEvent(new BlockOk(blockok.group, blockok.view_id), c, echo.getDir(), this);
            copy.go();
            blockOkCounter++;
          } catch (AppiaEventException e2) {
            e2.printStackTrace();
          }
        }
      }
      try {
        echo.go();
        blockOkCounter++;
      } catch (AppiaEventException e1) {
        e1.printStackTrace();
      }

    } else {
      try {
        echo.go();
      } catch (AppiaEventException e) {
        e.printStackTrace();
      }
    }
  }