public CoordinatorAdminClient(RESTClientConfig config) { this.config = config; this.httpClientFactory = new HttpClientFactory(); Map<String, String> properties = Maps.newHashMap(); properties.put(HttpClientFactory.HTTP_POOL_SIZE, Integer.toString(this.config.getMaxR2ConnectionPoolSize())); this.client = new TransportClientAdapter(httpClientFactory.getClient(properties)); }
@Override public void close() throws IOException { if (_restClient.isPresent()) { _restClient.get().shutdown(new FutureCallback<None>()); } if (_httpClientFactory.isPresent()) { _httpClientFactory.get().shutdown(new FutureCallback<None>()); } } }
private static Map<String, TransportClientFactory> createTransportClientFactories() { return ImmutableMap.<String, TransportClientFactory>builder() .put("http", new HttpClientFactory()) //It won't route to SSL port without this. .put("https", new HttpClientFactory()) .build(); } }
@Override public TransportClient getClient(Map<String, ? extends Object> properties) { SSLContext sslContext; SSLParameters sslParameters; // Copy the properties map since we don't want to mutate the passed-in map by removing keys properties = new HashMap<String,Object>(properties); sslContext = coerceAndRemoveFromMap(HTTP_SSL_CONTEXT, properties, SSLContext.class); sslParameters = coerceAndRemoveFromMap(HTTP_SSL_PARAMS, properties, SSLParameters.class); return getClient(properties, sslContext, sslParameters); }
private Client newTransportClient(Map<String, ? extends Object> properties) { Client client = new TransportClientAdapter(_clientFactory.getClient(properties)); _transportClients.add(client); return client; }
properties, sslContext); TransportClient client = getRawClient(properties, sslContext, sslParameters); EncodingType restRequestContentEncoding = getRestRequestContentEncoding(httpRequestServerSupportedEncodings); StreamEncodingType streamRequestContentEncoding = getStreamRequestContentEncoding(httpRequestServerSupportedEncodings); getRestRequestCompressionConfig(httpServiceName, restRequestContentEncoding), buildRestAcceptEncodingSchemaNames(responseEncodings), _responseCompressionConfigs.get(httpServiceName), httpResponseCompressionOperations)); CompressionConfig compressionConfig = getStreamRequestCompressionConfig(httpServiceName, streamRequestContentEncoding); filters = filters.addLast(new ClientStreamCompressionFilter(streamRequestContentEncoding, compressionConfig, buildStreamAcceptEncodingSchemas(responseEncodings), _responseCompressionConfigs.get(httpServiceName), httpResponseCompressionOperations, Integer queryPostThreshold = chooseNewOverDefault(getIntValue(properties, HTTP_QUERY_POST_THRESHOLD), DEFAULT_QUERY_POST_THRESHOLD); ClientQueryTunnelFilter clientQueryTunnelFilter = new ClientQueryTunnelFilter(queryPostThreshold); filters = filters.addLastRest(clientQueryTunnelFilter); Integer requestTimeout = chooseNewOverDefault(getIntValue(properties, HTTP_REQUEST_TIMEOUT), DEFAULT_REQUEST_TIMEOUT); DisruptFilter disruptFilter = new DisruptFilter(_executor, _eventLoopGroup, requestTimeout); filters = filters.addLastRest(disruptFilter);
private Client createHttpClient(Config config) { boolean isSSLEnabled = config.getBoolean(SSL_ENABLED); SSLContext sslContext = null; SSLParameters sslParameters = null; if (isSSLEnabled) { sslContext = SSLContextFactory.createInstance(config); sslParameters = sslContext.getDefaultSSLParameters(); } Map<String, Object> properties = new HashMap<>(); properties.put(HttpClientFactory.HTTP_SSL_CONTEXT, sslContext); properties.put(HttpClientFactory.HTTP_SSL_PARAMS, sslParameters); if (config.hasPath(PROPERTIES)) { properties.putAll(toMap(config.getConfig(PROPERTIES))); } return new R2HttpClientProxy(new HttpClientFactory(), properties); }
properties.put(HttpClientFactory.HTTP_POOL_SIZE, Integer.toString(this.config.getMaxR2ConnectionPoolSize())); transportClient = _clientFactory.getClient(properties); r2store = new R2Store(storeName, this.config.getHttpBootstrapURL(),
public JobExecutionInfoClient(String serverUri) { this.httpClientFactory = new HttpClientFactory(); Client r2Client = new TransportClientAdapter(this.httpClientFactory.getClient(Collections.<String, String>emptyMap())); this.restClient = new RestClient(r2Client, serverUri); }
public RESTClientFactory(RESTClientFactoryConfig config) { this.restClientFactoryConfig = config; this.config = new RESTClientConfig(restClientFactoryConfig.getClientConfig()); this.stats = new StoreStats("aggregate.rest-client-factory"); this.rawStoreList = new ArrayList<R2Store>(); // Create the R2 (Netty) Factory object // TODO: Add monitoring for R2 factory this._clientFactory = new HttpClientFactory(); this.RESTClientFactoryStats = new StoreClientFactoryStats(); keySerializerMap = new HashMap<String, SerializerDefinition>(); valueSerializerMap = new HashMap<String, SerializerDefinition>(); }
@Override public void close() throws IOException { if (_restClient.isPresent()) { _restClient.get().shutdown(new FutureCallback<None>()); } if (_httpClientFactory.isPresent()) { _httpClientFactory.get().shutdown(new FutureCallback<None>()); } } }
/** * Construct a {@link FlowStatusClient} to communicate with http flow status server at URI serverUri * @param serverUri address and port of the REST server */ public FlowStatusClient(String serverUri) { LOG.debug("FlowConfigClient with serverUri " + serverUri); _httpClientFactory = Optional.of(new HttpClientFactory()); Client r2Client = new TransportClientAdapter(_httpClientFactory.get().getClient(Collections.<String, String>emptyMap())); _restClient = Optional.of(new RestClient(r2Client, serverUri)); _flowstatusesRequestBuilders = new FlowstatusesRequestBuilders(); }
@BeforeClass public void init() throws Exception { _serverScheduler = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors() + 1); EngineBuilder serverEngineBuilder = new EngineBuilder(); serverEngineBuilder.setTaskExecutor(_serverScheduler).setTimerScheduler(_serverScheduler) .setPlanDeactivationListener(_batchingSupport); _serverEngine = serverEngineBuilder.build(); _server = RestLiIntTestServer.createServer(_serverEngine, _port, true, 5000, null, FilterChains.empty(), true, false, false); _server.start(); _clientFactory = new HttpClientFactory(); _transportClients = new ArrayList<>(); _restClient = createRestClient(); }
@Override public void close() throws IOException { if (_restClient.isPresent()) { _restClient.get().shutdown(new FutureCallback<None>()); } if (_httpClientFactory.isPresent()) { _httpClientFactory.get().shutdown(new FutureCallback<None>()); } } }
/** * Construct a {@link FlowConfigV2Client} to communicate with http flow config server at URI serverUri * @param serverUri address and port of the REST server */ public FlowConfigV2Client(String serverUri) { LOG.debug("FlowConfigClient with serverUri " + serverUri); _httpClientFactory = Optional.of(new HttpClientFactory()); Client r2Client = new TransportClientAdapter(_httpClientFactory.get().getClient(Collections.<String, String>emptyMap())); _restClient = Optional.of(new RestClient(r2Client, serverUri)); _flowconfigsV2RequestBuilders = new FlowconfigsV2RequestBuilders(); }
private static Map<String, TransportClientFactory> createTransportClientFactories() { return ImmutableMap.<String, TransportClientFactory>builder() .put("http", new HttpClientFactory()) //It won't route to SSL port without this. .put("https", new HttpClientFactory()) .build(); } }
@Override public void close() throws IOException { this.restClient.shutdown(new FutureCallback<None>()); this.httpClientFactory.shutdown(new FutureCallback<None>()); } }
/** * Construct a {@link FlowConfigClient} to communicate with http flow config server at URI serverUri * @param serverUri address and port of the REST server */ public FlowConfigClient(String serverUri) { LOG.debug("FlowConfigClient with serverUri " + serverUri); _httpClientFactory = Optional.of(new HttpClientFactory()); Client r2Client = new TransportClientAdapter(_httpClientFactory.get().getClient(Collections.<String, String>emptyMap())); _restClient = Optional.of(new RestClient(r2Client, serverUri)); _flowconfigsRequestBuilders = new FlowconfigsRequestBuilders(); }
private Client createHttpClient(Config config) { boolean isSSLEnabled = config.getBoolean(SSL_ENABLED); SSLContext sslContext = null; SSLParameters sslParameters = null; if (isSSLEnabled) { sslContext = SSLContextFactory.createInstance(config); sslParameters = sslContext.getDefaultSSLParameters(); } Map<String, Object> properties = new HashMap<>(); properties.put(HttpClientFactory.HTTP_SSL_CONTEXT, sslContext); properties.put(HttpClientFactory.HTTP_SSL_PARAMS, sslParameters); if (config.hasPath(PROPERTIES)) { properties.putAll(toMap(config.getConfig(PROPERTIES))); } return new R2HttpClientProxy(new HttpClientFactory(), properties); }
this._clientFactory.shutdown(factoryShutdownCallback, SHUTDOWN_TIMEOUT, TimeUnit.SECONDS); try { factoryShutdownCallback.get();