• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DefaultClientConfigImpl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testSubContext

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Test
public void testSubContext() {
    ExecutionContext<String> context = new ExecutionContext<String>("hello", DefaultClientConfigImpl.getEmptyConfig(),
            DefaultClientConfigImpl.getClientConfigWithDefaultValues(), RetryHandler.DEFAULT);
    ExecutionContext<String> subContext1 = context.getChildContext("foo");
    ExecutionContext<String> subContext2 = context.getChildContext("bar");
    assertSame(context, context.getGlobalContext());
    context.put("dummy", "globalValue");
    context.put("dummy2", "globalValue");
    subContext1.put("dummy", "context1Value");
    subContext2.put("dummy", "context2Value");
    assertEquals("context1Value", subContext1.get("dummy"));
    assertEquals("context2Value", subContext2.get("dummy"));
    assertEquals("globalValue", subContext1.getGlobalContext().get("dummy"));
    assertNull(subContext1.get("dummy2"));
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:17,代码来源:ExecutionContextTest.java


示例17: init

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@BeforeClass
public static void init() {
    Configuration config = ConfigurationManager.getConfigInstance();
    config.setProperty(
            DefaultClientConfigImpl.DEFAULT_PROPERTY_NAME_SPACE + ".ServerListSubsetFilter.forceEliminatePercent", "0.6");
    config.setProperty(
            DefaultClientConfigImpl.DEFAULT_PROPERTY_NAME_SPACE + ".ServerListSubsetFilter.eliminationFailureThresold", 2);
    config.setProperty(
            DefaultClientConfigImpl.DEFAULT_PROPERTY_NAME_SPACE + ".ServerListSubsetFilter.eliminationConnectionThresold", 2);
    config.setProperty(
            DefaultClientConfigImpl.DEFAULT_PROPERTY_NAME_SPACE + ".ServerListSubsetFilter.size", "5");
    
    config.setProperty("SubsetFilerTest.ribbon.NFLoadBalancerClassName", 
            com.netflix.loadbalancer.DynamicServerListLoadBalancer.class.getName());
    config.setProperty("SubsetFilerTest.ribbon.NIWSServerListClassName", MockServerList.class.getName());
    config.setProperty("SubsetFilerTest.ribbon.NIWSServerListFilterClassName", ServerListSubsetFilter.class.getName());
    // turn off auto refresh
    config.setProperty("SubsetFilerTest.ribbon.ServerListRefreshInterval", String.valueOf(Integer.MAX_VALUE));
    config.setProperty("SubsetFilerTest.ribbon.ServerListSubsetFilter.forceEliminatePercent", "0.6");
    config.setProperty("SubsetFilerTest.ribbon.ServerListSubsetFilter.eliminationFailureThresold", 2);
    config.setProperty("SubsetFilerTest.ribbon.ServerListSubsetFilter.eliminationConnectionThresold", 2);
    config.setProperty("SubsetFilerTest.ribbon.ServerListSubsetFilter.size", "5");
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:24,代码来源:SubsetFilterTest.java


示例18: testList

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Test
public void testList() {		
	ConfigurationBasedServerList list = new ConfigurationBasedServerList();
	DefaultClientConfigImpl config = DefaultClientConfigImpl.getClientConfigWithDefaultValues("junit1");
	list.initWithNiwsConfig(config);
	assertTrue(list.getInitialListOfServers().isEmpty());
	ConfigurationManager.getConfigInstance().setProperty("junit1.ribbon.listOfServers", "abc.com:80,microsoft.com,1.2.3.4:8080");
	List<Server> servers = list.getUpdatedListOfServers();
	List<Server> expected = new ArrayList<Server>();
	expected.add(new Server("abc.com:80"));
	expected.add(new Server("microsoft.com:80"));
	expected.add(new Server("1.2.3.4:8080"));
	assertEquals(expected, servers);
	ConfigurationManager.getConfigInstance().setProperty("junit1.ribbon.listOfServers", "");
	assertTrue(list.getUpdatedListOfServers().isEmpty());
	ConfigurationManager.getConfigInstance().clearProperty("junit1.ribbon.listOfServers");
	assertTrue(list.getUpdatedListOfServers().isEmpty());
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:19,代码来源:ConfigurationBasedServerListTest.java


示例19: createRxClient

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
@Override
protected RxClient<I, O> createRxClient(Server server) {
    ClientBuilder<I, O> builder = RxNetty.newTcpClientBuilder(server.getHost(), server.getPort());
    if (pipelineConfigurator != null) {
        builder.pipelineConfigurator(pipelineConfigurator);
    }
    Integer connectTimeout = getProperty(IClientConfigKey.Keys.ConnectTimeout, null, DefaultClientConfigImpl.DEFAULT_CONNECT_TIMEOUT);
    builder.channelOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout);
    if (isPoolEnabled()) {
        builder.withConnectionPoolLimitStrategy(poolStrategy)
        .withIdleConnectionsTimeoutMillis(idleConnectionEvictionMills)
        .withPoolIdleCleanupScheduler(poolCleanerScheduler);
    } else {
        builder.withNoConnectionPooling();
    }
    RxClient<I, O> client = builder.build();
    return client;
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:19,代码来源:LoadBalancingTcpClient.java


示例20: LoadBalancingRxClientWithPoolOptions

import com.netflix.client.config.DefaultClientConfigImpl; //导入依赖的package包/类
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);
    }
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:20,代码来源:LoadBalancingRxClientWithPoolOptions.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Messages类代码示例发布时间:2022-05-22
下一篇:
Java BeanSerializer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap