Search in sources :

Example 16 with TransportDispatcher

use of com.linkedin.r2.transport.common.bridge.server.TransportDispatcher in project rest.li by linkedin.

the class TestJetty404 method setup.

@BeforeClass
public void setup() throws IOException {
    _clientFactory = new HttpClientFactory();
    _client = new TransportClientAdapter(_clientFactory.getClient(Collections.<String, String>emptyMap()), true);
    _server = new HttpServerFactory().createH2cServer(PORT, "/correct-path", 50, new TransportDispatcher() {

        @Override
        public void handleRestRequest(RestRequest req, Map<String, String> wireAttrs, RequestContext requestContext, TransportCallback<RestResponse> callback) {
            callback.onResponse(TransportResponseImpl.success(new RestResponseBuilder().build()));
        }

        @Override
        public void handleStreamRequest(StreamRequest req, Map<String, String> wireAttrs, RequestContext requestContext, TransportCallback<StreamResponse> callback) {
            req.getEntityStream().setReader(new DrainReader());
            callback.onResponse(TransportResponseImpl.success(new StreamResponseBuilder().build(EntityStreams.emptyStream())));
        }
    }, true);
    _server.start();
}
Also used : HttpServerFactory(com.linkedin.r2.transport.http.server.HttpServerFactory) TransportCallback(com.linkedin.r2.transport.common.bridge.common.TransportCallback) RestRequest(com.linkedin.r2.message.rest.RestRequest) StreamResponseBuilder(com.linkedin.r2.message.stream.StreamResponseBuilder) TransportClientAdapter(com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter) RestResponseBuilder(com.linkedin.r2.message.rest.RestResponseBuilder) TransportDispatcher(com.linkedin.r2.transport.common.bridge.server.TransportDispatcher) RequestContext(com.linkedin.r2.message.RequestContext) HttpClientFactory(com.linkedin.r2.transport.http.client.HttpClientFactory) Map(java.util.Map) DrainReader(com.linkedin.r2.message.stream.entitystream.DrainReader) StreamRequest(com.linkedin.r2.message.stream.StreamRequest) BeforeClass(org.testng.annotations.BeforeClass)

Example 17 with TransportDispatcher

use of com.linkedin.r2.transport.common.bridge.server.TransportDispatcher in project rest.li by linkedin.

the class TestDisruptor method setup.

@BeforeClass
public void setup() throws IOException {
    final TransportDispatcher dispatcher = new TransportDispatcherBuilder(REST_OVER_STREAM).addRestHandler(URI.create(PATH), new AbstractHttpServerTest.HeaderEchoHandler()).build();
    final HttpServerFactory factory = new HttpServerFactory();
    _server = factory.createH2cServer(PORT, dispatcher, REST_OVER_STREAM);
    _server.start();
}
Also used : HttpServerFactory(com.linkedin.r2.transport.http.server.HttpServerFactory) TransportDispatcher(com.linkedin.r2.transport.common.bridge.server.TransportDispatcher) TransportDispatcherBuilder(com.linkedin.r2.transport.common.bridge.server.TransportDispatcherBuilder) BeforeClass(org.testng.annotations.BeforeClass)

Example 18 with TransportDispatcher

use of com.linkedin.r2.transport.common.bridge.server.TransportDispatcher in project rest.li by linkedin.

the class TestHttp2Server method doSetup.

@Override
protected void doSetup() throws IOException {
    final TransportDispatcher dispatcher = new TransportDispatcherBuilder(_restOverStream).addRestHandler(URI.create("/error"), new ErrorHandler()).addRestHandler(URI.create("/headerEcho"), new HeaderEchoHandler()).addRestHandler(URI.create("/foobar"), new FoobarHandler(_scheduler)).build();
    _server = new HttpServerFactory(_servletType).createH2cServer(_port, dispatcher, _restOverStream);
    _server.start();
}
Also used : HttpServerFactory(com.linkedin.r2.transport.http.server.HttpServerFactory) TransportDispatcher(com.linkedin.r2.transport.common.bridge.server.TransportDispatcher) TransportDispatcherBuilder(com.linkedin.r2.transport.common.bridge.server.TransportDispatcherBuilder)

Example 19 with TransportDispatcher

use of com.linkedin.r2.transport.common.bridge.server.TransportDispatcher in project rest.li by linkedin.

the class TestHttpServer method doSetup.

@Override
protected void doSetup() throws IOException {
    final TransportDispatcher dispatcher = new TransportDispatcherBuilder(_restOverStream).addRestHandler(URI.create("/error"), new ErrorHandler()).addRestHandler(URI.create("/headerEcho"), new HeaderEchoHandler()).addRestHandler(URI.create("/foobar"), new FoobarHandler(_scheduler)).build();
    _server = new HttpServerFactory(_servletType).createServer(_port, dispatcher, _restOverStream);
    _server.start();
}
Also used : HttpServerFactory(com.linkedin.r2.transport.http.server.HttpServerFactory) TransportDispatcher(com.linkedin.r2.transport.common.bridge.server.TransportDispatcher) TransportDispatcherBuilder(com.linkedin.r2.transport.common.bridge.server.TransportDispatcherBuilder)

Example 20 with TransportDispatcher

use of com.linkedin.r2.transport.common.bridge.server.TransportDispatcher in project rest.li by linkedin.

the class TestMIMEChainingMultipleSources method setup.

@BeforeMethod
public void setup() throws IOException {
    _latch = new CountDownLatch(2);
    _clientFactory = new HttpClientFactory();
    _client = new TransportClientAdapter(_clientFactory.getClient(Collections.<String, String>emptyMap()));
    _server_A_client = new TransportClientAdapter(_clientFactory.getClient(Collections.<String, String>emptyMap()));
    final HttpServerFactory httpServerFactory = new HttpServerFactory();
    final ServerARequestHandler serverARequestHandler = new ServerARequestHandler();
    final TransportDispatcher serverATransportDispatcher = new TransportDispatcherBuilder().addStreamHandler(SERVER_A_URI, serverARequestHandler).build();
    final ServerBRequestHandler serverBRequestHandler = new ServerBRequestHandler();
    final TransportDispatcher serverBTransportDispatcher = new TransportDispatcherBuilder().addStreamHandler(SERVER_B_URI, serverBRequestHandler).build();
    _serverA = httpServerFactory.createServer(PORT_SERVER_A, serverATransportDispatcher, true);
    _serverB = httpServerFactory.createServer(PORT_SERVER_B, serverBTransportDispatcher, true);
    _serverA.start();
    _serverB.start();
}
Also used : HttpServerFactory(com.linkedin.r2.transport.http.server.HttpServerFactory) TransportClientAdapter(com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter) TransportDispatcher(com.linkedin.r2.transport.common.bridge.server.TransportDispatcher) CountDownLatch(java.util.concurrent.CountDownLatch) HttpClientFactory(com.linkedin.r2.transport.http.client.HttpClientFactory) TransportDispatcherBuilder(com.linkedin.r2.transport.common.bridge.server.TransportDispatcherBuilder) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

TransportDispatcher (com.linkedin.r2.transport.common.bridge.server.TransportDispatcher)20 HttpServerFactory (com.linkedin.r2.transport.http.server.HttpServerFactory)13 TransportDispatcherBuilder (com.linkedin.r2.transport.common.bridge.server.TransportDispatcherBuilder)9 TransportClientAdapter (com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter)7 RequestContext (com.linkedin.r2.message.RequestContext)6 StreamRequest (com.linkedin.r2.message.stream.StreamRequest)6 HttpClientFactory (com.linkedin.r2.transport.http.client.HttpClientFactory)6 FilterChainDispatcher (com.linkedin.r2.filter.transport.FilterChainDispatcher)5 RestRequest (com.linkedin.r2.message.rest.RestRequest)5 StreamRequestHandler (com.linkedin.r2.transport.common.StreamRequestHandler)5 HashMap (java.util.HashMap)5 BeforeClass (org.testng.annotations.BeforeClass)5 StreamResponse (com.linkedin.r2.message.stream.StreamResponse)4 TransportCallback (com.linkedin.r2.transport.common.bridge.common.TransportCallback)4 Map (java.util.Map)4 ByteString (com.linkedin.data.ByteString)3 FilterChain (com.linkedin.r2.filter.FilterChain)3 RestResponse (com.linkedin.r2.message.rest.RestResponse)3 DrainReader (com.linkedin.r2.message.stream.entitystream.DrainReader)3 DelegatingTransportDispatcher (com.linkedin.restli.server.DelegatingTransportDispatcher)3