本文整理汇总了Java中com.netflix.client.config.DefaultClientConfigImpl.set方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultClientConfigImpl.set方法的具体用法?Java DefaultClientConfigImpl.set怎么用?Java DefaultClientConfigImpl.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.client.config.DefaultClientConfigImpl
的用法示例。
在下文中一共展示了DefaultClientConfigImpl.set方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
public ZoneAwareLoadBalancer<Server> build(String schemeName) {
String servicename = URI.create(schemeName).getHost();
log.info("creating a loadbalancer {} ", servicename);
final DefaultClientConfigImpl clientConfig = new DefaultClientConfigImpl();
clientConfig.setClientName(servicename);
clientConfig.set(CommonClientConfigKey.ServerListRefreshInterval, 300 * 1000);
return LoadBalancerBuilder.newBuilder().withClientConfig(clientConfig)
.withRule(new WeightedResponseTimeRule()).withDynamicServerList(factory.build(servicename))
.buildDynamicServerListLoadBalancer();
}
示例2: build
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
/**
* Builds a new {@link RibbonJerseyClient} with an existing Jersey Client
* and service discoverer
*
* @param name
* Client name
* @param jerseyClient
* Jersey Client
* @param serviceDiscoverer
* Service discoverer
* @return new RibbonJerseyClient
*/
public RibbonJerseyClient build(@Nonnull final String name,
@Nonnull final Client jerseyClient,
@Nonnull final ConsulServiceDiscoverer serviceDiscoverer) {
// dynamic server list that is refreshed from Consul
final ConsulServerList serverList = new ConsulServerList(consul,
serviceDiscoverer);
// build a new load balancer based on the configuration
final DefaultClientConfigImpl clientConfig = new DefaultClientConfigImpl();
clientConfig.setClientName(name);
clientConfig.set(CommonClientConfigKey.ServerListRefreshInterval,
Ints.checkedCast(
configuration.getRefreshInterval().toMilliseconds()));
final ZoneAwareLoadBalancer<Server> loadBalancer = LoadBalancerBuilder
.newBuilder().withClientConfig(clientConfig)
.withRule(new WeightedResponseTimeRule())
.withDynamicServerList(serverList)
.buildDynamicServerListLoadBalancer();
final RibbonJerseyClient client = new RibbonJerseyClient(
configuration.getScheme(), loadBalancer, jerseyClient);
environment.lifecycle().manage(new Managed() {
@Override
public void start() throws Exception {
// nothing to start
}
@Override
public void stop() throws Exception {
client.close();
}
});
return client;
}
示例3: ribbonClientConfig
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Bean
@ConditionalOnMissingBean
public IClientConfig ribbonClientConfig() {
DefaultClientConfigImpl config = new DefaultClientConfigImpl();
config.loadProperties(this.name);
config.set(CommonClientConfigKey.ConnectTimeout, DEFAULT_CONNECT_TIMEOUT);
config.set(CommonClientConfigKey.ReadTimeout, DEFAULT_READ_TIMEOUT);
return config;
}
示例4: testOkHttpClientDoNotFollowRedirectsOverrideWithFollowRedirects
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testOkHttpClientDoNotFollowRedirectsOverrideWithFollowRedirects()
throws Exception {
DefaultClientConfigImpl override = new DefaultClientConfigImpl();
override.set(CommonClientConfigKey.FollowRedirects, true);
override.set(CommonClientConfigKey.IsSecure, false);
OkHttpClient result = getHttpClient(DoNotFollowRedirects.class, override);
assertThat(result.followRedirects(), is(true));
}
示例5: testOkHttpClientFollowRedirectsOverrideWithDoNotFollowRedirects
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testOkHttpClientFollowRedirectsOverrideWithDoNotFollowRedirects()
throws Exception {
DefaultClientConfigImpl override = new DefaultClientConfigImpl();
override.set(CommonClientConfigKey.FollowRedirects, false);
override.set(CommonClientConfigKey.IsSecure, false);
OkHttpClient result = getHttpClient(FollowRedirects.class, override);
assertThat(result.followRedirects(), is(false));
}
示例6: testTimeoutsOverride
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testTimeoutsOverride() throws Exception {
DefaultClientConfigImpl override = new DefaultClientConfigImpl();
override.set(CommonClientConfigKey.ConnectTimeout, 60);
override.set(CommonClientConfigKey.ReadTimeout, 50);
OkHttpClient result = getHttpClient(Timeouts.class, override);
assertThat(result.readTimeoutMillis(), is(50));
assertThat(result.connectTimeoutMillis(), is(60));
}
示例7: clientConfig
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Bean
public IClientConfig clientConfig() {
DefaultClientConfigImpl config = new DefaultClientConfigImpl();
config.set(CommonClientConfigKey.ConnectTimeout, 60000);
config.set(CommonClientConfigKey.ReadTimeout, 50000);
return config;
}
示例8: testRequestConfigDoNotFollowRedirectsOverrideWithFollowRedirects
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testRequestConfigDoNotFollowRedirectsOverrideWithFollowRedirects()
throws Exception {
DefaultClientConfigImpl override = new DefaultClientConfigImpl();
override.set(CommonClientConfigKey.FollowRedirects, true);
override.set(CommonClientConfigKey.IsSecure, false);
RequestConfig result = getBuiltRequestConfig(DoNotFollowRedirects.class, override);
assertThat(result.isRedirectsEnabled(), is(true));
}
示例9: testRequestConfigFollowRedirectsOverrideWithDoNotFollowRedirects
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testRequestConfigFollowRedirectsOverrideWithDoNotFollowRedirects()
throws Exception {
DefaultClientConfigImpl override = new DefaultClientConfigImpl();
override.set(CommonClientConfigKey.FollowRedirects, false);
override.set(CommonClientConfigKey.IsSecure, false);
RequestConfig result = getBuiltRequestConfig(FollowRedirects.class, override);
assertThat(result.isRedirectsEnabled(), is(false));
}
示例10: setupClientForRetry
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
private RetryableRibbonLoadBalancingHttpClient setupClientForRetry(int retriesNextServer, int retriesSameServer,
boolean retryable, boolean retryOnAllOps,
String serviceName, String host, int port,
CloseableHttpClient delegate, ILoadBalancer lb, String statusCodes,
LoadBalancedBackOffPolicyFactory loadBalancedBackOffPolicyFactory,
boolean isSecure) throws Exception {
ServerIntrospector introspector = mock(ServerIntrospector.class);
RetryHandler retryHandler = new DefaultLoadBalancerRetryHandler(retriesSameServer, retriesNextServer, retryable);
doReturn(new Server(host, port)).when(lb).chooseServer(eq(serviceName));
DefaultClientConfigImpl clientConfig = new DefaultClientConfigImpl();
clientConfig.set(CommonClientConfigKey.OkToRetryOnAllOperations, retryOnAllOps);
clientConfig.set(CommonClientConfigKey.MaxAutoRetriesNextServer, retriesNextServer);
clientConfig.set(CommonClientConfigKey.MaxAutoRetries, retriesSameServer);
clientConfig.set(RibbonLoadBalancedRetryPolicy.RETRYABLE_STATUS_CODES, statusCodes);
clientConfig.set(CommonClientConfigKey.IsSecure, isSecure);
clientConfig.setClientName(serviceName);
RibbonLoadBalancerContext context = new RibbonLoadBalancerContext(lb, clientConfig, retryHandler);
SpringClientFactory clientFactory = mock(SpringClientFactory.class);
doReturn(context).when(clientFactory).getLoadBalancerContext(eq(serviceName));
doReturn(clientConfig).when(clientFactory).getClientConfig(eq(serviceName));
LoadBalancedRetryPolicyFactory factory = new RibbonLoadBalancedRetryPolicyFactory(clientFactory);
RetryableRibbonLoadBalancingHttpClient client = new RetryableRibbonLoadBalancingHttpClient(delegate, clientConfig,
introspector, factory, loadBalancedBackOffPolicyFactory);
client.setLoadBalancer(lb);
ReflectionTestUtils.setField(client, "delegate", delegate);
return client;
}
示例11: getClientConfig
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Override
public IClientConfig getClientConfig(String name) {
DefaultClientConfigImpl config = new DefaultClientConfigImpl();
config.set(CommonClientConfigKey.ConnectTimeout, 1000);
config.set(CommonClientConfigKey.ReadTimeout, 500);
return config;
}