use of org.apache.tez.http.SSLFactory in project tez by apache.
the class AsyncHttpConnection method initClient.
private void initClient(HttpConnectionParams httpConnParams) throws IOException {
if (httpAsyncClient != null) {
return;
}
if (httpAsyncClient == null) {
synchronized (AsyncHttpConnection.class) {
if (httpAsyncClient == null) {
LOG.info("Initializing AsyncClient (TezBodyDeferringAsyncHandler)");
AsyncHttpClientConfig.Builder builder = new AsyncHttpClientConfig.Builder();
if (httpConnParams.isSslShuffle()) {
// Configure SSL
SSLFactory sslFactory = httpConnParams.getSslFactory();
Preconditions.checkArgument(sslFactory != null, "SSLFactory can not be null");
sslFactory.configure(builder);
}
/**
* TODO : following settings need fine tuning.
* Change following config to accept common thread pool later.
* Change max connections based on the total inputs (ordered & unordered). Need to tune
* setMaxConnections & addRequestFilter.
*/
builder.setAllowPoolingConnection(httpConnParams.isKeepAlive()).setAllowSslConnectionPool(httpConnParams.isKeepAlive()).setCompressionEnabled(false).setMaximumConnectionsPerHost(1).setConnectionTimeoutInMs(httpConnParams.getConnectionTimeout()).setRequestTimeoutInMs(httpConnParams.getReadTimeout()).setUseRawUrl(true).build();
httpAsyncClient = new AsyncHttpClient(builder.build());
}
}
}
}
use of org.apache.tez.http.SSLFactory in project tez by apache.
the class TezRuntimeUtils method getHttpConnectionParams.
public static HttpConnectionParams getHttpConnectionParams(Configuration conf) {
int connectionTimeout = conf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_CONNECT_TIMEOUT, TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_STALLED_COPY_TIMEOUT_DEFAULT);
int readTimeout = conf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_READ_TIMEOUT, TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_READ_TIMEOUT_DEFAULT);
int bufferSize = conf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_BUFFER_SIZE, TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_BUFFER_SIZE_DEFAULT);
boolean keepAlive = conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_KEEP_ALIVE_ENABLED, TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_KEEP_ALIVE_ENABLED_DEFAULT);
int keepAliveMaxConnections = conf.getInt(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_KEEP_ALIVE_MAX_CONNECTIONS, TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_KEEP_ALIVE_MAX_CONNECTIONS_DEFAULT);
if (keepAlive) {
System.setProperty("sun.net.http.errorstream.enableBuffering", "true");
System.setProperty("http.maxConnections", String.valueOf(keepAliveMaxConnections));
}
boolean sslShuffle = conf.getBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_ENABLE_SSL, TezRuntimeConfiguration.TEZ_RUNTIME_SHUFFLE_ENABLE_SSL_DEFAULT);
if (sslShuffle) {
if (sslFactory == null) {
synchronized (HttpConnectionParams.class) {
// Create sslFactory if it is null or if it was destroyed earlier
if (sslFactory == null || sslFactory.getKeystoresFactory().getTrustManagers() == null) {
sslFactory = new SSLFactory(org.apache.hadoop.security.ssl.SSLFactory.Mode.CLIENT, conf);
try {
sslFactory.init();
} catch (Exception ex) {
sslFactory.destroy();
sslFactory = null;
throw new RuntimeException(ex);
}
}
}
}
}
HttpConnectionParams httpConnParams = new HttpConnectionParams(keepAlive, keepAliveMaxConnections, connectionTimeout, readTimeout, bufferSize, sslShuffle, sslFactory);
return httpConnParams;
}
Aggregations