public class DefaultClientConfigImpl extends java.lang.Object implements IClientConfig
The easiest way to configure client and load balancer is through loading properties into Archaius that conform to the specific format:
<clientName>.<nameSpace>.<propertyName>=<value>
You can define properties in a file on classpath or as system properties. If former, ConfigurationManager.loadPropertiesFromResources() API should be called to load the file.
By default, "ribbon" should be the nameSpace.
If there is no property specified for a named client, com.netflix.client.ClientFactory will still create the client and
load balancer with default values for all necessary properties. The default
values are specified in this class as constants.
If a property is missing the clientName, it is interpreted as a property that applies to all clients. For example
ribbon.ReadTimeout=1000
This will establish the default ReadTimeout property for all clients.
You can also programmatically set properties by constructing instance of DefaultClientConfigImpl. Follow these steps:
getClientConfigWithDefaultValues(String) to load default values,
and any properties that are already defined with Configuration in Archaius
setProperty(IClientConfigKey, Object) API.
com.netflix.client.ClientFactory API.
If it is desired to have properties defined in a different name space, for example, "foo"
myclient.foo.ReadTimeout=1000
You should use getClientConfigWithDefaultValues(String, String) - in the first step above.IClientConfig.Builder| Constructor and Description |
|---|
DefaultClientConfigImpl()
Create instance with no properties in default name space
DEFAULT_PROPERTY_NAME_SPACE |
DefaultClientConfigImpl(java.lang.String nameSpace)
Create instance with no properties in the specified name space
|
| Modifier and Type | Method and Description |
|---|---|
IClientConfig |
applyOverride(IClientConfig override) |
boolean |
containsProperty(IClientConfigKey key) |
<T> T |
get(IClientConfigKey<T> key)
Returns a typed property.
|
<T> T |
get(IClientConfigKey<T> key,
T defaultValue)
Returns a typed property.
|
java.lang.String |
getAppName() |
static DefaultClientConfigImpl |
getClientConfigWithDefaultValues() |
static DefaultClientConfigImpl |
getClientConfigWithDefaultValues(java.lang.String clientName) |
static DefaultClientConfigImpl |
getClientConfigWithDefaultValues(java.lang.String clientName,
java.lang.String nameSpace) |
java.lang.String |
getClientName() |
java.lang.String |
getDefaultClientClassname() |
int |
getDefaultConnectionidleTimeInMsecs() |
int |
getDefaultConnectionIdleTimertaskRepeatInMsecs() |
int |
getDefaultConnectionManagerTimeout() |
java.lang.Boolean |
getDefaultConnectionPoolCleanerTaskEnabled() |
int |
getDefaultConnectTimeout() |
java.lang.Boolean |
getDefaultEnableConnectionPool() |
java.lang.Boolean |
getDefaultEnableGzipContentEncodingFilter() |
java.lang.Boolean |
getDefaultEnableLoadbalancer() |
java.lang.Boolean |
getDefaultEnablePrimeConnections() |
java.lang.Boolean |
getDefaultEnableRequestThrottling() |
java.lang.Boolean |
getDefaultEnableZoneAffinity() |
java.lang.Boolean |
getDefaultEnableZoneExclusivity() |
java.lang.Boolean |
getDefaultFollowRedirects() |
java.lang.Boolean |
getDefaultIsClientAuthRequired() |
int |
getDefaultMaxAutoRetries() |
int |
getDefaultMaxAutoRetriesNextServer() |
int |
getDefaultMaxConnectionsPerHost() |
int |
getDefaultMaxHttpConnectionsPerHost()
Deprecated.
|
int |
getDefaultMaxRequestsAllowedPerWindow() |
int |
getDefaultMaxRetriesPerServerPrimeConnection() |
int |
getDefaultMaxTotalConnections() |
int |
getDefaultMaxTotalHttpConnections()
Deprecated.
|
int |
getDefaultMaxTotalTimeToPrimeConnections() |
float |
getDefaultMinPrimeConnectionsRatio() |
java.lang.String |
getDefaultNfloadbalancerClassname() |
java.lang.String |
getDefaultNfloadbalancerPingClassname() |
java.lang.String |
getDefaultNfloadbalancerRuleClassname() |
java.lang.Boolean |
getDefaultOkToRetryOnAllOperations() |
float |
getDefaultPercentageNiwsEventLogged() |
long |
getDefaultPoolKeepAliveTime() |
java.util.concurrent.TimeUnit |
getDefaultPoolKeepAliveTimeUnits() |
int |
getDefaultPoolMaxThreads() |
int |
getDefaultPoolMinThreads() |
int |
getDefaultPort() |
java.lang.String |
getDefaultPrimeConnectionsClass() |
java.lang.String |
getDefaultPrimeConnectionsUri() |
java.lang.Boolean |
getDefaultPrioritizeVipAddressBasedServers() |
java.lang.String |
getDefaultPropName(IClientConfigKey propName) |
int |
getDefaultReadTimeout() |
int |
getDefaultRequestThrottlingWindowInMillis() |
java.lang.String |
getDefaultSeverListClass() |
boolean |
getDefaultUseIpAddressForServer() |
java.lang.String |
getDefaultVipaddressResolverClassname() |
static DefaultClientConfigImpl |
getEmptyConfig() |
java.lang.String |
getInstancePropName(java.lang.String restClientName,
IClientConfigKey configKey) |
java.lang.String |
getInstancePropName(java.lang.String restClientName,
java.lang.String key) |
java.lang.String |
getNameSpace() |
java.util.Map<java.lang.String,java.lang.Object> |
getProperties() |
java.lang.Object |
getProperty(IClientConfigKey key) |
java.lang.Object |
getProperty(IClientConfigKey key,
java.lang.Object defaultVal) |
static java.lang.Object |
getProperty(java.util.Map<java.lang.String,java.lang.Object> config,
IClientConfigKey key) |
static java.lang.Object |
getProperty(java.util.Map<java.lang.String,java.lang.Object> config,
IClientConfigKey key,
java.lang.Object defaultVal) |
protected java.lang.Object |
getProperty(java.lang.String key) |
boolean |
getPropertyAsBoolean(IClientConfigKey key,
boolean defaultValue) |
int |
getPropertyAsInteger(IClientConfigKey key,
int defaultValue) |
java.lang.String |
getPropertyAsString(IClientConfigKey key,
java.lang.String defaultValue) |
VipAddressResolver |
getResolver() |
protected static java.lang.String |
getStringValue(org.apache.commons.configuration.Configuration config,
java.lang.String key)
This is to workaround the issue that
AbstractConfiguration by default
automatically convert comma delimited string to array |
java.lang.String |
getVersion() |
boolean |
isEnableDynamicProperties() |
boolean |
isSecure() |
void |
loadDefaultValues()
load default values for this configuration
|
void |
loadProperties(java.lang.String restClientName)
Load properties for a given client.
|
protected void |
putDefaultBooleanProperty(IClientConfigKey propName,
java.lang.Boolean defaultValue) |
protected void |
putDefaultFloatProperty(IClientConfigKey propName,
java.lang.Float defaultValue) |
protected void |
putDefaultIntegerProperty(IClientConfigKey propName,
java.lang.Integer defaultValue) |
protected void |
putDefaultLongProperty(IClientConfigKey propName,
java.lang.Long defaultValue) |
protected void |
putDefaultStringProperty(IClientConfigKey propName,
java.lang.String defaultValue) |
protected void |
putDefaultTimeUnitProperty(IClientConfigKey propName,
java.util.concurrent.TimeUnit defaultValue) |
java.lang.String |
resolveDeploymentContextbasedVipAddresses()
Returns the applicable virtual addresses ("vip") used by this client configuration.
|
<T> DefaultClientConfigImpl |
set(IClientConfigKey<T> key,
T value)
Set the typed property with the given value.
|
void |
setClientName(java.lang.String clientName) |
void |
setProperty(IClientConfigKey key,
java.lang.Object value) |
void |
setProperty(java.util.Properties props,
java.lang.String restClientName,
java.lang.String key,
java.lang.String value) |
protected void |
setPropertyInternal(IClientConfigKey propName,
java.lang.Object value) |
protected void |
setPropertyInternal(java.lang.String propName,
java.lang.Object value) |
java.lang.String |
toString() |
DefaultClientConfigImpl |
withProperty(IClientConfigKey key,
java.lang.Object value) |
public static final java.lang.Boolean DEFAULT_PRIORITIZE_VIP_ADDRESS_BASED_SERVERS
public static final java.lang.String DEFAULT_NFLOADBALANCER_PING_CLASSNAME
public static final java.lang.String DEFAULT_NFLOADBALANCER_RULE_CLASSNAME
public static final java.lang.String DEFAULT_NFLOADBALANCER_CLASSNAME
public static final boolean DEFAULT_USEIPADDRESS_FOR_SERVER
public static final java.lang.String DEFAULT_CLIENT_CLASSNAME
public static final java.lang.String DEFAULT_VIPADDRESS_RESOLVER_CLASSNAME
public static final java.lang.String DEFAULT_PRIME_CONNECTIONS_URI
public static final int DEFAULT_MAX_TOTAL_TIME_TO_PRIME_CONNECTIONS
public static final int DEFAULT_MAX_RETRIES_PER_SERVER_PRIME_CONNECTION
public static final java.lang.Boolean DEFAULT_ENABLE_PRIME_CONNECTIONS
public static final int DEFAULT_MAX_REQUESTS_ALLOWED_PER_WINDOW
public static final int DEFAULT_REQUEST_THROTTLING_WINDOW_IN_MILLIS
public static final java.lang.Boolean DEFAULT_ENABLE_REQUEST_THROTTLING
public static final java.lang.Boolean DEFAULT_ENABLE_GZIP_CONTENT_ENCODING_FILTER
public static final java.lang.Boolean DEFAULT_CONNECTION_POOL_CLEANER_TASK_ENABLED
public static final java.lang.Boolean DEFAULT_FOLLOW_REDIRECTS
public static final float DEFAULT_PERCENTAGE_NIWS_EVENT_LOGGED
public static final int DEFAULT_MAX_AUTO_RETRIES_NEXT_SERVER
public static final int DEFAULT_MAX_AUTO_RETRIES
public static final int DEFAULT_BACKOFF_INTERVAL
public static final int DEFAULT_READ_TIMEOUT
public static final int DEFAULT_CONNECTION_MANAGER_TIMEOUT
public static final int DEFAULT_CONNECT_TIMEOUT
public static final java.lang.Boolean DEFAULT_ENABLE_CONNECTION_POOL
@Deprecated public static final int DEFAULT_MAX_HTTP_CONNECTIONS_PER_HOST
@Deprecated public static final int DEFAULT_MAX_TOTAL_HTTP_CONNECTIONS
public static final int DEFAULT_MAX_CONNECTIONS_PER_HOST
public static final int DEFAULT_MAX_TOTAL_CONNECTIONS
public static final float DEFAULT_MIN_PRIME_CONNECTIONS_RATIO
public static final java.lang.String DEFAULT_PRIME_CONNECTIONS_CLASS
public static final java.lang.String DEFAULT_SEVER_LIST_CLASS
public static final java.lang.String DEFAULT_SERVER_LIST_UPDATER_CLASS
public static final int DEFAULT_CONNECTION_IDLE_TIMERTASK_REPEAT_IN_MSECS
public static final int DEFAULT_CONNECTIONIDLE_TIME_IN_MSECS
protected volatile java.util.Map<java.lang.String,java.lang.Object> properties
protected java.util.Map<IClientConfigKey<?>,java.lang.Object> typedProperties
public static final int DEFAULT_POOL_MAX_THREADS
public static final int DEFAULT_POOL_MIN_THREADS
public static final long DEFAULT_POOL_KEEP_ALIVE_TIME
public static final java.util.concurrent.TimeUnit DEFAULT_POOL_KEEP_ALIVE_TIME_UNITS
public static final java.lang.Boolean DEFAULT_ENABLE_ZONE_AFFINITY
public static final java.lang.Boolean DEFAULT_ENABLE_ZONE_EXCLUSIVITY
public static final int DEFAULT_PORT
public static final java.lang.Boolean DEFAULT_ENABLE_LOADBALANCER
public static final java.lang.String DEFAULT_PROPERTY_NAME_SPACE
public static final java.lang.Boolean DEFAULT_OK_TO_RETRY_ON_ALL_OPERATIONS
public static final java.lang.Boolean DEFAULT_ENABLE_NIWS_EVENT_LOGGING
public static final java.lang.Boolean DEFAULT_IS_CLIENT_AUTH_REQUIRED
public DefaultClientConfigImpl()
DEFAULT_PROPERTY_NAME_SPACEpublic DefaultClientConfigImpl(java.lang.String nameSpace)
public java.lang.Boolean getDefaultPrioritizeVipAddressBasedServers()
public java.lang.String getDefaultNfloadbalancerPingClassname()
public java.lang.String getDefaultNfloadbalancerRuleClassname()
public java.lang.String getDefaultNfloadbalancerClassname()
public boolean getDefaultUseIpAddressForServer()
public java.lang.String getDefaultClientClassname()
public java.lang.String getDefaultVipaddressResolverClassname()
public java.lang.String getDefaultPrimeConnectionsUri()
public int getDefaultMaxTotalTimeToPrimeConnections()
public int getDefaultMaxRetriesPerServerPrimeConnection()
public java.lang.Boolean getDefaultEnablePrimeConnections()
public int getDefaultMaxRequestsAllowedPerWindow()
public int getDefaultRequestThrottlingWindowInMillis()
public java.lang.Boolean getDefaultEnableRequestThrottling()
public java.lang.Boolean getDefaultEnableGzipContentEncodingFilter()
public java.lang.Boolean getDefaultConnectionPoolCleanerTaskEnabled()
public java.lang.Boolean getDefaultFollowRedirects()
public float getDefaultPercentageNiwsEventLogged()
public int getDefaultMaxAutoRetriesNextServer()
public int getDefaultMaxAutoRetries()
public int getDefaultReadTimeout()
public int getDefaultConnectionManagerTimeout()
public int getDefaultConnectTimeout()
@Deprecated public int getDefaultMaxHttpConnectionsPerHost()
@Deprecated public int getDefaultMaxTotalHttpConnections()
public int getDefaultMaxConnectionsPerHost()
public int getDefaultMaxTotalConnections()
public float getDefaultMinPrimeConnectionsRatio()
public java.lang.String getDefaultPrimeConnectionsClass()
public java.lang.String getDefaultSeverListClass()
public int getDefaultConnectionIdleTimertaskRepeatInMsecs()
public int getDefaultConnectionidleTimeInMsecs()
public VipAddressResolver getResolver()
public boolean isEnableDynamicProperties()
public int getDefaultPoolMaxThreads()
public int getDefaultPoolMinThreads()
public long getDefaultPoolKeepAliveTime()
public java.util.concurrent.TimeUnit getDefaultPoolKeepAliveTimeUnits()
public java.lang.Boolean getDefaultEnableZoneAffinity()
public java.lang.Boolean getDefaultEnableZoneExclusivity()
public int getDefaultPort()
public java.lang.Boolean getDefaultEnableLoadbalancer()
public java.lang.Boolean getDefaultOkToRetryOnAllOperations()
public java.lang.Boolean getDefaultIsClientAuthRequired()
public void loadDefaultValues()
IClientConfigloadDefaultValues in interface IClientConfigpublic java.lang.Boolean getDefaultEnableConnectionPool()
protected void setPropertyInternal(IClientConfigKey propName, java.lang.Object value)
protected void setPropertyInternal(java.lang.String propName,
java.lang.Object value)
protected void putDefaultIntegerProperty(IClientConfigKey propName, java.lang.Integer defaultValue)
protected void putDefaultLongProperty(IClientConfigKey propName, java.lang.Long defaultValue)
protected void putDefaultFloatProperty(IClientConfigKey propName, java.lang.Float defaultValue)
protected void putDefaultTimeUnitProperty(IClientConfigKey propName, java.util.concurrent.TimeUnit defaultValue)
public java.lang.String getDefaultPropName(IClientConfigKey propName)
protected void putDefaultStringProperty(IClientConfigKey propName, java.lang.String defaultValue)
protected void putDefaultBooleanProperty(IClientConfigKey propName, java.lang.Boolean defaultValue)
public void setClientName(java.lang.String clientName)
public java.lang.String getClientName()
getClientName in interface IClientConfigpublic void loadProperties(java.lang.String restClientName)
loadProperties in interface IClientConfigprotected static java.lang.String getStringValue(org.apache.commons.configuration.Configuration config,
java.lang.String key)
AbstractConfiguration by default
automatically convert comma delimited string to arraypublic java.lang.String resolveDeploymentContextbasedVipAddresses()
IClientConfigresolveDeploymentContextbasedVipAddresses in interface IClientConfigpublic java.lang.String getAppName()
public java.lang.String getVersion()
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
getProperties in interface IClientConfigpublic void setProperty(IClientConfigKey key, java.lang.Object value)
setProperty in interface IClientConfigpublic DefaultClientConfigImpl withProperty(IClientConfigKey key, java.lang.Object value)
public IClientConfig applyOverride(IClientConfig override)
protected java.lang.Object getProperty(java.lang.String key)
public java.lang.Object getProperty(IClientConfigKey key)
getProperty in interface IClientConfigpublic java.lang.Object getProperty(IClientConfigKey key, java.lang.Object defaultVal)
getProperty in interface IClientConfigpublic static java.lang.Object getProperty(java.util.Map<java.lang.String,java.lang.Object> config,
IClientConfigKey key,
java.lang.Object defaultVal)
public static java.lang.Object getProperty(java.util.Map<java.lang.String,java.lang.Object> config,
IClientConfigKey key)
public boolean isSecure()
public boolean containsProperty(IClientConfigKey key)
containsProperty in interface IClientConfigpublic java.lang.String toString()
toString in class java.lang.Objectpublic void setProperty(java.util.Properties props,
java.lang.String restClientName,
java.lang.String key,
java.lang.String value)
public java.lang.String getInstancePropName(java.lang.String restClientName,
IClientConfigKey configKey)
public java.lang.String getInstancePropName(java.lang.String restClientName,
java.lang.String key)
public java.lang.String getNameSpace()
getNameSpace in interface IClientConfigpublic static DefaultClientConfigImpl getEmptyConfig()
public static DefaultClientConfigImpl getClientConfigWithDefaultValues(java.lang.String clientName)
public static DefaultClientConfigImpl getClientConfigWithDefaultValues()
public static DefaultClientConfigImpl getClientConfigWithDefaultValues(java.lang.String clientName, java.lang.String nameSpace)
public int getPropertyAsInteger(IClientConfigKey key, int defaultValue)
getPropertyAsInteger in interface IClientConfigpublic java.lang.String getPropertyAsString(IClientConfigKey key, java.lang.String defaultValue)
getPropertyAsString in interface IClientConfigpublic boolean getPropertyAsBoolean(IClientConfigKey key, boolean defaultValue)
getPropertyAsBoolean in interface IClientConfigpublic <T> T get(IClientConfigKey<T> key)
IClientConfig
For DefaultClientConfigImpl, if the value of the property is String,
it will do basic type conversion from String to the following type:
get in interface IClientConfigpublic <T> DefaultClientConfigImpl set(IClientConfigKey<T> key, T value)
IClientConfigset in interface IClientConfigpublic <T> T get(IClientConfigKey<T> key, T defaultValue)
IClientConfigget in interface IClientConfig