public final class DefaultRiakClient extends Object implements IRiakClient
This class is a wrapper around a RawClient of your choice. The RawClient wrapped is passed to all
RiakOperations created by this class, so it really needs to be Thread Safe and reusable.
This class provides a Retrier to each RiakOperation it creates. If you provide one please make sure it is
Thread safe and reusable.
If you do not provide a Retrier a DefaultRetrier configured for 3 attempts is created.
RawClient,
PBClientAdapter,
HTTPClientAdapter,
DefaultRetrier| 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()
Set view of buckets in Riak
|
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)
(non-Javadoc)
|
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 b)
Create a new
WriteBucket operation to update passed bucket. |
LinkWalk |
walk(IRiakObject startObject)
Create a
LinkWalk operation that starts at startObject. |
public Set<String> listBuckets() throws RiakException
IRiakClientlistBuckets in interface IRiakClientRiakExceptionpublic StreamingOperation<String> listBucketsStreaming() throws RiakException
IRiakClientStreamingOperation.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.listBucketsStreaming in interface IRiakClientRiakExceptionRawClient.listBucketsStreaming()public WriteBucket updateBucket(Bucket b)
IRiakClientWriteBucket operation to update passed bucket.updateBucket in interface IRiakClientb - the name of the Bucket.WriteBucket configured to update the supplied bucket
for further configuration and execution.WriteBucketpublic FetchBucket fetchBucket(String bucketName)
IRiakClientFetchBucket operation, and return it.fetchBucket in interface IRiakClientFetchBucket configured to return the Bucket called bucketName
for further configuration and execution.FetchBucketpublic WriteBucket createBucket(String bucketName)
IRiakClientWriteBucket operation
to create a Bucket named for the passed String.createBucket in interface IRiakClientbucketName - the name of the new bucket.WriteBucket configured to create the new bucket
for further configuration and execution.WriteBucketpublic void resetBucket(String bucketName) throws RiakException
resetBucket in interface IRiakClientRiakExceptionRawClient.resetBucketProperties(java.lang.String)public IRiakClient setClientId(byte[] clientId) throws RiakException
IRiakClientsetClientId in interface IRiakClientclientId - byte[4] that uniquely identify the clientRiakException - if operation failspublic byte[] generateAndSetClientId()
throws RiakException
IRiakClientgenerateAndSetClientId in interface IRiakClientRiakExceptionClientIdpublic byte[] getClientId()
throws RiakException
IRiakClientgetClientId in interface IRiakClientRiakExceptionpublic BucketKeyMapReduce mapReduce()
IRiakClientMapReduce operation for a set of
bucket/key inputs.
See also Map Reduce on the basho site.mapReduce in interface IRiakClientBucketKeyMapReduce for configuration and execution.MapReduce,
BucketKeyMapReducepublic BucketMapReduce mapReduce(String bucket)
IRiakClientMapReduce operation that has the supplied bucket as its input.mapReduce in interface IRiakClientbucket - the String name of the input bucket to the M/R job.BucketMapReduce for further configuration and execution.MapReduce,
BucketMapReducepublic SearchMapReduce mapReduce(String bucket, String query)
IRiakClientMapReduce operation that uses the supplied Riak Search
query as input.
See also
Riak Search on the basho wiki for more information.mapReduce in interface IRiakClientbucket - the input bucket for the search queryquery - the input query for the searchSearchMapReduce operation for further configuration and
execution.public IndexMapReduce mapReduce(IndexQuery query)
IRiakClientMapReduce 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
mapReduce in interface IRiakClientquery - the IndexQuery to use as inputMapReduce operation for further configuration and
executionpublic LinkWalk walk(IRiakObject startObject)
IRiakClientLinkWalk operation that starts at startObject.
See also Link Walking on the basho site.walk in interface IRiakClientstartObject - the IRiakObject to start the Link walk from.LinkWalk operation for further configuration and execution.LinkWalkpublic void ping()
throws RiakException
IRiakClientping in interface IRiakClientRiakException - if Riak does not respond OKpublic Transport getTransport()
IRiakClientgetTransport in interface IRiakClientTransport or null if not implemented.public void shutdown()
shutdown in interface IRiakClientpublic Iterable<NodeStats> stats() throws RiakException
IRiakClient/stats operation on the node(s) this client
is connected to.
This is not supported by the Riak Protobuf API
stats in interface IRiakClientIterable object that contains one or more NodeStatsRiakException - If Riak does not respond or if the protobuf API is being usedCopyright © 2014. All Rights Reserved.