Bucket creation.

OJ Reeves oj at buffered.io
Wed Feb 6 07:41:45 EST 2013


Kevin,

Please see the Unit Test[1] that I've just added to the CI source base. The
test sets all the properties that you have listed on a bucket that doesn't
exist (ie. the test generates a GUID and uses that as the bucket name).

Setting the properties works fine, getting the properties results in the
same values that are set in the first part of the test. In other words,
this functionality works fine in CI. As Alex has already alluded to, the
bucket name that you have chosen might be part of the problem given that
you have a forward slash in the name. If you can replace that with a hyphen
(for example) perhaps you won't have the problem. Having a bucket name with
a slash would easily confuse things in the HTTP interface.

Also, the example test that I have committed shows the fluent nature of the
properties API. It makes for less code that's a bit easier to read.

Hope that helps.
OJ


[1]:
https://github.com/DistributedNonsense/CorrugatedIron/commit/aadc194401627f27e816e9c2829f60eaf0270942

On Wed, Feb 6, 2013 at 2:44 PM, Alexander Moore <moore.alex at gmail.com>wrote:

> I think the problem you are having here is that you are using an invalid
> bucket name.
>
> "buyseasons/products" would actually refer to a bucket/key pair.  Riak
> doesn't have nested buckets.
>
> If you change your bucket name to "buyseasons-products" or
> "buyseasons%20products" it should work.
>
> As for the weird/misleading exception, I'll report it to CorrugatedIron.
>
> Thanks,
> Alex Moore
>
>
> I still have a question. Based on your input I modified the code slightly
>> as follows:
>>
>> ** **
>>
>>             RiakBucketProperties bucketProperties = new
>> RiakBucketProperties();****
>>
>>             bucketProperties.SetNVal(4);****
>>
>>             bucketProperties.SetSearch(true);****
>>
>>             bucketProperties.SetAllowMultiple(true);****
>>
>>             bucketProperties.SetWVal("all");****
>>
>>             bucketProperties.SetRVal("quorum");****
>>
>>             if (!client.SetBucketProperties("buyseasons/products",
>> bucketProperties).IsSuccess)****
>>
>>             {****
>>
>>                 Console.WriteLine("Setting bucket properties failed");***
>> *
>>
>>             }****
>>
>>             RiakResult<RiakBucketProperties> riakBuckpropertiesResult =
>> client.GetBucketProperties("buyseasons/products", true);****
>>
>> ** **
>>
>> But I get a NullReferenceException****
>>
>> ** **
>>
>>   at CorrugatedIron.Models.RiakBucketProperties.ReadQuorum(JObject props,
>> String key, Action`1 setter)****
>>
>>    at CorrugatedIron.Models.RiakBucketProperties..ctor(RiakRestResponse
>> response)****
>>
>>    at CorrugatedIron.RiakClient.GetBucketProperties(String bucket,
>> Boolean extended)****
>>
>> . . . . .****
>>
>> ** **
>>
>> So the bucket should have been created when I set the properties. But
>> then I tried to read the properties back and I get the exception.****
>>
>> ** **
>>
>> *From:* Alexander Sicular [mailto:siculars at gmail.com]
>> *Sent:* Tuesday, February 05, 2013 5:17 PM
>> *To:* Kevin Burton
>> *Cc:* riak-users
>> *Subject:* Re: Bucket creation.****
>>
>> ** **
>>
>> "buckets" are a virtual concept. you dont need to "create" them. just
>> write a key to any bucket. also by modifying the default bucket parameters,
>> by adding the search hook on a bucket, let's say, you are also "creating"
>> the bucket.****
>>
>> ** **
>>
>> -alexander****
>>
>> ** **
>>
>> On Tue, Feb 5, 2013 at 6:09 PM, Kevin Burton <rkevinburton at charter.net>
>> wrote:****
>>
>>  ****
>>
>> I have filed to find code that would create a bucket. It must be in the
>> past I have just put objects into a bucket and Riak must construct the
>> bucket if it does not exist. Now I would like to create the bucket and set
>> some properties on that bucket. But I don’t know how to create the bucket.
>> ****
>>
>>  ****
>>
>> So I have code like:****
>>
>>  ****
>>
>>                             BuildProduct(source, destination);****
>>
>>                             RiakObject value = new RiakObject("products",
>> keySku, JsonConvert.SerializeObject(destination))****
>>
>>                                 {****
>>
>>                                     ContentType = "application/json"****
>>
>>                                 };****
>>
>>  ****
>>
>>                             RiakResult<RiakObject> response =
>> client.Put(value, new RiakPutOptions { W = 2 });****
>>
>>  ****
>>
>> But I would like to create the bucket and set properties on the bucket
>> before I put things into the bucket. Like:****
>>
>>  ****
>>
>>             RiakResult<RiakBucketProperties> riakBuckpropertiesResult =
>> client.GetBucketProperties("products", true);****
>>
>>             if (riakBuckpropertiesResult.IsSuccess)****
>>
>>             {****
>>
>>                 riakBuckpropertiesResult.Value
>>
>
>
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>
>


-- 

OJ Reeves
+61 431 952 586
http://buffered.io/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20130206/5969d8fe/attachment.html>


More information about the riak-users mailing list