public class DnsSrvConnectionStrategy extends java.lang.Object implements ConnectionStrategy
| Modifier and Type | Class and Description |
|---|---|
protected static class |
DnsSrvConnectionStrategy.SrvRecord
SRV record.
|
| Modifier and Type | Field and Description |
|---|---|
private static long |
DEFAULT_TTL
Default time to live for DNS results.
|
private static java.lang.String |
DNS_CONTEXT_FACTORY
JNDI context factory for DNS.
|
private static java.lang.String |
DNS_PROVIDER_URL
JNDI context factory for DNS.
|
private java.util.Map<java.lang.String,java.lang.Object> |
jndiEnv
JNDI environment.
|
protected org.slf4j.Logger |
logger
Logger for this class.
|
private java.util.List<DnsSrvConnectionStrategy.SrvRecord> |
srvRecords
SRV records from the last DNS lookup.
|
private long |
srvTtl
Time to live for SRV records in milliseconds.
|
ACTIVE_PASSIVE, DEFAULT, RANDOM, ROUND_ROBIN| Constructor and Description |
|---|
DnsSrvConnectionStrategy()
Creates a new DNS SRV connection strategy.
|
DnsSrvConnectionStrategy(long ttl)
Creates a new DNS SRV connection strategy.
|
DnsSrvConnectionStrategy(java.util.Map<java.lang.String,java.lang.Object> env,
long ttl)
Creates a new DNS SRV connection strategy.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<java.lang.String,java.lang.Object> |
getJndiEnvironment()
Returns the JNDI environment used for DNS lookup.
|
java.lang.String[] |
getLdapUrls(ConnectionFactoryMetadata metadata)
Returns a list of URLs retrieved from DNS SRV records.
|
long |
getTimeToLive()
Returns the time that DNS lookups will be cached.
|
protected java.util.List<DnsSrvConnectionStrategy.SrvRecord> |
retrieveDNSRecords(java.lang.String name,
java.util.Map<java.lang.String,java.lang.Object> props,
long ttl)
Uses JNDI to retrieve the DNS SRV record from the supplied url.
|
void |
setJndiEnvironment(java.util.Map<java.lang.String,java.lang.Object> env)
Sets the JNDI environment used for DNS lookups.
|
void |
setTimeToLive(long ttl)
Sets the time that DNS lookups will be cached.
|
protected java.util.List<DnsSrvConnectionStrategy.SrvRecord> |
sortSrvRecords(java.util.List<DnsSrvConnectionStrategy.SrvRecord> records)
Sorts the supplied SRV records according to RFC 2782.
|
java.lang.String |
toString() |
private static final java.lang.String DNS_CONTEXT_FACTORY
private static final java.lang.String DNS_PROVIDER_URL
private static final long DEFAULT_TTL
protected final org.slf4j.Logger logger
private java.util.Map<java.lang.String,java.lang.Object> jndiEnv
private long srvTtl
private java.util.List<DnsSrvConnectionStrategy.SrvRecord> srvRecords
public DnsSrvConnectionStrategy()
public DnsSrvConnectionStrategy(long ttl)
ttl - time to live in milliseconds for SRV recordspublic DnsSrvConnectionStrategy(java.util.Map<java.lang.String,java.lang.Object> env,
long ttl)
env - JNDI environmentttl - time to live in milliseconds for SRV recordspublic java.util.Map<java.lang.String,java.lang.Object> getJndiEnvironment()
public long getTimeToLive()
public void setJndiEnvironment(java.util.Map<java.lang.String,java.lang.Object> env)
Context.INITIAL_CONTEXT_FACTORY is set, it is
defaulted to DNS_CONTEXT_FACTORY. If no Context.PROVIDER_URL is set, it is defaulted to DNS_PROVIDER_URL.env - jndi environment or nullpublic void setTimeToLive(long ttl)
ttl - time to live in millisecondspublic java.lang.String[] getLdapUrls(ConnectionFactoryMetadata metadata)
getLdapUrls in interface ConnectionStrategymetadata - which can be used to produce the URL listprotected java.util.List<DnsSrvConnectionStrategy.SrvRecord> retrieveDNSRecords(java.lang.String name, java.util.Map<java.lang.String,java.lang.Object> props, long ttl) throws javax.naming.NamingException
name - of the SRV recordsprops - for the JNDI contextttl - time to live for each SRV recordjavax.naming.NamingException - if the DNS record cannot be retrievedprotected java.util.List<DnsSrvConnectionStrategy.SrvRecord> sortSrvRecords(java.util.List<DnsSrvConnectionStrategy.SrvRecord> records)
records - to sortpublic java.lang.String toString()
toString in class java.lang.Object