public interface IRiakClient
Used to create/fetch/update Bucket
s and to
perform Map/Reduce query operations.
For example:
IRiakClient client = RiakFactory.pbcClient();
final byte[] id = client.generateAndSetClientId()
Bucket b = client.createBucket("myNewBucket")
.nVal(3)
.allowSiblings(true)
.execute();
// do things with the bucket
Modifier and Type | Method and Description |
---|---|
WriteBucket |
createBucket(String bucketName)
Create a new
WriteBucket operation
to create a Bucket named for the passed String. |
FetchBucket |
fetchBucket(String bucketName)
Create a new
FetchBucket operation, and return it. |
byte[] |
generateAndSetClientId()
Generate, set and return "random" byte[4] id for the client.
|
byte[] |
getClientId()
Retrieve the client id from Riak that this client is using.
|
Transport |
getTransport()
Optional method, the underlying transport.
|
Set<String> |
listBuckets()
Deprecated.
|
StreamingOperation<String> |
listBucketsStreaming()
Iterate over the bucket names in Riak.
|
BucketKeyMapReduce |
mapReduce()
Create
MapReduce operation for a set of
bucket/key inputs. |
IndexMapReduce |
mapReduce(IndexQuery query)
Create a
MapReduce operation that uses the supplied
IndexQuery as input |
BucketMapReduce |
mapReduce(String bucket)
Create
MapReduce operation that has the supplied bucket as its input. |
SearchMapReduce |
mapReduce(String bucket,
String query)
Create a
MapReduce operation that uses the supplied Riak Search
query as input. |
void |
ping()
Ping Riak, check it is available
|
void |
resetBucket(String bucketName)
Reset a bucket's properties back to the defaults
|
IRiakClient |
setClientId(byte[] clientId)
Set an ID for this client.
|
void |
shutdown() |
Iterable<NodeStats> |
stats()
Perform the Riak
/stats operation on the node(s) this client
is connected to. |
WriteBucket |
updateBucket(Bucket bucket)
Create a new
WriteBucket operation to update passed bucket. |
LinkWalk |
walk(IRiakObject startObject)
Create a
LinkWalk operation that starts at startObject. |
IRiakClient setClientId(byte[] clientId) throws RiakException
clientId
- byte[4] that uniquely identify the clientRiakException
- if operation failsIllegalArgumentException
- if clientId is null or not byte[4]byte[] generateAndSetClientId() throws RiakException
RiakException
ClientId
byte[] getClientId() throws RiakException
RiakException
Set<String> listBuckets() throws RiakException
RiakException
StreamingOperation<String> listBucketsStreaming() throws RiakException
StreamingOperation.cancel()
on the returned
StreamingOperation
if you do not iterate through the entire set.
As a safeguard the stream is closed automatically when the iterator is
weakly reachable but due to the nature of the GC it is inadvisable to
rely on this to close the iterator. Do not retain a reference to this Iterable
after you have used it.RiakException
RawClient.listBucketsStreaming()
FetchBucket fetchBucket(String bucketName)
FetchBucket
operation, and return it.bucketName
- FetchBucket
configured to return the Bucket
called bucketName
for further configuration and execution.FetchBucket
WriteBucket updateBucket(Bucket bucket)
WriteBucket
operation to update passed bucket.bucket
- the name of the Bucket
.WriteBucket
configured to update the supplied bucket
for further configuration and execution.WriteBucket
WriteBucket createBucket(String bucketName)
WriteBucket
operation
to create a Bucket
named for the passed String.bucketName
- the name of the new bucket.WriteBucket
configured to create the new bucket
for further configuration and execution.WriteBucket
void resetBucket(String bucketName) throws RiakException
bucketName
- RiakException
LinkWalk walk(IRiakObject startObject)
LinkWalk
operation that starts at startObject.
See also Link Walking on the basho site.BucketKeyMapReduce mapReduce()
MapReduce
operation for a set of
bucket/key inputs.
See also Map Reduce on the basho site.BucketKeyMapReduce
for configuration and execution.MapReduce
,
BucketKeyMapReduce
BucketMapReduce mapReduce(String bucket)
MapReduce
operation that has the supplied bucket as its input.bucket
- the String name of the input bucket to the M/R job.BucketMapReduce
for further configuration and execution.MapReduce
,
BucketMapReduce
SearchMapReduce mapReduce(String bucket, String query)
MapReduce
operation that uses the supplied Riak Search
query as input.
See also
Riak Search on the basho wiki for more information.bucket
- the input bucket for the search queryquery
- the input query for the searchSearchMapReduce
operation for further configuration and
execution.IndexMapReduce mapReduce(IndexQuery query)
MapReduce
operation that uses the supplied
IndexQuery
as input
Note: if you just want to fetch an index see
Bucket.fetchIndex(com.basho.riak.client.query.indexes.RiakIndex)
to create a FetchIndex
operation
query
- the IndexQuery
to use as inputMapReduce
operation for further configuration and
executionvoid ping() throws RiakException
RiakException
- if Riak does not respond OKTransport getTransport()
Transport
or null if not implemented.void shutdown()
Iterable<NodeStats> stats() throws RiakException
/stats
operation on the node(s) this client
is connected to.
This is not supported by the Riak Protobuf API
Iterable
object that contains one or more NodeStats
RiakException
- If Riak does not respond or if the protobuf API is being usedCopyright © 2014. All Rights Reserved.