Unfortunately it doesn't look like The org.apache.hadoop.gateway.shell.Hadoop 
class is setup in such a way to provide access to the internal HttpClient to 
provide the access you need.  You also might want to take a look at 
https://issues.apache.org/jira/browse/KNOX-695 which is more of a server side 
solution to the problem.  If I were going to try and make an enhancement to 
support this I can think of several approaches.

  1.  Change the Hadoop class to take a HttpClient object as an input parameter 
to the constructor.
  2.  Change the Hadoop class to make createClient protected so subclasses 
could customize the client.
  3.  Extend AbstractRequest with a socketTimeout attribute and have the 
various concrete implementations do request.setConfig(requestConfig) where 
requestConfig is something like RequestConfig requestConfig = 
RequestConfig.custom().setSocketTimeout(TIMEOUT_MILLIS).build(); from the 
HttpClient API.  This would be done just prior to the "return new Response( 
execute( request ) );" found in most of those concrete implementations.

From: chris snow <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Date: Wednesday, April 13, 2016 at 5:18 AM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: How to access the HTTPClient object?

I have a basic connectivity test for hbase:

   env = System.getenv()
   session = Hadoop.login( env.gateway, env.username, env.password )

   println "System version : " + 
HBase.session(session).systemVersion().now().string
   println "Cluster version : " + 
HBase.session(session).clusterVersion().now().string
   println "Status : " + HBase.session(session).status().now().string

However, there is an issue on the server that is causing the connection to 
hang.  Is it possible to get access to the HTTPClient object so that I can set 
a timeout?

E.g.

   session = Hadoop.login( env.gateway, env.username, env.password )
   session.httpClient.params.setConnectionTimeout(10000)


Many thanks,

Chris

Reply via email to