本文整理汇总了Java中javax.jmdns.impl.constants.DNSConstants.DNS_TTL属性的典型用法代码示例。如果您正苦于以下问题:Java DNSConstants.DNS_TTL属性的具体用法?Java DNSConstants.DNS_TTL怎么用?Java DNSConstants.DNS_TTL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.jmdns.impl.constants.DNSConstants
的用法示例。
在下文中一共展示了DNSConstants.DNS_TTL属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleQuery
@Override
boolean handleQuery(JmDNSImpl dns, long expirationTime) {
ServiceInfoImpl info = (ServiceInfoImpl) dns.getServices().get(this.getKey());
if (info != null && (info.isAnnouncing() || info.isAnnounced()) && (_port != info.getPort() || !_server.equalsIgnoreCase(dns.getLocalHost().getName()))) {
logger1.finer("handleQuery() Conflicting probe detected from: " + getRecordSource());
DNSRecord.Service localService = new DNSRecord.Service(info.getQualifiedName(), DNSRecordClass.CLASS_IN, DNSRecordClass.UNIQUE, DNSConstants.DNS_TTL, info.getPriority(), info.getWeight(), info.getPort(), dns.getLocalHost().getName());
// This block is useful for debugging race conditions when jmdns is responding to itself.
try {
if (dns.getInetAddress().equals(getRecordSource())) {
logger1.warning("Got conflicting probe from ourselves\n" + "incoming: " + this.toString() + "\n" + "local : " + localService.toString());
}
} catch (IOException e) {
logger1.log(Level.WARNING, "IOException", e);
}
int comparison = this.compareTo(localService);
if (comparison == 0) {
// the 2 records are identical this probably means we are seeing our own record.
// With multiple interfaces on a single computer it is possible to see our
// own records come in on different interfaces than the ones they were sent on.
// see section "10. Conflict Resolution" of mdns draft spec.
logger1.finer("handleQuery() Ignoring a identical service query");
return false;
}
// Tie breaker test
if (info.isProbing() && comparison > 0) {
// We lost the tie break
String oldName = info.getQualifiedName().toLowerCase();
info.setName(NameRegister.Factory.getRegistry().incrementName(dns.getLocalHost().getInetAddress(), info.getName(), NameRegister.NameType.SERVICE));
dns.getServices().remove(oldName);
dns.getServices().put(info.getQualifiedName().toLowerCase(), info);
logger1.finer("handleQuery() Lost tie break: new unique name chosen:" + info.getName());
// We revert the state to start probing again with the new name
info.revertState();
} else {
// We won the tie break, so this conflicting probe should be ignored
// See paragraph 3 of section 9.2 in mdns draft spec
return false;
}
return true;
}
return false;
}
示例2: handleQuery
@Override
boolean handleQuery(JmDNSImpl dns, long expirationTime) {
ServiceInfoImpl info = (ServiceInfoImpl) dns.getServices().get(this.getKey());
if (info != null && (info.isAnnouncing() || info.isAnnounced()) && (_port != info.getPort() || !_server.equalsIgnoreCase(dns.getLocalHost().getName()))) {
logger1.finer("handleQuery() Conflicting probe detected from: " + getRecordSource());
DNSRecord.Service localService = new DNSRecord.Service(info.getQualifiedName(), DNSRecordClass.CLASS_IN, DNSRecordClass.UNIQUE, DNSConstants.DNS_TTL, info.getPriority(), info.getWeight(), info.getPort(), dns.getLocalHost().getName());
// This block is useful for debugging race conditions when jmdns is responding to itself.
try {
if (dns.getInterface().equals(getRecordSource())) {
logger1.warning("Got conflicting probe from ourselves\n" + "incoming: " + this.toString() + "\n" + "local : " + localService.toString());
}
} catch (IOException e) {
logger1.log(Level.WARNING, "IOException", e);
}
int comparison = this.compareTo(localService);
if (comparison == 0) {
// the 2 records are identical this probably means we are seeing our own record.
// With multiple interfaces on a single computer it is possible to see our
// own records come in on different interfaces than the ones they were sent on.
// see section "10. Conflict Resolution" of mdns draft spec.
logger1.finer("handleQuery() Ignoring a identical service query");
return false;
}
// Tie breaker test
if (info.isProbing() && comparison > 0) {
// We lost the tie break
String oldName = info.getQualifiedName().toLowerCase();
info.setName(dns.incrementName(info.getName()));
dns.getServices().remove(oldName);
dns.getServices().put(info.getQualifiedName().toLowerCase(), info);
logger1.finer("handleQuery() Lost tie break: new unique name chosen:" + info.getName());
// We revert the state to start probing again with the new name
info.revertState();
} else {
// We won the tie break, so this conflicting probe should be ignored
// See paragraph 3 of section 9.2 in mdns draft spec
return false;
}
return true;
}
return false;
}
示例3: handleQuery
@Override
boolean handleQuery(JmDNSImpl dns, long expirationTime)
{
ServiceInfoImpl info = (ServiceInfoImpl) dns.getServices().get(this.getKey());
if (info != null && (info.isAnnouncing() || info.isAnnounced()) && (_port != info.getPort() || !_server.equalsIgnoreCase(dns.getLocalHost().getName())))
{
logger1.finer("handleQuery() Conflicting probe detected from: " + getRecordSource());
Service localService = new Service(info.getQualifiedName(), DNSRecordClass.CLASS_IN, DNSRecordClass.UNIQUE, DNSConstants.DNS_TTL, info.getPriority(), info.getWeight(), info.getPort(), dns.getLocalHost().getName());
// This block is useful for debugging race conditions when jmdns is responding to itself.
try
{
if (dns.getInterface().equals(getRecordSource()))
{
logger1.warning("Got conflicting probe from ourselves\n" + "incoming: " + this.toString() + "\n" + "local : " + localService.toString());
}
}
catch (IOException e)
{
e.printStackTrace();
}
int comparison = this.compareTo(localService);
if (comparison == 0)
{
// the 2 records are identical this probably means we are seeing our own record.
// With multiple interfaces on a single computer it is possible to see our
// own records come in on different interfaces than the ones they were sent on.
// see section "10. Conflict Resolution" of mdns draft spec.
logger1.finer("handleQuery() Ignoring a identical service query");
return false;
}
// Tie breaker test
if (info.isProbing() && comparison > 0)
{
// We lost the tie break
String oldName = info.getQualifiedName().toLowerCase();
info.setName(dns.incrementName(info.getName()));
dns.getServices().remove(oldName);
dns.getServices().put(info.getQualifiedName().toLowerCase(), info);
logger1.finer("handleQuery() Lost tie break: new unique name chosen:" + info.getName());
// We revert the state to start probing again with the new name
info.revertState();
}
else
{
// We won the tie break, so this conflicting probe should be ignored
// See paragraph 3 of section 9.2 in mdns draft spec
return false;
}
return true;
}
return false;
}