public class StoreObject<T> extends Object implements RiakOperation<T>
Use Bucket.store(Object)
methods to create a store operation. Also
look at DomainBucket.store(Object)
.
Bucket
,
DomainBucket
Constructor and Description |
---|
StoreObject(RawClient client,
String bucket,
String key,
Retrier retrier)
Create a new StoreObject operation for the object in
bucket
at key . |
Modifier and Type | Method and Description |
---|---|
StoreObject<T> |
asis(boolean asis)
If you don't know what this is or what it does, you should not
be using it.
|
StoreObject<T> |
basicQuorum(boolean basicQuorum)
fail early if a quorum of error/notfounds are reached before a successful
read (for the pre-store fetch)
|
StoreObject<T> |
dw(int dw)
The durable write quorum for this store operation
|
StoreObject<T> |
dw(Quora dw)
The durable write quorum for this store operation
|
StoreObject<T> |
dw(Quorum dw)
The durable write quorum for this store operation
|
T |
execute()
Fetches data from
bucket/key , if item exists it is converted
with Converter and any siblings resolved with
ConflictResolver . |
StoreObject<T> |
ifNoneMatch(boolean ifNoneMatch)
Default is false (i.e.
|
StoreObject<T> |
ifNotModified(boolean ifNotModified)
Default is false (i.e.
|
StoreObject<T> |
notFoundOK(boolean notFoundOK)
if notfound_ok counts towards r count (for the pre-store fetch)
|
StoreObject<T> |
pr(int pr)
The pr for the pre-store fetch
|
StoreObject<T> |
pr(Quora pr)
The pr for the pre-store fetch
|
StoreObject<T> |
pr(Quorum pr)
The pr for the pre-store fetch
|
StoreObject<T> |
pw(int pw)
Set the primary write quorum for the store operation, takes precedence
over w.
|
StoreObject<T> |
pw(Quora pw)
Set the primary write quorum for the store operation, takes precedence
over w.
|
StoreObject<T> |
pw(Quorum pw)
Set the primary write quorum for the store operation, takes precedence
over w.
|
StoreObject<T> |
r(int r)
A store performs a fetch first (to get a vclock and resolve any conflicts), set the read quorum for the fetch
|
StoreObject<T> |
r(Quora r)
A store performs a fetch first (to get a vclock and resolve any conflicts), set the read quorum for the fetch
|
StoreObject<T> |
r(Quorum r)
A store performs a fetch first (to get a vclock and resolve any conflicts), set the read quorum for the fetch
|
StoreObject<T> |
returnBody(boolean returnBody)
Should the store operation return a response body?
|
StoreObject<T> |
returnDeletedVClock(boolean returnDeletedVClock)
If the object has just been deleted, there maybe a tombstone value
vclock, set to true to have this returned in the pre-store fetch.
|
StoreObject<T> |
timeout(int timeout)
Set an operation timeout in milliseconds to be sent to Riak
As of 1.4 Riak allows a timeout to be sent for get, put, and delete operations.
|
StoreObject<T> |
w(int w)
Set the write quorum for the store operation
|
StoreObject<T> |
w(Quora w)
Set the write quorum for the store operation
|
StoreObject<T> |
w(Quorum w)
Set the write quorum for the store operation
|
StoreObject<T> |
withConverter(Converter<T> converter)
The
Converter to use |
StoreObject<T> |
withMutator(Mutation<T> mutation)
The
Mutation to apply to the value retrieved from the fetch operation |
StoreObject<T> |
withoutFetch()
Eliminates fetching the existing value before storing the current one.
|
StoreObject<T> |
withResolver(ConflictResolver<T> resolver)
The
ConflictResolver to use on any sibling results returned from the fetch (and store if returnBody is true)
NOTE: since it is used for fetch and after store must be reusable. |
StoreObject<T> |
withRetrier(Retrier retrier)
The
Retrier to use for the fetch and store operations. |
StoreObject<T> |
withValue(T value)
Creates a
ClobberMutation that applies value |
public StoreObject(RawClient client, String bucket, String key, Retrier retrier)
bucket
at key
.
Use Bucket
to create a store operation.
client
- the RawClient to usebucket
- location of data to storekey
- location of data to storeretrier
- the Retrier to use for this operationpublic T execute() throws RiakRetryFailedException, UnresolvedConflictException, ConversionException
bucket/key
, if item exists it is converted
with Converter
and any siblings resolved with
ConflictResolver
. Mutation
is applied to the result which
is then converted back to IRiakObject
and stored with the
RawClient
. If returnBody
is true then the returned
result is treated like a fetch (converted, conflict resolved) and the
resultant object returned.
If you wish to eliminate the fetch and conflict resolution, calling
withoutFetch()
prior to this will do so.execute
in interface RiakOperation<T>
returnBody
is
true
, null
if returnBody
is false
RiakException
{@link
- MatchFoundException} if a 'ifNoneMatch' conditional store
fails because a match existsRiakRetryFailedException
UnresolvedConflictException
ConversionException
public StoreObject<T> r(int r)
r
- the read quorum for the pre-store fetchpublic StoreObject<T> r(Quora r)
r
- the read quorum for the pre-store fetchpublic StoreObject<T> r(Quorum r)
r
- the read quorum for the pre-store fetchpublic StoreObject<T> pr(int pr)
pr
- FetchObject.pr(int)
public StoreObject<T> pr(Quora pr)
pr
- FetchObject.pr(Quora)
public StoreObject<T> pr(Quorum pr)
pr
- FetchObject.pr(Quorum)
public StoreObject<T> notFoundOK(boolean notFoundOK)
notFoundOK
- FetchObject.notFoundOK(boolean)
public StoreObject<T> basicQuorum(boolean basicQuorum)
basicQuorum
- FetchObject.basicQuorum(boolean)
public StoreObject<T> timeout(int timeout)
timeout
- FetchMeta.Builder.timeout
public StoreObject<T> returnDeletedVClock(boolean returnDeletedVClock)
returnDeletedVClock
- FetchObject.returnDeletedVClock(boolean)
public StoreObject<T> pw(int pw)
pw
- public StoreObject<T> pw(Quora pw)
pw
- public StoreObject<T> pw(Quorum pw)
pw
- public StoreObject<T> w(int w)
w
- public StoreObject<T> w(Quora w)
w
- public StoreObject<T> w(Quorum w)
w
- public StoreObject<T> dw(int dw)
dw
- public StoreObject<T> dw(Quora dw)
dw
- public StoreObject<T> dw(Quorum dw)
dw
- public StoreObject<T> returnBody(boolean returnBody)
returnBody
- public StoreObject<T> asis(boolean asis)
asis
- public StoreObject<T> ifNoneMatch(boolean ifNoneMatch)
NOTE: This has different meanings depending on the underlying transport.
In the case of the PB interface it means: Only store if there is no bucket/key entry for this object in the database already.
For the HTTP API it means: Only store if there is no entity that matches some etags I provide you
To make this transparent the StoreOperation will pull the etag from the object returned in the pre-store fetch, and use that as supplementary data to the HTTP Store request.
If there is match (b/k or etag) then the operation is *not* retried by the retrier, to override this, provide a custom retrier.
ifNoneMatch
- true if you want a conditional store, false otherwise,
defaults to false.public StoreObject<T> ifNotModified(boolean ifNotModified)
NOTE: This has different meanings depending on the underlying transport.
In the case of the PB interface it means: Only store if the vclock provided with the store is the same as the one in Riak for this object (i.e. the object has not been modified since you last got it), of course, since this StoreObject does a fetch before a store the window for concurrent modification is minimized, but this is an extra guard, still.
For the HTTP API it means: Only store if there has been no modification since the provided timestamp.
To make this transparent the StoreOperation will pull the last modified date from the object returned in the pre-store fetch, and use that as supplementary data to the HTTP Store request.
ifNotModified
- true if you want a conditional store, false otherwise,
defaults to false.public StoreObject<T> withRetrier(Retrier retrier)
Retrier
to use for the fetch and store operations.retrier
- a Retrier
public StoreObject<T> withMutator(Mutation<T> mutation)
Mutation
to apply to the value retrieved from the fetch operationmutation
- a Mutation
public StoreObject<T> withResolver(ConflictResolver<T> resolver)
ConflictResolver
to use on any sibling results returned from the fetch (and store if returnBody
is true)
NOTE: since it is used for fetch and after store must be reusable.resolver
- a ConflictResolver
public StoreObject<T> withConverter(Converter<T> converter)
Converter
to useconverter
- a Converter
public StoreObject<T> withValue(T value)
ClobberMutation
that applies value
value
- new valuepublic StoreObject<T> withoutFetch()
null
will be passed to the Mutation
object (if
you are using the default ClobberMutation
this is fine).
2) A vector clock should be provided by the object returned from your
Mutation
.Copyright © 2013. All Rights Reserved.