當前位置: 首頁>>代碼示例>>Java>>正文


Java Lookup.SUCCESSFUL屬性代碼示例

本文整理匯總了Java中org.xbill.DNS.Lookup.SUCCESSFUL屬性的典型用法代碼示例。如果您正苦於以下問題:Java Lookup.SUCCESSFUL屬性的具體用法?Java Lookup.SUCCESSFUL怎麽用?Java Lookup.SUCCESSFUL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.xbill.DNS.Lookup的用法示例。


在下文中一共展示了Lookup.SUCCESSFUL屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getUpdatedListOfServers

@Override
public List<ServiceCallServer> getUpdatedListOfServers(String name) {
    final Lookup lookup = lookupFactory.apply(name);
    final Record[] records = lookup.run();

    List<ServiceCallServer> servers;
    if (Objects.nonNull(records) && lookup.getResult() == Lookup.SUCCESSFUL) {
        servers = Arrays.stream(records)
            .filter(SRVRecord.class::isInstance)
            .map(SRVRecord.class::cast)
            .sorted(DnsServiceCallServer.COMPARATOR)
            .map(DnsServiceCallServer::new)
            .collect(Collectors.toList());
    } else {
        servers = Collections.emptyList();
    }

    return servers;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:19,代碼來源:DnsServiceCallServerListStrategies.java

示例2: testDnsJavaWithDnsServer

@Test
public void testDnsJavaWithDnsServer() throws TextParseException, UnknownHostException {
    final Lookup l = new Lookup("example.com", Type.AAAA);
    final SimpleResolver resolver = new SimpleResolver("::1");
    resolver.setPort(9153);
    l.setResolver(resolver);
    l.run();
    
    System.out.println("result: " + l.getResult());
    final Record[] answers = l.getAnswers();
    assertEquals(answers.length, 1);
    
    final Record record = answers[0];
    System.err.println(record.getTTL());
    
    if(l.getResult() == Lookup.SUCCESSFUL) {
        System.out.println(l.getAnswers()[0].rdataToString());
    }
    assertTrue(l.getResult() == Lookup.SUCCESSFUL);
}
 
開發者ID:qoswork,項目名稱:opennmszh,代碼行數:20,代碼來源:DnsMonitorTest.java

示例3: reverseDNSLookup

public static String reverseDNSLookup(final InetAddress adr)
{
    try
    {
        final Name name = ReverseMap.fromAddress(adr);
        
        final Lookup lookup = new Lookup(name, Type.PTR);
        lookup.setResolver(new SimpleResolver());
        lookup.setCache(null);
        final Record[] records = lookup.run();
        if (lookup.getResult() == Lookup.SUCCESSFUL)
            for (final Record record : records)
                if (record instanceof PTRRecord)
                {
                    final PTRRecord ptr = (PTRRecord) record;
                    return ptr.getTarget().toString();
                }
    }
    catch (final Exception e)
    {
    }
    return null;
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:23,代碼來源:Helperfunctions.java

示例4: resolve

@Override
public List<LookupResult> resolve(final String fqdn) {
  Lookup lookup = lookupFactory.forName(fqdn);
  Record[] queryResult = lookup.run();

  switch (lookup.getResult()) {
    case Lookup.SUCCESSFUL:
      return toLookupResults(queryResult);
    case Lookup.HOST_NOT_FOUND:
      // fallthrough
    case Lookup.TYPE_NOT_FOUND:
      LOG.warn("No results returned for query '{}'; result from XBill: {} - {}",
          fqdn, lookup.getResult(), lookup.getErrorString());
      return ImmutableList.of();
    default:
      throw new DnsException(
          String.format("Lookup of '%s' failed with code: %d - %s ",
              fqdn, lookup.getResult(), lookup.getErrorString()));
  }
}
 
開發者ID:spotify,項目名稱:dns-java,代碼行數:20,代碼來源:XBillDnsSrvResolver.java

示例5: testNoAnswer

@Test
@JUnitDNSServer(port=9153, zones={})
public void testNoAnswer() throws Exception {
    final Lookup l = new Lookup("example.com", Type.AAAA);
    final SimpleResolver resolver = new SimpleResolver("::1");
    resolver.setPort(9153);
    l.setResolver(resolver);
    l.run();
    
    System.out.println("result: " + l.getResult());
    final Record[] answers = l.getAnswers();
    assertNotNull(answers);
    assertEquals(answers.length, 1);
    
    final Record record = answers[0];
    System.err.println(record.getTTL());
    
    if(l.getResult() == Lookup.SUCCESSFUL) {
        System.out.println(l.getAnswers()[0].rdataToString());
    }
    assertTrue(l.getResult() == Lookup.SUCCESSFUL);
}
 
開發者ID:qoswork,項目名稱:opennmszh,代碼行數:22,代碼來源:DnsMonitorTest.java

示例6: testNoAnswer

@Test
@JUnitDNSServer(port=9153, zones={})
public void testNoAnswer() throws Exception {
    final Lookup l = new Lookup("example.com", Type.AAAA);
    final SimpleResolver resolver = new SimpleResolver("::1");
    resolver.setPort(9153);
    l.setResolver(resolver);
    l.run();
    
    System.out.println("result: " + l.getResult());
    final Record[] answers = l.getAnswers();
    assertEquals(answers.length, 1);
    
    final Record record = answers[0];
    System.err.println(record.getTTL());
    
    if(l.getResult() == Lookup.SUCCESSFUL) {
        System.out.println(l.getAnswers()[0].rdataToString());
    }
    assertTrue(l.getResult() == Lookup.SUCCESSFUL);
}
 
開發者ID:vishwaabhinav,項目名稱:OpenNMS,代碼行數:21,代碼來源:DnsMonitorTest.java

示例7: getASN

public static Long getASN(final InetAddress adr)
{
    try
    {
        final Name postfix;
        if (adr instanceof Inet6Address)
            postfix = Name.fromConstantString("origin6.asn.cymru.com");
        else
            postfix = Name.fromConstantString("origin.asn.cymru.com");
        
        final Name name = getReverseIPName(adr, postfix);
        System.out.println("lookup: " + name);
        
        final Lookup lookup = new Lookup(name, Type.TXT);
        lookup.setResolver(new SimpleResolver());
        lookup.setCache(null);
        final Record[] records = lookup.run();
        if (lookup.getResult() == Lookup.SUCCESSFUL)
            for (final Record record : records)
                if (record instanceof TXTRecord)
                {
                    final TXTRecord txt = (TXTRecord) record;
                    @SuppressWarnings("unchecked")
                    final List<String> strings = txt.getStrings();
                    if (strings != null && !strings.isEmpty())
                    {
                        final String result = strings.get(0);
                        final String[] parts = result.split(" ?\\| ?");
                        if (parts != null && parts.length >= 1)
                            return new Long(parts[0].split(" ")[0]);
                    }
                }
    }
    catch (final Exception e)
    {
    }
    return null;
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:38,代碼來源:Helperfunctions.java

示例8: getASName

public static String getASName(final long asn)
{
    try
    {
        final Name postfix = Name.fromConstantString("asn.cymru.com.");
        final Name name = new Name(String.format("AS%d", asn), postfix);
        System.out.println("lookup: " + name);
        
        final Lookup lookup = new Lookup(name, Type.TXT);
        lookup.setResolver(new SimpleResolver());
        lookup.setCache(null);
        final Record[] records = lookup.run();
        if (lookup.getResult() == Lookup.SUCCESSFUL)
            for (final Record record : records)
                if (record instanceof TXTRecord)
                {
                    final TXTRecord txt = (TXTRecord) record;
                    @SuppressWarnings("unchecked")
                    final List<String> strings = txt.getStrings();
                    if (strings != null && !strings.isEmpty())
                    {
                        System.out.println(strings);
                        
                        final String result = strings.get(0);
                        final String[] parts = result.split(" ?\\| ?");
                        if (parts != null && parts.length >= 1)
                            return parts[4];
                    }
                }
    }
    catch (final Exception e)
    {
    }
    return null;
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:35,代碼來源:Helperfunctions.java

示例9: getAScountry

public static String getAScountry(final long asn)
{
    try
    {
        final Name postfix = Name.fromConstantString("asn.cymru.com.");
        final Name name = new Name(String.format("AS%d", asn), postfix);
        System.out.println("lookup: " + name);
        
        final Lookup lookup = new Lookup(name, Type.TXT);
        lookup.setResolver(new SimpleResolver());
        lookup.setCache(null);
        final Record[] records = lookup.run();
        if (lookup.getResult() == Lookup.SUCCESSFUL)
            for (final Record record : records)
                if (record instanceof TXTRecord)
                {
                    final TXTRecord txt = (TXTRecord) record;
                    @SuppressWarnings("unchecked")
                    final List<String> strings = txt.getStrings();
                    if (strings != null && !strings.isEmpty())
                    {
                        final String result = strings.get(0);
                        final String[] parts = result.split(" ?\\| ?");
                        if (parts != null && parts.length >= 1)
                            return parts[1];
                    }
                }
    }
    catch (final Exception e)
    {
    }
    return null;
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:33,代碼來源:Helperfunctions.java

示例10: queryAddressRecords

private Record[] queryAddressRecords(Name name) throws SendException {
    Lookup lookup = new Lookup(name);
    Record[] records = lookup.run();
    switch (lookup.getResult()) {
    case Lookup.SUCCESSFUL:
        return records;
    case Lookup.TYPE_NOT_FOUND:
        throw new SendException("Host " + name + " has no address record ("
                + lookup.getErrorString() + ")",
                EnhancedStatus.PERMANENT_UNABLE_TO_ROUTE);
    case Lookup.HOST_NOT_FOUND:
        throw new SendException("Host " + name + " is not found ("
                + lookup.getErrorString() + ")",
                EnhancedStatus.PERMANENT_UNABLE_TO_ROUTE);
    case Lookup.TRY_AGAIN:
        throw new SendException(
                "DNS network failure while looking up address of " + name
                        + ": " + lookup.getErrorString(),
                EnhancedStatus.TRANSIENT_DIRECTORY_SERVER_FAILURE);
    case Lookup.UNRECOVERABLE:
        throw new SendException(
                "Unrecoverable DNS error while looking up address of "
                        + name + ": " + lookup.getErrorString(),
                EnhancedStatus.PERMANENT_UNABLE_TO_ROUTE);
    default:
        throw new SendException(
                "Unknown DNS status while looking up address of " + name
                        + ": " + lookup.getResult() + ". "
                        + lookup.getErrorString(),
                EnhancedStatus.PERMANENT_INTERNAL_ERROR);
    }
}
 
開發者ID:hontvari,項目名稱:mireka,代碼行數:32,代碼來源:AddressLookup.java

示例11: testDnsJavaResponse

@Test
public void testDnsJavaResponse() throws IOException {
    final Lookup l = new Lookup("example.com");
    final SimpleResolver resolver = new SimpleResolver("127.0.0.1");
    resolver.setPort(9153);
    l.setResolver(resolver);
    l.run();
    
    System.out.println("result: " + l.getResult());
    if(l.getResult() == Lookup.SUCCESSFUL) {
        System.out.println(l.getAnswers()[0].rdataToString());
    }
    assertTrue(l.getResult() == Lookup.SUCCESSFUL);
}
 
開發者ID:qoswork,項目名稱:opennmszh,代碼行數:14,代碼來源:DnsMonitorTest.java

示例12: testDnsJavaQuadARecord

@Test
public void testDnsJavaQuadARecord() throws IOException {
    final Lookup l = new Lookup("ipv6.example.com", Type.AAAA);
    final SimpleResolver resolver = new SimpleResolver("::1");
    resolver.setPort(9153);
    l.setResolver(resolver);
    l.run();
    
    System.out.println("result: " + l.getResult());
    if(l.getResult() == Lookup.SUCCESSFUL) {
        System.out.println(l.getAnswers()[0].rdataToString());
    }
    assertTrue(l.getResult() == Lookup.SUCCESSFUL);
}
 
開發者ID:qoswork,項目名稱:opennmszh,代碼行數:14,代碼來源:DnsMonitorTest.java


注:本文中的org.xbill.DNS.Lookup.SUCCESSFUL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。