Class LocalhostResolver
- java.lang.Object
-
- org.apache.cassandra.sidecar.testing.LocalhostResolver
-
- All Implemented Interfaces:
org.apache.cassandra.sidecar.common.server.dns.DnsResolver
public class LocalhostResolver extends java.lang.Object implements org.apache.cassandra.sidecar.common.server.dns.DnsResolverADnsResolverinstance used for tests that provides fast DNS resolution, to avoid blocking DNS resolution at the JDK/OS-level.NOTE: The resolver assumes that the addresses are of the form 127.0.0.x, which is what is currently configured for integration tests.
-
-
Constructor Summary
Constructors Constructor Description LocalhostResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringresolve(java.lang.String hostname)Returns the resolved IP address from the hostname.java.lang.StringreverseResolve(java.lang.String address)Returns the resolved hostname from the givenaddress.
-
-
-
Method Detail
-
resolve
public java.lang.String resolve(java.lang.String hostname) throws java.net.UnknownHostExceptionReturns the resolved IP address from the hostname. If thehostnamepattern is not matched, delegate the resolution to the delegate resolver.resolver.resolve("localhost") = "127.0.0.1" resolver.resolve("localhost2") = "127.0.0.2" resolver.resolve("localhost20") = "127.0.0.20" resolver.resolve("127.0.0.5") = "127.0.0.5"- Specified by:
resolvein interfaceorg.apache.cassandra.sidecar.common.server.dns.DnsResolver- Parameters:
hostname- the hostname to resolve- Returns:
- the resolved IP address
- Throws:
java.net.UnknownHostException
-
reverseResolve
public java.lang.String reverseResolve(java.lang.String address) throws java.net.UnknownHostExceptionReturns the resolved hostname from the givenaddress. When an invalid IP address is provided, delegatesaddressresolution to the delegate.resolver.reverseResolve("127.0.0.1") = "localhost" resolver.reverseResolve("127.0.0.2") = "localhost2" resolver.reverseResolve("127.0.0.20") = "localhost20" resolver.reverseResolve("localhost5") = "localhost5"- Specified by:
reverseResolvein interfaceorg.apache.cassandra.sidecar.common.server.dns.DnsResolver- Parameters:
address- the IP address to perform the reverse resolution- Returns:
- the resolved hostname for the given
address - Throws:
java.net.UnknownHostException
-
-