Jgroups is still useful in the cluster environment, such as developing a distributed cache Layer Based on jgroups & memcached, splitting cluster tasks and
Merge computing results, jbosscache component...
XML-protocol stack-an example of TCP. XML standard for jgroups
1. Read the <element> set in the <config> lower part of the XML file. Each <element> is initialized to a protocolconfiguration
-Protocolconfiguration-> protocol_name | Map <key, value>
Form a list <protocolconfiguration>
------
2. protocolconfiguration parameter Processing
A. iterate every key-value of map to process value. If group (1) in the regular expression $ {([^ \}] +)} In value is found, it is extracted for processing.
B. extracts all the Groups (1). If the regular expressions ([^:] +) :( [^:] +) are used, group (1) and group (2) are used) extracted separately, otherwise the entire
As a group (1)
C. if group (1) satisfies [([^,] +),] * ([^,] +), all group iterations are extracted to call system. getproperty (value) if not empty
Exit iteration. If the value obtained by group (1) is null, use group (2) instead. If the value obtained by this layer is not
If it is null, the group (1) of the previous layer uses this value instead. Otherwise, the key-value is deleted from the protocolconfiguration attribute.
------
3. Build protocol stack protocolstack
A. List <protocolconfiguration> to list <protocol> Processing
Iterate protocolconfiguration to initialize the Protocol Class Based on protocolconfiguration. protocol_name.
Protocolconfiguration. properties: Set the properties of protocol. The specific step is to first obtain the outdated Protocol
Properties are removed from properties, and the properties that can be set in protocol can be obtained. If properties contains properties, the properties are set,
Finally, if there are redundant mappings in properties, an exception is thrown. Initialize a list <protocol> generated protocol and add it to this list.
B. List <protocol> Verification
The first step is to verify whether the list <protocol> is repeated, and then the protocol that requires the services provided by the upper and lower layers to be connected to each layer.
And the following protocol to find whether it provides the services it needs
iterate the list to connect the Protocol linked list
-----------
-Protocol protocol: List
-protocol. upprotocol = nextprotocol
-nextprotocol. downprotocol = protocol
-----------
C. protocol Stack protocolstack itself is also a protocol, which maintains two references to top_prot and bottom_prot, where top_prot is
streaming_state_transfer, bottom_prot is TCP, and top_prot's upprotocol is set to protocolstack.
call protocol. init in reverse order to initialize the protocol.