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

The following examples show how to use com.netflix.client.config.IClientConfig#getClientName() . 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: LoadBalancerStats.java    From ribbon with Apache License 2.0 6 votes vote down vote up
@Override
public void initWithNiwsConfig(IClientConfig clientConfig) {
    this.name = clientConfig.getClientName();
    Preconditions.checkArgument(name != null, "IClientConfig#getCLientName() must not be null");
    this.connectionFailureThreshold = new UnboxedIntProperty(
            clientConfig.getGlobalProperty(CONNECTION_FAILURE_COUNT_THRESHOLD.format(name))
                .fallbackWith(clientConfig.getGlobalProperty(DEFAULT_CONNECTION_FAILURE_COUNT_THRESHOLD))
    );
    this.circuitTrippedTimeoutFactor = new UnboxedIntProperty(
            clientConfig.getGlobalProperty(CIRCUIT_TRIP_TIMEOUT_FACTOR_SECONDS.format(name))
                    .fallbackWith(clientConfig.getGlobalProperty(DEFAULT_CIRCUIT_TRIP_TIMEOUT_FACTOR_SECONDS))
    );
    this.maxCircuitTrippedTimeout = new UnboxedIntProperty(
            clientConfig.getGlobalProperty(CIRCUIT_TRIP_MAX_TIMEOUT_SECONDS.format(name))
                    .fallbackWith(clientConfig.getGlobalProperty(DEFAULT_CIRCUIT_TRIP_MAX_TIMEOUT_SECONDS))
    );
    this.activeRequestsCountTimeout = new UnboxedIntProperty(
            clientConfig.getGlobalProperty(ACTIVE_REQUESTS_COUNT_TIMEOUT));
}
 
Example 2
Source File: LoadBalancerContext.java    From ribbon with Apache License 2.0 6 votes vote down vote up
/**
 * Set necessary parameters from client configuration and register with Servo monitors.
 */
@Override
public void initWithNiwsConfig(IClientConfig clientConfig) {
    if (clientConfig == null) {
        return;    
    }
    clientName = clientConfig.getClientName();
    if (StringUtils.isEmpty(clientName)) {
        clientName = "default";
    }
    vipAddresses = clientConfig.resolveDeploymentContextbasedVipAddresses();
    maxAutoRetries = clientConfig.getOrDefault(CommonClientConfigKey.MaxAutoRetries);
    maxAutoRetriesNextServer = clientConfig.getOrDefault(CommonClientConfigKey.MaxAutoRetriesNextServer);
    okToRetryOnAllOperations = clientConfig.getOrDefault(CommonClientConfigKey.OkToRetryOnAllOperations);
    defaultRetryHandler = new DefaultLoadBalancerRetryHandler(clientConfig);
    
    tracer = getExecuteTracer();

    Monitors.registerObject("Client_" + clientName, this);
}
 
Example 3
Source File: LoadBalancingRxClientWithPoolOptions.java    From ribbon with Apache License 2.0 6 votes vote down vote up
public LoadBalancingRxClientWithPoolOptions(ILoadBalancer lb, IClientConfig config,
        RetryHandler retryHandler,
        PipelineConfigurator<O, I> pipelineConfigurator, ScheduledExecutorService poolCleanerScheduler) {
    super(lb, config, retryHandler, pipelineConfigurator);
    poolEnabled = config.get(CommonClientConfigKey.EnableConnectionPool, 
            DefaultClientConfigImpl.DEFAULT_ENABLE_CONNECTION_POOL);
    if (poolEnabled) {
        this.poolCleanerScheduler = poolCleanerScheduler;
        int maxTotalConnections = config.get(IClientConfigKey.Keys.MaxTotalConnections,
                DefaultClientConfigImpl.DEFAULT_MAX_TOTAL_CONNECTIONS);
        int maxConnections = config.get(Keys.MaxConnectionsPerHost, DefaultClientConfigImpl.DEFAULT_MAX_CONNECTIONS_PER_HOST);
        MaxConnectionsBasedStrategy perHostStrategy = new DynamicPropertyBasedPoolStrategy(maxConnections,
                config.getClientName() + "." + config.getNameSpace() + "." + CommonClientConfigKey.MaxConnectionsPerHost);
        globalStrategy = new DynamicPropertyBasedPoolStrategy(maxTotalConnections, 
                config.getClientName() + "." + config.getNameSpace() + "." + CommonClientConfigKey.MaxTotalConnections);
        poolStrategy = new CompositePoolLimitDeterminationStrategy(perHostStrategy, globalStrategy);
        idleConnectionEvictionMills = config.get(Keys.ConnIdleEvictTimeMilliSeconds, DefaultClientConfigImpl.DEFAULT_CONNECTIONIDLE_TIME_IN_MSECS);
    }
}
 
Example 4
Source File: DynamicServerListLoadBalancer.java    From ribbon with Apache License 2.0 5 votes vote down vote up
@Override
public void initWithNiwsConfig(IClientConfig clientConfig, Factory factory) {
    try {
        super.initWithNiwsConfig(clientConfig, factory);
        String niwsServerListClassName = clientConfig.getOrDefault(CommonClientConfigKey.NIWSServerListClassName);

        ServerList<T> niwsServerListImpl = (ServerList<T>) factory.create(niwsServerListClassName, clientConfig);
        this.serverListImpl = niwsServerListImpl;

        if (niwsServerListImpl instanceof AbstractServerList) {
            AbstractServerListFilter<T> niwsFilter = ((AbstractServerList) niwsServerListImpl)
                    .getFilterImpl(clientConfig);
            niwsFilter.setLoadBalancerStats(getLoadBalancerStats());
            this.filter = niwsFilter;
        }

        String serverListUpdaterClassName = clientConfig.getOrDefault(
                CommonClientConfigKey.ServerListUpdaterClassName);

        this.serverListUpdater = (ServerListUpdater) factory.create(serverListUpdaterClassName, clientConfig);

        restOfInit(clientConfig);
    } catch (Exception e) {
        throw new RuntimeException(
                "Exception while initializing NIWSDiscoveryLoadBalancer:"
                        + clientConfig.getClientName()
                        + ", niwsClientConfig:" + clientConfig, e);
    }
}
 
Example 5
Source File: BaseLoadBalancer.java    From ribbon with Apache License 2.0 5 votes vote down vote up
void initWithConfig(IClientConfig clientConfig, IRule rule, IPing ping, LoadBalancerStats stats) {
    this.config = clientConfig;
    this.name = clientConfig.getClientName();
    int pingIntervalTime = clientConfig.get(CommonClientConfigKey.NFLoadBalancerPingInterval, 30);
    int maxTotalPingTime = clientConfig.get(CommonClientConfigKey.NFLoadBalancerMaxTotalPingTime, 2);

    setPingInterval(pingIntervalTime);
    setMaxTotalPingTime(maxTotalPingTime);

    // cross associate with each other
    // i.e. Rule,Ping meet your container LB
    // LB, these are your Ping and Rule guys ...
    setRule(rule);
    setPing(ping);

    setLoadBalancerStats(stats);
    rule.setLoadBalancer(this);
    if (ping instanceof AbstractLoadBalancerPing) {
        ((AbstractLoadBalancerPing) ping).setLoadBalancer(this);
    }
    logger.info("Client: {} instantiated a LoadBalancer: {}", name, this);
    boolean enablePrimeConnections = clientConfig.getOrDefault(CommonClientConfigKey.EnablePrimeConnections);

    if (enablePrimeConnections) {
        this.setEnablePrimingConnections(true);
        PrimeConnections primeConnections = new PrimeConnections(
                this.getName(), clientConfig);
        this.setPrimeConnections(primeConnections);
    }
    init();

}
 
Example 6
Source File: ServiceCombServerList.java    From spring-cloud-huawei with Apache License 2.0 4 votes vote down vote up
@Override
public void initWithNiwsConfig(IClientConfig iClientConfig) {
  this.serviceId = iClientConfig.getClientName();
}
 
Example 7
Source File: CamelCloudNetflixServerList.java    From camel-spring-boot with Apache License 2.0 4 votes vote down vote up
@Override
public void initWithNiwsConfig(IClientConfig clientConfig) {
    this.serviceId = clientConfig.getClientName();
}
 
Example 8
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");
			}
		}
	}

}
 
Example 9
Source File: NacosServerList.java    From spring-cloud-alibaba with Apache License 2.0 4 votes vote down vote up
@Override
public void initWithNiwsConfig(IClientConfig iClientConfig) {
	this.serviceId = iClientConfig.getClientName();
}
 
Example 10
Source File: KubernetesServerList.java    From spring-cloud-kubernetes with Apache License 2.0 4 votes vote down vote up
public void initWithNiwsConfig(IClientConfig clientConfig) {
    this.serviceId = clientConfig.getClientName();
    this.namespace = clientConfig.getPropertyAsString(KubernetesConfigKey.Namespace, client.getNamespace());
    this.portName = clientConfig.getPropertyAsString(KubernetesConfigKey.PortName, null);
}
 
Example 11
Source File: TopologyServerList.java    From thorntail with Apache License 2.0 4 votes vote down vote up
@Override
public void initWithNiwsConfig(IClientConfig config) {
    this.appName = config.getClientName();
    this.isSecure = config.get(IClientConfigKey.Keys.IsSecure, false);
}
 
Example 12
Source File: LatticeServerList.java    From spring-cloud-lattice with Apache License 2.0 4 votes vote down vote up
@Override
public void initWithNiwsConfig(IClientConfig clientConfig) {
	this.serviceId = clientConfig.getClientName();
}
 
Example 13
Source File: EtcdServerList.java    From spring-cloud-etcd with Apache License 2.0 4 votes vote down vote up
@Override
public void initWithNiwsConfig(IClientConfig clientConfig) {
	this.serviceId = clientConfig.getClientName();
}
 
Example 14
Source File: TopologyServerList.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 4 votes vote down vote up
@Override
public void initWithNiwsConfig(IClientConfig config) {
    this.appName = config.getClientName();
    this.isSecure = config.get(IClientConfigKey.Keys.IsSecure, false);
}