public class DnsSrvRecordAddressResolver extends Object implements AddressResolver
AddressResolver
that resolves addresses against a DNS SRV request.
SRV records contain the hostname and the port for a given service.
They also support priorities, to give precedence to a given host
over other hosts.
Note the hosts returned by the SRV query must be resolvable by
the DNS servers of the underlying platform (or the default ones
specified for this Java process). This class does not issue a
query for A records after the SRV query.
This implementation returns the highest-priority records first.
This behavior can be changed by overriding the sort
method.
This implementation uses internally the com.sun.jndi.dns.DnsContextFactory
class for the DNS query.
The first returned address is used when automatic recovery is NOT enabled
at the ConnectionFactory
level.
When automatic recovery is enabled, a random address will be picked up
from the returned list of Address
es.Modifier and Type | Class and Description |
---|---|
static class |
DnsSrvRecordAddressResolver.SrvRecord |
Constructor and Description |
---|
DnsSrvRecordAddressResolver(String service) |
DnsSrvRecordAddressResolver(String service,
String dnsUrls) |
Modifier and Type | Method and Description |
---|---|
List<Address> |
getAddresses()
Get the potential
Address es to connect to. |
protected List<DnsSrvRecordAddressResolver.SrvRecord> |
lookupSrvRecords(String service,
String dnsUrls) |
protected DnsSrvRecordAddressResolver.SrvRecord |
mapSrvRecord(String srvResult) |
protected List<DnsSrvRecordAddressResolver.SrvRecord> |
sort(List<DnsSrvRecordAddressResolver.SrvRecord> records) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
maybeShuffle
public DnsSrvRecordAddressResolver(String service)
public List<Address> getAddresses() throws IOException
AddressResolver
Address
es to connect to.getAddresses
in interface AddressResolver
Address
esIOException
- if it encounters a problemprotected List<DnsSrvRecordAddressResolver.SrvRecord> lookupSrvRecords(String service, String dnsUrls) throws IOException
IOException
protected DnsSrvRecordAddressResolver.SrvRecord mapSrvRecord(String srvResult)
protected List<DnsSrvRecordAddressResolver.SrvRecord> sort(List<DnsSrvRecordAddressResolver.SrvRecord> records)
Copyright © 2022 VMware, Inc. or its affiliates.. All rights reserved.