com.netflix.client.config.CommonClientConfigKey Maven / Gradle / Ivy
/*
*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.netflix.client.config;
import com.google.common.reflect.TypeToken;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.Set;
import static com.google.common.base.Preconditions.checkArgument;
public abstract class CommonClientConfigKey implements IClientConfigKey {
public static final IClientConfigKey AppName = new CommonClientConfigKey("AppName"){};
public static final IClientConfigKey Version = new CommonClientConfigKey("Version"){};
public static final IClientConfigKey Port = new CommonClientConfigKey("Port"){};
public static final IClientConfigKey SecurePort = new CommonClientConfigKey("SecurePort"){};
public static final IClientConfigKey VipAddress = new CommonClientConfigKey("VipAddress"){};
public static final IClientConfigKey ForceClientPortConfiguration = new CommonClientConfigKey("ForceClientPortConfiguration"){}; // use client defined port regardless of server advert
public static final IClientConfigKey DeploymentContextBasedVipAddresses = new CommonClientConfigKey("DeploymentContextBasedVipAddresses"){};
public static final IClientConfigKey MaxAutoRetries = new CommonClientConfigKey("MaxAutoRetries"){};
public static final IClientConfigKey MaxAutoRetriesNextServer = new CommonClientConfigKey("MaxAutoRetriesNextServer"){};
public static final IClientConfigKey OkToRetryOnAllOperations = new CommonClientConfigKey("OkToRetryOnAllOperations"){};
public static final IClientConfigKey RequestSpecificRetryOn = new CommonClientConfigKey("RequestSpecificRetryOn"){};
public static final IClientConfigKey ReceiveBufferSize = new CommonClientConfigKey("ReceiveBufferSize"){};
public static final IClientConfigKey EnablePrimeConnections = new CommonClientConfigKey("EnablePrimeConnections"){};
public static final IClientConfigKey PrimeConnectionsClassName = new CommonClientConfigKey("PrimeConnectionsClassName"){};
public static final IClientConfigKey MaxRetriesPerServerPrimeConnection = new CommonClientConfigKey("MaxRetriesPerServerPrimeConnection"){};
public static final IClientConfigKey MaxTotalTimeToPrimeConnections = new CommonClientConfigKey("MaxTotalTimeToPrimeConnections"){};
public static final IClientConfigKey MinPrimeConnectionsRatio = new CommonClientConfigKey("MinPrimeConnectionsRatio"){};
public static final IClientConfigKey PrimeConnectionsURI = new CommonClientConfigKey("PrimeConnectionsURI"){};
public static final IClientConfigKey PoolMaxThreads = new CommonClientConfigKey("PoolMaxThreads"){};
public static final IClientConfigKey PoolMinThreads = new CommonClientConfigKey("PoolMinThreads"){};
public static final IClientConfigKey PoolKeepAliveTime = new CommonClientConfigKey("PoolKeepAliveTime"){};
public static final IClientConfigKey PoolKeepAliveTimeUnits = new CommonClientConfigKey("PoolKeepAliveTimeUnits"){};
public static final IClientConfigKey EnableConnectionPool = new CommonClientConfigKey("EnableConnectionPool") {};
/**
* Use {@link #MaxConnectionsPerHost}
*/
@Deprecated
public static final IClientConfigKey MaxHttpConnectionsPerHost = new CommonClientConfigKey("MaxHttpConnectionsPerHost"){};
/**
* Use {@link #MaxTotalConnections}
*/
@Deprecated
public static final IClientConfigKey MaxTotalHttpConnections = new CommonClientConfigKey("MaxTotalHttpConnections"){};
public static final IClientConfigKey MaxConnectionsPerHost = new CommonClientConfigKey("MaxConnectionsPerHost"){};
public static final IClientConfigKey MaxTotalConnections = new CommonClientConfigKey("MaxTotalConnections"){};
public static final IClientConfigKey IsSecure = new CommonClientConfigKey("IsSecure"){};
public static final IClientConfigKey GZipPayload = new CommonClientConfigKey("GZipPayload"){};
public static final IClientConfigKey ConnectTimeout = new CommonClientConfigKey("ConnectTimeout"){};
public static final IClientConfigKey BackoffInterval = new CommonClientConfigKey("BackoffTimeout"){};
public static final IClientConfigKey ReadTimeout = new CommonClientConfigKey("ReadTimeout"){};
public static final IClientConfigKey SendBufferSize = new CommonClientConfigKey("SendBufferSize"){};
public static final IClientConfigKey StaleCheckingEnabled = new CommonClientConfigKey("StaleCheckingEnabled"){};
public static final IClientConfigKey Linger = new CommonClientConfigKey("Linger"){};
public static final IClientConfigKey ConnectionManagerTimeout = new CommonClientConfigKey("ConnectionManagerTimeout"){};
public static final IClientConfigKey FollowRedirects = new CommonClientConfigKey("FollowRedirects"){};
public static final IClientConfigKey ConnectionPoolCleanerTaskEnabled = new CommonClientConfigKey("ConnectionPoolCleanerTaskEnabled"){};
public static final IClientConfigKey ConnIdleEvictTimeMilliSeconds = new CommonClientConfigKey("ConnIdleEvictTimeMilliSeconds"){};
public static final IClientConfigKey ConnectionCleanerRepeatInterval = new CommonClientConfigKey("ConnectionCleanerRepeatInterval"){};
public static final IClientConfigKey EnableGZIPContentEncodingFilter = new CommonClientConfigKey("EnableGZIPContentEncodingFilter"){};
public static final IClientConfigKey ProxyHost = new CommonClientConfigKey("ProxyHost"){};
public static final IClientConfigKey ProxyPort = new CommonClientConfigKey("ProxyPort"){};
public static final IClientConfigKey KeyStore = new CommonClientConfigKey("KeyStore"){};
public static final IClientConfigKey KeyStorePassword = new CommonClientConfigKey("KeyStorePassword"){};
public static final IClientConfigKey TrustStore = new CommonClientConfigKey("TrustStore"){};
public static final IClientConfigKey TrustStorePassword = new CommonClientConfigKey("TrustStorePassword"){};
// if this is a secure rest client, must we use client auth too?
public static final IClientConfigKey IsClientAuthRequired = new CommonClientConfigKey("IsClientAuthRequired"){};
public static final IClientConfigKey CustomSSLSocketFactoryClassName = new CommonClientConfigKey("CustomSSLSocketFactoryClassName"){};
// must host name match name in certificate?
public static final IClientConfigKey IsHostnameValidationRequired = new CommonClientConfigKey("IsHostnameValidationRequired"){};
// see also http://hc.apache.org/httpcomponents-client-ga/tutorial/html/advanced.html
public static final IClientConfigKey IgnoreUserTokenInConnectionPoolForSecureClient = new CommonClientConfigKey("IgnoreUserTokenInConnectionPoolForSecureClient"){};
// Client implementation
public static final IClientConfigKey ClientClassName = new CommonClientConfigKey("ClientClassName"){};
//LoadBalancer Related
public static final IClientConfigKey InitializeNFLoadBalancer = new CommonClientConfigKey("InitializeNFLoadBalancer"){};
public static final IClientConfigKey NFLoadBalancerClassName = new CommonClientConfigKey("NFLoadBalancerClassName"){};
public static final IClientConfigKey NFLoadBalancerRuleClassName = new CommonClientConfigKey("NFLoadBalancerRuleClassName"){};
public static final IClientConfigKey NFLoadBalancerPingClassName = new CommonClientConfigKey("NFLoadBalancerPingClassName"){};
public static final IClientConfigKey NFLoadBalancerPingInterval = new CommonClientConfigKey("NFLoadBalancerPingInterval"){};
public static final IClientConfigKey NFLoadBalancerMaxTotalPingTime = new CommonClientConfigKey("NFLoadBalancerMaxTotalPingTime"){};
public static final IClientConfigKey NIWSServerListClassName = new CommonClientConfigKey("NIWSServerListClassName"){};
public static final IClientConfigKey ServerListUpdaterClassName = new CommonClientConfigKey("ServerListUpdaterClassName"){};
public static final IClientConfigKey NIWSServerListFilterClassName = new CommonClientConfigKey("NIWSServerListFilterClassName"){};
public static final IClientConfigKey ServerListRefreshInterval = new CommonClientConfigKey("ServerListRefreshInterval"){};
public static final IClientConfigKey EnableMarkingServerDownOnReachingFailureLimit = new CommonClientConfigKey("EnableMarkingServerDownOnReachingFailureLimit"){};
public static final IClientConfigKey ServerDownFailureLimit = new CommonClientConfigKey("ServerDownFailureLimit"){};
public static final IClientConfigKey ServerDownStatWindowInMillis = new CommonClientConfigKey("ServerDownStatWindowInMillis"){};
public static final IClientConfigKey EnableZoneAffinity = new CommonClientConfigKey("EnableZoneAffinity"){};
public static final IClientConfigKey EnableZoneExclusivity = new CommonClientConfigKey("EnableZoneExclusivity"){};
public static final IClientConfigKey PrioritizeVipAddressBasedServers = new CommonClientConfigKey("PrioritizeVipAddressBasedServers"){};
public static final IClientConfigKey VipAddressResolverClassName = new CommonClientConfigKey("VipAddressResolverClassName"){};
public static final IClientConfigKey TargetRegion = new CommonClientConfigKey("TargetRegion"){};
public static final IClientConfigKey RulePredicateClasses = new CommonClientConfigKey("RulePredicateClasses"){};
public static final IClientConfigKey RequestIdHeaderName = new CommonClientConfigKey("RequestIdHeaderName") {};
public static final IClientConfigKey UseIPAddrForServer = new CommonClientConfigKey("UseIPAddrForServer") {};
public static final IClientConfigKey ListOfServers = new CommonClientConfigKey("listOfServers") {};
private static final Set keys = new HashSet();
static {
for (Field f: CommonClientConfigKey.class.getDeclaredFields()) {
if (Modifier.isStatic(f.getModifiers()) //&& Modifier.isPublic(f.getModifiers())
&& IClientConfigKey.class.isAssignableFrom(f.getType())) {
try {
keys.add((IClientConfigKey) f.get(null));
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
}
/**
* @deprecated see {@link #keys()}
*/
@edu.umd.cs.findbugs.annotations.SuppressWarnings
@Deprecated
public static IClientConfigKey[] values() {
return keys().toArray(new IClientConfigKey[0]);
}
/**
* return all the public static keys defined in this class
*/
public static Set keys() {
return keys;
}
public static IClientConfigKey valueOf(final String name) {
for (IClientConfigKey key: keys()) {
if (key.key().equals(name)) {
return key;
}
}
return new IClientConfigKey() {
@Override
public String key() {
return name;
}
@Override
public Class type() {
return String.class;
}
};
}
private final String configKey;
private final Class type;
@SuppressWarnings("unchecked")
protected CommonClientConfigKey(String configKey) {
this.configKey = configKey;
Type superclass = getClass().getGenericSuperclass();
checkArgument(superclass instanceof ParameterizedType,
"%s isn't parameterized", superclass);
Type runtimeType = ((ParameterizedType) superclass).getActualTypeArguments()[0];
type = (Class) TypeToken.of(runtimeType).getRawType();
}
@Override
public Class type() {
return type;
}
/* (non-Javadoc)
* @see com.netflix.niws.client.ClientConfig#key()
*/
@Override
public String key() {
return configKey;
}
@Override
public String toString() {
return configKey;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy