本文整理汇总了Java中com.netflix.client.config.DefaultClientConfigImpl.getEmptyConfig方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultClientConfigImpl.getEmptyConfig方法的具体用法?Java DefaultClientConfigImpl.getEmptyConfig怎么用?Java DefaultClientConfigImpl.getEmptyConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.client.config.DefaultClientConfigImpl
的用法示例。
在下文中一共展示了DefaultClientConfigImpl.getEmptyConfig方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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"));
}
示例2: submit
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
/**
* Subject an operation to run in the load balancer
*
* @param request
* @param errorHandler
* @param requestConfig
* @param rxClientConfig
* @return
*/
private Observable<HttpClientResponse<O>> submit(final Server server, final HttpClientRequest<I> request, final RetryHandler errorHandler, final IClientConfig requestConfig, final ClientConfig rxClientConfig) {
RetryHandler retryHandler = errorHandler;
if (retryHandler == null) {
retryHandler = getRequestRetryHandler(request, requestConfig);
}
final IClientConfig config = requestConfig == null ? DefaultClientConfigImpl.getEmptyConfig() : requestConfig;
final ExecutionContext<HttpClientRequest<I>> context = new ExecutionContext<HttpClientRequest<I>>(request, config, this.getClientConfig(), retryHandler);
Observable<HttpClientResponse<O>> result = submitToServerInURI(request, config, rxClientConfig, retryHandler, context);
if (result == null) {
LoadBalancerCommand<HttpClientResponse<O>> command;
if (retryHandler != defaultRetryHandler) {
// need to create new builder instead of the default one
command = LoadBalancerCommand.<HttpClientResponse<O>>builder()
.withExecutionContext(context)
.withLoadBalancerContext(lbContext)
.withListeners(listeners)
.withClientConfig(this.getClientConfig())
.withRetryHandler(retryHandler)
.withServer(server)
.build();
}
else {
command = defaultCommandBuilder;
}
result = command.submit(requestToOperation(request, getRxClientConfig(config, rxClientConfig)));
}
return result;
}
示例3: testFailedExecution
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testFailedExecution() {
IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues().withProperty(CommonClientConfigKey.ConnectTimeout, "100")
.withProperty(CommonClientConfigKey.MaxAutoRetries, 1)
.withProperty(CommonClientConfigKey.MaxAutoRetriesNextServer, 1);
HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/testAsync/person");
Server badServer = new Server("localhost:12345");
Server badServer2 = new Server("localhost:34567");
List<Server> servers = Lists.newArrayList(badServer, badServer2);
BaseLoadBalancer lb = LoadBalancerBuilder.<Server>newBuilder()
.withRule(new AvailabilityFilteringRule())
.withPing(new DummyPing())
.buildFixedServerListLoadBalancer(servers);
IClientConfig overrideConfig = DefaultClientConfigImpl.getEmptyConfig();
TestExecutionListener<ByteBuf, ByteBuf> listener = new TestExecutionListener<ByteBuf, ByteBuf>(request, overrideConfig);
List<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>> listeners = Lists.<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>>newArrayList(listener);
LoadBalancingHttpClient<ByteBuf, ByteBuf> client = RibbonTransport.newHttpClient(lb, config, new NettyHttpLoadBalancerErrorHandler(config), listeners);
try {
client.submit(request, null, overrideConfig).toBlocking().last();
fail("Exception expected");
} catch(Exception e) {
assertNotNull(e);
}
assertEquals(1, listener.executionStartCounter.get());
assertEquals(4, listener.startWithServerCounter.get());
assertEquals(4, listener.exceptionWithServerCounter.get());
assertEquals(1, listener.executionFailedCounter.get());
assertTrue(listener.isContextChecked());
assertTrue(listener.isCheckExecutionInfo());
assertNotNull(listener.getFinalThrowable());
listener.getFinalThrowable().printStackTrace();
assertTrue(listener.getFinalThrowable() instanceof ClientException);
assertEquals(100, listener.getContext().getClientProperty(CommonClientConfigKey.ConnectTimeout).intValue());
}
示例4: testFailedExecutionForAbsoluteURI
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testFailedExecutionForAbsoluteURI() {
IClientConfig config = DefaultClientConfigImpl
.getClientConfigWithDefaultValues()
.withProperty(CommonClientConfigKey.ConnectTimeout, "100")
.withProperty(CommonClientConfigKey.MaxAutoRetries, 1)
.withProperty(CommonClientConfigKey.MaxAutoRetriesNextServer, 1);
HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("http://xyz.unknowhost.xyz/testAsync/person");
Server badServer = new Server("localhost:12345");
Server badServer2 = new Server("localhost:34567");
List<Server> servers = Lists.newArrayList(badServer, badServer2);
BaseLoadBalancer lb = LoadBalancerBuilder.<Server>newBuilder()
.withRule(new AvailabilityFilteringRule())
.withPing(new DummyPing())
.buildFixedServerListLoadBalancer(servers);
IClientConfig overrideConfig = DefaultClientConfigImpl.getEmptyConfig();
TestExecutionListener<ByteBuf, ByteBuf> listener = new TestExecutionListener<ByteBuf, ByteBuf>(request, overrideConfig);
List<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>> listeners = Lists.<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>>newArrayList(listener);
LoadBalancingHttpClient<ByteBuf, ByteBuf> client = RibbonTransport.newHttpClient(lb, config, new NettyHttpLoadBalancerErrorHandler(config), listeners);
try {
client.submit(request, null, overrideConfig).toBlocking().last();
fail("Exception expected");
} catch(Exception e) {
assertNotNull(e);
}
assertEquals(1, listener.executionStartCounter.get());
assertEquals(2, listener.startWithServerCounter.get());
assertEquals(2, listener.exceptionWithServerCounter.get());
assertEquals(1, listener.executionFailedCounter.get());
assertTrue(listener.isContextChecked());
assertTrue(listener.isCheckExecutionInfo());
assertTrue(listener.getFinalThrowable() instanceof ClientException);
}
示例5: testAbortedExecution
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testAbortedExecution() {
IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues().withProperty(CommonClientConfigKey.ConnectTimeout, "100")
.withProperty(CommonClientConfigKey.MaxAutoRetries, 1)
.withProperty(CommonClientConfigKey.MaxAutoRetriesNextServer, 1);
HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/testAsync/person");
Server badServer = new Server("localhost:12345");
Server badServer2 = new Server("localhost:34567");
List<Server> servers = Lists.newArrayList(badServer, badServer2);
BaseLoadBalancer lb = LoadBalancerBuilder.<Server>newBuilder()
.withRule(new AvailabilityFilteringRule())
.withPing(new DummyPing())
.buildFixedServerListLoadBalancer(servers);
IClientConfig overrideConfig = DefaultClientConfigImpl.getEmptyConfig();
TestExecutionListener listener = new TestExecutionListener(request, overrideConfig) {
@Override
public void onExecutionStart(ExecutionContext context) {
throw new AbortExecutionException("exit now");
}
};
List<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>> listeners = Lists.<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>>newArrayList(listener);
LoadBalancingHttpClient<ByteBuf, ByteBuf> client = RibbonTransport.newHttpClient(lb, config, new NettyHttpLoadBalancerErrorHandler(config), listeners);
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<Throwable> ref = new AtomicReference<Throwable>();
client.submit(request, null, overrideConfig).subscribe(new Action1<HttpClientResponse<ByteBuf>>() {
@Override
public void call(HttpClientResponse<ByteBuf> byteBufHttpClientResponse) {
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
ref.set(throwable);
latch.countDown();
}
});
try {
latch.await(500, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
assertTrue(ref.get() instanceof AbortExecutionException);
}
示例6: testAbortedExecutionOnServer
import com.netflix.client.config.DefaultClientConfigImpl; //导入方法依赖的package包/类
@Test
public void testAbortedExecutionOnServer() {
IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues().withProperty(CommonClientConfigKey.ConnectTimeout, "100")
.withProperty(CommonClientConfigKey.MaxAutoRetries, 1)
.withProperty(CommonClientConfigKey.MaxAutoRetriesNextServer, 1);
HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/testAsync/person");
Server badServer = new Server("localhost:12345");
Server badServer2 = new Server("localhost:34567");
List<Server> servers = Lists.newArrayList(badServer, badServer2);
BaseLoadBalancer lb = LoadBalancerBuilder.<Server>newBuilder()
.withRule(new AvailabilityFilteringRule())
.withPing(new DummyPing())
.buildFixedServerListLoadBalancer(servers);
IClientConfig overrideConfig = DefaultClientConfigImpl.getEmptyConfig();
TestExecutionListener listener = new TestExecutionListener(request, overrideConfig) {
@Override
public void onStartWithServer(ExecutionContext context, ExecutionInfo info) {
throw new AbortExecutionException("exit now");
}
};
List<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>> listeners = Lists.<ExecutionListener<HttpClientRequest<ByteBuf>, HttpClientResponse<ByteBuf>>>newArrayList(listener);
LoadBalancingHttpClient<ByteBuf, ByteBuf> client = RibbonTransport.newHttpClient(lb, config, new NettyHttpLoadBalancerErrorHandler(config), listeners);
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<Throwable> ref = new AtomicReference<Throwable>();
client.submit(request, null, overrideConfig).subscribe(new Action1<HttpClientResponse<ByteBuf>>() {
@Override
public void call(HttpClientResponse<ByteBuf> byteBufHttpClientResponse) {
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
ref.set(throwable);
latch.countDown();
}
});
try {
latch.await(500, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
assertTrue(ref.get() instanceof AbortExecutionException);
}