com.basho.riak.client.raw
Interface RawClient

All Known Implementing Classes:
ClusterClient, HTTPClientAdapter, HTTPClusterClient, PBClientAdapter, PBClusterClient

public interface RawClient

Common interface for low-level clients.

If you have the urge to write a client to Riak, please, please implement this interface so it can drop straight into all the higher level API code

Author:
russell

Method Summary
 void delete(String bucket, String key)
          Delete the data at bucket/key
 void delete(String bucket, String key, DeleteMeta deleteMeta)
          Delete the data at bucket/key using the parameters in deleteMeta
 void delete(String bucket, String key, int deleteQuorum)
          Delete the data at bucket/key using deleteQuorum as the rw param
 RiakResponse fetch(String bucket, String key)
          Fetch data from bucket/key
 RiakResponse fetch(String bucket, String key, FetchMeta fetchMeta)
          Fetch data from the given bucket/key with fetchMeta
 RiakResponse fetch(String bucket, String key, int readQuorum)
          Fetch data from the given bukcet/key with read quorum readQuorum
 BucketProperties fetchBucket(String bucketName)
          The set of properties for the given bucket
 List<String> fetchIndex(IndexQuery indexQuery)
          Performs an 2i index query
 byte[] generateAndSetClientId()
          If you don't set a client id explicitly at least call this to set one.
 byte[] getClientId()
          Ask Riak for the client id for the current connection.
 Transport getTransport()
          The raw transport name.
 RiakResponse head(String bucket, String key, FetchMeta fetchMeta)
          Fetch only the meta-data from bucket/key
 WalkResult linkWalk(LinkWalkSpec linkWalkSpec)
          Performs a link walk operation described by the LinkWalkSpec provided.
 Set<String> listBuckets()
          An Unmodifiable Iterator view of the all the Buckets in Riak
 Iterable<String> listKeys(String bucketName)
          An unmodifiable Iterator view of the keys for the bucket named bucketName May be backed by a stream or a collection.
 MapReduceResult mapReduce(MapReduceSpec spec)
          Perform a map/reduce query defined by MapReduceSpec
 void ping()
          Riak connection health check, is Riak reachable.
 void setClientId(byte[] clientId)
          Set a client id, currently must be a 4 bytes exactly
 void shutdown()
           
 NodeStats stats()
          Performs a Riak /stats operation on the node(s) this client is connected to.
 void store(IRiakObject object)
          Store the given IRiakObject in Riak using the bucket default w/dw and false for returnBody
 RiakResponse store(IRiakObject object, StoreMeta storeMeta)
          Store the given IRiakObject in Riak at the location bucket/key
 void updateBucket(String name, BucketProperties bucketProperties)
          Update a buckets properties from the BucketProperties provided.
 

Method Detail

head

RiakResponse head(String bucket,
                  String key,
                  FetchMeta fetchMeta)
                  throws IOException
Fetch only the meta-data from bucket/key

Parameters:
bucket - the bucket
key - the key
fetchMeta - the fetch options
Returns:
a RiakResponse that, if it has an IRiakObject it will have an empty value
Throws:
IOException

fetch

RiakResponse fetch(String bucket,
                   String key)
                   throws IOException
Fetch data from bucket/key

Parameters:
bucket - the bucket
key - the key
Returns:
a RiakResponse
Throws:
IOException

fetch

RiakResponse fetch(String bucket,
                   String key,
                   int readQuorum)
                   throws IOException
Fetch data from the given bukcet/key with read quorum readQuorum

Parameters:
bucket - the bucket
key - the key
readQuorum - readQuorum, needs to be =< the buckets n_val
Returns:
a RiakResponse
Throws:
IOException

fetch

RiakResponse fetch(String bucket,
                   String key,
                   FetchMeta fetchMeta)
                   throws IOException
Fetch data from the given bucket/key with fetchMeta

Parameters:
bucket - the bucket
key - the key
fetchMeta - the extra fetch parameters FetchMeta
Returns:
a RiakResponse
Throws:
IOException

store

RiakResponse store(IRiakObject object,
                   StoreMeta storeMeta)
                   throws IOException
Store the given IRiakObject in Riak at the location bucket/key

Parameters:
object - the data to store
storeMeta - meta data for the store operation as a StoreMeta
Returns:
a RiakResponse if StoreMeta.getReturnBody() is true, or null
Throws:
IOException

store

void store(IRiakObject object)
           throws IOException
Store the given IRiakObject in Riak using the bucket default w/dw and false for returnBody

Parameters:
object - the data to store as an IRiakObject
Throws:
IOException

delete

void delete(String bucket,
            String key)
            throws IOException
Delete the data at bucket/key

Parameters:
bucket -
key -
Throws:
IOException

delete

void delete(String bucket,
            String key,
            int deleteQuorum)
            throws IOException
Delete the data at bucket/key using deleteQuorum as the rw param

Parameters:
bucket -
key -
deleteQuorum - an int that is less than or equal to the bucket's n_val
Throws:
IOException

delete

void delete(String bucket,
            String key,
            DeleteMeta deleteMeta)
            throws IOException
Delete the data at bucket/key using the parameters in deleteMeta

Parameters:
bucket -
key -
deleteMeta - the DeleteMeta containing the operation parameters
Throws:
IOException

listBuckets

Set<String> listBuckets()
                        throws IOException
An Unmodifiable Iterator view of the all the Buckets in Riak

Throws:
IOException

fetchBucket

BucketProperties fetchBucket(String bucketName)
                             throws IOException
The set of properties for the given bucket

Parameters:
bucketName - the name of the bucket
Returns:
a populated BucketProperties (by populated, as populated as the underlying API allows)
Throws:
IOException

updateBucket

void updateBucket(String name,
                  BucketProperties bucketProperties)
                  throws IOException
Update a buckets properties from the BucketProperties provided. No guarantees that the underlying API is able to set all the properties passed.

Parameters:
name - the bucket to be updated
bucketProperties - the set of properties to be writen
Throws:
IOException

listKeys

Iterable<String> listKeys(String bucketName)
                          throws IOException
An unmodifiable Iterator view of the keys for the bucket named bucketName May be backed by a stream or a collection. Be careful, expensive.

Parameters:
bucketName -
Returns:
an unmodifiable, iterable view of the keys for tha bucket
Throws:
IOException

linkWalk

WalkResult linkWalk(LinkWalkSpec linkWalkSpec)
                    throws IOException
Performs a link walk operation described by the LinkWalkSpec provided. The underlying API may not support Link Walking directly but will approximate it at some cost.

Parameters:
linkWalkSpec -
Returns:
a WalkResult
Throws:
IOException

mapReduce

MapReduceResult mapReduce(MapReduceSpec spec)
                          throws IOException,
                                 MapReduceTimeoutException
Perform a map/reduce query defined by MapReduceSpec

Parameters:
spec - the m/r job specification
Returns:
A MapReduceResult
Throws:
IOException
MapReduceTimeoutException

generateAndSetClientId

byte[] generateAndSetClientId()
                              throws IOException
If you don't set a client id explicitly at least call this to set one. It generates the 4 byte ID and sets that Id on the client IE you *don't* need to call setClientId() with the result of generate.

Returns:
the generated clientId for the client
Throws:
IOException

setClientId

void setClientId(byte[] clientId)
                 throws IOException
Set a client id, currently must be a 4 bytes exactly

Parameters:
clientId - any 4 bytes
Throws:
IOException

getClientId

byte[] getClientId()
                   throws IOException
Ask Riak for the client id for the current connection.

Returns:
whatever 4 bytes Riak uses to identify this client
Throws:
IOException

ping

void ping()
          throws IOException
Riak connection health check, is Riak reachable. Can be used for diagnostics/monitoring

Throws:
IOException - if Riak is not reachable or returns anything other than OK

fetchIndex

List<String> fetchIndex(IndexQuery indexQuery)
                        throws IOException
Performs an 2i index query

Type Parameters:
T -
Parameters:
indexQuery - the query to perform
Returns:
a List of keys (or empty list)
Throws:
IOException

getTransport

Transport getTransport()
The raw transport name.

Returns:
the Transport for the client or null if not implemented.

shutdown

void shutdown()

stats

NodeStats stats()
                throws IOException
Performs a Riak /stats operation on the node(s) this client is connected to. The NodeStats object that is returned contains one or more sets of stats and can be Iterated over.

Returns:
a NodeStats object that represents one or more sets of stats.
Throws:
IOException


Copyright © 2012. All Rights Reserved.