HTTP interface for conflict resolution?

Bryan Fink bryan at basho.com
Thu Oct 29 22:19:30 EDT 2009


On Thu, Oct 29, 2009 at 6:43 PM, Moore, Jonathan (CIM)
<Jonathan_Moore at comcast.com> wrote:
> Hi, just joined the list after seeing Justin's Riak talk today at NoSQL East.

Hi, Jonathan.  We'll all be hanging around tomorrow as well.  Please
come introduce yourself - we'd love to hear about your first
impressions.

> I'm playing around with Riak, and am wondering a couple of things about client conflict resolution. Looking at the various Java and Python client
> libraries, they don't appear to have support for this (i.e. there is just a singular "getvalue" on the JiakObject). Similarly, the documentation of
> the HTTP API at:
>
> http://riak.basho.com/edoc/jiak_resource.html or
> http://riak.basho.com/programming.html
>
> don't appear to contemplate this either.
>
...
> Is there a working example of this somewhere else?
>
> 1. Is "allow multi" the default configuration for a bucket? Is this set as part of the "schema" portion of the bucket document?
> 2. If I do a GET on a key, what does a multi-valued response look like from a raw HTTP/JSON point of view?

Yes, indeed.  The JSON interface we call Jiak tries to help by giving
you a little framework in which to describe the conflict resolution
you want.  Right now, that conflict resolution has to be described in
Erlang.

Jiak has the concept of "bucket modules", which are Erlang modules
that know about how to manage data in their buckets.  jiak_example.erl
is a simple implementation of one of these bucket modules.  If you set
the bucket-property 'bucket_mod' to 'jiak_example', then the functions
in the jiak_example module will be called as requests for documents in
that bucket are evaluated.  (See the documentation in
jiak_resource.erl and jiak_example.erl for more detail.)

The bucket module function you're most interested in here is
merge_siblings/1.  When Jiak attempts to read an object that has
siblings, the merge_siblings function in the bucket module will be
called, and in there is where the conflict resolution logic should be
defined.

So, the answer to your question is that there is no built-in JSON
representation for multi-valued data, because the merge would happen
before the JSON rendering.

Also, allow_mult is set to false by default, because that's the
setting that seems to surprise the fewest new developers when they
first touch Riak.  It's easy to change the default to 'true' - just
add to your riak config file:

{default_bucket_props, [{allow_mult, true}]}.

All that said, I'm also about to commit a more "raw" HTTP interface
that does expose the multiple versions all the way to the client.  If
all goes well, I expect that to be available sometime tomorrow.

> Also, the edoc at http://riak.basho.com/edoc/basic-client.txt seems a little out of date (e.g. riak:client_connect/3 does not exist anymore).

Unfortunately, the change from client_connect/3 to client_connect/1
was a quick one, and we weren't careful with the documentation.  Sorry
for the confusion, and thanks for the pointer.

Good luck,
Bryan




More information about the riak-users mailing list