Search in sources :

Example 6 with HttpNettyStreamClient

use of com.linkedin.r2.transport.http.client.stream.http.HttpNettyStreamClient in project rest.li by linkedin.

the class TestHttpNettyStreamClient method testShutdownStuckInPool.

@Test
public void testShutdownStuckInPool() throws InterruptedException, ExecutionException, TimeoutException {
    // Test that shutdown works when the outstanding request is stuck in the pool waiting for a channel
    HttpNettyStreamClient client = new HttpNettyStreamClient(new NoCreations(_scheduler), _scheduler, 60000, 1);
    RestRequest r = new RestRequestBuilder(URI.create("http://some.host/")).build();
    FutureCallback<StreamResponse> futureCallback = new FutureCallback<>();
    client.streamRequest(Messages.toStreamRequest(r), new RequestContext(), new HashMap<>(), new TransportCallbackAdapter<>(futureCallback));
    FutureCallback<None> shutdownCallback = new FutureCallback<>();
    client.shutdown(shutdownCallback);
    shutdownCallback.get(30, TimeUnit.SECONDS);
    try {
        futureCallback.get(30, TimeUnit.SECONDS);
        Assert.fail("get should have thrown exception");
    } catch (ExecutionException e) {
        verifyCauseChain(e, RemoteInvocationException.class, TimeoutException.class);
    }
}
Also used : StreamResponse(com.linkedin.r2.message.stream.StreamResponse) HttpNettyStreamClient(com.linkedin.r2.transport.http.client.stream.http.HttpNettyStreamClient) RestRequest(com.linkedin.r2.message.rest.RestRequest) RestRequestBuilder(com.linkedin.r2.message.rest.RestRequestBuilder) RequestContext(com.linkedin.r2.message.RequestContext) RemoteInvocationException(com.linkedin.r2.RemoteInvocationException) ExecutionException(java.util.concurrent.ExecutionException) None(com.linkedin.common.util.None) FutureCallback(com.linkedin.common.callback.FutureCallback) TimeoutException(java.util.concurrent.TimeoutException) Test(org.testng.annotations.Test)

Aggregations

HttpNettyStreamClient (com.linkedin.r2.transport.http.client.stream.http.HttpNettyStreamClient)6 FutureCallback (com.linkedin.common.callback.FutureCallback)5 RequestContext (com.linkedin.r2.message.RequestContext)5 RestRequest (com.linkedin.r2.message.rest.RestRequest)5 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)5 StreamResponse (com.linkedin.r2.message.stream.StreamResponse)5 TransportCallbackAdapter (com.linkedin.r2.transport.common.bridge.client.TransportCallbackAdapter)4 Test (org.testng.annotations.Test)4 RemoteInvocationException (com.linkedin.r2.RemoteInvocationException)3 Http2NettyStreamClient (com.linkedin.r2.transport.http.client.stream.http2.Http2NettyStreamClient)3 ExecutionException (java.util.concurrent.ExecutionException)3 HttpProtocolVersion (com.linkedin.r2.transport.http.common.HttpProtocolVersion)2 TimeoutException (java.util.concurrent.TimeoutException)2 None (com.linkedin.common.util.None)1 ByteString (com.linkedin.data.ByteString)1 HttpServerBuilder (com.linkedin.r2.testutils.server.HttpServerBuilder)1 TransportClient (com.linkedin.r2.transport.common.bridge.client.TransportClient)1 ChannelPoolManager (com.linkedin.r2.transport.http.client.common.ChannelPoolManager)1 ChannelPoolManagerKey (com.linkedin.r2.transport.http.client.common.ChannelPoolManagerKey)1 HttpNettyClient (com.linkedin.r2.transport.http.client.rest.HttpNettyClient)1