Bucket Types allow groups of buckets to share configuration
details. Each bucket belongs to a type and inherits its
properties. Buckets can override the properties they inherit using
riak_core_bucket. The "Default Bucket Type" always
exists. The Default Type's properties come from the riak_core
default_bucket_props application config, so the Default Type and
its buckets continue to act as they had prior to the existence of
Bucket Types.
Unlike Buckets, Bucket Types must be explicitly created. In
addition, types support setting some properties only on creation
(via riak_core_bucket_props:validate/4). Since, types are
stored using riak_core_metadata, in order to provide safe
creation semantics the following invariant must be satisfied: all
nodes in the cluster either see no type or a single version of the
type for the lifetime of the cluster (nodes need not see the single
version at the same time). As part of ensuring this invariant, creation
is a two-step process:
1. The type is created and is inactive. To the node an inactive type does not exist 2. When the creation has propogated to all nodes, the type may be activated. As the activation propogates, nodes will be able to use the type
The first step is performed using create/2. The second by
activate/1. After the type has been activated, some
properties may be updated using update/2. All operations are
serialized through riak_core_claimant except reading bucket
type properties with get/1.
Bucket types can be in one of four states. The
state of a type can be queried using status/1.
1. undefined - the type has not been created 2. created - the type has been created but has not propogated to all nodes 3. ready - the type has been created and has propogated to all nodes but has not been activated 4. active - the Bucket Type has been activated, but the activation may not have propogated to all nodes yet
In order for the invariant to hold, additional restrictions are
placed on the operations, generally and based on the state of the
Bucket Type. These restrictions are in-place to ensure safety
during cases where membership changes or node failures change the
riak_core_claimant to a new node -- ensuring concurrent
updates do not break the invariant.
* calling create/1 multiple times before a Bucket Type
is active is allowed. The newer creation will supersede any
previous ones. In addition, the type will be "claimed" by the
riak_core_claimant node writing the property. Future
calls to create/1 must be serialized through the same
claimant node or the call will not succeed. In the case where
the claimed type fails to propogate to a new claimant during a
a failure the potential concurrent update is resolved with
last-write-wins. Since nodes can not use inactive types, this is
safe.
* A type may only be activated if it is in the ready state. This means
all nodes must be reachable from the claimant
* create/1 will fail if the type is active. Activation concurrent
with creation is not possible due to the previous restriction
* update/1 will fail unless the type is updated. update/1 does
not allow modifications to properties for which the invariant must hold
(NOTE: this is up to the implementor of the riak_core bucket_validator).
bucket_type() = binary()
bucket_type_props() = riak_core_bucket:properties()
| activate/1 | Activate the type. |
| all_n/0 | iterate over bucket types and find any active buckets. |
| create/2 | Create the type. |
| defaults/0 | The hardcoded defaults for all bucket types. |
| defaults/1 | The hardcoded defaults for the legacy, default bucket type. |
| fold/2 | Fold over all bucket types, storing result in accumulator. |
| get/1 | Return the properties associated with the given bucket type. |
| iterator/0 | Return an iterator that can be used to walk through all existing bucket types and their properties. |
| itr_close/1 | |
| itr_done/1 | Returns true if there are no more bucket types to iterate over. |
| itr_next/1 | Advance the iterator to the next bucket type. |
| itr_value/1 | Returns the type and properties that the iterator points too. |
| property_hash/2 | Returns a hash of a specified set of bucket type properties whose values may have implications on the treatment or handling of buckets created using the bucket type. |
| property_hash/3 | |
| reset/1 | Reset the properties of the bucket. |
| status/1 | Returns the state the type is in. |
| update/2 | Update an existing bucket type. |
activate(BucketType::bucket_type()) -> ok | {error, undefined | not_ready}
Activate the type. This will succeed only if the type is in the ready state. Otherwise,
an error is returned.
all_n() -> riak_core_bucket:nval_set()
iterate over bucket types and find any active buckets.
create(BucketType::bucket_type(), Props::bucket_type_props()) -> ok | {error, term()}
Create the type. The type is not activated (available to nodes) at this time. This function may be called arbitratily many times if the claimant does not change between calls and the type is not active. An error will also be returned if the properties are not valid. Properties not provided will be taken from those returned by
See also: defaults/0.
defaults() -> bucket_type_props()
The hardcoded defaults for all bucket types.
defaults(X1::default_type) -> bucket_type_props()
The hardcoded defaults for the legacy, default bucket
type. These find their way into the default_bucket_props
environment variable
fold(Fun::fun(({bucket_type(), bucket_type_props()}, any()) -> any()), Accumulator::any()) -> any()
Fold over all bucket types, storing result in accumulator
get(BucketType::bucket_type()) -> undefined | bucket_type_props()
Return the properties associated with the given bucket type.
iterator() -> riak_core_metadata:iterator()
Return an iterator that can be used to walk through all existing bucket types and their properties
itr_close(It::riak_core_metadata:iterator()) -> ok
itr_done(It::riak_core_metadata:iterator()) -> boolean()
Returns true if there are no more bucket types to iterate over
itr_next(It::riak_core_metadata:iterator()) -> riak_core_metadata:iterator()
Advance the iterator to the next bucket type. itr_done/1 should always be called before this function
itr_value(It::riak_core_metadata:iterator()) -> {bucket_type(), bucket_type_props()}
Returns the type and properties that the iterator points too. Any siblings, are resolved at this time. itr_done/1 should be checked before calling this function.
property_hash(Type::bucket_type(), PropKeys::[term()]) -> undefined | integer()
Returns a hash of a specified set of bucket type properties whose values may have implications on the treatment or handling of buckets created using the bucket type.
property_hash(Type::bucket_type(), PropKeys::[term()], Props::undefined | bucket_type_props()) -> undefined | integer()
reset(BucketType::bucket_type()) -> ok | {error, term()}
Reset the properties of the bucket. This only affects properties that
can be set using update/2 and can only be performed on an active
type.
riak-admin but can be invoked
from the console.
status(BucketType::bucket_type()) -> undefined | created | ready | active
Returns the state the type is in.
update(BucketType::bucket_type(), Props::bucket_type_props()) -> ok | {error, term()}
Update an existing bucket type. Updates may only be performed on active types. Properties not provided will keep their existing values.
Generated by EDoc