public interface AddressTranslater
The driver auto-detect new Cassandra nodes added to the cluster through server
side pushed notifications and through checking the system tables. For each
node, the address the driver will receive will correspond to the address set as
rpc_address
in the node yaml file. In most case, this is the correct
address to use by the driver and that is what is used by default. However,
sometimes the addresses received through this mechanism will either not be
reachable directly by the driver or should not be the prefered address to use
to reach the node (for instance, the rpc_address
set on Cassandra nodes
might be a private IP, but some clients may have to use a public IP, or
pass by a router to reach that node). This interface allows to deal with
such cases, by allowing to translate an address as sent by a Cassandra node
to another address to be used by the driver for connection.
Please note that the contact points addresses provided while creating the
Cluster
instance are not "tanslated", only IP address retrieve from or sent
by Cassandra nodes to the driver are.
Modifier and Type | Method and Description |
---|---|
InetSocketAddress |
translate(InetSocketAddress address)
Translates a Cassandra
rpc_address to another address if necessary. |
InetSocketAddress translate(InetSocketAddress address)
rpc_address
to another address if necessary.address
- the address of a node as returned by Cassandra. Note that
if the rpc_address
of a node has been configured to 0.0.0.0
server side, then the provided address will be the node listen_address
,
*not* 0.0.0.0
. Also note that the port for InetSocketAddress
will always be the one set at Cluster construction time (9042 by default).address
. If the return is null
, then address
will be used by the driver (it is thus equivalent to returing
address
directly)Copyright © 2012–2015. All rights reserved.