com.basho.riak.client.operations
Class FetchObject<T>

java.lang.Object
  extended by com.basho.riak.client.operations.FetchObject<T>
All Implemented Interfaces:
RiakOperation<T>

public class FetchObject<T>
extends Object
implements RiakOperation<T>

An operation to get some data from Riak.

Use Bucket.fetch(String) methods to create a fetch operation. Also look at DomainBucket.fetch(Object).

Author:
russell
See Also:
Bucket, DomainBucket

Constructor Summary
FetchObject(RawClient client, String bucket, String key, Retrier retrier)
          Create a new FetchOperation that delegates to the given client to fetch the data from bucket at key using retrier
 
Method Summary
 FetchObject<T> basicQuorum(boolean basicQuorum)
           
 T execute()
          Attempts to fetch the data at bucket/key, convert it with Converter and resolve any siblings with ConflictResolver
 VClock getVClock()
           
 boolean hasDeletedVclock()
           
 boolean hasVclock()
           
 FetchObject<T> ifModified(VClock vclock)
          *NOTE* PB Only.
 boolean isUnmodified()
           
 FetchObject<T> modifiedSince(Date modifiedSince)
          *NOTE* HTTP Only.
 FetchObject<T> notFoundOK(boolean notFoundOK)
           
 FetchObject<T> pr(int pr)
           
 FetchObject<T> pr(Quora pr)
           
 FetchObject<T> pr(Quorum pr)
           
 FetchObject<T> r(int r)
          The read quorum for this fetch operation
 FetchObject<T> r(Quora r)
          The read quorum for this fetch operation
 FetchObject<T> r(Quorum r)
          The read quorum for this fetch operation
 FetchObject<T> returnDeletedVClock(boolean returnDeletedVClock)
           
 FetchObject<T> withConverter(Converter<T> converter)
          A Converter to use to convert the data fetched to some other type
 FetchObject<T> withResolver(ConflictResolver<T> resolver)
           
 FetchObject<T> withRetrier(Retrier retrier)
          A Retrier to use
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FetchObject

public FetchObject(RawClient client,
                   String bucket,
                   String key,
                   Retrier retrier)
Create a new FetchOperation that delegates to the given client to fetch the data from bucket at key using retrier

Use Bucket to create a Fetch operation, also consider using DomainBucket

Parameters:
client - the RawClient to use for the operation
bucket - the name of the bucket to get the data item from
key - the name of the key to get the data item from
retrier - the Retrier to use when executing the operation.
Method Detail

execute

public T execute()
          throws UnresolvedConflictException,
                 RiakRetryFailedException,
                 ConversionException
Attempts to fetch the data at bucket/key, convert it with Converter and resolve any siblings with ConflictResolver

Specified by:
execute in interface RiakOperation<T>
Returns:
an instance ofT that was stored at bucket/key or null if not found.
Throws:
UnresolvedConflictException - if the ConflictResolver used cannot get a single value from any siblings
RiakRetryFailedException - if the Retrier fails to execute the operation beyond some internal bound
ConversionException - if the supplied Converter throws trying to convert the retrieved value.

withResolver

public FetchObject<T> withResolver(ConflictResolver<T> resolver)

r

public FetchObject<T> r(int r)
The read quorum for this fetch operation

Parameters:
r - an Integer for the read quorum
Returns:
this

r

public FetchObject<T> r(Quora r)
The read quorum for this fetch operation

Parameters:
r - an Quora for the read quorum
Returns:
this

r

public FetchObject<T> r(Quorum r)
The read quorum for this fetch operation

Parameters:
r - an Quorum for the read quorum
Returns:
this

pr

public FetchObject<T> pr(int pr)
Parameters:
pr -
Returns:
See Also:
FetchMeta.Builder.pr(int)

pr

public FetchObject<T> pr(Quora pr)
Parameters:
pr -
Returns:
See Also:
FetchMeta.Builder.pr(Quora)

pr

public FetchObject<T> pr(Quorum pr)
Parameters:
pr -
Returns:
See Also:
FetchMeta.Builder.pr(Quora)

notFoundOK

public FetchObject<T> notFoundOK(boolean notFoundOK)
Parameters:
notFoundOK -
Returns:
See Also:
FetchMeta.Builder.notFoundOK(boolean)

basicQuorum

public FetchObject<T> basicQuorum(boolean basicQuorum)
Parameters:
basicQuorum -
Returns:
See Also:
FetchMeta.Builder.basicQuorum(boolean)

returnDeletedVClock

public FetchObject<T> returnDeletedVClock(boolean returnDeletedVClock)
Parameters:
returnDeletedVClock -
Returns:
See Also:
FetchMeta.Builder.returnDeletedVClock(boolean)

modifiedSince

public FetchObject<T> modifiedSince(Date modifiedSince)
*NOTE* HTTP Only. TODO using generics and transports make this generic Transport for either Date/VClock

Parameters:
modifiedSince - a last modified date.
Returns:
this

ifModified

public FetchObject<T> ifModified(VClock vclock)
*NOTE* PB Only. TODO using generics and transports make this generic T for either Date/VClock

Parameters:
vclock - a vclock
Returns:
this

withConverter

public FetchObject<T> withConverter(Converter<T> converter)
A Converter to use to convert the data fetched to some other type

Parameters:
converter -
Returns:
this

withRetrier

public FetchObject<T> withRetrier(Retrier retrier)
A Retrier to use

Parameters:
retrier -
Returns:

isUnmodified

public boolean isUnmodified()
Returns:
true if the fetch was conditional and no result was returned since the value was unmodified

hasDeletedVclock

public boolean hasDeletedVclock()
Returns:
true if the fetch was to a deleted key but the returnDeletedVClock parameter was set, and the response has that vclock

hasVclock

public boolean hasVclock()
Returns:
checks that the response had a vclock (i.e. was some kind of success)

getVClock

public VClock getVClock()
Returns:
if hasDeletedVclock or hasVclock return true, this method returns the vclock


Copyright © 2012. All Rights Reserved.