com.basho.riak.client.bucket
Class FetchBucket

java.lang.Object
  extended by com.basho.riak.client.bucket.FetchBucket
All Implemented Interfaces:
RiakOperation<Bucket>

public class FetchBucket
extends Object
implements RiakOperation<Bucket>

A RiakOperation that gets a Bucket from Riak.

Calls the underlying RiakClients fetch method via the Retrier attempt method, builds a Bucket from the response.

Example:

   final String bucketName = "userAccounts";
   // fetch a bucket
   Bucket b = client.fetchBucket(bucketName).execute();
   // use the bucket
   IRiakObject o = b.store("k", "v").execute();
 

Author:
russell

Constructor Summary
FetchBucket(RawClient client, String bucket, Retrier retrier)
          Create a FetchBucket that delegates to the provided RawClient.
 
Method Summary
 Bucket execute()
          Execute the fetch operation using the RawClient
 FetchBucket lazyLoadBucketProperties()
          Prior to the addition of this method there was no way to prevent execute() from fetching the BucketProperties from Riak.
 FetchBucket withRetrier(Retrier retrier)
          Provide a Retrier to use for the fetch operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FetchBucket

public FetchBucket(RawClient client,
                   String bucket,
                   Retrier retrier)
Create a FetchBucket that delegates to the provided RawClient.

Parameters:
client - the RawClient to use when fetching the bucket data.
bucket - the name of the bucket to fetch.
retrier - the Retrier to use when fetching bucket data.
Method Detail

execute

public Bucket execute()
               throws RiakRetryFailedException
Execute the fetch operation using the RawClient

Specified by:
execute in interface RiakOperation<Bucket>
Returns:
a Bucket configured to use this instances RawClient and Retrier for its operations
Throws:
RiakRetryFailedException - if the Retrier throws RiakRetryFailedException

withRetrier

public FetchBucket withRetrier(Retrier retrier)
Provide a Retrier to use for the fetch operation.

Parameters:
retrier - the Retrier to use
Returns:
this

lazyLoadBucketProperties

public FetchBucket lazyLoadBucketProperties()
Prior to the addition of this method there was no way to prevent execute() from fetching the BucketProperties from Riak.

Calling this prior to execute() allows you to defer fetching the bucket properties for this bucket from Riak until they are required by one of the Bucket methods that accesses them (e.g. BucketProperties.getR() ). If none of those methods are called then they are never retrieved.

Returns:
this
Since:
1.0.4


Copyright © 2012. All Rights Reserved.