此内容没有您所选择的语言版本。
Chapter 7. Setting Up Cluster Transport
Data Grid nodes rely on a transport layer to join and leave clusters as well as to replicate data across the network.
Data Grid uses JGroups technology to handle cluster transport. You configure cluster transport with JGroups stacks, which define properties for either UDP or TCP protocols.
7.1. Getting Started with Default Stacks 复制链接链接已复制到粘贴板!
Use default JGroups stacks with recommended settings as a starting point for your cluster transport layer.
Declaratively
Specify default JGroups stacks with the
stack
attribute.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- uses the
default-jgroups-udp.xml
stack for cluster transport.
Programmatically
Specify default JGroups stacks with the
addProperty()
method.GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().transport() .defaultTransport() .clusterName("qa-cluster") .addProperty("configurationFile", "default-jgroups-udp.xml") .build();
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().transport() .defaultTransport() .clusterName("qa-cluster") .addProperty("configurationFile", "default-jgroups-udp.xml")
1 .build();
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- uses the
default-jgroups-udp.xml
stack for cluster transport.
Use the cluster-stack
argument with the Data Grid server startup script.
bin/server.sh --cluster-stack=tcp
$ bin/server.sh --cluster-stack=tcp
7.1.1. Default JGroups Stacks 复制链接链接已复制到粘贴板!
Default JGroups stacks are included in infinispan-core.jar
and on the classpath. You can locate the default JGroups stacks in the default-configs
directory.
File name | Stack name | Description |
---|---|---|
|
| Uses UDP for transport and UDP multicast for discovery. Suitable for larger clusters (over 100 nodes) or if you are using replicated caches or invalidation mode. Minimizes the number of open sockets. |
|
|
Uses TCP for transport and the |
|
|
Uses TCP for transport and |
|
|
Uses TCP for transport and |
|
|
Uses TCP for transport and |
|
|
Uses TCP for transport and |
Reference
7.2. Using Inline JGroups Stacks 复制链接链接已复制到粘贴板!
Custom JGroups stacks can help you optimize network performance for Data Grid clusters compared to using the default stacks.
Procedure
Embed your custom JGroups stack definitions in
infinispan.xml
as in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Use inheritance with inline JGroups stacks to tune and customize specific transport properties.
7.3. Adjusting and Tuning JGroups Stacks 复制链接链接已复制到粘贴板!
Use inheritance to combine, extend, remove, and replace specific properties in the default JGroups stacks or custom configurations.
Procedure
- Add a new JGroups stack declaration.
Name a parent stack with the
extends
attribute.TipUse the default JGroups stacks as parents. For example,
extends="tcp"
to tunes the default TCP stack.-
Modify transport properties with the
stack.combine
attribute.
7.3.1. Stack Combine Attribute 复制链接链接已复制到粘贴板!
stack.combine
modifies inherited JGroups properties.
stack.position
identifies protocols to modify. If you do not specify stack.position
, Data Grid defaults to the same protocol as the inherited configuration, which resets all non-specified attributes to the default values.
Value | Description |
---|---|
| Overrides existing protocol attributes. |
| Replaces existing protocols. |
| Inserts protocols into the JGroups stack. |
| Removes protocols from the inherited configuration. |
For example, evaluate a Gossip router for cluster discovery using a TCP stack configuration named "prod":
7.4. Using JGroups Stacks in External Files 复制链接链接已复制到粘贴板!
You can use custom JGroups transport configuration from external files.
Data Grid looks for JGroups configuration files on your classpath first and then for absolute path names.
Declaratively
Specify your JGroups transport configuration with the
stack-file
element.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Programmatically
Specify your JGroups transport configuration with the
addProperty()
method.GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().transport() .defaultTransport() .clusterName("prod-cluster") .addProperty("configurationFile", "prod-jgroups-tcp.xml") .build();
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().transport() .defaultTransport() .clusterName("prod-cluster") .addProperty("configurationFile", "prod-jgroups-tcp.xml")
1 .build();
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- adds the "prod-jgroups-tcp.xml" stack definition as the default for the cluster transport.
7.5. Tuning JGroups Stacks with System Properties 复制链接链接已复制到粘贴板!
Pass system properties to the JVM at startup to tune JGroups stacks.
For example, to change the TCP
port and IP address do the following:
java -cp ... -Djgroups.tcp.port=1234 -Djgroups.tcp.address=192.0.2.0
$ java -cp ... -Djgroups.tcp.port=1234 -Djgroups.tcp.address=192.0.2.0
7.5.1. System Properties for Default JGroups Stacks 复制链接链接已复制到粘贴板!
Use system properties with default JGroups stacks.
Common Properties
The following system properties apply to all JGroups stacks, including default-jgroups-udp.xml
and default-jgroups-tcp.xml
:
System Property | Description | Default Value | Required/Optional |
---|---|---|---|
| Bind address for cluster transport. |
| Optional |
| Bind port for the socket. |
| Optional |
| IP address for multicast, both discovery and inter-cluster communication. The IP address must be a valid "class D" address that is suitable for IP multicast. |
| Optional |
| Port for the multicast socket. |
| Optional |
| Time-to-live (TTL) for IP multicast packets. The value defines the number of network hops a packet can make before it is dropped. | 2 | Optional |
| Minimum number of threads for the thread pool. | 0 | Optional |
| Maximum number of threads for the thread pool. | 200 | Optional |
| Maximum number of milliseconds to wait for join requests to succeed. | 2000 | Optional |
Amazon EC3
The following system properties apply to default-jgroups-ec2.xml
:
System Property | Description | Default Value | Required/Optional |
---|---|---|---|
| Amazon S3 access key for an S3 bucket. | No default value. | Optional |
| Amazon S3 secret key used for an S3 bucket. | No default value. | Optional |
| Name of the Amazon S3 bucket. The name must exist and be unique. | No default value. | Optional |
Kubernetes
The following system properties apply to default-jgroups-kubernetes.xml
:
System Property | Description | Default Value | Required/Optional |
---|---|---|---|
| Sets the DNS record that returns cluster members. | N/A |
Required if you do not set the |
Google Cloud Platform
The following system properties apply to default-jgroups-google.xml
:
System Property | Description | Default Value | Required/Optional |
---|---|---|---|
| Name of the Google Compute Engine bucket. The name must exist and be unique. | N/A |
Required if you do not set the |