next up previous contents
Next: The JChannel protocol stack Up: JavaGroups User's Guide Previous: Using multiple Routers

   
Implementing Protocols Using JChannel

This chapter discusses how to write protocols for JavaGroups. It describes the architecture of the JChannel protocol stack (creation, setup and event flow) and the various types of protocols that can be written subclassing different protocol 'templates'. It is intended for people who want to write their own protocols or modify an existing one.

The beauty of protocol layers is that they are independent from each other, therefore they can easily be replaced by other versions. They're also (usually) fairly small, focusing on just one functionality, which makes them easy to understand. If a protocol becomes too large, incorporating multiple functionalities, it should be broken into a number of smaller ones.

Protocol layers can be added to JavaGroups (currently by placing them in directory JavaGroups/JavaStack/Protocols), without modifying JavaGroups' core code. Note, however, that the protocol code will be loaded into and running with JavaGroups' core code in the same JVM, therefore it may affect the whole JChannel4.1.

Since each protocol has the same interface and is completely independent from other protocols, it can be stacked on top or below every other protocol. However, this wouldn't make sense in most cases semantically: a certain order has to be observed. Therefore, although protocols are syntactically independent, they are not semantically independent: for example the GMS protocol requires that a PING (or PING-like) protocol be present somewhere below it for the discovery of the initial membership. More precisely: the GMS protocol at some point will send a FIND_INITIAL_MBRS event down the stack (see 4.1.2), which it expects to be handled by some other protocol. That protocol is required to perform the task of finding the initial members and passing a FIND_INITIAL_MBRS_OK event up the stack, containing the initial membership. The GMS layer will wait for the response, or time out and become a singleton member in the group. Therefore, although GMS does not syntactically depend on PING (it does not call a method of PING), it does have a dependence on some layer below it that answers to FIND_INITIAL_MBRS events. Yet this kind of dependence is less binding than a method-call binding: any layer that sees fit may answer to the request for initial membership, and GMS does not even know which layer it will be.



 
next up previous contents
Next: The JChannel protocol stack Up: JavaGroups User's Guide Previous: Using multiple Routers

1999-12-13