public static String getIp()

in kernel/src/main/java/org/apache/shardingsphere/elasticjob/kernel/infra/env/IpUtils.java [55:71]


    public static String getIp() {
        if (null != cachedIpAddress) {
            return cachedIpAddress;
        }
        NetworkInterface networkInterface = findNetworkInterface();
        if (null != networkInterface) {
            Enumeration<InetAddress> ipAddresses = networkInterface.getInetAddresses();
            while (ipAddresses.hasMoreElements()) {
                InetAddress ipAddress = ipAddresses.nextElement();
                if (isValidAddress(ipAddress) && isPreferredAddress(ipAddress)) {
                    cachedIpAddress = ipAddress.getHostAddress();
                    return cachedIpAddress;
                }
            }
        }
        throw new HostException("ip is null");
    }