@@ -2704,18 +2704,15 @@ FORK refers to an external file to configure its fork stacks:
27042704----
27052705
27062706The file fork-stacks.xml defines 2 fork stacks: "counter" and "lock". Each fork-stack element has an
2707- 'id' attribute which defines the fork stack's ID. Note that all fork stacks have to have unique IDs.
2707+ 'id' attribute which defines the fork stack's ID. Note that all fork stacks have to have unique IDs.
27082708
27092709
27102710After the fork-stack element, the child element starting with 'config' is a regular JGroups XML config
2711- file schema, where protocols are defined from bottom to top. For example, fork stack "lock" defines
2712- that CENTRAL_LOCK is the first protocol on top of FORK for the given fork stack, and
2713- STATS is on top of CENTRAL_LOCK.
2711+ file schema, where protocols are defined from bottom to top. For example, fork stack "lock" defines that CENTRAL_LOCK
2712+ is the first protocol on top of FORK for the given fork stack, and STATS is on top of CENTRAL_LOCK.
27142713
2715-
27162714When FORK is initialized, it will create the 2 fork stacks. When fork channels are created (see the next section),
2717- they can pick one of the 2 existing fork stacks to be created over, or they can dynamically create new fork
2718- stacks.
2715+ they can pick one of the 2 existing fork stacks to be created over, or they can dynamically create new fork stacks.
27192716
27202717
27212718[[ForkChannelCreation]]
@@ -2727,39 +2724,36 @@ A fork channel is created by instantiating a new ForkChannel object:
27272724
27282725[source,java]
27292726----
2730-
27312727JChannel main_ch=new JChannel("/home/bela/udp.xml").name("A");
27322728ForkChannel fork_ch=new ForkChannel(main_ch, "lock", "fork-ch4",
27332729 new CENTRAL_LOCK(), new STATS());
2734- fork_ch.connect("bla");
2730+
27352731main_ch.connect("cluster");
2736-
2732+ fork_ch.connect("bla");
27372733----
27382734
27392735First the main channel is created. Note that udp.xml may or may not contain FORK, but for this example, we
2740- assume it is present.
2736+ assume it is present.
27412737
2742-
27432738Then the ForkChannel is created. It is passed the main channel, the fork stack ID ("lock") and the
2744- fork channel ID ("fork-ch4"), plus a list of already instantiated protocols (CENTRAL_LOCK and STATS). If
2745- FORK already contains a fork stack with ID="lock", the existing fork stack will be used, or else a new
2746- one will be created with protocols CENTRAL_LOCK and STATS. Then a new fork channel with ID="fork-ch4" will
2747- be added to the top of fork stack "lock". An exception will be thrown if a fork channel with the same ID
2748- already exists.
2739+ fork channel ID ("fork-ch4"), plus a list of already instantiated protocols (CENTRAL_LOCK and STATS). If
2740+ FORK already contains a fork stack with ID="lock", the existing fork stack will be used, or else a new
2741+ one will be created with protocols CENTRAL_LOCK and STATS. Then a new fork channel with ID="fork-ch4" will
2742+ be added to the top of fork stack "lock". An exception will be thrown if a fork channel with the same ID
2743+ already exists.
27492744
2745+ The main channel then calls `connect()`, and - after this - the ForkChannel also calls `connect()`. (Note that the
2746+ latter's connect argument (the cluster name)) is ignored as fork channels have the same cluster name as the
2747+ main channel they reference. The local address, name, view and state are also the same.
27502748
2751- The ForkChannel now calls connect(), but the cluster name is ignored as fork channels have the same
2752- cluster name as they main channel the reference. The local address, name, view and state are also the same.
2753- This means, that even though connect() was called, the fork channel is not yet connected. As soon as the
2754- main channel is connected, the fork channel will be connected, too.
2755-
2749+ NOTE: A fork channel's `connect()` must be called after the main channel has been connected. If this is not the case,
2750+ `ForkChannel.connect()` will throw an exception.
27562751
27572752The lifetime of a fork channel is always dominated by the main channel: if the main channel is closed, all
2758- fork channels atttached to it are in closed state, too, and trying to send a message will throw an exception.
2753+ fork channels atttached to it are in closed state, too, and trying to send a message will throw an exception.
27592754
2760-
27612755The example above showed the simplified constructor, which requires the FORK protocol to be present in the
2762- stack. There's another constructor which allows for FORK to be created dynamically if not present:
2756+ stack. There's another constructor which allows for FORK to be created dynamically if not present:
27632757
27642758
27652759
0 commit comments