Compare commits

...

1 Commits

Author SHA1 Message Date
hwang
6fca3781a3 bugfix(TUP-24076):Unresponsive Nexus blocks Studio during remote
connection start-up
2019-10-16 11:45:37 +08:00
11 changed files with 145 additions and 1 deletions

View File

@@ -63,6 +63,7 @@ import org.talend.designer.components.exchange.model.ExchangePackage;
import org.talend.designer.components.exchange.model.RevisionInfo;
import org.talend.designer.components.exchange.model.VersionRevision;
import org.talend.repository.ProjectManager;
import org.talend.utils.thread.TimeoutManager;
/**
* DOC hcyi class global comment. Detailled comment
@@ -149,6 +150,16 @@ public class ExchangeUtils {
public static String sendGetRequest(String urlAddress) throws Exception {
HttpClient httpclient = new HttpClient();
if(TimeoutManager.getSocketTimeout() != null) {
httpclient.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
httpclient.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
GetMethod getMethod = new GetMethod(urlAddress);
TransportClientProperties tcp = TransportClientPropertiesFactory.create("http");
if (tcp.getProxyHost().length() != 0) {
@@ -169,6 +180,14 @@ public class ExchangeUtils {
public static String sendPostRequest(String urlAddress, Map<String, String> parameters) throws Exception {
HttpClient httpclient = new HttpClient();
if(TimeoutManager.getSocketTimeout() != null) {
httpclient.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
httpclient.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
PostMethod postMethod = new PostMethod(urlAddress);
if (parameters != null) {
NameValuePair[] postData = new NameValuePair[parameters.size()];

View File

@@ -71,12 +71,28 @@ public class RestClient {
public RestClient() {
PoolingClientConnectionManager conMan = getConnectionManager();
httpClient = new DefaultHttpClient(conMan);
if(TimeoutManager.getSocketTimeout() != null) {
httpclient.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
httpclient.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
this.bonitaURI = BONITA_URI;
}
public RestClient(String bonitaURI) {
PoolingClientConnectionManager conMan = getConnectionManager();
httpClient = new DefaultHttpClient(conMan);
if(TimeoutManager.getSocketTimeout() != null) {
httpclient.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
httpclient.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
this.bonitaURI = bonitaURI;
}

View File

@@ -26,6 +26,16 @@ public class MDMTransaction {
public void commit() throws IOException {
HttpClient client = new HttpClient();
if(TimeoutManager.getSocketTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
HttpMethod method = new PostMethod(url + "/" + id);
@@ -51,6 +61,16 @@ public class MDMTransaction {
public void rollback() throws IOException {
HttpClient client = new HttpClient();
if(TimeoutManager.getSocketTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
HttpMethod method = new DeleteMethod(url + "/" + id);

View File

@@ -18,6 +18,16 @@ public class MDMTransactionClient {
public static MDMTransaction newTransaction(String url, String username, String password) throws IOException {
HttpClient client = new HttpClient();
if(TimeoutManager.getSocketTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
client.getParams().setAuthenticationPreemptive(true);
@@ -78,6 +88,15 @@ public class MDMTransactionClient {
HttpClient client = new HttpClient();
client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
client.getParams().setAuthenticationPreemptive(true);
if(TimeoutManager.getSocketTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
GetMethod get = new GetMethod(url);
get.setDoAuthentication(true);

View File

@@ -142,6 +142,14 @@ public class paloconnection {
ClientConnectionManager connMgr = new ThreadSafeClientConnManager(params, supportedSchemes);
paloHttpClient = new DefaultHttpClient(connMgr, params);
if(TimeoutManager.getSocketTimeout() != null) {
paloHttpClient.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
paloHttpClient.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
}
private void pingPaloServer() {

View File

@@ -37,6 +37,15 @@ public class Util {
new org.apache.http.auth.AuthScope(new org.apache.http.HttpHost("sandbox.service-now.com")), new org.apache.http.auth.UsernamePasswordCredentials("talend", "talend")
);
client = org.apache.http.impl.client.HttpClients.custom().setDefaultCredentialsProvider(credsProvider).build();
if(TimeoutManager.getSocketTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
//get metadata
Util util = new Util(client,"https://sandbox.service-now.com");

View File

@@ -181,7 +181,14 @@ public final class DeviceIdManager {
params.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 180000);
HttpClient client = new SystemDefaultHttpClient(params);
if(TimeoutManager.getSocketTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
// Uncomment following lines to view the traffic in fiddler.
// HttpHost proxy = new HttpHost("localhost", 8888);
// client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);

View File

@@ -140,6 +140,15 @@ public class WSDLLocatorImpl implements WSDLLocator {
httpClient.getState().setProxyCredentials(AuthScope.ANY, credentials);
httpClient.getHostConfiguration().setProxy(configuration.getProxyServer(), configuration.getProxyPort());
}
if(TimeoutManager.getSocketTimeout() != null) {
httpclient.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
httpclient.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
return httpClient;
}
}

View File

@@ -18,6 +18,7 @@ import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.GetMethod;
import org.talend.utils.thread.TimeoutManager;
import org.xml.sax.InputSource;
public class WSDLLocatorImpl implements WSDLLocator {
@@ -133,6 +134,14 @@ public class WSDLLocatorImpl implements WSDLLocator {
httpClient.getState().setProxyCredentials(AuthScope.ANY, credentials);
httpClient.getHostConfiguration().setProxy(configuration.getProxyServer(), configuration.getProxyPort());
}
if(TimeoutManager.getSocketTimeout() != null) {
httpClient.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
httpClient.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
return httpClient;
}
}

View File

@@ -34,6 +34,7 @@ import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.talend.sbi.engines.client.i18n.Messages;
import org.talend.utils.thread.TimeoutManager;
/**
* @author Andrea Gioia
@@ -98,6 +99,14 @@ public class SpagoBITalendEngineClient implements ISpagoBITalendEngineClient {
version = null;
client = new HttpClient();
if(TimeoutManager.getSocketTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
method = new PostMethod(url);
// Provide custom retry handler is necessary

View File

@@ -37,6 +37,7 @@ import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
import org.apache.commons.httpclient.methods.multipart.Part;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.talend.sbi.engines.client.i18n.Messages;
import org.talend.utils.thread.TimeoutManager;
/**
* @author Andrea Gioia
@@ -108,6 +109,16 @@ class SpagoBITalendEngineClient_0_5_0 implements ISpagoBITalendEngineClient {
version = null;
client = new HttpClient();
if(TimeoutManager.getSocketTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
method = new PostMethod(getServiceUrl(ENGINE_INFO_SERVICE));
// Provide custom retry handler is necessary
@@ -156,6 +167,14 @@ class SpagoBITalendEngineClient_0_5_0 implements ISpagoBITalendEngineClient {
boolean result = false;
client = new HttpClient();
if(TimeoutManager.getSocketTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.SOCKET_TIMEOUT,
TimeoutManager.getSocketTimeout());
}
if(TimeoutManager.getConnectionTimeout() != null) {
client.getParams().setIntParameter(TimeoutManager.CONNECTION_TIMEOUT,
TimeoutManager.getConnectionTimeout());
}
method = new PostMethod(getServiceUrl(JOB_UPLOAD_SERVICE));
deploymentDescriptorFile = null;