Example #1
0
    /**
     * Sets the absolute health check {@link URL} for this instance for both secure and non-secure
     * communication The users can provide the <code>healthCheckUrlPath</code> if the healthcheck
     * page resides in the same instance talking to discovery, else in the cases where the instance
     * is a proxy for some other server, it can provide the full {@link URL}. If the full {@link
     * URL} is provided it takes precedence.
     *
     * <p>The full {@link URL} should follow the format
     * http://${netflix.appinfo.hostname}:7001/healthcheck where the value
     * ${netflix.appinfo.hostname} is replaced at runtime.
     *
     * @param relativeUrl - The {@link URL} path for healthcheck page for this instance.
     * @param explicitUrl - The full {@link URL} for the healthcheck page.
     * @param secureExplicitUrl the full secure explicit url of the healthcheck page.
     * @return the instance builder
     */
    public Builder setHealthCheckUrls(
        String relativeUrl, String explicitUrl, String secureExplicitUrl) {
      String hostNameInterpolationExpression = "${" + namespace + "hostname}";
      result.healthCheckRelativeUrl = relativeUrl;
      result.healthCheckExplicitUrl = explicitUrl;
      result.healthCheckSecureExplicitUrl = secureExplicitUrl;
      if (explicitUrl != null) {
        result.healthCheckUrl =
            explicitUrl.replace(hostNameInterpolationExpression, result.hostName);
      } else if (result.isUnsecurePortEnabled) {
        result.healthCheckUrl = HTTP_PROTOCOL + result.hostName + COLON + result.port + relativeUrl;
      }

      if (secureExplicitUrl != null) {
        result.secureHealthCheckUrl =
            secureExplicitUrl.replace(hostNameInterpolationExpression, result.hostName);
      } else if (result.isSecurePortEnabled) {
        result.secureHealthCheckUrl =
            HTTPS_PROTOCOL + result.hostName + COLON + result.securePort + relativeUrl;
      }
      return this;
    }