Skip to content

Commit b6bc879

Browse files
author
alexsa
committed
Update docs
1 parent d4fae06 commit b6bc879

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

core/src/main/resources/reference.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,8 +1036,20 @@ datastax-java-driver {
10361036
# You can also specify a custom class that implements AddressTranslator and has a public
10371037
# constructor with a DriverContext argument.
10381038
class = PassThroughAddressTranslator
1039+
#
10391040
# This property has to be set only in case you use FixedHostNameAddressTranslator.
10401041
# advertised-hostname = mycustomhostname
1042+
#
1043+
# Theses properties have to be set only in case you use SubnetAddressTranslator.
1044+
# subnet-addresses {
1045+
# "100.64.0.0/15" = "cassandra.datacenter1.com:9042"
1046+
# "100.66.0.0/15" = "cassandra.datacenter2.com" # port defaults to 9042 if not specified
1047+
# # IPv6 example:
1048+
# # "::ffff:6440:0/111" = "cassandra.datacenter1.com:9042"
1049+
# # "::ffff:6442:0/111" = "cassandra.datacenter2.com" # port defaults to 9042 if not specified
1050+
# }
1051+
# Optional. When configured, addresses not matching the configured subnets are translated to it. Port defaults to 9042 if not specified.
1052+
# default-address = "cassandra.datacenter1.com:9042"
10411053
}
10421054

10431055
# Whether to resolve the addresses passed to `basic.contact-points`.

manual/core/address_resolution/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,52 @@ datastax-java-driver.advanced.address-translator.class = com.mycompany.MyAddress
118118
Note: the contact points provided while creating the `CqlSession` are not translated, only addresses
119119
retrieved from or sent by Cassandra nodes are.
120120

121+
### Fixed proxy hostname
122+
123+
If your client applications access Cassandra through some kind of proxy (eg. with AWS PrivateLink when all Cassandra
124+
nodes are exposed via one hostname pointing to AWS Endpoint), you can configure driver with
125+
`FixedHostNameAddressTranslator` to always translate all node addresses to that same proxy hostname, no matter what IP
126+
address a node has but still using its native transport port.
127+
128+
To use it, specify the following in the [configuration](../configuration):
129+
130+
```
131+
datastax-java-driver.advanced.address-translator.class = FixedHostNameAddressTranslator
132+
advertised-hostname = proxyhostname
133+
```
134+
135+
### Fixed proxy hostname per subnet
136+
137+
When running Cassandra in a private network and accessing it from outside of that private network via some kind of
138+
proxy, we have an option to use `FixedHostNameAddressTranslator`. But for multi-datacenter Cassandra deployments, we
139+
want to have more control over routing queries to a specific datacenter (eg. for optimizing latencies), which requires
140+
setting up a separate proxy per datacenter.
141+
142+
Normally, each Cassandra datacenter nodes are deployed to a separate subnet to support internode communications in the
143+
cluster and avoid IP addresses collisions. So when Cassandra broadcasts its nodes IP addresses, we can determine which
144+
datacenter that node belongs to by checking its IP address against the given datacenter subnet.
145+
146+
For such scenarios you can use `SubnetAddressTranslator` to translate node IPs to the datacenter proxy address
147+
associated with it.
148+
149+
To use it, specify the following in the [configuration](../configuration):
150+
```
151+
datastax-java-driver.advanced.address-translator {
152+
class = SubnetAddressTranslator
153+
subnet-addresses {
154+
"100.64.0.0/15" = "cassandra.datacenter1.com:9042"
155+
"100.66.0.0/15" = "cassandra.datacenter2.com" # port defaults to 9042 if not specified
156+
# IPv6 example:
157+
# "::ffff:6440:0/111" = "cassandra.datacenter1.com:9042"
158+
# "::ffff:6442:0/111" = "cassandra.datacenter2.com" # port defaults to 9042 if not specified
159+
}
160+
# Optional. When configured, addresses not matching the configured subnets are translated to it. Port defaults to 9042 if not specified.
161+
default-address = "cassandra.datacenter1.com:9042"
162+
}
163+
```
164+
165+
Such setup is common for running Cassandra on Kubernetes with [k8ssandra](https://docs.k8ssandra.io/).
166+
121167
### EC2 multi-region
122168

123169
If you deploy both Cassandra and client applications on Amazon EC2, and your cluster spans multiple regions, you'll have

0 commit comments

Comments
 (0)