JDG basically is built on top of JGroups is a toolkit for messaging and is based on protocols. Bela Ban developed it for his post-doc at Cornell University, as he explains on the manual, is a pure java implementation of group communication transport that ended up being used by JBoss (the company).
Github
What is it?
JGroups is a Java library for reliable group communication.
It consists of 3 parts: (1) a socket-like API for application development, (2) a protocol stack, which implements reliable communication, and (3) a set of building blocks, which give the developer high-level abstractions (e.g. ReplicatedHashMap, an implementation of java.util.Map).
Relation to Infinispan
Infinispan <uses> JGroups as its underlying clustering layer. In order to configure the finer details of clustering (discovery, flow control, cross-site, etc) you have to provide a separate XML file with the desired configuration and reference it from your Infinispan XML file as follows – that will have the protocols (which every message will pass through):
udp.xml
<config>
<UDP mcast_port=”${jgroups.udp.mcast_port:45588}”
ip_ttl=”8″
mcast_recv_buf_size=”5M”
mcast_send_buf_size=”5M”
enable_diagnostics=”true”thread_pool.min_threads=”2″
thread_pool.max_threads=”8″
thread_pool.keep_alive_time=”5000″/><PING />
<MERGE3 max_interval=”30000″ min_interval=”10000″/>
<FD_SOCK/>
<FD_ALL/>
<VERIFY_SUSPECT timeout=”1500″ />
<pbcast.NAKACK2 xmit_interval=”1000″/>
<UNICAST3 xmit_interval=”1000″/>
<pbcast.STABLE desired_avg_gossip=”50000″
max_bytes=”4M”/>
<pbcast.GMS print_local_addr=”true” join_timeout=”2000″/>
<UFC max_credits=”2M” min_threshold=”0.4″/>
<MFC max_credits=”2M” min_threshold=”0.4″/>
<FRAG2 frag_size=”60K” />
<pbcast.STATE_TRANSFER />
</config>
Sample Code
JChannel channel=new JChannel("/home/bela/udp.xml"); channel.setReceiver(new ReceiverAdapter() { public void receive(Message msg) { System.out.println("received msg from " + msg.getSrc() + ": " + msg.getObject()); } }); channel.connect("MyCluster"); channel.send(new ObjectMessageSerializable(null, "hello world")); channel.close();
JGroup and JChannel
While a group is a cluster, a JChannel a is the mean to the members to communicate as well as the building blocks, which are an abstraction above the JChannel. Finally the XML will contain a protocol stack, which has the bi-directional message path, from the building blocks up to the network.
Demo
[fdemeloj@fdemeloj Downloads]$ /home/fdemeloj/Downloads/jdk-11.0.1/bin/java -jar jgroups-5.0.0.Alpha6.jar
Version: 5.0.0.Alpha6 (Stelvio)
/home/fdemeloj/Downloads/jdk-11.0.1/bin/java -cp jgroups-5.0.0.Alpha6.jar org.jgroups.demos.Draw
Help:
[fdemeloj@fdemeloj jgroups]$ /home/fdemeloj/Downloads/jdk-11.0.1/bin/java -cp jgroups-5.0.0.Alpha6.jar org.jgroups.demos.Draw -help
Draw [-help] [-no_channel] [-props <protocol stack definition>] [-clustername <name>] [-state] [-timeout <state timeout>] [-use_unicasts] [-jmx <true | false>] [-name <logical name>] [-send_own_state_on_merge true|false] [-uuid <UUID>]
–no_channel: doesn’t use JGroups at all, any drawing will be relected on the whiteboard directly
–props: argument can be an old-style protocol stack specification, or it can be a URL. In the latter case, the protocol specification will be read from the URL