// ... GlobalConfiguration gc = new GlobalConfigurationBuilder().transport().addProperty("configurationFile", "jgroups.xml").build(); // ...
Infinispan ships with pre-configured JGroups stacks that make it easy for you to jump-start a clustered configuration.
If you are configuring your cache programmatically, all you need to do is:
// ... GlobalConfiguration gc = new GlobalConfigurationBuilder().transport().addProperty("configurationFile", "jgroups.xml").build(); // ...
<infinispan> <global> <transport> <properties> <property name="configurationFile" value="jgroups.xml" /> </properties> </transport> </global> ... </infinispan>
Infinispan ships with a few different JGroups files (packaged in infinispan-core.jar) which means they will already be on your classpath by default. All you need to do is specify the file name, e.g., instead of jgroups.xml above, specify jgroups-tcp.xml.
The configurations available are:
jgroups-udp.xml - Uses UDP as a transport, and UDP multicast for discovery. Usually suitable for larger (over 100 nodes) clusters or if you are using replication or invalidation. Minimises opening too many sockets.
jgroups-tcp.xml - Uses TCP as a transport and UDP multicast for discovery. Better for smaller clusters (under 100 nodes) only if you are using distribution, as TCP is more efficient as a point-to-point protocol
jgroups-ec2.xml - Uses TCP as a transport and S3_PING for discovery. Suitable on Amazon EC2 nodes where UDP multicast isn't available.
The settings above can be further tuned without editing the XML files themselves. Passing in certain system properties to your JVM at startup can affect the behaviour of some of these settings. The table below shows you which settings can be configured in this way. E.g.,
$ java -cp ... -Djgroups.tcp.port=1234 -Djgroups.tcp.address=10.11.12.13
System Property |
Description |
Default |
Required? |
jgroups.udp.mcast_addr |
IP address to use for multicast (both for communications and discovery). Must be a valid Class D IP address, suitable for IP multicast. |
228.6.7.8 |
No |
jgroups.udp.mcast_port |
Port to use for multicast socket |
46655 |
No |
jgroups.udp.ip_ttl |
Specifies the time-to-live (TTL) for IP multicast packets. The value here refers to the number of network hops a packet is allowed to make before it is dropped |
2 |
No |
System Property |
Description |
Default |
Required? |
jgroups.tcp.address |
IP address to use for the TCP transport. |
127.0.0.1 |
No |
jgroups.tcp.port |
Port to use for TCP socket |
7800 |
No |
jgroups.udp.mcast_addr |
IP address to use for multicast (for discovery). Must be a valid Class D IP address, suitable for IP multicast. |
228.6.7.8 |
No |
jgroups.udp.mcast_port |
Port to use for multicast socket |
46655 |
No |
jgroups.udp.ip_ttl |
Specifies the time-to-live (TTL) for IP multicast packets. The value here refers to the number of network hops a packet is allowed to make before it is dropped |
2 |
No |
System Property |
Description |
Default |
Required? |
jgroups.tcp.address |
IP address to use for the TCP transport. |
127.0.0.1 |
No |
jgroups.tcp.port |
Port to use for TCP socket |
7800 |
No |
jgroups.s3.access_key |
The Amazon S3 access key used to access an S3 bucket |
|
No |
jgroups.s3.secret_access_key |
The Amazon S3 secret key used to access an S3 bucket |
|
No |
jgroups.s3.bucket |
Name of the Amazon S3 bucket to use. Must be unique and must already exist |
|
No |
JGroups also supports more system property overrides, details of which can be found on this page: SystemProps
In addition, the JGroups configuration files shipped with Infinispan are intended as a jumping off point to getting something up and running, and working. More often than not though, you will want to fine-tune your JGroups stack further to extract every ounce of performance from your network equipment. For this, your next stop should be the JGroups manual which has a detailed section on configuring each of the protocols you see in a JGroups configuration file.