use of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter in project rest.li by linkedin.
the class TestRequestCompression method requestCompressionData.
@DataProvider
public Object[][] requestCompressionData() {
StreamEncodingType[] encodings = new StreamEncodingType[] { StreamEncodingType.GZIP, StreamEncodingType.DEFLATE, StreamEncodingType.SNAPPY_FRAMED, StreamEncodingType.BZIP2 };
String[] protocols = new String[] { HttpProtocolVersion.HTTP_1_1.name(), HttpProtocolVersion.HTTP_2.name() };
Object[][] args = new Object[encodings.length * protocols.length][2];
int cur = 0;
for (StreamEncodingType requestEncoding : encodings) {
for (String protocol : protocols) {
StreamFilter clientCompressionFilter = new ClientStreamCompressionFilter(requestEncoding, new CompressionConfig(THRESHOLD), null, new CompressionConfig(THRESHOLD), Arrays.asList(new String[] { "*" }), _executor);
TransportClientFactory factory = new HttpClientFactory.Builder().setFilterChain(FilterChains.createStreamChain(clientCompressionFilter)).build();
HashMap<String, String> properties = new HashMap<>();
properties.put(HttpClientFactory.HTTP_PROTOCOL_VERSION, protocol);
Client client = new TransportClientAdapter(factory.getClient(properties), true);
args[cur][0] = client;
args[cur][1] = URI.create("/" + requestEncoding.getHttpName());
cur++;
_clientFactories.add(factory);
_clients.add(client);
}
}
return args;
}
use of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter in project rest.li by linkedin.
the class TestHttpClient method configs.
@DataProvider
public Object[][] configs() {
Map<String, String> http1ClientProperties = new HashMap<>();
http1ClientProperties.put(HttpClientFactory.HTTP_PROTOCOL_VERSION, HttpProtocolVersion.HTTP_1_1.name());
http1ClientProperties.put(HttpClientFactory.HTTP_REQUEST_TIMEOUT, Integer.toString(REQUEST_TIMEOUT));
Map<String, String> http2ClientProperties = new HashMap<>();
http2ClientProperties.put(HttpClientFactory.HTTP_PROTOCOL_VERSION, HttpProtocolVersion.HTTP_2.name());
http2ClientProperties.put(HttpClientFactory.HTTP_REQUEST_TIMEOUT, Integer.toString(REQUEST_TIMEOUT));
TransportDispatcher dispatcher = new TransportDispatcherBuilder().addRestHandler(DISPATCHER_URI, new EchoHandler()).build();
return new Object[][] { { new HttpServerFactory().createH2cServer(PORT, dispatcher, REST_OVER_STREAM), new TransportClientAdapter(_clientFactory.getClient(http1ClientProperties), REST_OVER_STREAM) }, { new HttpServerFactory().createH2cServer(PORT, dispatcher, REST_OVER_STREAM), new TransportClientAdapter(_clientFactory.getClient(http2ClientProperties), REST_OVER_STREAM) }, { new HttpServerFactory().createH2cServer(PORT, dispatcher, NOT_REST_OVER_STREAM), new TransportClientAdapter(_clientFactory.getClient(http1ClientProperties), NOT_REST_OVER_STREAM) }, { new HttpServerFactory().createH2cServer(PORT, dispatcher, NOT_REST_OVER_STREAM), new TransportClientAdapter(_clientFactory.getClient(http2ClientProperties), NOT_REST_OVER_STREAM) } };
}
use of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter in project rest.li by linkedin.
the class PerfClients method httpRest.
public static PerfClient httpRest(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, PerfConfig.clientRestOverStream());
final Generator<RestRequest> reqGen = new RestRequestGenerator(uri, numMsgs, msgSize, numHeaders, headerSize);
final ClientRunnableFactory crf = new RestClientRunnableFactory(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 Bootstrap method createHttpClient.
public static Client createHttpClient(FilterChain filters, boolean restOverStream) {
HashMap<String, String> properties = new HashMap<>();
properties.put(HttpClientFactory.HTTP_PROTOCOL_VERSION, HttpProtocolVersion.HTTP_1_1.name());
final TransportClient client = new HttpClientFactory.Builder().setFilterChain(filters).build().getClient(properties);
return new TransportClientAdapter(client, restOverStream);
}
use of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter in project rest.li by linkedin.
the class RestLiIntegrationTest method newTransportClient.
/**
* Creates a {@link com.linkedin.r2.transport.common.bridge.client.TransportClient}
* with the given properties. The lifecycle of this client is governed by
* {@link RestLiIntegrationTest}.
*
* @param properties Transport client properties.
*/
protected Client newTransportClient(Map<String, ? extends Object> properties) {
Client client = new TransportClientAdapter(_clientFactory.getClient(properties));
_transportClients.add(client);
return client;
}
Aggregations