org.jgroups.ping.dns.GetServiceHosts Maven / Gradle / Ivy
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