src/main/java/com/baidu/fsg/uid/utils/DockerUtils.java
private static void retrieveFromEnv() {
        // retrieve host & port from environment
        DOCKER_HOST = System.getenv(ENV_KEY_HOST);
        DOCKER_PORT = System.getenv(ENV_KEY_PORT);

        // not found from 'JPAAS_HTTP_PORT', then try to find from 'JPAAS_HOST_PORT_8080'
        if (StringUtils.isBlank(DOCKER_PORT)) {
            DOCKER_PORT = System.getenv(ENV_KEY_PORT_ORIGINAL);
        }

        boolean hasEnvHost = StringUtils.isNotBlank(DOCKER_HOST);
        boolean hasEnvPort = StringUtils.isNotBlank(DOCKER_PORT);

        // docker can find both host & port from environment
        if (hasEnvHost && hasEnvPort) {
            IS_DOCKER = true;

            // found nothing means not a docker, maybe an actual machine
        } else if (!hasEnvHost && !hasEnvPort) {
            IS_DOCKER = false;

        } else {
            LOGGER.error("Missing host or port from env for Docker. host:{}, port:{}", DOCKER_HOST, DOCKER_PORT);
            throw new RuntimeException(
                    "Missing host or port from env for Docker. host:" + DOCKER_HOST + ", port:" + DOCKER_PORT);
        }
    }
/**
     * Retrieve host & port from environment
     */
Retrieve host & port from environment
Retrieve host & port from environment
private static void retrieveFromEnv() {
        DOCKER_HOST = System.getenv(ENV_KEY_HOST);
        DOCKER_PORT = System.getenv(ENV_KEY_PORT);
        if (StringUtils.isBlank(DOCKER_PORT)) {
            DOCKER_PORT = System.getenv(ENV_KEY_PORT_ORIGINAL);
        }
        boolean hasEnvHost = StringUtils.isNotBlank(DOCKER_HOST);
        boolean hasEnvPort = StringUtils.isNotBlank(DOCKER_PORT);
        if (hasEnvHost && hasEnvPort) {
            IS_DOCKER = true;
        } else if (!hasEnvHost && !hasEnvPort) {
            IS_DOCKER = false;
        } else {
            LOGGER.error("Missing host or port from env for Docker. host:{}, port:{}", DOCKER_HOST, DOCKER_PORT);
            throw new RuntimeException(
                    "Missing host or port from env for Docker. host:" + DOCKER_HOST + ", port:" + DOCKER_PORT);
        }
    }
private static void retrieveFromEnv ( ) { DOCKER_HOST = System . getenv ( ENV_KEY_HOST ) ; DOCKER_PORT = System . getenv ( ENV_KEY_PORT ) ; if ( StringUtils . isBlank ( DOCKER_PORT ) ) { DOCKER_PORT = System . getenv ( ENV_KEY_PORT_ORIGINAL ) ; } boolean hasEnvHost = StringUtils . isNotBlank ( DOCKER_HOST ) ; boolean hasEnvPort = StringUtils . isNotBlank ( DOCKER_PORT ) ; if ( hasEnvHost && hasEnvPort ) { IS_DOCKER = true ; } else if ( ! hasEnvHost && ! hasEnvPort ) { IS_DOCKER = false ; } else { LOGGER . error ( "Missing host or port from env for Docker. host:{}, port:{}" , DOCKER_HOST , DOCKER_PORT ) ; throw new RuntimeException ( "Missing host or port from env for Docker. host:" + DOCKER_HOST + ", port:" + DOCKER_PORT ) ; } }
Retrieve host & port from environment
Retrieve host & port from environment
// retrieve host & port from environment
 // not found from 'JPAAS_HTTP_PORT', then try to find from 'JPAAS_HOST_PORT_8080'
 // docker can find both host & port from environment
 // found nothing means not a docker, maybe an actual machine
