Search in sources :

Example 11 with TransportDispatcher

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

the class LoadBalancerEchoServer method startServer.

public void startServer() throws IOException, InterruptedException, URISyntaxException {
    final RestDispatcher restDispatcher = new RestDispatcher();
    final TransportDispatcherBuilder dispatcherBuilder = new TransportDispatcherBuilder();
    for (String validPath : _validPaths) {
        dispatcherBuilder.addRestHandler(URI.create(validPath), restDispatcher);
    }
    final TransportDispatcher dispatcher = dispatcherBuilder.build();
    // start the server
    if (_scheme.equals("http")) {
        _server = getHttpServer(dispatcher);
    }
    _server.start();
}
Also used : TransportDispatcher(com.linkedin.r2.transport.common.bridge.server.TransportDispatcher) TransportDispatcherBuilder(com.linkedin.r2.transport.common.bridge.server.TransportDispatcherBuilder)

Example 12 with TransportDispatcher

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

the class HttpServerFactory method createServer.

public HttpServer createServer(int port, String contextPath, int threadPoolSize, TransportDispatcher transportDispatcher, HttpJettyServer.ServletType servletType, int asyncTimeOut, boolean restOverStream) {
    final TransportDispatcher filterDispatcher = new FilterChainDispatcher(transportDispatcher, _filters);
    final HttpDispatcher dispatcher = new HttpDispatcher(filterDispatcher);
    return new HttpJettyServer(port, contextPath, threadPoolSize, dispatcher, servletType, asyncTimeOut, restOverStream);
}
Also used : FilterChainDispatcher(com.linkedin.r2.filter.transport.FilterChainDispatcher) TransportDispatcher(com.linkedin.r2.transport.common.bridge.server.TransportDispatcher)

Example 13 with TransportDispatcher

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

the class HttpServerFactory method createRAPServer.

public HttpServer createRAPServer(int port, TransportDispatcher transportDispatcher, int timeout, boolean restOverStream) {
    final TransportDispatcher filterDispatcher = new FilterChainDispatcher(transportDispatcher, _filters);
    HttpServlet httpServlet = restOverStream ? new RAPStreamServlet(filterDispatcher, timeout) : new RAPServlet(filterDispatcher);
    return new HttpJettyServer(port, httpServlet);
}
Also used : FilterChainDispatcher(com.linkedin.r2.filter.transport.FilterChainDispatcher) HttpServlet(javax.servlet.http.HttpServlet) TransportDispatcher(com.linkedin.r2.transport.common.bridge.server.TransportDispatcher)

Example 14 with TransportDispatcher

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

the class HttpNettyServerFactory method createServer.

public HttpServer createServer(int port, int threadPoolSize, TransportDispatcher transportDispatcher) {
    final TransportDispatcher filterDispatcher = new FilterChainDispatcher(transportDispatcher, _filters);
    final HttpDispatcher dispatcher = new HttpDispatcher(filterDispatcher);
    return new HttpNettyServer(port, threadPoolSize, dispatcher);
}
Also used : FilterChainDispatcher(com.linkedin.r2.filter.transport.FilterChainDispatcher) TransportDispatcher(com.linkedin.r2.transport.common.bridge.server.TransportDispatcher)

Example 15 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