You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@knox.apache.org by chris snow <ch...@gmail.com> on 2016/04/13 11:18:54 UTC

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

Re: How to access the HTTPClient object?

Posted by Kevin Minder <ke...@hortonworks.com>.
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 <ch...@gmail.com>>
Reply-To: "user@knox.apache.org<ma...@knox.apache.org>" <us...@knox.apache.org>>
Date: Wednesday, April 13, 2016 at 5:18 AM
To: "user@knox.apache.org<ma...@knox.apache.org>" <us...@knox.apache.org>>
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