Search in sources :

Example 1 with ServerSentEvent

use of io.reactivex.netty.protocol.text.sse.ServerSentEvent in project ribbon by Netflix.

the class NettyClientTest method testStreamWithLoadBalancer.

@Test
public void testStreamWithLoadBalancer() throws Exception {
    // NettyHttpLoadBalancerErrorHandler errorHandler = new NettyHttpLoadBalancerErrorHandler(1, 3, true);
    // IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues().withProperty(CommonClientConfigKey.ConnectTimeout, "1000");
    IClientConfig config = IClientConfig.Builder.newBuilder().withRetryOnAllOperations(true).withMaxAutoRetries(1).withMaxAutoRetriesNextServer(3).build();
    BaseLoadBalancer lb = new BaseLoadBalancer(new DummyPing(), new AvailabilityFilteringRule());
    LoadBalancingHttpClient<ByteBuf, ServerSentEvent> lbObservables = (LoadBalancingHttpClient<ByteBuf, ServerSentEvent>) RibbonTransport.newSSEClient(lb, config);
    HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/testAsync/personStream");
    List<Person> result = Lists.newArrayList();
    Server goodServer = new Server("localhost:" + port);
    Server badServer = new Server("localhost:12245");
    List<Server> servers = Lists.newArrayList(badServer, badServer, badServer, goodServer);
    lb.setServersList(servers);
    result = getPersonListFromResponse(lbObservables.submit(request, null, null));
    assertEquals(EmbeddedResources.entityStream, result);
}
Also used : HttpServer(com.sun.net.httpserver.HttpServer) Server(com.netflix.loadbalancer.Server) MockWebServer(com.google.mockwebserver.MockWebServer) ServerSentEvent(io.reactivex.netty.protocol.text.sse.ServerSentEvent) BaseLoadBalancer(com.netflix.loadbalancer.BaseLoadBalancer) ByteBuf(io.netty.buffer.ByteBuf) DummyPing(com.netflix.loadbalancer.DummyPing) IClientConfig(com.netflix.client.config.IClientConfig) AvailabilityFilteringRule(com.netflix.loadbalancer.AvailabilityFilteringRule) Person(com.netflix.ribbon.test.resources.EmbeddedResources.Person) Test(org.junit.Test)

Aggregations

MockWebServer (com.google.mockwebserver.MockWebServer)1 IClientConfig (com.netflix.client.config.IClientConfig)1 AvailabilityFilteringRule (com.netflix.loadbalancer.AvailabilityFilteringRule)1 BaseLoadBalancer (com.netflix.loadbalancer.BaseLoadBalancer)1 DummyPing (com.netflix.loadbalancer.DummyPing)1 Server (com.netflix.loadbalancer.Server)1 Person (com.netflix.ribbon.test.resources.EmbeddedResources.Person)1 HttpServer (com.sun.net.httpserver.HttpServer)1 ByteBuf (io.netty.buffer.ByteBuf)1 ServerSentEvent (io.reactivex.netty.protocol.text.sse.ServerSentEvent)1 Test (org.junit.Test)1