All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jgroups.ping.dns.GetServiceHosts Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.jgroups.ping.dns;

import java.net.InetAddress;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.Callable;

public class GetServiceHosts implements Callable> {

    private final String _serviceName;

    public GetServiceHosts(String serviceName) {
        _serviceName = serviceName;
    }

    @Override
    public Set call() throws Exception {
        Set serviceHosts = null;
        InetAddress[] inetAddresses = InetAddress.getAllByName(_serviceName);
        for (InetAddress inetAddress : inetAddresses) {
            if (serviceHosts == null) {
                serviceHosts = new LinkedHashSet();
            }
            serviceHosts.add(inetAddress.getHostAddress());
        }
        return serviceHosts;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy