pl.allegro.tech.hermes.common.util.InetAddressInstanceIdResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hermes-common Show documentation
Show all versions of hermes-common Show documentation
Fast and reliable message broker built on top of Kafka.
package pl.allegro.tech.hermes.common.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.InetAddress;
import java.net.UnknownHostException;
public final class InetAddressInstanceIdResolver implements InstanceIdResolver {
private static final Logger LOGGER = LoggerFactory.getLogger(InetAddressInstanceIdResolver.class);
public InetAddressInstanceIdResolver() { }
public String resolve() {
String hostname = "hostname-could-not-be-detected";
try {
hostname = InetAddress.getLocalHost().getCanonicalHostName();
} catch (UnknownHostException e) {
LOGGER.warn("Could not determine hostname");
}
return hostname;
}
}