Class EC2MultiRegionAddressTranslator

  • All Implemented Interfaces:
    AddressTranslator

    public class EC2MultiRegionAddressTranslator
    extends Object
    implements AddressTranslator
    AddressTranslator implementation 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.
    This optimizes network costs, because Amazon charges more for communication over public 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 Detail

      • EC2MultiRegionAddressTranslator

        public EC2MultiRegionAddressTranslator()
    • Method Detail

      • init

        public void init​(Cluster cluster)
        Description copied from interface: AddressTranslator
        Initializes this address translator.
        Specified by:
        init in interface AddressTranslator
        Parameters:
        cluster - the Cluster instance for which the translator is created.
      • translate

        public InetSocketAddress translate​(InetSocketAddress socketAddress)
        Description copied from interface: AddressTranslator
        Translates a Cassandra rpc_address to another address if necessary.
        Specified by:
        translate in interface AddressTranslator
        Parameters:
        socketAddress - 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).
        Returns:
        the address the driver should actually use to connect to the node designated by address. If the return is null, then address will be used by the driver (it is thus equivalent to returning address directly)