org.apache.hadoop.hbase.rest.client
Class Client

java.lang.Object
  extended by org.apache.hadoop.hbase.rest.client.Client

public class Client
extends java.lang.Object

A wrapper around HttpClient which provides some useful function and semantics for interacting with the REST gateway.


Field Summary
static org.apache.commons.httpclient.Header[] EMPTY_HEADER_ARRAY
           
 
Constructor Summary
Client()
          Default Constructor
Client(Cluster cluster)
          Constructor
 
Method Summary
 Response delete(Cluster cluster, java.lang.String path)
          Send a DELETE request
 Response delete(java.lang.String path)
          Send a DELETE request
 int execute(Cluster cluster, org.apache.commons.httpclient.HttpMethod method, org.apache.commons.httpclient.Header[] headers, java.lang.String path)
          Execute a transaction method.
 int executePathOnly(Cluster cluster, org.apache.commons.httpclient.HttpMethod method, org.apache.commons.httpclient.Header[] headers, java.lang.String path)
          Execute a transaction method given only the path.
 int executeURI(org.apache.commons.httpclient.HttpMethod method, org.apache.commons.httpclient.Header[] headers, java.lang.String uri)
          Execute a transaction method given a complete URI.
 Response get(Cluster cluster, java.lang.String path)
          Send a GET request
 Response get(Cluster c, java.lang.String path, org.apache.commons.httpclient.Header[] headers)
          Send a GET request
 Response get(Cluster cluster, java.lang.String path, java.lang.String accept)
          Send a GET request
 Response get(java.lang.String path)
          Send a GET request
 Response get(java.lang.String path, org.apache.commons.httpclient.Header[] headers)
          Send a GET request
 Response get(java.lang.String path, java.lang.String accept)
          Send a GET request
 Cluster getCluster()
           
 Response head(Cluster cluster, java.lang.String path, org.apache.commons.httpclient.Header[] headers)
          Send a HEAD request
 Response head(java.lang.String path)
          Send a HEAD request
 Response post(Cluster cluster, java.lang.String path, org.apache.commons.httpclient.Header[] headers, byte[] content)
          Send a POST request
 Response post(Cluster cluster, java.lang.String path, java.lang.String contentType, byte[] content)
          Send a POST request
 Response post(java.lang.String path, org.apache.commons.httpclient.Header[] headers, byte[] content)
          Send a POST request
 Response post(java.lang.String path, java.lang.String contentType, byte[] content)
          Send a POST request
 Response put(Cluster cluster, java.lang.String path, org.apache.commons.httpclient.Header[] headers, byte[] content)
          Send a PUT request
 Response put(Cluster cluster, java.lang.String path, java.lang.String contentType, byte[] content)
          Send a PUT request
 Response put(java.lang.String path, org.apache.commons.httpclient.Header[] headers, byte[] content)
          Send a PUT request
 Response put(java.lang.String path, java.lang.String contentType, byte[] content)
          Send a PUT request
 void setCluster(Cluster cluster)
           
 void shutdown()
          Shut down the client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_HEADER_ARRAY

public static final org.apache.commons.httpclient.Header[] EMPTY_HEADER_ARRAY
Constructor Detail

Client

public Client()
Default Constructor


Client

public Client(Cluster cluster)
Constructor

Parameters:
cluster - the cluster definition
Method Detail

shutdown

public void shutdown()
Shut down the client. Close any open persistent connections.


executePathOnly

public int executePathOnly(Cluster cluster,
                           org.apache.commons.httpclient.HttpMethod method,
                           org.apache.commons.httpclient.Header[] headers,
                           java.lang.String path)
                    throws java.io.IOException
Execute a transaction method given only the path. Will select at random one of the members of the supplied cluster definition and iterate through the list until a transaction can be successfully completed. The definition of success here is a complete HTTP transaction, irrespective of result code.

Parameters:
cluster - the cluster definition
method - the transaction method
headers - HTTP header values to send
path - the properly urlencoded path
Returns:
the HTTP response code
Throws:
java.io.IOException

executeURI

public int executeURI(org.apache.commons.httpclient.HttpMethod method,
                      org.apache.commons.httpclient.Header[] headers,
                      java.lang.String uri)
               throws java.io.IOException
Execute a transaction method given a complete URI.

Parameters:
method - the transaction method
headers - HTTP header values to send
uri - a properly urlencoded URI
Returns:
the HTTP response code
Throws:
java.io.IOException

execute

public int execute(Cluster cluster,
                   org.apache.commons.httpclient.HttpMethod method,
                   org.apache.commons.httpclient.Header[] headers,
                   java.lang.String path)
            throws java.io.IOException
Execute a transaction method. Will call either executePathOnly or executeURI depending on whether a path only is supplied in 'path', or if a complete URI is passed instead, respectively.

Parameters:
cluster - the cluster definition
method - the HTTP method
headers - HTTP header values to send
path - the properly urlencoded path or URI
Returns:
the HTTP response code
Throws:
java.io.IOException

getCluster

public Cluster getCluster()
Returns:
the cluster definition

setCluster

public void setCluster(Cluster cluster)
Parameters:
cluster - the cluster definition

head

public Response head(java.lang.String path)
              throws java.io.IOException
Send a HEAD request

Parameters:
path - the path or URI
Returns:
a Response object with response detail
Throws:
java.io.IOException

head

public Response head(Cluster cluster,
                     java.lang.String path,
                     org.apache.commons.httpclient.Header[] headers)
              throws java.io.IOException
Send a HEAD request

Parameters:
cluster - the cluster definition
path - the path or URI
headers - the HTTP headers to include in the request
Returns:
a Response object with response detail
Throws:
java.io.IOException

get

public Response get(java.lang.String path)
             throws java.io.IOException
Send a GET request

Parameters:
path - the path or URI
Returns:
a Response object with response detail
Throws:
java.io.IOException

get

public Response get(Cluster cluster,
                    java.lang.String path)
             throws java.io.IOException
Send a GET request

Parameters:
cluster - the cluster definition
path - the path or URI
Returns:
a Response object with response detail
Throws:
java.io.IOException

get

public Response get(java.lang.String path,
                    java.lang.String accept)
             throws java.io.IOException
Send a GET request

Parameters:
path - the path or URI
accept - Accept header value
Returns:
a Response object with response detail
Throws:
java.io.IOException

get

public Response get(Cluster cluster,
                    java.lang.String path,
                    java.lang.String accept)
             throws java.io.IOException
Send a GET request

Parameters:
cluster - the cluster definition
path - the path or URI
accept - Accept header value
Returns:
a Response object with response detail
Throws:
java.io.IOException

get

public Response get(java.lang.String path,
                    org.apache.commons.httpclient.Header[] headers)
             throws java.io.IOException
Send a GET request

Parameters:
path - the path or URI
headers - the HTTP headers to include in the request, Accept must be supplied
Returns:
a Response object with response detail
Throws:
java.io.IOException

get

public Response get(Cluster c,
                    java.lang.String path,
                    org.apache.commons.httpclient.Header[] headers)
             throws java.io.IOException
Send a GET request

Parameters:
c - the cluster definition
path - the path or URI
headers - the HTTP headers to include in the request
Returns:
a Response object with response detail
Throws:
java.io.IOException

put

public Response put(java.lang.String path,
                    java.lang.String contentType,
                    byte[] content)
             throws java.io.IOException
Send a PUT request

Parameters:
path - the path or URI
contentType - the content MIME type
content - the content bytes
Returns:
a Response object with response detail
Throws:
java.io.IOException

put

public Response put(Cluster cluster,
                    java.lang.String path,
                    java.lang.String contentType,
                    byte[] content)
             throws java.io.IOException
Send a PUT request

Parameters:
cluster - the cluster definition
path - the path or URI
contentType - the content MIME type
content - the content bytes
Returns:
a Response object with response detail
Throws:
java.io.IOException

put

public Response put(java.lang.String path,
                    org.apache.commons.httpclient.Header[] headers,
                    byte[] content)
             throws java.io.IOException
Send a PUT request

Parameters:
path - the path or URI
headers - the HTTP headers to include, Content-Type must be supplied
content - the content bytes
Returns:
a Response object with response detail
Throws:
java.io.IOException

put

public Response put(Cluster cluster,
                    java.lang.String path,
                    org.apache.commons.httpclient.Header[] headers,
                    byte[] content)
             throws java.io.IOException
Send a PUT request

Parameters:
cluster - the cluster definition
path - the path or URI
headers - the HTTP headers to include, Content-Type must be supplied
content - the content bytes
Returns:
a Response object with response detail
Throws:
java.io.IOException

post

public Response post(java.lang.String path,
                     java.lang.String contentType,
                     byte[] content)
              throws java.io.IOException
Send a POST request

Parameters:
path - the path or URI
contentType - the content MIME type
content - the content bytes
Returns:
a Response object with response detail
Throws:
java.io.IOException

post

public Response post(Cluster cluster,
                     java.lang.String path,
                     java.lang.String contentType,
                     byte[] content)
              throws java.io.IOException
Send a POST request

Parameters:
cluster - the cluster definition
path - the path or URI
contentType - the content MIME type
content - the content bytes
Returns:
a Response object with response detail
Throws:
java.io.IOException

post

public Response post(java.lang.String path,
                     org.apache.commons.httpclient.Header[] headers,
                     byte[] content)
              throws java.io.IOException
Send a POST request

Parameters:
path - the path or URI
headers - the HTTP headers to include, Content-Type must be supplied
content - the content bytes
Returns:
a Response object with response detail
Throws:
java.io.IOException

post

public Response post(Cluster cluster,
                     java.lang.String path,
                     org.apache.commons.httpclient.Header[] headers,
                     byte[] content)
              throws java.io.IOException
Send a POST request

Parameters:
cluster - the cluster definition
path - the path or URI
headers - the HTTP headers to include, Content-Type must be supplied
content - the content bytes
Returns:
a Response object with response detail
Throws:
java.io.IOException

delete

public Response delete(java.lang.String path)
                throws java.io.IOException
Send a DELETE request

Parameters:
path - the path or URI
Returns:
a Response object with response detail
Throws:
java.io.IOException

delete

public Response delete(Cluster cluster,
                       java.lang.String path)
                throws java.io.IOException
Send a DELETE request

Parameters:
cluster - the cluster definition
path - the path or URI
Returns:
a Response object with response detail
Throws:
java.io.IOException


Copyright © 2011 The Apache Software Foundation. All Rights Reserved.