Java Code Examples for org.xbill.DNS.Lookup#HOST_NOT_FOUND

The following examples show how to use org.xbill.DNS.Lookup#HOST_NOT_FOUND . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XBillDnsSrvResolver.java    From dns-java with Apache License 2.0 7 votes vote down vote up
@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()));
  }
}
 
Example 2
Source File: AddressLookup.java    From mireka with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 3
Source File: MxLookupTest.java    From mireka with Apache License 2.0 5 votes vote down vote up
@Test(expected = SendException.class)
public void testHostNotFound() throws MxLookupException {
    new Expectations() {
        {
            lookup.run();
            result = null;

            lookup.getResult();
            result = Lookup.HOST_NOT_FOUND;
        }

    };

    mxLookup.queryMxTargets(EXAMPLE_COM_DOMAIN);
}