Skip to content

Commit

Permalink
Merge changes from 8.0.0.0-1
Browse files Browse the repository at this point in the history
  • Loading branch information
zhicwu committed Oct 24, 2017
1 parent 1673329 commit 34be542
Show file tree
Hide file tree
Showing 56 changed files with 637 additions and 970 deletions.
Binary file not shown.
4 changes: 3 additions & 1 deletion pentaho-kettle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.zhicwu</groupId>
<artifactId>pdi-cluster</artifactId>
<version>7.1.0.5-SNAPSHOT</version>
<version>8.0.0.0-SNAPSHOT</version>
</parent>
<artifactId>pentaho-kettle</artifactId>
<packaging>jar</packaging>
Expand Down Expand Up @@ -55,6 +55,8 @@
<groupId>pentaho-kettle</groupId>
<artifactId>pdi-pur-plugin</artifactId>
<version>${pentaho-ce.version}</version>
<scope>system</scope>
<systemPath>${basedir}/lib/pdi-pur-plugin-core-${pentaho-ce.version}.jar</systemPath>
</dependency>
</dependencies>
<licenses>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2016 by Pentaho : http://www.pentaho.com
* Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
Expand All @@ -22,10 +22,17 @@

package org.pentaho.di.cluster;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.config.SocketConfig;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;

import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
Expand Down Expand Up @@ -62,7 +69,8 @@ public class SlaveConnectionManager {

private static SlaveConnectionManager slaveConnectionManager;

private MultiThreadedHttpConnectionManager manager;
private final PoolingHttpClientConnectionManager manager;
private final RequestConfig defaultRequestConfig;

private SlaveConnectionManager() {
if (needToInitializeSSLContext()) {
Expand All @@ -74,14 +82,19 @@ private SlaveConnectionManager() {
//log.logError( "Default SSL context hasn't been initialized", e );
}
}
manager = new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams connParams = manager.getParams();
connParams.setDefaultMaxConnectionsPerHost(KETTLE_HTTPCLIENT_MAX_CONNECTIONS_PER_HOST);
connParams.setMaxTotalConnections(KETTLE_HTTPCLIENT_MAX_CONNECTIONS);

connParams.setConnectionTimeout(KETTLE_HTTPCLIENT_CONNECTION_TIMEOUT * 1000);
connParams.setLinger(KETTLE_HTTPCLIENT_SOCKET_LINGER);
connParams.setStaleCheckingEnabled(KETTLE_HTTPCLIENT_STALE_CHECKING);

manager = new PoolingHttpClientConnectionManager();
manager.setDefaultMaxPerRoute(KETTLE_HTTPCLIENT_MAX_CONNECTIONS_PER_HOST);
manager.setMaxTotal(KETTLE_HTTPCLIENT_MAX_CONNECTIONS);

manager.setDefaultSocketConfig(
SocketConfig.custom()
.setSoTimeout(KETTLE_HTTPCLIENT_SOCKET_TIMEOUT)
.setSoLinger(KETTLE_HTTPCLIENT_SOCKET_LINGER).build());

defaultRequestConfig = RequestConfig.custom()
.setConnectTimeout(KETTLE_HTTPCLIENT_CONNECTION_MANAGER_TIMEOUT * 1000)
.build();
}

private static boolean needToInitializeSSLContext() {
Expand All @@ -96,15 +109,45 @@ public static SlaveConnectionManager getInstance() {
}

public HttpClient createHttpClient() {
HttpClient client = new HttpClient(manager);

HttpClientParams clientParams = client.getParams();
return HttpClients.custom().setConnectionManager(manager)
.setDefaultRequestConfig(defaultRequestConfig)
.build();
}

clientParams.setConnectionManagerTimeout(KETTLE_HTTPCLIENT_CONNECTION_MANAGER_TIMEOUT * 1000);
clientParams.setSoTimeout(KETTLE_HTTPCLIENT_SOCKET_TIMEOUT * 1000);
client.getHostConfiguration().getParams().setDefaults(clientParams);
public HttpClient createHttpClient(String user, String password) {
CredentialsProvider provider = new BasicCredentialsProvider();
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(user, password);
provider.setCredentials(AuthScope.ANY, credentials);

return
HttpClientBuilder
.create()
.setDefaultCredentialsProvider(provider)
.setConnectionManager(manager)
.setDefaultRequestConfig(defaultRequestConfig)
.build();
}

return client;
public HttpClient createHttpClient(String user, String password,
String proxyHost, int proxyPort, AuthScope authScope) {
HttpHost httpHost = new HttpHost(proxyHost, proxyPort);

RequestConfig requestConfig = RequestConfig.custom()
.setProxy(httpHost)
.setConnectTimeout(defaultRequestConfig.getConnectTimeout())
.build();

CredentialsProvider provider = new BasicCredentialsProvider();
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(user, password);
provider.setCredentials(authScope, credentials);

return
HttpClientBuilder
.create()
.setDefaultCredentialsProvider(provider)
.setDefaultRequestConfig(requestConfig)
.setConnectionManager(manager)
.build();
}

public void shutdown() {
Expand Down
Loading

0 comments on commit 34be542

Please sign in to comment.