当前位置: 首页>>代码示例>>Java>>正文


Java DNSConstants.DNS_TTL属性代码示例

本文整理汇总了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;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:49,代码来源:DNSRecord.java

示例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;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:49,代码来源:DNSRecord.java

示例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;
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:59,代码来源:DNSRecord.java


注:本文中的javax.jmdns.impl.constants.DNSConstants.DNS_TTL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。