use of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter in project rest.li by linkedin.
the class PerfClients method httpPureStream.
public static PerfClient httpPureStream(URI uri, int numThreads, int numMsgs, int msgSize, int numHeaders, int headerSize) {
final TransportClient transportClient = FACTORY.getClient(Collections.<String, String>emptyMap());
final Client client = new TransportClientAdapter(transportClient, true);
final Generator<StreamRequest> reqGen = new StreamRequestGenerator(uri, numMsgs, msgSize, numHeaders, headerSize);
final ClientRunnableFactory crf = new StreamClientRunnableFactory(client, reqGen);
return new FactoryClient(crf, numThreads);
}
use of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter in project rest.li by linkedin.
the class SimpleLoadBalancerStrawMan method main.
public static void main(String[] args) throws URISyntaxException, ServiceUnavailableException {
// define the load balancing strategies that we support (round robin, etc)
Map<String, LoadBalancerStrategyFactory<? extends LoadBalancerStrategy>> loadBalancerStrategyFactories = new HashMap<String, LoadBalancerStrategyFactory<? extends LoadBalancerStrategy>>();
loadBalancerStrategyFactories.put("rr", new RandomLoadBalancerStrategyFactory());
loadBalancerStrategyFactories.put("degrader", new DegraderLoadBalancerStrategyFactoryV3());
// define the clients that we support (http, etc)
Map<String, TransportClientFactory> clientFactories = new HashMap<String, TransportClientFactory>();
clientFactories.put("http", new HttpClientFactory());
// listen for service updates (could be a glu discovery client, zk discovery client,
// config discovery client, etc)
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
MockStore<ServiceProperties> serviceRegistry = new MockStore<ServiceProperties>();
MockStore<ClusterProperties> clusterRegistry = new MockStore<ClusterProperties>();
MockStore<UriProperties> uriRegistry = new MockStore<UriProperties>();
SimpleLoadBalancerState state = new SimpleLoadBalancerState(executorService, uriRegistry, clusterRegistry, serviceRegistry, clientFactories, loadBalancerStrategyFactories);
// create the load balancer
SimpleLoadBalancer loadBalancer = new SimpleLoadBalancer(state);
final TransportClient tc = loadBalancer.getClient(new URIRequest("d2://browsemaps/52"), new RequestContext());
final Client c = new TransportClientAdapter(tc, true);
c.restRequest(null);
}
use of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter 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();
}
use of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter in project rest.li by linkedin.
the class AbstractStreamTest method setup.
@BeforeClass
public void setup() throws IOException {
_scheduler = Executors.newSingleThreadScheduledExecutor();
_clientFactory = getClientFactory();
_http1Client = new TransportClientAdapter(_clientFactory.getClient(getHttp1ClientProperties()), true);
_http2Client = new TransportClientAdapter(_clientFactory.getClient(getHttp2ClientProperties()), true);
_server = getServerFactory().createH2cServer(PORT, getTransportDispatcher(), true);
_server.start();
}
use of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter in project rest.li by linkedin.
the class TestChannelPoolBehavior method setup.
@BeforeClass
public void setup() throws IOException {
_scheduler = Executors.newSingleThreadScheduledExecutor();
_clientFactory = new HttpClientFactory();
_client1 = new TransportClientAdapter(_clientFactory.getClient(getClientProperties()), true);
_client2 = new TransportClientAdapter(_clientFactory.getClient(getClientProperties()), true);
_server = new HttpServerFactory().createServer(PORT, getTransportDispatcher(), true);
_server.start();
}
Aggregations