Tags

, , ,

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.

Getting Started

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

When viewing a bucket, Rekon now loads job specs that are saved in the bucket rekon.jobs. It will load map jobs that end in .map and reduce jobs that end in .red. Jobs can be either Javascript or Erlang, but the spec must be valid JSON(1). Save the jobs into $REKON/jobs from the source.

The example below is based on Basho’s Alice in Wonderland text example. The selected phase is the first phase described in the tutorial.

Select a phase from the menu of loaded jobs

Running the first phase only will provide the unaggregated word counts over the bucket.

Result of just the map phase

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.

Run the job composed of the selected phases

When the phases are arranged how you want, click Run and it will process the bucket and generate the output(2).

Result of a two phase job

To see how the job loading and running works in Javascript, see this earlier post.

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).

Select a map job to execute on a single key

Moving Keys

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.

Move data from one key to another

Notes

(1) Currently double quotes and other escape characters aren’t supported very well due to interpolation of the string from Riak.

(2) The output is a little funky since the result of the reduce is a Javascript object. On the todo list is to provide a custom handler for rendering the output.

(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.