Search in sources :

Example 21 with IClientConfig

use of com.netflix.client.config.IClientConfig in project ribbon by Netflix.

the class RibbonTransportFactory method newUdpClient.

public RxClient<DatagramPacket, DatagramPacket> newUdpClient(String name) {
    IClientConfig config = clientConfigFactory.newConfig();
    config.loadProperties(name);
    return newUdpClient(config);
}
Also used : IClientConfig(com.netflix.client.config.IClientConfig)

Example 22 with IClientConfig

use of com.netflix.client.config.IClientConfig in project ribbon by Netflix.

the class RibbonTransportFactory method newHttpClient.

public final HttpClient<ByteBuf, ByteBuf> newHttpClient(String name) {
    IClientConfig config = clientConfigFactory.newConfig();
    config.loadProperties(name);
    return newHttpClient(config);
}
Also used : IClientConfig(com.netflix.client.config.IClientConfig)

Example 23 with IClientConfig

use of com.netflix.client.config.IClientConfig in project ribbon by Netflix.

the class AbstractLoadBalancerAwareClient method isRetriable.

@Deprecated
protected boolean isRetriable(S request) {
    if (request.isRetriable()) {
        return true;
    } else {
        boolean retryOkayOnOperation = okToRetryOnAllOperations;
        IClientConfig overriddenClientConfig = request.getOverrideConfig();
        if (overriddenClientConfig != null) {
            retryOkayOnOperation = overriddenClientConfig.getPropertyAsBoolean(CommonClientConfigKey.RequestSpecificRetryOn, okToRetryOnAllOperations);
        }
        return retryOkayOnOperation;
    }
}
Also used : IClientConfig(com.netflix.client.config.IClientConfig)

Example 24 with IClientConfig

use of com.netflix.client.config.IClientConfig in project ribbon by Netflix.

the class ClientFactory method getNamedConfig.

/**
     * Get the client configuration given the name or create one with clientConfigClass if it does not exist. An instance of IClientConfig
     * is created and {@link IClientConfig#loadProperties(String)} will be called.
     */
public static IClientConfig getNamedConfig(String name, Class<? extends IClientConfig> clientConfigClass) {
    IClientConfig config = namedConfig.get(name);
    if (config != null) {
        return config;
    } else {
        try {
            config = (IClientConfig) clientConfigClass.newInstance();
            config.loadProperties(name);
        } catch (InstantiationException | IllegalAccessException e) {
            logger.error("Unable to create named client config '{}' instance for config class {}", name, clientConfigClass, e);
            return null;
        }
        config.loadProperties(name);
        IClientConfig old = namedConfig.putIfAbsent(name, config);
        if (old != null) {
            config = old;
        }
        return config;
    }
}
Also used : IClientConfig(com.netflix.client.config.IClientConfig)

Example 25 with IClientConfig

use of com.netflix.client.config.IClientConfig in project ribbon by Netflix.

the class FollowRedirectTest method testRedirectNotFollowed.

@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());
}
Also used : HttpRequest(com.netflix.client.http.HttpRequest) IClientConfig(com.netflix.client.config.IClientConfig) HttpResponse(com.netflix.client.http.HttpResponse) URI(java.net.URI) Test(org.junit.Test)

Aggregations

IClientConfig (com.netflix.client.config.IClientConfig)36 Test (org.junit.Test)27 Server (com.netflix.loadbalancer.Server)20 ByteBuf (io.netty.buffer.ByteBuf)20 AvailabilityFilteringRule (com.netflix.loadbalancer.AvailabilityFilteringRule)18 BaseLoadBalancer (com.netflix.loadbalancer.BaseLoadBalancer)18 DummyPing (com.netflix.loadbalancer.DummyPing)18 MockWebServer (com.google.mockwebserver.MockWebServer)17 HttpServer (com.sun.net.httpserver.HttpServer)10 Person (com.netflix.ribbon.test.resources.EmbeddedResources.Person)9 ServerStats (com.netflix.loadbalancer.ServerStats)8 ExecutionListener (com.netflix.loadbalancer.reactive.ExecutionListener)7 MockResponse (com.google.mockwebserver.MockResponse)6 ClientException (com.netflix.client.ClientException)6 AbortExecutionException (com.netflix.loadbalancer.reactive.ExecutionListener.AbortExecutionException)5 HttpClientResponse (io.reactivex.netty.protocol.http.client.HttpClientResponse)5 RequestSpecificRetryHandler (com.netflix.client.RequestSpecificRetryHandler)4 RetryHandler (com.netflix.client.RetryHandler)4 HttpClientListener (io.reactivex.netty.servo.http.HttpClientListener)4 ExecutionContext (com.netflix.loadbalancer.reactive.ExecutionContext)3