com.basho.riak.client.bucket
Class WriteBucket

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

public class WriteBucket
extends Object
implements RiakOperation<Bucket>

A RiakOperation for creating/updating a Bucket.

This class is a fluid builder for creating a RiakOperation that sets bucket properties on a bucket in Riak. It delegates to a BucketPropertiesBuilder then uses its RawClient and Retrier to set the bucket properties in Riak.

NOTE: all the parameters on the builder are optional. If omitted then the Riak defaults will be used. Also, very few of these properties are supported by both underlying APIs at present. They are here for completeness sake. Changes are underway to support all the properties. Check the docs for the individual parameters to see what is supported.

Author:
russell

Constructor Summary
WriteBucket(RawClient client, Bucket bucket, Retrier retrier)
          Create WriteBucket operation that delegates to the given RawClient via the give Retrier.
WriteBucket(RawClient client, String name, Retrier retrier)
          Create WriteBucket operation that delegates to the given RawClient via the give Retrier.
 
Method Summary
 WriteBucket addPostcommitHook(NamedErlangFunction postcommitHook)
          Add a postcommit hook to the Collection of post commit hooks for the bucket to written.
 WriteBucket addPrecommitHook(NamedFunction preCommitHook)
          Add a precommit hook to the Collection of hooks to be written.
 WriteBucket allowSiblings(boolean allowSiblings)
          Should the bucket have allow_mult set to true?
 WriteBucket backend(String backend)
          Which backend this bucket uses.
 WriteBucket basicQuorum(boolean basicQuorum)
          The default basic_quorum value NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket bigVClock(int bigVClock)
          set the big_vclock prune size NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket chashKeyFunction(NamedErlangFunction chashKeyFunction)
          Set the chash_key_fun on the bucket to be written NOTE: at present this is not supported by the PB API and has no effect for that client.
 WriteBucket disableSearch()
          convenience for setting search=false **and** removing the search precommit hook (support for both pre-1.0 and 1.0 search) NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket dw(int dw)
          The default dw quorom as an int NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket dw(Quora dw)
          The default dw quorom NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket enableForSearch()
          convenience for setting search=true **and** adding the search precommit hook (support for both pre-1.0 and 1.0 search) NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 Bucket execute()
          Creates/updates a Bucket in Riak with the set of properties configured.
 WriteBucket lastWriteWins(boolean lastWriteWins)
          Is this bucket last_write_wins? NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport.
 WriteBucket lazyLoadBucketProperties()
          Prior to the addition of this method there was no way to prevent execute() from fetching the BucketProperties from Riak after storing any modifications made via this object.
 WriteBucket linkWalkFunction(NamedErlangFunction linkWalkFunction)
          Set the link_walk_fun used by Riak on the bucket to be written.
 WriteBucket notFoundOK(boolean notFoundOK)
          The default notfound_ok value NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket nVal(int nVal)
          The n_val for this bucket
 WriteBucket oldVClock(long oldVClock)
          set the old_vclock prune age NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket postcommitHooks(Collection<NamedErlangFunction> postCommitHooks)
          Add a collection of postcommit hooks to the bucket to be written.
 WriteBucket pr(int pr)
          The default pr quorom as an int NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket pr(Quora pr)
          The default pr quorom NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket precommitHooks(Collection<NamedFunction> precommitHooks)
          A Collection of precommit hooks for this bucket NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket pw(int pw)
          The default dw quorom as an int NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket pw(Quora pw)
          The default pw quorom NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket r(int r)
          The default r quorom as an int NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket r(Quora r)
          The default r Quorom for the bucket NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket rw(int rw)
          The default rw quorom as an int NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket rw(Quora rw)
          The default rw quorom NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket smallVClock(int smallVClock)
          set the small vclock prune size NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket w(int w)
          The default w quorom as an int NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket w(Quora w)
          The default w quorom NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 WriteBucket withRetrier(Retrier retrier)
          Specify the retrier to use for this operation.
 WriteBucket youngVClock(long youngVClock)
          set the young_vclock prune age NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WriteBucket

public WriteBucket(RawClient client,
                   String name,
                   Retrier retrier)
Create WriteBucket operation that delegates to the given RawClient via the give Retrier.

Parameters:
client - the RawClient to delegate to
name - the name of the bucket to create/update
retrier - the Retrier to use

WriteBucket

public WriteBucket(RawClient client,
                   Bucket bucket,
                   Retrier retrier)
Create WriteBucket operation that delegates to the given RawClient via the give Retrier.

Parameters:
client - the RawClient to delegate to
bucket - the bucket to update
retrier - the Retrier to use
Method Detail

execute

public Bucket execute()
               throws RiakRetryFailedException
Creates/updates a Bucket in Riak with the set of properties configured.

Specified by:
execute in interface RiakOperation<Bucket>
Returns:
the Bucket
Throws:
RiakRetryFailedException

allowSiblings

public WriteBucket allowSiblings(boolean allowSiblings)
Should the bucket have allow_mult set to true?

Parameters:
allowSiblings -
Returns:
this

lastWriteWins

public WriteBucket lastWriteWins(boolean lastWriteWins)
Is this bucket last_write_wins? NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport.

Parameters:
lastWriteWins -
Returns:
this

nVal

public WriteBucket nVal(int nVal)
The n_val for this bucket

Parameters:
nVal -
Returns:
this

backend

public WriteBucket backend(String backend)
Which backend this bucket uses. NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
backend -
Returns:
this

precommitHooks

public WriteBucket precommitHooks(Collection<NamedFunction> precommitHooks)
A Collection of precommit hooks for this bucket NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
precommitHooks -
Returns:

addPrecommitHook

public WriteBucket addPrecommitHook(NamedFunction preCommitHook)
Add a precommit hook to the Collection of hooks to be written. NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
preCommitHook -
Returns:
this

postcommitHooks

public WriteBucket postcommitHooks(Collection<NamedErlangFunction> postCommitHooks)
Add a collection of postcommit hooks to the bucket to be written. NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
postCommitHooks -
Returns:

addPostcommitHook

public WriteBucket addPostcommitHook(NamedErlangFunction postcommitHook)
Add a postcommit hook to the Collection of post commit hooks for the bucket to written. NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
postcommitHook -
Returns:

chashKeyFunction

public WriteBucket chashKeyFunction(NamedErlangFunction chashKeyFunction)
Set the chash_key_fun on the bucket to be written NOTE: at present this is not supported by the PB API and has no effect for that client.

Parameters:
chashKeyFunction -
Returns:

linkWalkFunction

public WriteBucket linkWalkFunction(NamedErlangFunction linkWalkFunction)
Set the link_walk_fun used by Riak on the bucket to be written. NOTE: at present this is not supported by the PB API and has no effect for that client.

Parameters:
linkWalkFunction -
Returns:

smallVClock

public WriteBucket smallVClock(int smallVClock)
set the small vclock prune size NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
smallVClock -
Returns:

bigVClock

public WriteBucket bigVClock(int bigVClock)
set the big_vclock prune size NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
bigVClock -
Returns:

youngVClock

public WriteBucket youngVClock(long youngVClock)
set the young_vclock prune age NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
youngVClock -
Returns:

oldVClock

public WriteBucket oldVClock(long oldVClock)
set the old_vclock prune age NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
oldVClock -
Returns:

r

public WriteBucket r(Quora r)
The default r Quorom for the bucket NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
r -
Returns:

r

public WriteBucket r(int r)
The default r quorom as an int NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
r -
Returns:

w

public WriteBucket w(Quora w)
The default w quorom NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
w -
Returns:

w

public WriteBucket w(int w)
The default w quorom as an int NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
w -
Returns:

rw

public WriteBucket rw(Quora rw)
The default rw quorom NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
rw -
Returns:

rw

public WriteBucket rw(int rw)
The default rw quorom as an int NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
rw -
Returns:

dw

public WriteBucket dw(Quora dw)
The default dw quorom NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
dw -
Returns:

dw

public WriteBucket dw(int dw)
The default dw quorom as an int NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
dw -
Returns:

pr

public WriteBucket pr(Quora pr)
The default pr quorom NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
pr -
Returns:

pr

public WriteBucket pr(int pr)
The default pr quorom as an int NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
pr -
Returns:

pw

public WriteBucket pw(Quora pw)
The default pw quorom NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
pw -
Returns:

pw

public WriteBucket pw(int pw)
The default dw quorom as an int NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
dw -
Returns:

basicQuorum

public WriteBucket basicQuorum(boolean basicQuorum)
The default basic_quorum value NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
basicQuorum -
Returns:

notFoundOK

public WriteBucket notFoundOK(boolean notFoundOK)
The default notfound_ok value NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Parameters:
notFoundOK -
Returns:

withRetrier

public WriteBucket withRetrier(Retrier retrier)
Specify the retrier to use for this operation. If non-provided will use the client configured default.

Parameters:
retrier - a Retrier to use for the execute operation
Returns:
this

enableForSearch

public WriteBucket enableForSearch()
convenience for setting search=true **and** adding the search precommit hook (support for both pre-1.0 and 1.0 search) NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Returns:
this

disableSearch

public WriteBucket disableSearch()
convenience for setting search=false **and** removing the search precommit hook (support for both pre-1.0 and 1.0 search) NOTE: at present this is not supported by PB API and an UnsupportedPropertyException will be thrown if called for that transport

Returns:
this

lazyLoadBucketProperties

public WriteBucket lazyLoadBucketProperties()
Prior to the addition of this method there was no way to prevent execute() from fetching the BucketProperties from Riak after storing any modifications made via this object.

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.