[ 
https://issues.apache.org/jira/browse/AMBARI-25538?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Junseok updated AMBARI-25538:
-----------------------------
    Description: 
There is Problem that the Proxy Setting doesn't work in Ambari-server 2.7.5 
even if pass system properties(-Dhttp.proxyHost and -Dhttp.proxyPort).

I find the reason. During URLRedirectProvider.buildHttpClient() build 
httpClient, no code inherited java system properties relevant HTTP.

The ambari 2.7.4 is fine. Since ambari 2.7.4 use *HttpURLConnection* to load 
VDF.XML, the proxy property (http.proxyHost, http.proxyPort) is passed for HTTP 
Request and It is fine.

Here is sample code to be inherited system properties when build httpClient.
{code:java}
public static String executeGet(String spec, boolean useSystemProperty) throws 
Exception {
   CloseableHttpClient httpClient = useSystemProperty ?
         builder.useSystemProperties().build() : 
HttpClientBuilder.create().build();

   HttpGet httpGet = new HttpGet(spec);
   CloseableHttpResponse response = httpClient.execute(httpGet);

   final InputStream is = response.getEntity().getContent();
   return IOUtils.toString(is, StandardCharsets.UTF_8);
}
{code}

  was:
There is Problem that the Proxy Setting doesn't work in Ambari-server 2.7.5 
even if pass system properties -Dhttp.proxyHost and -Dhttp.proxyPort.

I find the reason. During URLRedirectProvider.buildHttpClient() build 
httpClient, no code inherited java system properties relevant HTTP.

The ambari 2.7.4 is fine. Since ambari 2.7.4 use *HttpURLConnection* to load 
VDF.XML, the proxy property (http.proxyHost, http.proxyPort) is passed for HTTP 
Request and It is fine.

Here is sample code to be inherited system properties when build httpClient.
{code:java}
public static String executeGet(String spec, boolean useSystemProperty) throws 
Exception {
   CloseableHttpClient httpClient = useSystemProperty ?
         builder.useSystemProperties().build() : 
HttpClientBuilder.create().build();

   HttpGet httpGet = new HttpGet(spec);
   CloseableHttpResponse response = httpClient.execute(httpGet);

   final InputStream is = response.getEntity().getContent();
   return IOUtils.toString(is, StandardCharsets.UTF_8);
}
{code}


> Property -Dhttp.proxyHost doesn't work when install HDP.
> --------------------------------------------------------
>
>                 Key: AMBARI-25538
>                 URL: https://issues.apache.org/jira/browse/AMBARI-25538
>             Project: Ambari
>          Issue Type: Bug
>          Components: ambari-sever
>    Affects Versions: 2.7.5
>            Reporter: Junseok
>            Priority: Major
>             Fix For: 2.7.4
>
>
> There is Problem that the Proxy Setting doesn't work in Ambari-server 2.7.5 
> even if pass system properties(-Dhttp.proxyHost and -Dhttp.proxyPort).
> I find the reason. During URLRedirectProvider.buildHttpClient() build 
> httpClient, no code inherited java system properties relevant HTTP.
> The ambari 2.7.4 is fine. Since ambari 2.7.4 use *HttpURLConnection* to load 
> VDF.XML, the proxy property (http.proxyHost, http.proxyPort) is passed for 
> HTTP Request and It is fine.
> Here is sample code to be inherited system properties when build httpClient.
> {code:java}
> public static String executeGet(String spec, boolean useSystemProperty) 
> throws Exception {
>    CloseableHttpClient httpClient = useSystemProperty ?
>          builder.useSystemProperties().build() : 
> HttpClientBuilder.create().build();
>    HttpGet httpGet = new HttpGet(spec);
>    CloseableHttpResponse response = httpClient.execute(httpGet);
>    final InputStream is = response.getEntity().getContent();
>    return IOUtils.toString(is, StandardCharsets.UTF_8);
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to