next up previous contents
Next: Channel properties Up: Channel Previous: Channel   Contents

Creating a channel

A channel can be created in two ways: an instance of a subclass of Channel is created directly using its public constructor (e.g. new JChannel()), or a channel factory is created, which - upon request - creates instances of channels. We will only look at the first method of creating channel: by direct instantiation. Note that instantiation may differ between the various channel implementations. As example we will look at JChannel.

The public constructor of JChannel looks as follows:

    public JChannel(Object properties) throws ChannelException {}

It creates an instance of JChannel. The properties argument defines the composition of the protocol stack (number and type of layers, parameters for each layer, and their order). For JChannel, this has to be a String (see 3.7.2 for how to define one's own properties string). An example of a channel creation is

    String props="UDP(mcast_addr=228.1.2.3;mcast_port=45566;ip_ttl=32):" +
        "PING(timeout=3000;num_initial_members=6):" +
        "FD(timeout=5000):" +
        "VERIFY_SUSPECT(timeout=1500):" +
        "pbcast.STABLE(desired_avg_gossip=10000):" +
        "pbcast.NAKACK(gc_lag=10;retransmit_timeout=3000):" +
        "UNICAST(timeout=5000;min_wait_time=2000):" +
        "FRAG:" +
        "pbcast.GMS(initial_mbrs_timeout=4000;join_timeout=5000;" +
        "join_retry_timeout=2000;shun=false;print_local_addr=false)";
    JChannel channel;
    try {
        channel=new JChannel(props);
    }
    catch(Exception ex) {
        // channel creation failed
    }

The argument is a colon-delimited string of protocols, specified from bottom to top (left to right). The example properties argument will be used to create a protocol stack that uses IP Multicast (UDP) as bottom protocol, the PING protocol to locate the initial members, FD for failure detection, VERIFY_SUSPECT for double-checking of suspected members, STABLE for garbage collection of messages received by all members, NAKACK for lossless delivery of multicast messages, UNICAST for lossless delivery of unicast messages and GMS for group membership (handling of join or leave requests).

If the properties argument is null, the default properties will be used. An exception will be thrown if the channel cannot be created. Possible causes include protocols that were specified in the property argument, but were not found, or wrong parameters to protocols.


next up previous contents
Next: Channel properties Up: Channel Previous: Channel   Contents
Bela Ban 2002-11-16