com.basho.riak.client.http.util
Class ClientHelper

java.lang.Object
  extended by com.basho.riak.client.http.util.ClientHelper

public class ClientHelper
extends Object

This class performs the actual HTTP requests underlying the operations in RiakClient and returns the resulting HTTP responses. It is up to RiakClient to interpret the responses and translate them into the appropriate format.


Constructor Summary
ClientHelper(RiakConfig config, String clientId)
           
 
Method Summary
 HttpResponse delete(String bucket, String key, RequestMeta meta)
          Same as RiakClient, except only returning the HTTP response
 HttpResponse fetch(String bucket, String key, RequestMeta meta)
           
 HttpResponse fetch(String bucket, String key, RequestMeta meta, boolean streamResponse)
          Same as RiakClient, except only returning the HTTP response and allows the response to be streamed.
 HttpResponse fetchIndex(String bucket, String indexName, int[] values)
          Perform the fetch/query on an index
 HttpResponse fetchIndex(String bucket, String indexName, String[] values)
          Perform the fetch/query on an index
 HttpResponse fetchMeta(String bucket, String key, RequestMeta meta)
          Same as RiakClient, except only returning the HTTP response
 HttpResponse getBucketSchema(String bucket, RequestMeta meta)
          Same as RiakClient.getBucketSchema(String, RequestMeta), except only returning the HTTP response.
 byte[] getClientId()
          See RiakClient.getClientId()
 RiakConfig getConfig()
           
 RiakExceptionHandler getExceptionHandler()
           
 org.apache.http.client.HttpClient getHttpClient()
          Return the HttpClient used to make requests, which can be configured.
 HttpResponse listBucket(String bucket, RequestMeta meta, boolean streamResponse)
          Same as RiakClient, except only returning the HTTP response, and if streamResponse==true, the response will be streamed back, so the user is responsible for calling HttpResponseDecorator.close()
 HttpResponse listBuckets()
          List the buckets in Riak
 HttpResponse mapReduce(String job, RequestMeta meta)
          Same as RiakClient, except only returning the HTTP response
 HttpResponse ping()
          Same as RiakClient.ping()
 HttpResponse setBucketSchema(String bucket, JSONObject schema, RequestMeta meta)
          See RiakClient.setBucketSchema(String, com.basho.riak.client.http.RiakBucketInfo, RequestMeta)
 void setClientId(String clientId)
           
 void setExceptionHandler(RiakExceptionHandler exceptionHandler)
          Install an exception handler.
 HttpResponse stats()
          Same as RiakClient.stats()
 HttpResponse store(RiakObject object, RequestMeta meta)
          Same as RiakClient, except only returning the HTTP response
 boolean stream(String bucket, String key, StreamHandler handler, RequestMeta meta)
          Same as RiakClient, except only returning the HTTP response
 HttpResponse toss(RiakIORuntimeException e)
          Hands exception e to installed exception handler if there is one or throw it.
 HttpResponse toss(RiakResponseRuntimeException e)
           
 HttpResponse walk(String bucket, String key, String walkSpec, RequestMeta meta)
          Same as RiakClient, except only returning the HTTP response
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientHelper

public ClientHelper(RiakConfig config,
                    String clientId)
Method Detail

getClientId

public byte[] getClientId()
See RiakClient.getClientId()


setClientId

public void setClientId(String clientId)

setBucketSchema

public HttpResponse setBucketSchema(String bucket,
                                    JSONObject schema,
                                    RequestMeta meta)
See RiakClient.setBucketSchema(String, com.basho.riak.client.http.RiakBucketInfo, RequestMeta)


getBucketSchema

public HttpResponse getBucketSchema(String bucket,
                                    RequestMeta meta)
Same as RiakClient.getBucketSchema(String, RequestMeta), except only returning the HTTP response.


listBuckets

public HttpResponse listBuckets()
List the buckets in Riak

Returns:
an HttpResponse whose body should be the result of asking Riak to list buckets.

listBucket

public HttpResponse listBucket(String bucket,
                               RequestMeta meta,
                               boolean streamResponse)
Same as RiakClient, except only returning the HTTP response, and if streamResponse==true, the response will be streamed back, so the user is responsible for calling HttpResponseDecorator.close()


store

public HttpResponse store(RiakObject object,
                          RequestMeta meta)
Same as RiakClient, except only returning the HTTP response


fetchMeta

public HttpResponse fetchMeta(String bucket,
                              String key,
                              RequestMeta meta)
Same as RiakClient, except only returning the HTTP response


fetch

public HttpResponse fetch(String bucket,
                          String key,
                          RequestMeta meta,
                          boolean streamResponse)
Same as RiakClient, except only returning the HTTP response and allows the response to be streamed.

Parameters:
bucket - Same as RiakClient
key - Same as RiakClient
meta - Same as RiakClient
streamResponse - If true, the connection will NOT be released. Use HttpResponse.getHttpMethod().getResponseBodyAsStream() to get the response stream; HttpResponse.getBody() will return null.
Returns:
Same as RiakClient

fetch

public HttpResponse fetch(String bucket,
                          String key,
                          RequestMeta meta)

stream

public boolean stream(String bucket,
                      String key,
                      StreamHandler handler,
                      RequestMeta meta)
               throws IOException
Same as RiakClient, except only returning the HTTP response

Throws:
IOException

delete

public HttpResponse delete(String bucket,
                           String key,
                           RequestMeta meta)
Same as RiakClient, except only returning the HTTP response


walk

public HttpResponse walk(String bucket,
                         String key,
                         String walkSpec,
                         RequestMeta meta)
Same as RiakClient, except only returning the HTTP response


mapReduce

public HttpResponse mapReduce(String job,
                              RequestMeta meta)
Same as RiakClient, except only returning the HTTP response


fetchIndex

public HttpResponse fetchIndex(String bucket,
                               String indexName,
                               String[] values)
Perform the fetch/query on an index

Parameters:
bucket - the bucket
indexName - the name of the index
values - an array of Strings, if only 1 long, then a value, if longer the 1st 2 elements are treated as the bounds for a range
Returns:
an HttpResponse

fetchIndex

public HttpResponse fetchIndex(String bucket,
                               String indexName,
                               int[] values)
Perform the fetch/query on an index

Parameters:
bucket - the bucket
indexName - the name of the index
values - an array of ints, if only 1 long, then a value, if longer the 1st 2 elements are treated as the bounds for a range
Returns:
an HttpResponse

ping

public HttpResponse ping()
Same as RiakClient.ping()

Returns:
the ping HttpResponse

getExceptionHandler

public RiakExceptionHandler getExceptionHandler()
Returns:
the installed exception handler or null if not installed

stats

public HttpResponse stats()
Same as RiakClient.stats()

Returns:
an HttpResponse whose body should be the result of asking Riak for its stats (status).

setExceptionHandler

public void setExceptionHandler(RiakExceptionHandler exceptionHandler)
Install an exception handler. If an exception handler is provided, then the Riak client will hand exceptions to the handler rather than throwing them.


toss

public HttpResponse toss(RiakIORuntimeException e)
Hands exception e to installed exception handler if there is one or throw it.

Returns:
A 0-status HttpResponse.

toss

public HttpResponse toss(RiakResponseRuntimeException e)

getHttpClient

public org.apache.http.client.HttpClient getHttpClient()
Return the HttpClient used to make requests, which can be configured.


getConfig

public RiakConfig getConfig()
Returns:
The config used to construct the HttpClient connecting to Riak.


Copyright © 2012. All Rights Reserved.