Class EC2MultiRegionAddressTranslator
- java.lang.Object
-
- com.datastax.driver.core.policies.EC2MultiRegionAddressTranslator
-
- All Implemented Interfaces:
AddressTranslator
public class EC2MultiRegionAddressTranslator extends Object implements AddressTranslator
AddressTranslatorimplementation for a multi-region EC2 deployment where clients are also deployed in EC2.Its distinctive feature is that it translates addresses according to the location of the Cassandra host:
- addresses in different EC2 regions (than the client) are unchanged;
- addresses in the same EC2 region are translated to private IPs.
Implementation note: this class performs a reverse DNS lookup of the origin address, to find the domain name of the target instance. Then it performs a forward DNS lookup of the domain name; the EC2 DNS does the private/public switch automatically based on location.
-
-
Constructor Summary
Constructors Constructor Description EC2MultiRegionAddressTranslator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Called atClustershutdown.voidinit(Cluster cluster)Initializes this address translator.InetSocketAddresstranslate(InetSocketAddress socketAddress)Translates a Cassandrarpc_addressto another address if necessary.
-
-
-
Method Detail
-
init
public void init(Cluster cluster)
Description copied from interface:AddressTranslatorInitializes this address translator.- Specified by:
initin interfaceAddressTranslator- Parameters:
cluster- theClusterinstance for which the translator is created.
-
translate
public InetSocketAddress translate(InetSocketAddress socketAddress)
Description copied from interface:AddressTranslatorTranslates a Cassandrarpc_addressto another address if necessary.- Specified by:
translatein interfaceAddressTranslator- Parameters:
socketAddress- the address of a node as returned by Cassandra. Note that if therpc_addressof a node has been configured to0.0.0.0server side, then the provided address will be the nodelisten_address, *not*0.0.0.0. Also note that the port forInetSocketAddresswill always be the one set at Cluster construction time (9042 by default).- Returns:
- the address the driver should actually use to connect to the node designated by
address. If the return isnull, thenaddresswill be used by the driver (it is thus equivalent to returningaddressdirectly)
-
close
public void close()
Description copied from interface:AddressTranslatorCalled atClustershutdown.- Specified by:
closein interfaceAddressTranslator
-
-