Search in sources :

Example 46 with Server

use of com.netflix.loadbalancer.Server in project ribbon by Netflix.

the class MyLoadBalancerContext method testEncodedPath.

@Test
public void testEncodedPath() throws Exception {
    String uri = "http://localhost:8080/resources/abc%2Fxyz";
    URI request = new URI(uri);
    Server server = context.getServerFromLoadBalancer(request, null);
    URI newURI = context.reconstructURIWithServer(server, request);
    assertEquals(uri, newURI.toString());
}
Also used : Server(com.netflix.loadbalancer.Server) URI(java.net.URI) Test(org.junit.Test)

Example 47 with Server

use of com.netflix.loadbalancer.Server in project ribbon by Netflix.

the class MyLoadBalancerContext method testPreservesUserInfo.

@Test
public void testPreservesUserInfo() throws Exception {
    // %3A == ":" -- ensure user info is not decoded
    String uri = "http://us%3Aer:pass@localhost:8080?foo=bar";
    URI requestedURI = new URI(uri);
    Server server = context.getServerFromLoadBalancer(requestedURI, null);
    URI newURI = context.reconstructURIWithServer(server, requestedURI);
    assertEquals(uri, newURI.toString());
}
Also used : Server(com.netflix.loadbalancer.Server) URI(java.net.URI) Test(org.junit.Test)

Example 48 with Server

use of com.netflix.loadbalancer.Server in project ribbon by Netflix.

the class MyLoadBalancerContext method testEncodedPathAndHostChange.

@Test
public void testEncodedPathAndHostChange() throws Exception {
    String uri = "/abc%2Fxyz";
    URI request = new URI(uri);
    Server server = context.getServerFromLoadBalancer(request, null);
    URI newURI = context.reconstructURIWithServer(server, request);
    assertEquals("http://www.example.com:8080" + uri, newURI.toString());
}
Also used : Server(com.netflix.loadbalancer.Server) URI(java.net.URI) Test(org.junit.Test)

Example 49 with Server

use of com.netflix.loadbalancer.Server in project ribbon by Netflix.

the class ServerListLoabBalancerTest method init.

@BeforeClass
public static void init() {
    Configuration config = ConfigurationManager.getConfigInstance();
    config.setProperty("ServerListLoabBalancerTest.ribbon.NFLoadBalancerClassName", com.netflix.loadbalancer.DynamicServerListLoadBalancer.class.getName());
    config.setProperty("ServerListLoabBalancerTest.ribbon.NIWSServerListClassName", FixedServerList.class.getName());
    lb = (DynamicServerListLoadBalancer<Server>) ClientFactory.getNamedLoadBalancer("ServerListLoabBalancerTest");
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Server(com.netflix.loadbalancer.Server) DynamicServerListLoadBalancer(com.netflix.loadbalancer.DynamicServerListLoadBalancer) BeforeClass(org.junit.BeforeClass)

Example 50 with Server

use of com.netflix.loadbalancer.Server in project ribbon by Netflix.

the class PrimeConnectionsTest method testPrimeConnectionsSmallPool.

@Test
public void testPrimeConnectionsSmallPool() throws Exception {
    Configuration config = ConfigurationManager.getConfigInstance();
    config.setProperty("PrimeConnectionsTest1.ribbon.NFLoadBalancerClassName", com.netflix.loadbalancer.DynamicServerListLoadBalancer.class.getName());
    config.setProperty("PrimeConnectionsTest1.ribbon.NIWSServerListClassName", SmallFixedServerList.class.getName());
    config.setProperty("PrimeConnectionsTest1.ribbon.EnablePrimeConnections", "true");
    DynamicServerListLoadBalancer<Server> lb = (DynamicServerListLoadBalancer<Server>) ClientFactory.getNamedLoadBalancer("PrimeConnectionsTest1");
    PrimeConnectionEndStats stats = lb.getPrimeConnections().getEndStats();
    assertEquals(stats.success, SMALL_FIXED_SERVER_LIST_SIZE);
}
Also used : Configuration(org.apache.commons.configuration.Configuration) HttpServer(com.sun.net.httpserver.HttpServer) Server(com.netflix.loadbalancer.Server) DynamicServerListLoadBalancer(com.netflix.loadbalancer.DynamicServerListLoadBalancer) PrimeConnectionEndStats(com.netflix.client.PrimeConnections.PrimeConnectionEndStats)

Aggregations

Server (com.netflix.loadbalancer.Server)72 Test (org.junit.Test)56 ByteBuf (io.netty.buffer.ByteBuf)26 MockWebServer (com.google.mockwebserver.MockWebServer)25 BaseLoadBalancer (com.netflix.loadbalancer.BaseLoadBalancer)24 IClientConfig (com.netflix.client.config.IClientConfig)20 AvailabilityFilteringRule (com.netflix.loadbalancer.AvailabilityFilteringRule)19 DummyPing (com.netflix.loadbalancer.DummyPing)18 HttpServer (com.sun.net.httpserver.HttpServer)18 ArrayList (java.util.ArrayList)13 Person (com.netflix.ribbon.test.resources.EmbeddedResources.Person)12 URI (java.net.URI)11 ServerStats (com.netflix.loadbalancer.ServerStats)10 ClientException (com.netflix.client.ClientException)9 HttpClientResponse (io.reactivex.netty.protocol.http.client.HttpClientResponse)9 ExecutionListener (com.netflix.loadbalancer.reactive.ExecutionListener)8 MockResponse (com.google.mockwebserver.MockResponse)7 AbortExecutionException (com.netflix.loadbalancer.reactive.ExecutionListener.AbortExecutionException)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 DynamicServerListLoadBalancer (com.netflix.loadbalancer.DynamicServerListLoadBalancer)5