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


Java DefaultClientConfigImpl.setProperty方法代码示例

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


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

示例1: 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

示例2: testresolveDeploymentContextbasedVipAddresses

import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testresolveDeploymentContextbasedVipAddresses() throws Exception {
	DefaultClientConfigImpl clientConfig = new DefaultClientConfigImpl();
	clientConfig.loadDefaultValues();
    Properties props = new Properties();
    
    final String restClientName = "testRestClient2";
    
    clientConfig.setProperty(props, restClientName,CommonClientConfigKey.AppName.key(), "movieservice");
    clientConfig.setProperty(props, restClientName, CommonClientConfigKey.DeploymentContextBasedVipAddresses.key(),
            "${<appname>}-${netflix.appinfo.stack}-${netflix.environment}:${<port>},${<appname>}--${netflix.environment}:${<port>}");
    clientConfig.setProperty(props, restClientName, CommonClientConfigKey.Port.key(), "7001");
    clientConfig.setProperty(props, restClientName, CommonClientConfigKey.EnableZoneAffinity.key(), "true");        
    ConfigurationManager.loadProperties(props);
    
    clientConfig.loadProperties(restClientName);
    
    Assert.assertEquals("movieservice", clientConfig.getProperty(CommonClientConfigKey.AppName));
    Assert.assertEquals("true", clientConfig.getProperty(CommonClientConfigKey.EnableZoneAffinity));
    
    ConfigurationManager.getConfigInstance().setProperty("testRestClient2.ribbon.DeploymentContextBasedVipAddresses", "movieservice-xbox-test:7001");
    assertEquals("movieservice-xbox-test:7001", clientConfig.getProperty(CommonClientConfigKey.DeploymentContextBasedVipAddresses));
    
    ConfigurationManager.getConfigInstance().clearProperty("testRestClient2.ribbon.EnableZoneAffinity");
    assertNull(clientConfig.getProperty(CommonClientConfigKey.EnableZoneAffinity));
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:27,代码来源:ClientConfigTest.java

示例3: testDomainExtractingServerUseIpAddress

import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testDomainExtractingServerUseIpAddress() {
	DefaultClientConfigImpl config = new DefaultClientConfigImpl();
	config.setProperty(CommonClientConfigKey.UseIPAddrForServer, true);
	DomainExtractingServerList serverList = getDomainExtractingServerList(config,
			true);
	List<DiscoveryEnabledServer> servers = serverList.getInitialListOfServers();
	assertNotNull("servers was null", servers);
	assertEquals("servers was not size 1", 1, servers.size());
	DomainExtractingServer des = assertDomainExtractingServer(servers, ZONE);
	assertEquals("hostPort was wrong", IP_ADDR + ":" + PORT, des.getHostPort());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:13,代码来源:DomainExtractingServerListTests.java

示例4: getConfig

import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
static DefaultClientConfigImpl getConfig(boolean value) {
	DefaultClientConfigImpl config = new DefaultClientConfigImpl();
	config.setProperty(CommonClientConfigKey.IsSecure, value);
	return config;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:6,代码来源:RibbonUtilsTests.java

示例5: testNiwsConfigViaProperties

import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testNiwsConfigViaProperties() throws Exception {
	DefaultClientConfigImpl clientConfig = new DefaultClientConfigImpl();
	DefaultClientConfigImpl override = new DefaultClientConfigImpl();
	clientConfig.loadDefaultValues();
    Properties props = new Properties();
    
    final String restClientName = "testRestClient";
    
    props.setProperty("netflix.appinfo.stack","xbox");
    props.setProperty("netflix.environment","test");
    
    props.setProperty("appname", "movieservice");
    
    clientConfig.setProperty(props, restClientName, CommonClientConfigKey.AppName.key(), "movieservice");
    clientConfig.setProperty(props, restClientName, CommonClientConfigKey.DeploymentContextBasedVipAddresses.key(),
            "${appname}-${netflix.appinfo.stack}-${netflix.environment},movieservice--${netflix.environment}");
    clientConfig.setProperty(props, restClientName, CommonClientConfigKey.EnableZoneAffinity.key(), "false");
    
    ConfigurationManager.loadProperties(props);
    ConfigurationManager.getConfigInstance().setProperty("testRestClient.ribbon.customProperty", "abc");
    
    clientConfig.loadProperties(restClientName);
    clientConfig.setProperty(CommonClientConfigKey.ConnectTimeout, "1000");
    override.setProperty(CommonClientConfigKey.Port, "8000");
    override.setProperty(CommonClientConfigKey.ConnectTimeout, "5000");
    clientConfig.applyOverride(override);
    
    Assert.assertEquals("movieservice", clientConfig.getProperty(CommonClientConfigKey.AppName));
    Assert.assertEquals("false", clientConfig.getProperty(CommonClientConfigKey.EnableZoneAffinity));        
    Assert.assertEquals("movieservice-xbox-test,movieservice--test", clientConfig.resolveDeploymentContextbasedVipAddresses());
    Assert.assertEquals("5000", clientConfig.getProperty(CommonClientConfigKey.ConnectTimeout));

    Assert.assertEquals("8000", clientConfig.getProperty(CommonClientConfigKey.Port));
    assertEquals("abc", clientConfig.getProperties().get("customProperty"));
    System.out.println("AutoVipAddress:" + clientConfig.resolveDeploymentContextbasedVipAddresses());
    
    ConfigurationManager.getConfigInstance().setProperty("testRestClient.ribbon.EnableZoneAffinity", "true");
    ConfigurationManager.getConfigInstance().setProperty("testRestClient.ribbon.customProperty", "xyz");
    assertEquals("true", clientConfig.getProperty(CommonClientConfigKey.EnableZoneAffinity));
    assertEquals("xyz", clientConfig.getProperties().get("customProperty"));        
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:43,代码来源:ClientConfigTest.java


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