public class PlainClient extends Object
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 and Description |
---|
PlainClient(RiakClient riakClient)
The primary constructor.
|
Modifier and Type | Method and Description |
---|---|
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)
|
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. |
public PlainClient(RiakClient riakClient)
RiakClient
and
installs a custom RiakExceptionHandler
.public static PlainClient getClient(RiakConfig config)
public static PlainClient getClient(String url)
public void setBucketSchema(String bucket, RiakBucketInfo bucketInfo, RequestMeta meta) throws RiakIOException, RiakResponseException
RiakClient.setBucketSchema(String, RiakBucketInfo, RequestMeta)
,
except throws on a non-204 response.RiakIOException
- If an error occurs during communication with the Riak server.RiakResponseException
- if the server does not successfully update the bucket schema.public void setBucketSchema(String bucket, RiakBucketInfo bucketInfo) throws RiakIOException, RiakResponseException
RiakIOException
RiakResponseException
public RiakBucketInfo listBucket(String bucket, RequestMeta meta) throws RiakIOException, RiakResponseException
RiakClient.listBucket(String, RequestMeta)
, except throws on
a non-200 responseRiakIOException
- If an error occurs during communication with the Riak server.RiakResponseException
- if the server does not return the bucket informationpublic RiakBucketInfo listBucket(String bucket) throws RiakIOException, RiakResponseException
RiakIOException
RiakResponseException
public void store(RiakObject object, RequestMeta meta) throws RiakIOException, RiakResponseException
RiakClient.store(RiakObject, RequestMeta)
, except throws on
a non-200 or 204 response and updates the passed in RiakObject
with new metadata from Riak.RiakIOException
- If an error occurs during communication with the Riak server.RiakResponseException
- If the server does not succesfully store the object.public void store(RiakObject object) throws RiakIOException, RiakResponseException
RiakIOException
RiakResponseException
public RiakObject fetchMeta(String bucket, String key, RequestMeta meta) throws RiakIOException, RiakResponseException
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.RiakObject
or null if object doesn't exist.RiakIOException
- If an error occurs during communication with the Riak server.RiakResponseException
- If the server does return a valid objectpublic RiakObject fetchMeta(String bucket, String key) throws RiakIOException, RiakResponseException
RiakIOException
RiakResponseException
public RiakObject fetch(String bucket, String key, RequestMeta meta) throws RiakIOException, RiakResponseException
RiakClient.fetch(String, String, RequestMeta)
, except it
returns the fetched object directly or throws if the response is not a
200, 304 or 404.RiakObject
or null if object doesn't exist. If siblings
exist, then returns one of the siblings.RiakIOException
- If an error occurs during communication with the Riak server.RiakResponseException
- If the server does return a valid objectpublic RiakObject fetch(String bucket, String key) throws RiakIOException, RiakResponseException
RiakIOException
RiakResponseException
public Collection<? extends RiakObject> fetchAll(String bucket, String key, RequestMeta meta) throws RiakIOException, RiakResponseException
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
or null no object exist.RiakIOException
- If an error occurs during communication with the Riak server.RiakResponseException
- If the server does return any valid objectspublic Collection<? extends RiakObject> fetchAll(String bucket, String key) throws RiakIOException, RiakResponseException
RiakIOException
RiakResponseException
public boolean stream(String bucket, String key, StreamHandler handler, RequestMeta meta) throws IOException
IOException
public void delete(String bucket, String key, RequestMeta meta) throws RiakIOException, RiakResponseException
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).RiakIOException
- If an error occurs during communication with the Riak server.RiakResponseException
- If the object was not deleted.public void delete(String bucket, String key) throws RiakIOException, RiakResponseException
RiakIOException
RiakResponseException
public List<? extends List<? extends RiakObject>> walk(String bucket, String key, String walkSpec, RequestMeta meta) throws RiakIOException, RiakResponseException
RiakClient.walk(String, String, String, RequestMeta)
, except
throws on a non-200 or 404 response.RiakObject
s corresponding to steps of
the walk. Returns null if the source object doesn't exist.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.public List<? extends List<? extends RiakObject>> walk(String bucket, String key, String walkSpec) throws RiakIOException, RiakResponseException
RiakIOException
RiakResponseException
public List<? extends List<? extends RiakObject>> walk(String bucket, String key, RiakWalkSpec walkSpec) throws RiakIOException, RiakResponseException
RiakIOException
RiakResponseException
Copyright © 2014. All Rights Reserved.