public class DnsCacheManipulator extends Object
DnsCacheManipulatorException
if operation fail for all methods.DnsCacheEntry
,
DnsCacheManipulatorException
Modifier and Type | Method and Description |
---|---|
static void |
clearDnsCache()
Clear all dns cache entries, cause lookup dns server for all host after.
|
static List<DnsCacheEntry> |
getAllDnsCache()
Deprecated.
use
listDnsCache() instead. |
static DnsCacheEntry |
getDnsCache(String host)
Get dns cache.
|
static int |
getDnsCachePolicy()
Get JVM DNS cache policy.
|
static int |
getDnsNegativeCachePolicy()
JVM DNS negative cache policy
|
static DnsCache |
getWholeDnsCache()
Get whole dns cache info.
|
static List<DnsCacheEntry> |
listDnsCache()
Get all dns cache entries.
|
static void |
loadDnsCacheConfig()
Load dns config from properties file
dns-cache.properties on classpath, then set to dns cache. |
static void |
loadDnsCacheConfig(String propertiesFileName)
Load dns config from the specified properties file on classpath, then set dns cache.
|
static void |
removeDnsCache(String host)
Remove dns cache entry, cause lookup dns server for host after.
|
static void |
setDnsCache(long expireMillis,
String host,
String... ips)
Set a dns cache entry.
|
static void |
setDnsCache(Properties properties)
Set dns cache entries by properties
|
static void |
setDnsCache(String host,
String... ips)
Set a never expired dns cache entry
|
static void |
setDnsCachePolicy(int cacheSeconds)
Set JVM DNS cache policy
NOTE: if Security Manage is turn on, JVM DNS cache policy set will not take effective.
|
static void |
setDnsNegativeCachePolicy(int negativeCacheSeconds)
Set JVM DNS negative cache policy
|
public static void setDnsCache(String host, String... ips)
host
- hostips
- ipsDnsCacheManipulatorException
- Operation failsetDnsCache(long, java.lang.String, java.lang.String...)
public static void setDnsCache(long expireMillis, String host, String... ips)
expireMillis
- expire time in milliseconds.host
- hostips
- ipsDnsCacheManipulatorException
- Operation failpublic static void setDnsCache(Properties properties)
properties
- input properties. eg. www.example.com=42.42.42.42
, or www.example.com=42.42.42.42,43.43.43.43
DnsCacheManipulatorException
- Operation failpublic static void loadDnsCacheConfig()
dns-cache.properties
on classpath, then set to dns cache.DnsCacheManipulatorException
- Operation failsetDnsCache(java.util.Properties)
,
loadDnsCacheConfig(java.lang.String)
public static void loadDnsCacheConfig(String propertiesFileName)
propertiesFileName
- specified properties file name on classpath.DnsCacheManipulatorException
- Operation failsetDnsCache(java.util.Properties)
@Nullable public static DnsCacheEntry getDnsCache(String host)
null
if no entry for host or dns cache is expired.DnsCacheManipulatorException
- Operation fail@Deprecated public static List<DnsCacheEntry> getAllDnsCache()
listDnsCache()
instead.DnsCacheManipulatorException
- Operation failpublic static List<DnsCacheEntry> listDnsCache()
DnsCacheManipulatorException
- Operation failgetWholeDnsCache()
public static DnsCache getWholeDnsCache()
DnsCacheManipulatorException
- Operation failpublic static void removeDnsCache(String host)
host
- hostDnsCacheManipulatorException
- Operation failclearDnsCache()
public static void clearDnsCache()
DnsCacheManipulatorException
- Operation failpublic static int getDnsCachePolicy()
-1
means never expired.(In effect, all negative value)0
never cached.DnsCacheManipulatorException
- Operation failpublic static void setDnsCachePolicy(int cacheSeconds)
getDnsCachePolicy()
.cacheSeconds
- set default dns cache time. Special input case:
-1
means never expired.(In effect, all negative value)0
never cached.DnsCacheManipulatorException
- Operation failpublic static int getDnsNegativeCachePolicy()
-1
means never expired.(In effect, all negative value)0
never cached.DnsCacheManipulatorException
- Operation failpublic static void setDnsNegativeCachePolicy(int negativeCacheSeconds)
negativeCacheSeconds
- set default dns cache time. Special input case:
-1
means never expired.(In effect, all negative value)0
never cached.DnsCacheManipulatorException
- Operation failCopyright © 2015 Alibaba. All rights reserved.