public static int getPort(String portString) {
    if (StringUtils.isEmpty(portString)) {
      throw new IllegalArgumentException("port is null or empty");
    }

    int port = Integer.parseInt(portString);
    validatePort(port);
    return port;
  }
Returns an integer representation of the port number.
Also validates whether the given string represents a valid port number.
A valid port number is an integer between 0 and 65535 inclusive.

@param portString The string representing the port number.
@return {@code int} the port number.
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/common/IPStackUtils.java