use of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter in project parseq by linkedin.
the class ParSeqRestClientIntegrationTest method newTransportClient.
private Client newTransportClient(Map<String, ? extends Object> properties) {
Client client = new TransportClientAdapter(_clientFactory.getClient(properties));
_transportClients.add(client);
return client;
}
use of com.linkedin.r2.transport.common.bridge.client.TransportClientAdapter in project incubator-gobblin by apache.
the class SharedRestClientFactory method createResource.
@Override
public SharedResourceFactoryResponse<RestClient> createResource(SharedResourcesBroker<S> broker, ScopedConfigView<S, SharedRestClientKey> config) throws NotConfiguredException {
try {
SharedRestClientKey key = config.getKey();
if (!(key instanceof UriRestClientKey)) {
return new ResourceCoordinate<>(this, new UriRestClientKey(key.serviceName, resolveUriPrefix(config.getConfig(), key)), config.getScope());
}
String uriPrefix = ((UriRestClientKey) key).getUri();
log.info(String.format("Creating a brand new rest client for service name %s and uri prefix %s", key.serviceName, uriPrefix));
HttpClientFactory http = new HttpClientFactory(FilterChains.empty(), new NioEventLoopGroup(0, /* use default settings */
ExecutorsUtils.newDaemonThreadFactory(Optional.<Logger>absent(), Optional.of("R2 Nio Event Loop-%d"))), true, Executors.newSingleThreadScheduledExecutor(ExecutorsUtils.newDaemonThreadFactory(Optional.<Logger>absent(), Optional.of("R2 Netty Scheduler"))), true);
Properties props = ConfigUtils.configToProperties(config.getConfig());
if (!props.containsKey(HttpClientFactory.HTTP_REQUEST_TIMEOUT)) {
// Rest.li changed the default timeout from 10s to 1s. Since some clients (e.g. throttling) relied on the longer
// timeout, override this property uless set by the user explicitly
props.setProperty(HttpClientFactory.HTTP_REQUEST_TIMEOUT, "10000");
}
Client r2Client = new TransportClientAdapter(http.getClient(Maps.fromProperties(props)));
return new ResourceInstance<>(new RestClient(r2Client, uriPrefix));
} catch (URISyntaxException use) {
throw new RuntimeException("Could not create a rest client for key " + Optional.fromNullable(config.getKey().toConfigurationKey()).or("null"));
}
}
Aggregations