Java Code Examples for org.xbill.DNS.SRVRecord#getPort()

The following examples show how to use org.xbill.DNS.SRVRecord#getPort() . 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: DNSServiceAddressResolver.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private String dnsSrvLookup(String query) throws ServiceAddressResolvingException {
    String result;
    try {
        Record[] records = new Lookup(query, Type.SRV).run();
        if (records != null && records.length > 0) {
            SRVRecord srv = (SRVRecord) records[0];
            result = srv.getTarget().toString().replaceFirst("\\.$", "") + ':' + srv.getPort();
        } else {
            throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved");
        }
    } catch (TextParseException e) {
        throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved", e);
    }
    return result;
}
 
Example 2
Source File: DNSServiceAddressResolver.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private String dnsSrvLookup(String query) throws ServiceAddressResolvingException {
    String result;
    try {
        Record[] records = new Lookup(query, Type.SRV).run();
        if (records != null && records.length > 0) {
            SRVRecord srv = (SRVRecord) records[0];
            result = srv.getTarget().toString().replaceFirst("\\.$", "") + ':' + srv.getPort();
        } else {
            throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved");
        }
    } catch (TextParseException e) {
        throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved", e);
    }
    return result;
}
 
Example 3
Source File: DNSServiceAddressResolver.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private String dnsSrvLookup(String query) throws ServiceAddressResolvingException {
    String result;
    try {
        Record[] records = new Lookup(query, Type.SRV).run();
        if (records != null && records.length > 0) {
            SRVRecord srv = (SRVRecord) records[0];
            result = srv.getTarget().toString().replaceFirst("\\.$", "") + ':' + srv.getPort();
        } else {
            throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved");
        }
    } catch (TextParseException e) {
        throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved", e);
    }
    return result;
}
 
Example 4
Source File: DNSServiceAddressResolver.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private String dnsSrvLookup(String query) {
    String result;
    try {
        Record[] records = new Lookup(query, Type.SRV).run();
        if (records != null && records.length > 0) {
            SRVRecord srv = (SRVRecord) records[0];
            result = srv.getTarget().toString().replaceFirst("\\.$", "") + ':' + srv.getPort();
        } else {
            throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved");
        }
    } catch (TextParseException e) {
        throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved", e);
    }
    return result;
}
 
Example 5
Source File: DNSServiceAddressResolver.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private String dnsSrvLookup(String query) throws ServiceAddressResolvingException {
    String result;
    try {
        Record[] records = new Lookup(query, Type.SRV).run();
        if (records != null && records.length > 0) {
            SRVRecord srv = (SRVRecord) records[0];
            result = srv.getTarget().toString().replaceFirst("\\.$", "") + ':' + srv.getPort();
        } else {
            throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved");
        }
    } catch (TextParseException e) {
        throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved", e);
    }
    return result;
}
 
Example 6
Source File: DNSServiceAddressResolver.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private String dnsSrvLookup(String query) throws ServiceAddressResolvingException {
    String result;
    try {
        Record[] records = new Lookup(query, Type.SRV).run();
        if (records != null && records.length > 0) {
            SRVRecord srv = (SRVRecord) records[0];
            result = srv.getTarget().toString().replaceFirst("\\.$", "") + ':' + srv.getPort();
        } else {
            throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved");
        }
    } catch (TextParseException e) {
        throw new ServiceAddressResolvingException("The Service " + query + " cannot be resolved", e);
    }
    return result;
}