Java client: ConflictResolver for RiakObject, how to get the key?

Henning Verbeek hankipanky at gmail.com
Wed Apr 15 07:24:53 EDT 2015


I found a way to solve my problem:
http://stackoverflow.com/questions/29647674/determine-location-of-riakobject-during-conflict-resolution/29648677#29648677

On Mon, Apr 13, 2015 at 10:49 AM, Henning Verbeek <hankipanky at gmail.com> wrote:
> I'm in the process of migrating my code from Riak 1.4 to Riak 2.0.
>
> In Riak 2.0, I'm storing binary data as a RiakObject:
>
> RiakObject obj = new RiakObject();
>    obj.setContentType(CONTENT_TYPE);
>    obj.setValue(BinaryValue.create(someByteArray));
> StoreValue op = new StoreValue.Builder(obj)
>    .withLocation(new Location(ns, keyOfObject))
>    .withOption(StoreValue.Option.RETURN_BODY, false)
>    .build();
>
> A siphash-digest is computed over the byte-array beforehand, and is
> stored in a separate object in Riak (I call it 'manifest').
>
> When fetching the binary data, I want to provide a custom
> ConflictResolver. This resolver shall fetch the manifest to the binary
> data, where it can look up the expected digest. This can then be used
> for identifying and eliminating bad siblings. It can use the object's
> key to identify the corresponding manifest.
>
> My problem is: how does the conflict resolver know the key?
>
> In Riak 1.4, I used IRiakObject to transport the data. The key was
> available right on the IRiakObject:
> public IRiakObject resolve(Collection<IRiakObject> siblings) {
>     ...
>     String key = siblings.iterator().next().getKey();
>     ...
> }
>
> In Riak 2.0, the RiakObject does not expose this method. Is it
> available maybe in the RiakUserMetadata ?
>
> As an alternative, should I maybe create a POJO to encapsulate both
> key (annotated with @RiakKey ?) and byte[]-data? I guess, I'd need a
> custom converter for that, right?
>
> Thanks,
> Henning
>
> --
> My other signature is a regular expression.
> http://www.pray4snow.de



-- 
My other signature is a regular expression.
http://www.pray4snow.de




More information about the riak-users mailing list