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

pl.allegro.tech.hermes.common.util.InetAddressInstanceIdResolver Maven / Gradle / Ivy

There is a newer version: 2.6.21
Show newest version
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;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy