@BeforeMethod
  protected void setup() throws Exception {
    receiver = new MockProtocol();
    nak = (NAKACK2) new NAKACK2().setValue("use_mcast_xmit", false);
    transport = new MockTransport();
    ProtocolStack stack = new ProtocolStack();
    stack.addProtocols(transport, nak, receiver);
    stack.init();

    nak.down(new Event(Event.BECOME_SERVER));
    nak.down(new Event(Event.SET_LOCAL_ADDRESS, A));
    Digest digest = new Digest(view.getMembersRaw(), new long[] {0, 0, 0, 0});
    nak.down(new Event(Event.SET_DIGEST, digest));
  }
Пример #2
0
  /**
   * Creates a channel from an array of protocols. Note that after a {@link
   * org.jgroups.JChannel#close()}, the protocol list <em>should not</em> be reused, ie. new
   * JChannel(protocols) would reuse the same protocol list, and this might lead to problems !
   *
   * @param protocols The list of protocols, from bottom to top, ie. the first protocol in the list
   *     is the transport, the last the top protocol
   * @throws Exception
   */
  public JChannel(Collection<Protocol> protocols) throws Exception {
    prot_stack = new ProtocolStack();
    setProtocolStack(prot_stack);
    for (Protocol prot : protocols) {
      prot_stack.addProtocol(prot);
      prot.setProtocolStack(prot_stack);
    }
    prot_stack.init();

    // Substitute vars with defined system props (if any)
    List<Protocol> prots = prot_stack.getProtocols();
    Map<String, String> map = new HashMap<>();
    for (Protocol prot : prots) Configurator.resolveAndAssignFields(prot, map);
  }