|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.basho.riak.client.bucket.DefaultBucket
public class DefaultBucket
Default implementation of Bucket for creating RiakOperations
on k/v data and accessing BucketProperties.
Obtain a DefaultBucket from FetchBucket or
WriteBucket operations from
DefaultRiakClient.fetchBucket(String),
DefaultRiakClient.createBucket(String)
final String bucketName = UUID.randomUUID().toString();
Bucket b = client.createBucket(bucketName).execute();
//store something
IRiakObject o = b.store("k", "v").execute();
//fetch it back
IRiakObject fetched = b.fetch("k").execute();
// now update that riak object
b.store("k", "my new value").execute();
//fetch it back again
fetched = b.fetch("k").execute();
//delete it
b.delete("k").execute();
All operations created by instances of this class are configured with the
Retrier and RawClient passed at construction.
DomainBucket,
RiakBucket| Constructor Summary | |
|---|---|
protected |
DefaultBucket(String name,
BucketProperties properties,
RawClient client,
Retrier retrier)
All RiakOperations created by this instance will use the
RawClient and Retrier provided here. |
| Method Summary | ||
|---|---|---|
DeleteObject |
delete(String key)
Creates a DeleteObject operation that will delete the data at
key on execute(). |
|
|
delete(T o)
Creates a DeleteObject operation that will delete the data at
o's RiakKey annotated field value on
execute(). |
|
FetchObject<IRiakObject> |
fetch(String key)
Creates a FetchObject that returns the data at key
as an IRiakObject on execute(). |
|
|
fetch(String key,
Class<T> type)
Creates a FetchObject operation that returns the data at
key as an instance of type T on
execute(). |
|
|
fetch(T o)
Creates a FetchObject operation that returns the data at
o's annotated RiakKey field as an instance of type
T on execute(). |
|
|
fetchIndex(RiakIndex<T> index)
Creates a FetchIndex operation for the given index name and type |
|
Boolean |
getAllowSiblings()
The allow_mult value for the bucket. |
|
String |
getBackend()
The backend used by this bucket. |
|
Boolean |
getBasicQuorum()
Should a read request return early in some failure cases? E.g. |
|
Integer |
getBigVClock()
the big_vclock property for this bucket. |
|
NamedErlangFunction |
getChashKeyFunction()
The chash_keyfun for this bucket. |
|
Quorum |
getDW()
The default dw quorum for this bucket. |
|
Boolean |
getLastWriteWins()
The last_write_wins value for the bucket. |
|
NamedErlangFunction |
getLinkWalkFunction()
The linkwalk_fun for this bucket. |
|
String |
getName()
Get this Buckets name. |
|
Boolean |
getNotFoundOK()
True if a vnode returning notfound for a key increments the r tally. |
|
Integer |
getNVal()
This bucket's n_val. |
|
Long |
getOldVClock()
the old_vclock property for this bucket. |
|
Collection<NamedErlangFunction> |
getPostcommitHooks()
The set of postcommit hooks for this bucket. |
|
Quorum |
getPR()
The default pr quorum for this bucket. |
|
Collection<NamedFunction> |
getPrecommitHooks()
The set of precommit_hooks for this bucket. |
|
Quorum |
getPW()
The default pw quorum for this bucket. |
|
Quorum |
getR()
The default r quorum for this bucket. |
|
Quorum |
getRW()
The default rw quorum for this bucket. |
|
Boolean |
getSearch()
The search property |
|
Integer |
getSmallVClock()
the small_vclock property for this bucket. |
|
Quorum |
getW()
The default w quorum for this bucket. |
|
Long |
getYoungVClock()
The young_vclcok property for this bucket. |
|
boolean |
isSearchEnabled()
Is search enabled on this bucket |
|
Iterable<String> |
keys()
Iterate over the keys for this bucket (Expensive, are you sure?) Beware: at present all RawClient.listKeys(String) operations return a
stream of keys. |
|
StoreObject<IRiakObject> |
store(String key,
byte[] value)
Convenience method to create a RiakObject with a payload of application/octect-stream |
|
StoreObject<IRiakObject> |
store(String key,
String value)
Convenience methods will create an IRiakObject with
value as the data payload and
text/plain:charset=utf-8 as the contentType |
|
|
store(String key,
T o)
Store an instance of T in Riak. |
|
|
store(T o)
Store an instance of T in Riak. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected DefaultBucket(String name,
BucketProperties properties,
RawClient client,
Retrier retrier)
RiakOperations created by this instance will use the
RawClient and Retrier provided here.
name - this bucket's nameproperties - the BucketProperties for this bucketclient - a RawClient to use for all RiakOperationsretrier - a Retrier to use for all RiakOperations| Method Detail |
|---|
public String getName()
Bucket
getName in interface Bucketpublic Boolean getAllowSiblings()
BucketProperties
getAllowSiblings in interface BucketPropertiespublic Boolean getLastWriteWins()
BucketProperties
getLastWriteWins in interface BucketPropertiespublic Integer getNVal()
BucketProperties
getNVal in interface BucketPropertiespublic String getBackend()
BucketProperties
getBackend in interface BucketPropertiespublic Integer getSmallVClock()
BucketProperties
getSmallVClock in interface BucketPropertiespublic Integer getBigVClock()
BucketProperties
getBigVClock in interface BucketPropertiespublic Long getYoungVClock()
BucketProperties
getYoungVClock in interface BucketPropertiespublic Long getOldVClock()
BucketProperties
getOldVClock in interface BucketPropertiespublic Collection<NamedFunction> getPrecommitHooks()
BucketProperties
getPrecommitHooks in interface BucketPropertiespublic Collection<NamedErlangFunction> getPostcommitHooks()
BucketProperties
getPostcommitHooks in interface BucketPropertiespublic Quorum getR()
BucketPropertiesr quorum for this bucket.
getR in interface BucketPropertiespublic Quorum getW()
BucketPropertiesw quorum for this bucket.
getW in interface BucketPropertiespublic Quorum getRW()
BucketPropertiesrw quorum for this bucket.
getRW in interface BucketPropertiespublic Quorum getDW()
BucketPropertiesdw quorum for this bucket.
getDW in interface BucketPropertiespublic Quorum getPR()
BucketPropertiespr quorum for this bucket.
getPR in interface BucketPropertiespublic Quorum getPW()
BucketPropertiespw quorum for this bucket.
getPW in interface BucketPropertiespublic Boolean getBasicQuorum()
BucketProperties
getBasicQuorum in interface BucketPropertiespublic Boolean getNotFoundOK()
BucketProperties
getNotFoundOK in interface BucketPropertiespublic NamedErlangFunction getChashKeyFunction()
BucketProperties
getChashKeyFunction in interface BucketPropertiespublic NamedErlangFunction getLinkWalkFunction()
BucketProperties
getLinkWalkFunction in interface BucketPropertiespublic Boolean getSearch()
BucketProperties
getSearch in interface BucketPropertiespublic boolean isSearchEnabled()
BucketProperties
isSearchEnabled in interface BucketProperties
public Iterable<String> keys()
throws RiakException
RawClient.listKeys(String) operations return a
stream of keys. The stream is closed automatically when the iteratore is
weakly reachable. Do not retain a reference to this Iterable
after you have used it.
keys in interface BucketIterable of Strings.
RiakExceptionRawClient.listKeys(String)
public StoreObject<IRiakObject> store(String key,
byte[] value)
For example, to get a new IRiakObject into Riak.
IRiakObject myNewObject = bucket.store("k", myByteArray)
.w(2) // tunable CAP write quorum
.returnBody(true) // return the IRiakObject from the store
.execute(); // perform the operation.
Creates a StoreObject operation configured with a
Mutation that copies value and
DefaultRiakObject.DEFAULT_CONTENT_TYPE over the any existing
value at key or creates a new DefaultRiakObject with
value and DefaultRiakObject.DEFAULT_CONTENT_TYPE.
The StoreObject is configured with the DefaultResolver
which means the presence of siblings triggers a
UnresolvedConflictException
The StoreObject is configured with a Converter that
simply returns what it is given (IE does no conversion).
store in interface Bucketkey - the key to store the object under.value - a byte[] of the objects value.
StoreObject configured to store value at
key on execute().StoreObject
public StoreObject<IRiakObject> store(String key,
String value)
IRiakObject with
value as the data payload and
text/plain:charset=utf-8 as the contentType
For example, to get a new IRiakObject into Riak.
IRiakObject myNewObject = bucket.store("k", "myValue")
.w(2) // tunable CAP write quorum
.returnBody(true) // return the IRiakObject from the store
.execute(); // perform the operation.
Creates a StoreObject operation configured with a
Mutation that copies value and
Constants.CTYPE_TEXT_UTF8 over the any existing
value at key or creates a new DefaultRiakObject with
value and Constants.CTYPE_TEXT_UTF8.
The StoreObject is configured with the DefaultResolver
which means the presence of siblings triggers a
UnresolvedConflictException
The StoreObject is configured with a Converter that
simply returns what it is given (IE does no conversion).
store in interface Bucketkey - the key to store the object under.value - a String of the data to store
StoreObject configured to store value at
key on execute().StoreObjectpublic <T> StoreObject<T> store(T o)
T in Riak. Depends on the
Converter provided to StoreObject to convert
o from T to IRiakObject.
T must have a field annotated with RiakKey as the
Key to store this data under.
Creates a StoreObject operation configured with the
JSONConverter the ClobberMutation and
DefaultResolver.
store in interface BucketT - the Type of oo - the data to store
StoreObject configured to store o at the
RiakKey annotated key on
execute().StoreObject,
DomainBucket
public <T> StoreObject<T> store(String key,
T o)
T in Riak. Depends on the
Converter provided to StoreObject to convert
o from T to IRiakObject.
Creates a StoreObject operation configured with the
JSONConverter the ClobberMutation and
DefaultResolver.
store in interface BucketT - the Type of oo - the data to storekey - the key
StoreObject configured to store o at the
RiakKey annotated key on
execute().StoreObject,
DomainBucketpublic <T> FetchObject<T> fetch(T o)
FetchObject operation that returns the data at
o's annotated RiakKey field as an instance of type
T on execute().
Creates a FetchObject operation configured with the
JSONConverter and
DefaultResolver.
fetch in interface BucketT - the Type to returno - an instance ot T that has the key annotated with
RiakKey
FetchObjectFetchObject
public <T> FetchObject<T> fetch(String key,
Class<T> type)
FetchObject operation that returns the data at
key as an instance of type T on
execute().
Creates a FetchObject operation configured with the
JSONConverter and
DefaultResolver.
fetch in interface BucketT - the Type to returnkey - the key under which the data is storedtype - the Class of the type to return
FetchObjectFetchObjectpublic FetchObject<IRiakObject> fetch(String key)
FetchObject that returns the data at key
as an IRiakObject on execute().
Creates a FetchObject with the DefaultResolver and a Converter
that does nothing to the IRiakObject.
fetch in interface Bucketkey - the key
FetchObjectFetchObjectpublic <T> DeleteObject delete(T o)
BucketDeleteObject operation that will delete the data at
o's RiakKey annotated field value on
execute().
delete in interface BucketT - the Type of oo - an instance of T with a value for the key in the
field annotated by RiakKey
DeleteObjectDeleteObjectpublic DeleteObject delete(String key)
BucketDeleteObject operation that will delete the data at
key on execute().
delete in interface BucketDeleteObjectDeleteObjectpublic <T> FetchIndex<T> fetchIndex(RiakIndex<T> index)
BucketFetchIndex operation for the given index name and type
fetchIndex in interface BucketT - the index type (currently String or Integer)index - an index
FetchIndex operation for further configuration and
execution
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||