Java Code Examples for com.netflix.client.config.IClientConfig#getProperty()

The following examples show how to use com.netflix.client.config.IClientConfig#getProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProxyEndpoint.java    From zuul with Apache License 2.0 5 votes vote down vote up
@Override
public HttpResponseMessage apply(final HttpRequestMessage input) {
    // If no Origin has been selected, then just return a 404 static response.
    // handle any exception here
    try {

        if (origin == null) {
            handleNoOriginSelected();
            return null;
        }

        origin.getProxyTiming(zuulRequest).start();

        // To act the same as Ribbon, we must do this before starting execution (as well as before each attempt).
        IClientConfig requestConfig = origin.getExecutionContext(zuulRequest).getRequestConfig();
        originalReadTimeout = requestConfig.getProperty(ReadTimeout, null);
        setReadTimeoutOnContext(requestConfig, 1);

        origin.onRequestExecutionStart(zuulRequest);
        proxyRequestToOrigin();

        //Doesn't return origin response to caller, calls invokeNext() internally in response filter chain
        return null;
    } catch (Exception ex) {
        handleError(ex);
        return null;
    }
}
 
Example 2
Source File: DiscoveryServerList.java    From s2g-zuul with MIT License 4 votes vote down vote up
@Override
public void initWithNiwsConfig(IClientConfig clientConfig) {
	clientName = clientConfig.getClientName();

	isSecure = Boolean.parseBoolean("" + clientConfig.getProperty(CommonClientConfigKey.IsSecure, "false"));
	prioritizeVipAddressBasedServers = Boolean.parseBoolean("" + clientConfig
			.getProperty(CommonClientConfigKey.PrioritizeVipAddressBasedServers, prioritizeVipAddressBasedServers));
	datacenter = ConfigurationManager.getDeploymentContext().getDeploymentDatacenter();
	targetRegion = (String) clientConfig.getProperty(CommonClientConfigKey.TargetRegion);

	shouldUseIpAddr = clientConfig.getPropertyAsBoolean(CommonClientConfigKey.UseIPAddrForServer,
			DefaultClientConfigImpl.DEFAULT_USEIPADDRESS_FOR_SERVER);

	// override client configuration and use client-defined port
	if (clientConfig.getPropertyAsBoolean(CommonClientConfigKey.ForceClientPortConfiguration, false)) {

		if (isSecure) {

			if (clientConfig.containsProperty(CommonClientConfigKey.SecurePort)) {

				overridePort = clientConfig.getPropertyAsInteger(CommonClientConfigKey.SecurePort,
						DefaultClientConfigImpl.DEFAULT_PORT);
				shouldUseOverridePort = true;

			} else {
				logger.warn(clientName + " set to force client port but no secure port is set, so ignoring");
			}
		} else {

			if (clientConfig.containsProperty(CommonClientConfigKey.Port)) {

				overridePort = clientConfig.getPropertyAsInteger(CommonClientConfigKey.Port,
						DefaultClientConfigImpl.DEFAULT_PORT);
				shouldUseOverridePort = true;

			} else {
				logger.warn(clientName + " set to force client port but no port is set, so ignoring");
			}
		}
	}

}