com.basho.riak.client.http.plain
Class PlainClient

java.lang.Object
  extended by com.basho.riak.client.http.plain.PlainClient

public class PlainClient
extends Object

An adapter from RiakClient to a slightly less HTTP, more Java-centric, interface. Objects are returned without HTTP specific information and exceptions are thrown on unsuccessful responses.


Constructor Summary
PlainClient(RiakClient riakClient)
          The primary constructor.
 
Method Summary
 void delete(String bucket, String key)
           
 void delete(String bucket, String key, RequestMeta meta)
          Like RiakClient.delete(String, String, RequestMeta), except throws on a non-200 or 404 response.
 RiakObject fetch(String bucket, String key)
           
 RiakObject fetch(String bucket, String key, RequestMeta meta)
          Like RiakClient.fetch(String, String, RequestMeta), except it returns the fetched object directly or throws if the response is not a 200, 304 or 404.
 Collection<? extends RiakObject> fetchAll(String bucket, String key)
           
 Collection<? extends RiakObject> fetchAll(String bucket, String key, RequestMeta meta)
          Like RiakClient.fetch(String, String, RequestMeta), except it returns the all the fetched objects directly or throws if the response is not a 200, 304 or 404.
 RiakObject fetchMeta(String bucket, String key)
           
 RiakObject fetchMeta(String bucket, String key, RequestMeta meta)
          Like RiakClient.fetchMeta(String, String, RequestMeta), except it returns the fetched object metadata directly or throws if the response is not a 200, 304 or 404.
static PlainClient getClient(RiakConfig config)
          Connect to Riak using the given configuration.
static PlainClient getClient(String url)
          Connect to Riak using the given URL.
 RiakBucketInfo listBucket(String bucket)
           
 RiakBucketInfo listBucket(String bucket, RequestMeta meta)
          Like RiakClient.listBucket(String, RequestMeta), except throws on a non-200 response
 void setBucketSchema(String bucket, RiakBucketInfo bucketInfo)
           
 void setBucketSchema(String bucket, RiakBucketInfo bucketInfo, RequestMeta meta)
          Like RiakClient.setBucketSchema(String, RiakBucketInfo, RequestMeta), except throws on a non-204 response.
 void store(RiakObject object)
           
 void store(RiakObject object, RequestMeta meta)
          Like RiakClient.store(RiakObject, RequestMeta), except throws on a non-200 or 204 response and updates the passed in RiakObject with new metadata from Riak.
 boolean stream(String bucket, String key, StreamHandler handler, RequestMeta meta)
          Identical to RiakClient.stream(String, String, StreamHandler, RequestMeta).
 List<? extends List<? extends RiakObject>> walk(String bucket, String key, RiakWalkSpec walkSpec)
           
 List<? extends List<? extends RiakObject>> walk(String bucket, String key, String walkSpec)
           
 List<? extends List<? extends RiakObject>> walk(String bucket, String key, String walkSpec, RequestMeta meta)
          Like RiakClient.walk(String, String, String, RequestMeta), except throws on a non-200 or 404 response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlainClient

public PlainClient(RiakClient riakClient)
The primary constructor. Wraps an existing RiakClient and installs a custom RiakExceptionHandler.

Method Detail

getClient

public static PlainClient getClient(RiakConfig config)
Connect to Riak using the given configuration.


getClient

public static PlainClient getClient(String url)
Connect to Riak using the given URL.


setBucketSchema

public void setBucketSchema(String bucket,
                            RiakBucketInfo bucketInfo,
                            RequestMeta meta)
                     throws RiakIOException,
                            RiakResponseException
Like RiakClient.setBucketSchema(String, RiakBucketInfo, RequestMeta), except throws on a non-204 response.

Throws:
RiakIOException - If an error occurs during communication with the Riak server.
RiakResponseException - if the server does not successfully update the bucket schema.

setBucketSchema

public void setBucketSchema(String bucket,
                            RiakBucketInfo bucketInfo)
                     throws RiakIOException,
                            RiakResponseException
Throws:
RiakIOException
RiakResponseException

listBucket

public RiakBucketInfo listBucket(String bucket,
                                 RequestMeta meta)
                          throws RiakIOException,
                                 RiakResponseException
Like RiakClient.listBucket(String, RequestMeta), except throws on a non-200 response

Throws:
RiakIOException - If an error occurs during communication with the Riak server.
RiakResponseException - if the server does not return the bucket information

listBucket

public RiakBucketInfo listBucket(String bucket)
                          throws RiakIOException,
                                 RiakResponseException
Throws:
RiakIOException
RiakResponseException

store

public void store(RiakObject object,
                  RequestMeta meta)
           throws RiakIOException,
                  RiakResponseException
Like RiakClient.store(RiakObject, RequestMeta), except throws on a non-200 or 204 response and updates the passed in RiakObject with new metadata from Riak.

Throws:
RiakIOException - If an error occurs during communication with the Riak server.
RiakResponseException - If the server does not succesfully store the object.

store

public void store(RiakObject object)
           throws RiakIOException,
                  RiakResponseException
Throws:
RiakIOException
RiakResponseException

fetchMeta

public RiakObject fetchMeta(String bucket,
                            String key,
                            RequestMeta meta)
                     throws RiakIOException,
                            RiakResponseException
Like RiakClient.fetchMeta(String, String, RequestMeta), except it returns the fetched object metadata directly or throws if the response is not a 200, 304 or 404.

Returns:
RiakObject or null if object doesn't exist.
Throws:
RiakIOException - If an error occurs during communication with the Riak server.
RiakResponseException - If the server does return a valid object

fetchMeta

public RiakObject fetchMeta(String bucket,
                            String key)
                     throws RiakIOException,
                            RiakResponseException
Throws:
RiakIOException
RiakResponseException

fetch

public RiakObject fetch(String bucket,
                        String key,
                        RequestMeta meta)
                 throws RiakIOException,
                        RiakResponseException
Like RiakClient.fetch(String, String, RequestMeta), except it returns the fetched object directly or throws if the response is not a 200, 304 or 404.

Returns:
RiakObject or null if object doesn't exist. If siblings exist, then returns one of the siblings.
Throws:
RiakIOException - If an error occurs during communication with the Riak server.
RiakResponseException - If the server does return a valid object

fetch

public RiakObject fetch(String bucket,
                        String key)
                 throws RiakIOException,
                        RiakResponseException
Throws:
RiakIOException
RiakResponseException

fetchAll

public Collection<? extends RiakObject> fetchAll(String bucket,
                                                 String key,
                                                 RequestMeta meta)
                                          throws RiakIOException,
                                                 RiakResponseException
Like RiakClient.fetch(String, String, RequestMeta), except it returns the all the fetched objects directly or throws if the response is not a 200, 304 or 404.

Returns:
All sibling RiakObject or null no object exist.
Throws:
RiakIOException - If an error occurs during communication with the Riak server.
RiakResponseException - If the server does return any valid objects

fetchAll

public Collection<? extends RiakObject> fetchAll(String bucket,
                                                 String key)
                                          throws RiakIOException,
                                                 RiakResponseException
Throws:
RiakIOException
RiakResponseException

stream

public boolean stream(String bucket,
                      String key,
                      StreamHandler handler,
                      RequestMeta meta)
               throws IOException
Identical to RiakClient.stream(String, String, StreamHandler, RequestMeta).

Throws:
IOException

delete

public void delete(String bucket,
                   String key,
                   RequestMeta meta)
            throws RiakIOException,
                   RiakResponseException
Like RiakClient.delete(String, String, RequestMeta), except throws on a non-200 or 404 response. Note that delete succeeds if the object did not previously exist (404 response).

Throws:
RiakIOException - If an error occurs during communication with the Riak server.
RiakResponseException - If the object was not deleted.

delete

public void delete(String bucket,
                   String key)
            throws RiakIOException,
                   RiakResponseException
Throws:
RiakIOException
RiakResponseException

walk

public List<? extends List<? extends RiakObject>> walk(String bucket,
                                                       String key,
                                                       String walkSpec,
                                                       RequestMeta meta)
                                                throws RiakIOException,
                                                       RiakResponseException
Like RiakClient.walk(String, String, String, RequestMeta), except throws on a non-200 or 404 response.

Returns:
list of lists of RiakObjects corresponding to steps of the walk. Returns null if the source object doesn't exist.
Throws:
RiakIOException - If an error occurs during communication with the Riak server.
RiakResponseException - If the links could not be walked or the result steps were not returned.

walk

public List<? extends List<? extends RiakObject>> walk(String bucket,
                                                       String key,
                                                       String walkSpec)
                                                throws RiakIOException,
                                                       RiakResponseException
Throws:
RiakIOException
RiakResponseException

walk

public List<? extends List<? extends RiakObject>> walk(String bucket,
                                                       String key,
                                                       RiakWalkSpec walkSpec)
                                                throws RiakIOException,
                                                       RiakResponseException
Throws:
RiakIOException
RiakResponseException


Copyright © 2012. All Rights Reserved.