Skip to content

Instantly share code, notes, and snippets.

@jrwest

jrwest/btypes.md Secret

Last active December 26, 2015 17:49
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrwest/3652ecd1db609e25cdaa to your computer and use it in GitHub Desktop.
Save jrwest/3652ecd1db609e25cdaa to your computer and use it in GitHub Desktop.

Bucket Types

Previous version of Riak used Buckets as a mechanism for logically grouping keys and to associate configuration with certain types of data. Riak 2.0 adds Bucket Types, which associate configuration with groups of buckets and act as a second-level of names-spacing.

Unlike Buckets, Bucket Types must be explicitly created before being used. In addition, some properties may not be modifiable after creation. Other properties may be updated. Buckets grouped under a Bucket Type inherit all of the type's properties. Each bucket may override individual properties but some properties cannot be overridden.

Bucket Type administration is only supported via the riak-admin bucket-type commands. This release does not include an API to perform these actions. The Bucket Properties HTTP API and Protocol Buffers messages have been updated to set and retrieve Bucket Properties for a Bucket under a given Bucket Type, however.

Bucket Type creation is a two-step process: first creating the type and then activating it. Creation is done via riak-admin bucket-type create <TYPE> <PROPS> and activation with riak-admin bucket-type activate <TYPE>. Properties are specified in JSON in this release. That is likely to change in an upcoming release [1].

$ riak-admin bucket-type create mytype '{"props": {"n_val": 4, "allow_mult": false}}'

$ riak-admin bucket-type activate mytype

To view all the properties as well as the status of the type use riak-admin bucket-type status <TYPE>. bucket-type create may be called multiple times until the Bucket Type has been activated. Only properties from the final call to create, before activating, are persisted.

Activation may only be performed once a Bucket Type is considered ready by Riak. bucket-type status contains this information and bucket-type activate will fail unless this condition has been met. When a cluster is stable, Bucket Types will quickly reach the ready state. However, if nodes are down or there are network partitions, it will be necessary to resolve these issues first.

Once activating, most properties may be updated using riak-admin bucket-type update <TYPE> <PROPS> -- where <PROPS> takes the same form as bucket-type create. Some properties, however, are immutable from this point forward. The applies to the following properties:

  • datatype
  • consistent

In addition, these properties may not be overridden by Buckets grouped under a Bucket Type and their use may prevent modifications of other properties. More details on these properties can be found with documentation for the features that use them.

All Bucket Types and their activation status can be viewed using riak-admin bucket-type list.

Existing buckets and data stored in Riak are automatically assigned to the Default Type and will continue to act as Riak always has prior to this release. Requests using old APIs or Protocol Buffers messages excluding a Bucket Type will use the Default Type. In addition, buckets grouped under the Default type are still configurable via riak.conf or (advanced.config). However, all other Bucket Types are created with defaults that are not controlled by the user and must be overridden when creating the Bucket Type.

[1] basho/riak#424

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment