当前位置: 首页>>代码示例>>Java>>正文


Java DefaultClientConfigImpl类代码示例

本文整理汇总了Java中com.netflix.client.config.DefaultClientConfigImpl的典型用法代码示例。如果您正苦于以下问题:Java DefaultClientConfigImpl类的具体用法?Java DefaultClientConfigImpl怎么用?Java DefaultClientConfigImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DefaultClientConfigImpl类属于com.netflix.client.config包,在下文中一共展示了DefaultClientConfigImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Before
public void setup() {
	ILoadBalancer loadBalancer = new BaseLoadBalancer();
	loadBalancer.addServers(Arrays.asList(new Server("localhost", 7080)));
	loadBalancer.addServers(Arrays.asList(new Server("localhost", 7081)));
	loadBalancer.addServers(Arrays.asList(new Server("localhost", 7082)));

	IClientConfig clientConfig = new DefaultClientConfigImpl();

	RibbonHttpClientRequestFactory ribbonHttpClientRequestFactory = new RibbonHttpClientRequestFactory(loadBalancer, clientConfig);

	myApi = new RestifyProxyBuilder()
			.client(ribbonHttpClientRequestFactory)
			.target(MyApi.class, "http://myApi")
			.build();
}
 
开发者ID:ljtfreitas,项目名称:java-restify,代码行数:17,代码来源:RibbonHttpClientRequestFactoryTest.java

示例2: 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();
}
 
开发者ID:januslabs,项目名称:consul-ribbon-starter,代码行数:12,代码来源:ConsulRibbonLoadBalancer.java

示例3: testNeverRetry

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Test
public void testNeverRetry() throws Exception {
	ServerIntrospector introspector = mock(ServerIntrospector.class);
	CloseableHttpClient delegate = mock(CloseableHttpClient.class);
	HttpResponse response = mock(HttpResponse.class);
	doThrow(new IOException("boom")).when(delegate).execute(any(HttpUriRequest.class));
	DefaultClientConfigImpl clientConfig = new DefaultClientConfigImpl();
	clientConfig.setClientName("foo");
	RibbonLoadBalancingHttpClient client = new RibbonLoadBalancingHttpClient(delegate, clientConfig,
			introspector);
	RibbonApacheHttpRequest request = mock(RibbonApacheHttpRequest.class);
	when(request.toRequest(any(RequestConfig.class))).thenReturn(mock(HttpUriRequest.class));
	try {
		client.execute(request, null);
		fail("Expected IOException");
	} catch(IOException e) {} finally {
		verify(delegate, times(1)).execute(any(HttpUriRequest.class));
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:20,代码来源:RibbonLoadBalancingHttpClientTests.java

示例4: testHystrixTimeoutValueRibbonTimeouts

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Test
public void testHystrixTimeoutValueRibbonTimeouts() throws Exception {
	SpringClientFactory springClientFactory = mock(SpringClientFactory.class);
	ZuulProperties zuulProperties = new ZuulProperties();
	OkHttpLoadBalancingClient loadBalancingHttpClient = mock(OkHttpLoadBalancingClient.class);
	IClientConfig clientConfig = new DefaultClientConfigImpl();
	clientConfig.set(IClientConfigKey.Keys.ConnectTimeout, 100);
	clientConfig.set(IClientConfigKey.Keys.ReadTimeout, 500);
	doReturn(loadBalancingHttpClient).when(springClientFactory).getClient(anyString(),
			eq(OkHttpLoadBalancingClient.class));
	doReturn(clientConfig).when(springClientFactory).getClientConfig(anyString());
	OkHttpRibbonCommandFactory commandFactory = new OkHttpRibbonCommandFactory(springClientFactory, zuulProperties, new HashSet<FallbackProvider>());
	RibbonCommandContext context = mock(RibbonCommandContext.class);
	doReturn("service").when(context).getServiceId();
	OkHttpRibbonCommand ribbonCommand = commandFactory.create(context);
	assertEquals(600, ribbonCommand.getProperties().executionTimeoutInMilliseconds().get().intValue());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:18,代码来源:OkHttpRibbonCommandFactoryTest.java

示例5: testHystrixTimeoutValueRibbonTimeouts

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Test
public void testHystrixTimeoutValueRibbonTimeouts() throws Exception {
	SpringClientFactory springClientFactory = mock(SpringClientFactory.class);
	ZuulProperties zuulProperties = new ZuulProperties();
	RibbonLoadBalancingHttpClient loadBalancingHttpClient = mock(RibbonLoadBalancingHttpClient.class);
	IClientConfig clientConfig = new DefaultClientConfigImpl();
	clientConfig.set(IClientConfigKey.Keys.ConnectTimeout, 100);
	clientConfig.set(IClientConfigKey.Keys.ReadTimeout, 500);
	doReturn(loadBalancingHttpClient).when(springClientFactory).getClient(anyString(),
			eq(RibbonLoadBalancingHttpClient.class));
	doReturn(clientConfig).when(springClientFactory).getClientConfig(anyString());
	HttpClientRibbonCommandFactory ribbonCommandFactory = new HttpClientRibbonCommandFactory(springClientFactory, zuulProperties, new HashSet<FallbackProvider>());
	RibbonCommandContext context = mock(RibbonCommandContext.class);
	doReturn("service").when(context).getServiceId();
	HttpClientRibbonCommand ribbonCommand = ribbonCommandFactory.create(context);
	assertEquals(600, ribbonCommand.getProperties().executionTimeoutInMilliseconds().get().intValue());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:18,代码来源:HttpClientRibbonCommandFactoryTest.java

示例6: getDomainExtractingServerList

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
protected DomainExtractingServerList getDomainExtractingServerList(
		DefaultClientConfigImpl config, boolean approximateZoneFromHostname) {
	DiscoveryEnabledServer server = mock(DiscoveryEnabledServer.class);
	@SuppressWarnings("unchecked")
	ServerList<DiscoveryEnabledServer> originalServerList = mock(ServerList.class);
	InstanceInfo instanceInfo = mock(InstanceInfo.class);
	given(server.getInstanceInfo()).willReturn(instanceInfo);
	given(server.getHost()).willReturn(HOST_NAME);
	given(instanceInfo.getMetadata()).willReturn(this.metadata);
	given(instanceInfo.getHostName()).willReturn(HOST_NAME);
	given(instanceInfo.getIPAddr()).willReturn(IP_ADDR);
	given(instanceInfo.getPort()).willReturn(PORT);
	given(originalServerList.getInitialListOfServers()).willReturn(
			Arrays.asList(server));
	return new DomainExtractingServerList(originalServerList, config,
			approximateZoneFromHostname);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:18,代码来源:DomainExtractingServerListTests.java

示例7: contextLoads

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Test
public void contextLoads() {
	Response<Map<String, Service>> response = consul.getAgentServices();
	Map<String, Service> services = response.getValue();
	Service service = services.get("myTestService1-WithGroup");
	assertNotNull("service was null", service);
	assertNotEquals("service port is 0", 0, service.getPort().intValue());
	assertEquals("service id was wrong", "myTestService1-WithGroup", service.getId());
	assertTrue("service group was wrong", service.getTags().contains("group=test"));

	ConsulServerList serverList = new ConsulServerList(consul, properties);
	DefaultClientConfigImpl config = new DefaultClientConfigImpl();
	config.setClientName("myTestService-WithGroup");
	serverList.initWithNiwsConfig(config);

	List<ConsulServer> servers = serverList.getInitialListOfServers();
	assertEquals("servers was wrong size", 1, servers.size());
	assertEquals("service group was wrong", "test", servers.get(0).getMetaInfo().getServerGroup());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-consul,代码行数:20,代码来源:ConsulAutoServiceRegistrationCustomizedInstanceGroupTests.java

示例8: testDefaultHonorsVipPortDefinition

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Test
public void testDefaultHonorsVipPortDefinition() throws Exception{

    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testDefaultHonorsVipPortDefinition.ribbon.DeploymentContextBasedVipAddresses", "dummy");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testDefaultHonorsVipPortDefinition.ribbon.IsSecure", "false");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testDefaultHonorsVipPortDefinition.ribbon.Port", "6999");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testDefaultHonorsVipPortDefinition.ribbon.TargetRegion", "region");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testDefaultHonorsVipPortDefinition.ribbon.NIWSServerListClassName", DiscoveryEnabledNIWSServerList.class.getName());



    DiscoveryEnabledNIWSServerList deList = new DiscoveryEnabledNIWSServerList();

    DefaultClientConfigImpl clientConfig = DefaultClientConfigImpl.class.newInstance();
    clientConfig.loadProperties("DiscoveryEnabled.testDefaultHonorsVipPortDefinition");
    deList.initWithNiwsConfig(clientConfig);

    List<DiscoveryEnabledServer> serverList = deList.getInitialListOfServers();

    Assert.assertEquals(1, serverList.size());
    Assert.assertEquals(8001, serverList.get(0).getPort());                              // vip indicated
    Assert.assertEquals(8001, serverList.get(0).getInstanceInfo().getPort());            // vip indicated
    Assert.assertEquals(7002, serverList.get(0).getInstanceInfo().getSecurePort());      // 7002 is the secure default
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:25,代码来源:DiscoveryEnabledLoadBalancerSupportsPortOverrideTest.java

示例9: testDefaultHonorsVipSecurePortDefinition

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Test
public void testDefaultHonorsVipSecurePortDefinition() throws Exception{

    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testDefaultHonorsVipSecurePortDefinition.ribbon.DeploymentContextBasedVipAddresses", "secureDummy");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testDefaultHonorsVipSecurePortDefinition.ribbon.IsSecure", "true");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testDefaultHonorsVipSecurePortDefinition.ribbon.SecurePort", "6002");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testDefaultHonorsVipSecurePortDefinition.ribbon.TargetRegion", "region");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testDefaultHonorsVipSecurePortDefinition.ribbon.NIWSServerListClassName", DiscoveryEnabledNIWSServerList.class.getName());



    DiscoveryEnabledNIWSServerList deList = new DiscoveryEnabledNIWSServerList();

    DefaultClientConfigImpl clientConfig = DefaultClientConfigImpl.class.newInstance();
    clientConfig.loadProperties("DiscoveryEnabled.testDefaultHonorsVipSecurePortDefinition");
    deList.initWithNiwsConfig(clientConfig);

    List<DiscoveryEnabledServer> serverList = deList.getInitialListOfServers();

    Assert.assertEquals(1, serverList.size());
    Assert.assertEquals(8002, serverList.get(0).getPort());                         // vip indicated
    Assert.assertEquals(8002, serverList.get(0).getInstanceInfo().getPort());       // vip indicated
    Assert.assertEquals(7002, serverList.get(0).getInstanceInfo().getSecurePort()); // 7002 is the secure default
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:25,代码来源:DiscoveryEnabledLoadBalancerSupportsPortOverrideTest.java

示例10: testVipPortCanBeOverriden

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Test
public void testVipPortCanBeOverriden() throws Exception{

    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testVipPortCanBeOverriden.ribbon.DeploymentContextBasedVipAddresses", "dummy");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testVipPortCanBeOverriden.ribbon.IsSecure", "false");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testVipPortCanBeOverriden.ribbon.Port", "6001");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testVipPortCanBeOverriden.ribbon.TargetRegion", "region");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testVipPortCanBeOverriden.ribbon.NIWSServerListClassName", DiscoveryEnabledNIWSServerList.class.getName());

    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testVipPortCanBeOverriden.ribbon.ForceClientPortConfiguration", "true");

    DiscoveryEnabledNIWSServerList deList = new DiscoveryEnabledNIWSServerList();

    DefaultClientConfigImpl clientConfig = DefaultClientConfigImpl.class.newInstance();
    clientConfig.loadProperties("DiscoveryEnabled.testVipPortCanBeOverriden");
    deList.initWithNiwsConfig(clientConfig);

    List<DiscoveryEnabledServer> serverList = deList.getInitialListOfServers();

    Assert.assertEquals(1, serverList.size());
    Assert.assertEquals(6001, serverList.get(0).getPort());                           // client property indicated
    Assert.assertEquals(6001, serverList.get(0).getInstanceInfo().getPort());         // client property indicated
    Assert.assertEquals(7002, serverList.get(0).getInstanceInfo().getSecurePort());   // 7002 is the secure default
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:25,代码来源:DiscoveryEnabledLoadBalancerSupportsPortOverrideTest.java

示例11: testSecureVipPortCanBeOverriden

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Test
public void testSecureVipPortCanBeOverriden() throws Exception{

    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testSecureVipPortCanBeOverriden.ribbon.DeploymentContextBasedVipAddresses", "secureDummy");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testSecureVipPortCanBeOverriden.ribbon.IsSecure", "true");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testSecureVipPortCanBeOverriden.ribbon.SecurePort", "6002");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testSecureVipPortCanBeOverriden.ribbon.TargetRegion", "region");
    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testSecureVipPortCanBeOverriden.ribbon.NIWSServerListClassName", DiscoveryEnabledNIWSServerList.class.getName());

    ConfigurationManager.getConfigInstance().setProperty("DiscoveryEnabled.testSecureVipPortCanBeOverriden.ribbon.ForceClientPortConfiguration", "true");

    DiscoveryEnabledNIWSServerList deList = new DiscoveryEnabledNIWSServerList();

    DefaultClientConfigImpl clientConfig = DefaultClientConfigImpl.class.newInstance();
    clientConfig.loadProperties("DiscoveryEnabled.testSecureVipPortCanBeOverriden");
    deList.initWithNiwsConfig(clientConfig);

    List<DiscoveryEnabledServer> serverList = deList.getInitialListOfServers();

    Assert.assertEquals(1, serverList.size());
    Assert.assertEquals(8002, serverList.get(0).getPort());                           // vip indicated
    Assert.assertEquals(8002, serverList.get(0).getInstanceInfo().getPort());         // vip indicated
    Assert.assertEquals(6002, serverList.get(0).getInstanceInfo().getSecurePort());   // client property indicated
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:25,代码来源:DiscoveryEnabledLoadBalancerSupportsPortOverrideTest.java

示例12: setUp

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Before
public void setUp() {
    PowerMock.mockStatic(DiscoveryClient.class);

    EasyMock
            .expect(DiscoveryClient.getZone(EasyMock.isA(InstanceInfo.class)))
            .andReturn("zone")
            .anyTimes();

    eurekaClientMock = setUpEurekaClientMock(servers);
    eurekaClientProvider = new Provider<EurekaClient>() {
        @Override
        public EurekaClient get() {
            return eurekaClientMock;
        }
    };

    config = DefaultClientConfigImpl.getClientConfigWithDefaultValues();
    config.setProperty(CommonClientConfigKey.DeploymentContextBasedVipAddresses, vipAddress);
    config.setProperty(CommonClientConfigKey.ServerListUpdaterClassName, EurekaNotificationServerListUpdater.class.getName());
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:22,代码来源:EurekaDynamicServerListLoadBalancerTest.java

示例13: testThrottledWithRetryNextServer

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Test
public void testThrottledWithRetryNextServer() throws Exception {
    int connectionCount = connectionPoolManager.getConnectionsInPool();
    URI localUrl = new URI("/status?code=503");
    HttpRequest request = HttpRequest.newBuilder().uri(localUrl).build();
    try {
        client.executeWithLoadBalancer(request, DefaultClientConfigImpl.getEmptyConfig().set(CommonClientConfigKey.MaxAutoRetriesNextServer, 2));
        fail("Exception expected");
    } catch (ClientException e) { // NOPMD
    }
    assertEquals(3, lb.getLoadBalancerStats().getSingleServerStat(localServer).getSuccessiveConnectionFailureCount());
    System.out.println("Initial connections count " + connectionCount);
    System.out.println("Final connections count " + connectionPoolManager.getConnectionsInPool());
    // should be no connection leak        
    assertTrue(connectionPoolManager.getConnectionsInPool() <= connectionCount + 1);
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:17,代码来源:RetryTest.java

示例14: initWithNiwsConfig

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
/**
 * 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 (clientName == null) {
        clientName = "default";
    }
    vipAddresses = clientConfig.resolveDeploymentContextbasedVipAddresses();
    maxAutoRetries = clientConfig.getPropertyAsInteger(CommonClientConfigKey.MaxAutoRetries, DefaultClientConfigImpl.DEFAULT_MAX_AUTO_RETRIES);
    maxAutoRetriesNextServer = clientConfig.getPropertyAsInteger(CommonClientConfigKey.MaxAutoRetriesNextServer,maxAutoRetriesNextServer);

    okToRetryOnAllOperations = clientConfig.getPropertyAsBoolean(CommonClientConfigKey.OkToRetryOnAllOperations, okToRetryOnAllOperations);
    defaultRetryHandler = new DefaultLoadBalancerRetryHandler(clientConfig);
    
    tracer = getExecuteTracer();

    Monitors.registerObject("Client_" + clientName, this);
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:24,代码来源:LoadBalancerContext.java

示例15: testDynamicServerListLoadBalancer

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Test
public void testDynamicServerListLoadBalancer() throws Exception {
    DefaultClientConfigImpl config = DefaultClientConfigImpl.getClientConfigWithDefaultValues();
    config.setProperty(CommonClientConfigKey.NIWSServerListClassName, MyServerList.class.getName());
    config.setProperty(CommonClientConfigKey.NFLoadBalancerClassName, DynamicServerListLoadBalancer.class.getName());
    config.setProperty(CommonClientConfigKey.ServerListRefreshInterval, "50");
    DynamicServerListLoadBalancer<Server> lb = new DynamicServerListLoadBalancer<Server>(config);
    try {
        assertTrue(MyServerList.latch.await(2, TimeUnit.SECONDS));
    } catch (InterruptedException e) { // NOPMD
    }
    assertEquals(lb.getAllServers(), MyServerList.list);
    lb.stopServerListRefreshing();
    Thread.sleep(1000);
    int count = MyServerList.counter.get();
    assertTrue(count >= 5);
    Thread.sleep(1000);
    assertEquals(count, MyServerList.counter.get());
    
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:21,代码来源:DynamicServerListLoadBalancerTest.java


注:本文中的com.netflix.client.config.DefaultClientConfigImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。