本文整理汇总了Java中com.netflix.client.config.DefaultClientConfigImpl.getClientConfigWithDefaultValues方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultClientConfigImpl.getClientConfigWithDefaultValues方法的具体用法?Java DefaultClientConfigImpl.getClientConfigWithDefaultValues怎么用?Java DefaultClientConfigImpl.getClientConfigWithDefaultValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.client.config.DefaultClientConfigImpl
的用法示例。
在下文中一共展示了DefaultClientConfigImpl.getClientConfigWithDefaultValues方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
示例2: 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());
}
示例3: 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"));
}
示例4: 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());
}
示例5: testRedirectNotFollowed
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testRedirectNotFollowed() throws Exception {
IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues("myclient");
config.setProperty(CommonClientConfigKey.FollowRedirects, Boolean.FALSE);
ClientFactory.registerClientFromProperties("myclient", config);
RestClient client = (RestClient) ClientFactory.getNamedClient("myclient");
HttpRequest request = HttpRequest.newBuilder().uri(new URI("http://localhost:" + redirectingServer.getPort())).build();
HttpResponse response = client.executeWithLoadBalancer(request);
assertEquals(302, response.getStatus());
}
示例6: build
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
public LoadBalancingHttpClient<I, O> build() {
if (retryHandler == null) {
retryHandler = new NettyHttpLoadBalancerErrorHandler();
}
if (config == null) {
config = DefaultClientConfigImpl.getClientConfigWithDefaultValues();
}
if (lb == null) {
lb = LoadBalancerBuilder.newBuilder().withClientConfig(config).buildLoadBalancerFromConfigWithReflection();
}
if (listeners == null) {
listeners = Collections.<ExecutionListener<HttpClientRequest<I>, HttpClientResponse<O>>>emptyList();
}
if (backoffStrategy == null) {
backoffStrategy = new Func1<Integer, Integer>() {
@Override
public Integer call(Integer backoffCount) {
int interval = config.getPropertyAsInteger(IClientConfigKey.Keys.BackoffInterval, DefaultClientConfigImpl.DEFAULT_BACKOFF_INTERVAL);
if (backoffCount < 0) {
backoffCount = 0;
}
else if (backoffCount > 10) { // Reasonable upper bound
backoffCount = 10;
}
return (int)Math.pow(2, backoffCount) * interval;
}
};
}
if (responseToErrorPolicy == null) {
responseToErrorPolicy = new DefaultResponseToErrorPolicy<O>();
}
return build.call(this);
}
示例7: testUdpClientTimeout
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testUdpClientTimeout() throws Exception {
int port = choosePort();
UdpServer<DatagramPacket, DatagramPacket> server = new HelloUdpServer(port, 5000).createServer();
server.start();
BaseLoadBalancer lb = new BaseLoadBalancer();
Server myServer = new Server("localhost", port);
lb.setServersList(Lists.newArrayList(myServer));
MyUDPClient client = new MyUDPClient(lb, DefaultClientConfigImpl.getClientConfigWithDefaultValues());
try {
String response = client.submit("Is there anybody out there?")
.map(new Func1<DatagramPacket, String>() {
@Override
public String call(DatagramPacket datagramPacket) {
return datagramPacket.content().toString(Charset.defaultCharset());
}
})
.toBlocking()
.first();
fail("Exception expected");
} catch (Exception e) {
assertTrue(e.getCause() instanceof TimeoutException);
assertEquals(1, client.getLoadBalancerContext().getServerStats(myServer).getSuccessiveConnectionFailureCount());
}
finally {
server.shutdown();
}
}
示例8: createClientConfig
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
private static IClientConfig createClientConfig(String vipAddresses) {
IClientConfig clientConfig = DefaultClientConfigImpl.getClientConfigWithDefaultValues();
clientConfig.set(Keys.DeploymentContextBasedVipAddresses, vipAddresses);
return clientConfig;
}
示例9: NFHttpClient
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
protected NFHttpClient(String name) {
this(name, DefaultClientConfigImpl.getClientConfigWithDefaultValues(), true);
}
示例10: newHttpClient
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
public static LoadBalancingHttpClient<ByteBuf, ByteBuf> newHttpClient() {
IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues();
return newHttpClient(config);
}
示例11: newSSEClient
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
public static LoadBalancingHttpClient<ByteBuf, ServerSentEvent> newSSEClient() {
IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues();
return newSSEClient(config);
}
示例12: testLoadBalancingWithTwoServers
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testLoadBalancingWithTwoServers() throws Exception {
MockWebServer server = new MockWebServer();
String content = "{\"name\": \"ribbon\", \"age\": 2}";
server.enqueue(new MockResponse().setResponseCode(200).setHeader("Content-type", "application/json")
.setBody(content));
server.play();
IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues();
HttpClientRequest<ByteBuf> request = HttpClientRequest.createPost("/testAsync/person")
.withContent(SerializationUtils.serializeToBytes(JacksonCodec.getInstance(), EmbeddedResources.defaultPerson, null))
.withHeader("Content-type", "application/json");
NettyHttpLoadBalancerErrorHandler errorHandler = new NettyHttpLoadBalancerErrorHandler(1, 3, true);
BaseLoadBalancer lb = new BaseLoadBalancer(new DummyPing(), new AvailabilityFilteringRule());
LoadBalancingHttpClient<ByteBuf, ByteBuf> lbObservables = RibbonTransport.newHttpClient(lb, config, errorHandler);
HttpClientListener externalListener = HttpClientListener.newHttpListener("external");
lbObservables.subscribe(externalListener);
Server server1 = new Server("localhost:" + server.getPort());
Server server2 = new Server("localhost:" + port);
lb.setServersList(Lists.newArrayList(server1, server2));
RetryHandler handler = new RequestSpecificRetryHandler(true, true, errorHandler, null) {
@Override
public boolean isRetriableException(Throwable e, boolean sameServer) {
return true;
}
};
Observable<Person> observableWithRetries = getPersonObservable(lbObservables.submit(request, handler, null));
ObserverWithLatch<Person> observer = new ObserverWithLatch<Person>();
observableWithRetries.subscribe(observer);
observer.await();
if (observer.error != null) {
observer.error.printStackTrace();
}
assertEquals("ribbon", observer.obj.name);
assertEquals(EmbeddedResources.defaultPerson.age, observer.obj.age);
observer = new ObserverWithLatch<Person>();
observableWithRetries = getPersonObservable(lbObservables.submit(request, handler, null));
observableWithRetries.subscribe(observer);
observer.await();
if (observer.error != null) {
observer.error.printStackTrace();
}
assertEquals("ribbon", observer.obj.name);
assertEquals(2, observer.obj.age);
ServerStats stats = lbObservables.getServerStats(server1);
server.shutdown();
// assertEquals(1, stats.getTotalRequestsCount());
assertEquals(0, stats.getActiveRequestsCount());
stats = lbObservables.getServerStats(server2);
// two requests to bad server because retry same server is set to 1
assertEquals(1, stats.getTotalRequestsCount());
assertEquals(0, stats.getActiveRequestsCount());
assertEquals(0, stats.getSuccessiveConnectionFailureCount());
final HttpClientListener listener = lbObservables.getListener();
assertEquals(2, listener.getPoolAcquires());
waitUntilTrueOrTimeout(1000, new Func0<Boolean>() {
@Override
public Boolean call() {
return listener.getPoolReleases() == 2;
}
});
assertEquals(2, listener.getConnectionCount());
assertEquals(0, listener.getPoolReuse());
assertEquals(2, externalListener.getPoolAcquires());
}