public class HTTPClientAdapter extends Object implements RawClient
RiakClient to the new RawClient interface.| Constructor and Description |
|---|
HTTPClientAdapter(RiakClient client)
Create an instance of the adapter that delegates all API calls to
client |
HTTPClientAdapter(String url)
Convenience constructor that delegates to
RiakClient.RiakClient(String) to create a RiakClient to
adapt |
| Modifier and Type | Method and Description |
|---|---|
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
|
Long |
fetchCounter(String Bucket,
String counter,
FetchMeta meta)
Fetch the value for this counter
|
List<String> |
fetchIndex(IndexQuery indexQuery)
Performs an 2i index query
|
StreamingOperation<IndexEntry> |
fetchIndex(IndexSpec indexSpec)
Performs a 2i query as a streaming operation
|
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.
|
RiakConfig |
getConfig() |
Transport |
getTransport()
The raw transport name.
|
RiakResponse |
head(String bucket,
String key,
FetchMeta fetchMeta)
NOTE: returns the values *if* siblings are present
|
Long |
incrementCounter(String bucket,
String counter,
long increment,
StoreMeta meta)
Increments a counter by the specified increment
|
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 |
StreamingOperation<String> |
listBucketsStreaming()
Iterate over the bucket names in Riak.
|
StreamingOperation<String> |
listKeys(String bucketName)
An unmodifiable view of the keys for the bucket named
bucketName
* You *must* call StreamingOperation.cancel() on the returned
StreamingOperation if you do not iterate through the entire set. |
MapReduceResult |
mapReduce(MapReduceSpec spec)
Perform a map/reduce query defined by
MapReduceSpec |
void |
ping()
Riak connection health check, is Riak reachable.
|
void |
resetBucketProperties(String bucketName)
(non-Javadoc)
|
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. |
public HTTPClientAdapter(RiakClient client)
clientclient - the RiakClient to delegate to.public HTTPClientAdapter(String url)
RiakClient.RiakClient(String) to create a RiakClient to
adapturl - of the riak REST interfacepublic RiakResponse head(String bucket, String key, FetchMeta fetchMeta) throws IOException
head in interface RawClientbucket - the bucketkey - the keyfetchMeta - the fetch optionsRiakResponse that, if it has an IRiakObject it
will have an empty valueIOExceptioncom.basho.riak.client.raw.RawClient#head(java.lang.String,
java.lang.String)public RiakResponse fetch(String bucket, String key) throws IOException
RawClientbucket/keyfetch in interface RawClientbucket - the bucketkey - the keyRiakResponseIOExceptionpublic RiakResponse fetch(String bucket, String key, int readQuorum) throws IOException
RawClientbukcet/key with read quorum
readQuorumfetch in interface RawClientbucket - the bucketkey - the keyreadQuorum - readQuorum, needs to be =< the buckets n_valRiakResponseIOExceptionpublic RiakResponse fetch(String bucket, String key, FetchMeta fetchMeta) throws IOException
RawClientbucket/key with
fetchMetafetch in interface RawClientbucket - the bucketkey - the keyfetchMeta - the extra fetch parameters FetchMetaRiakResponseIOExceptionpublic RiakResponse store(IRiakObject object, StoreMeta storeMeta) throws IOException
RawClientIRiakObject in Riak at the location
bucket/keystore in interface RawClientobject - the data to storestoreMeta - meta data for the store operation as a StoreMetaRiakResponse if StoreMeta.getReturnBody() is
true, or nullIOExceptionpublic void store(IRiakObject object) throws IOException
RawClientIRiakObject in Riak using the bucket default w/dw
and false for returnBodystore in interface RawClientobject - the data to store as an IRiakObjectIOExceptionpublic void delete(String bucket, String key) throws IOException
RawClientbucket/keydelete in interface RawClientIOExceptionpublic void delete(String bucket, String key, int deleteQuorum) throws IOException
RawClientbucket/key using
deleteQuorum as the rw paramdelete in interface RawClientdeleteQuorum - an int that is less than or equal to the bucket's n_valIOExceptionpublic void delete(String bucket, String key, DeleteMeta deleteMeta) throws IOException
RawClientbucket/key using the parameters in
deleteMetadelete in interface RawClientdeleteMeta - the DeleteMeta containing the operation parametersIOExceptionpublic Set<String> listBuckets() throws IOException
RawClientIterator view of the all the Buckets in RiaklistBuckets in interface RawClientIOExceptionpublic StreamingOperation<String> listBucketsStreaming() throws IOException
RawClientStreamingOperation.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
after you have used it.listBucketsStreaming in interface RawClientIOExceptionpublic BucketProperties fetchBucket(String bucketName) throws IOException
RawClientfetchBucket in interface RawClientbucketName - the name of the bucketBucketProperties (by populated, as populated
as the underlying API allows)IOExceptionpublic void updateBucket(String name, BucketProperties bucketProperties) throws IOException
RawClientBucketProperties provided.
No guarantees that the underlying API is able to set all the properties
passed.updateBucket in interface RawClientname - the bucket to be updatedbucketProperties - the set of properties to be writenIOExceptionpublic void resetBucketProperties(String bucketName) throws IOException
resetBucketProperties in interface RawClientIOExceptionRawClient.resetBucketProperties(java.lang.String)public StreamingOperation<String> listKeys(String bucketName) throws IOException
RawClientbucketName
* You *must* call 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
after you have used it.
Be careful, expensive.listKeys in interface RawClientIOExceptionpublic WalkResult linkWalk(LinkWalkSpec linkWalkSpec) throws IOException
RawClientLinkWalkSpec
provided.
The underlying API may not support Link Walking directly but will
approximate it at some cost.linkWalk in interface RawClientWalkResultIOExceptionpublic MapReduceResult mapReduce(MapReduceSpec spec) throws IOException, MapReduceTimeoutException
RawClientMapReduceSpecmapReduce in interface RawClientspec - the m/r job specificationMapReduceResultIOExceptionMapReduceTimeoutExceptionpublic byte[] generateAndSetClientId()
throws IOException
RawClientgenerateAndSetClientId in interface RawClientIOExceptionpublic void setClientId(byte[] clientId)
throws IOException
RawClientsetClientId in interface RawClientclientId - any 4 bytesIOExceptionpublic byte[] getClientId()
throws IOException
RawClientgetClientId in interface RawClientIOExceptionpublic void ping()
throws IOException
RawClientping in interface RawClientIOException - if Riak is not reachable or returns anything other than OKpublic List<String> fetchIndex(IndexQuery indexQuery) throws IOException
RawClientfetchIndex in interface RawClientindexQuery - the query to performIOExceptionpublic StreamingOperation<IndexEntry> fetchIndex(IndexSpec indexSpec)
RawClientfetchIndex in interface RawClientpublic Long incrementCounter(String bucket, String counter, long increment, StoreMeta meta) throws IOException
RawClientincrementCounter in interface RawClientbucket - the name of the bucketcounter - the name (key) of the counterincrement - the amount to increment. Note this can be a negative value.meta - the query parametersIOExceptionpublic Long fetchCounter(String Bucket, String counter, FetchMeta meta) throws IOException
RawClientfetchCounter in interface RawClientBucket - the name of the bucketcounter - the name (key) of the countermeta - query parametersIOExceptionpublic Transport getTransport()
RawClientgetTransport in interface RawClientTransport for the client or null if not implemented.public NodeStats stats() throws IOException
RawClient/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.stats in interface RawClientNodeStats object that represents one or more sets of stats.IOExceptionpublic RiakConfig getConfig()
Copyright © 2014. All Rights Reserved.