Class: Cassandra::AddressResolution::Policies::EC2MultiRegion
- Inherits:
-
Object
- Object
- Cassandra::AddressResolution::Policies::EC2MultiRegion
- Defined in:
- lib/cassandra/address_resolution/policies/ec2_multi_region.rb
Overview
Note:
Initializing this policy is not necessary, you should just pass
:ec_multi_region
to the :address_resolution
option of
Cassandra.cluster
This policy resolves private ips of the hosts in the same datacenter and public ips of hosts in other datacenters.
Instance Method Summary collapse
-
#resolve(address) ⇒ IPAddr
Returns ip address after a double DNS lookup.
Instance Method Details
#resolve(address) ⇒ IPAddr
Returns ip address after a double DNS lookup. First, it will get hostname from a given ip, then resolve the resulting hostname. This policy works because AWS public hostnames resolve to a private ip address within the same datacenter.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cassandra/address_resolution/policies/ec2_multi_region.rb', line 43 def resolve(address) @resolver.each_name(Resolv::DNS::Name.create(address.reverse)) do |name| @resolver.each_address(name) do |addr| return ::IPAddr.new(addr) end end # default to original address if reverse DNS lookup failed address end |