Rekon is a light-weight data browser for Riak provided by Basho. It’s a great tool and illustrates some seriously slick features of Riak. However, it is limited to a few simple operations. I wanted a way for Rekon to act as an interface for running map/reduce jobs within Riak. Seems far simpler than doing it all via curl. That said, I forked and went off my merry way. This is the result.
Download my fork of Rekon at github. I updated the installer to support some command line options. To install everything to run the examples, you’ll need to run this:
./install.sh -av host:port
Also, you need to add /etc/riak/erlang to your riak code path (hint: use the configuration option) to run the erlang-based phases.
Running Jobs Over a Bucket
The example below is based on Basho’s Alice in Wonderland text example. The selected phase is the first phase described in the tutorial.
Running the first phase only will provide the unaggregated word counts over the bucket.
Multiple phases can be sequenced together. The phases can be rearranged and removed, so don’t worry about making a mistake. Obviously if the output of one format is different from the input of the next, things will get ugly pretty quickly.
When the phases are arranged how you want, click Run and it will process the bucket and generate the output(2).
Running a Job on a Key
It’s possible to run a job over a single key as well. Depending on the content type of your data, sometimes it’s nice to transform it a bit in order to view it in Rekon. This is certainly the case if you store erlang binaries in Riak. The erl_to_json.map job does just this and will turn records into a list that is easily displayed in the browser. This job calls an erlang module (found in the $REKON/erlang directory), which is compiled and saved to /etc/riak/erlang(3).
One final addition is the ability to move an object from one key to another. This is just a convenience when a key is entered incorrectly or if data needs to be migrated to work with some process. Clearly not a production feature, but useful during development. Just click the move icon (4) to open a modal dialog to move the key you chose.
(1) Currently double quotes and other escape characters aren’t supported very well due to interpolation of the string from Riak.
(3) The output directory is configurable by specifying the -E option.
(4) I didn’t create any new icons, so it is the same icon as the View column. Sorry.