本文整理汇总了Java中org.xbill.DNS.Cache类的典型用法代码示例。如果您正苦于以下问题:Java Cache类的具体用法?Java Cache怎么用?Java Cache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cache类属于org.xbill.DNS包,在下文中一共展示了Cache类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCached
import org.xbill.DNS.Cache; //导入依赖的package包/类
private Message getCached(Message query) {
Cache cache = getCache();
if (cache == null)
return null;
Record question = query.getQuestion();
RRset[] rrsets = cache.findAnyRecords(question.getName(), question.getType());
if (rrsets == null)
return null;
Message msg = new Message();
for (RRset rrset : rrsets) {
@SuppressWarnings("unchecked")
Iterator<Record> recordsIter = rrset.rrs();
while (recordsIter.hasNext()) {
msg.addRecord(recordsIter.next(), Section.ANSWER);
}
}
return msg;
}
示例2: DNSCacheManager
import org.xbill.DNS.Cache; //导入依赖的package包/类
public DNSCacheManager() {
setProperty(new CollectionProperty(SERVERS, new ArrayList<String>()));
//disabling cache
lookupCache = new Cache();
lookupCache.setMaxCache(0);
lookupCache.setMaxEntries(0);
}
示例3: DnsServicesDiscovery
import org.xbill.DNS.Cache; //导入依赖的package包/类
/**
* Overloaded constructor taking as argument Cache size and TTL.
*
* @param cacheSize Unsigned <code>int</code> defining the Cache size
* @param cacheTTL Unsigned <code>int</code> defining the Cache TTL
*/
public DnsServicesDiscovery(int cacheSize, int cacheTTL)
{
this.anyClassCache = new Cache(DClass.ANY);
this.anyClassCache.setMaxEntries(cacheSize);
this.anyClassCache.setMaxNCache(cacheTTL);
this.helper = this.new ServicesLookupHelper();
this.errorsTrace = new ThreadLocal<Map<String, StatusCode>>() {
@Override
protected Map<String, StatusCode> initialValue() {
return new LinkedHashMap<>();
}
};
}
示例4: doLookup
import org.xbill.DNS.Cache; //导入依赖的package包/类
private Lookup doLookup(final SimpleResolver resolver, String hostname)
throws TextParseException {
final Cache cache = new Cache();
final Lookup lookup = new Lookup(new Name(hostname), org.xbill.DNS.Type.SRV);
lookup.setResolver(resolver);
lookup.setCache(cache);
return lookup;
}
示例5: addCached
import org.xbill.DNS.Cache; //导入依赖的package包/类
private void addCached(Message msg) {
Cache cache = getCache();
if (cache != null)
cache.addMessage(msg);
}
示例6: init
import org.xbill.DNS.Cache; //导入依赖的package包/类
@PostConstruct
public void init() throws Exception {
logger.debug("DNSService init...");
// If no DNS servers were configured, default to local host
if (dnsServers.isEmpty()) {
try {
dnsServers.add(InetAddress.getLocalHost().getHostName());
} catch (UnknownHostException ue) {
dnsServers.add("127.0.0.1");
}
}
// Create the extended resolver...
final String[] serversArray = (String[]) dnsServers.toArray(new String[0]);
if (logger.isInfoEnabled()) {
for (int c = 0; c < serversArray.length; c++) {
logger.info("DNS Server is: " + serversArray[c]);
}
}
try {
resolver = new ExtendedResolver(serversArray);
} catch (UnknownHostException uhe) {
logger.error("DNS service could not be initialized. The DNS servers specified are not recognized hosts.", uhe);
throw uhe;
}
cache = new Cache(DClass.IN);
cache.setMaxEntries(maxCacheSize);
if (setAsDNSJavaDefault) {
Lookup.setDefaultResolver(resolver);
Lookup.setDefaultCache(cache, DClass.IN);
Lookup.setDefaultSearchPath(searchPaths);
logger.info("Registered cache, resolver and search paths as DNSJava defaults");
}
// Cache the local hostname and local address. This is needed because
// the following issues:
// JAMES-787
// JAMES-302
InetAddress addr = getLocalHost();
localCanonicalHostName = addr.getCanonicalHostName();
localHostName = addr.getHostName();
localAddress = addr.getHostAddress();
logger.debug("DNSService ...init end");
}
示例7: setCache
import org.xbill.DNS.Cache; //导入依赖的package包/类
public void setCache(Cache c) {
cache = c;
}