Initializing a commit hook

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Initializing a commit hook

Mav erick
Folks

Is there way RIAK can call an erlang function in a module when RIAK starts up ?

Thanks
Mav

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Initializing a commit hook

Luke Bakken
Mav -

Can you go into more detail? The subject of your message is
"initializing a commit hook".

--
Luke Bakken
Engineer
[hidden email]

On Thu, Nov 17, 2016 at 9:09 AM, Mav erick <[hidden email]> wrote:
> Folks
>
> Is there way RIAK can call an erlang function in a module when RIAK starts
> up ?
>
> Thanks
> Mav

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Initializing a commit hook

Luke Bakken
Mav -

Please remember to use "Reply All" so that the riak-users list can
learn from what you find out. Thanks.

Thebucket = riak_object:bucket(Object),

Can you check to see if "Thebucket" is really a two-tuple of
"{BucketType, Bucket}"? I believe that is what is returned.

--
Luke Bakken
Engineer
[hidden email]

On Fri, Nov 18, 2016 at 10:54 AM, Mav erick <[hidden email]> wrote:

> I have some initializing to do - like connecting to a notification server,
> before I can use the commit hook. But I think I have figured that out now
> that I learnt about supervisors and OTP
>
> I have one other question though ...
> How do I get the bucket type of the bucket of the key that was committed ?
>
> I am using these to get the key and bucket names. But I cant seem to find a
> call to get the bucket's bucket type
>
>   Thebucket = riak_object:bucket(Object),
>   Thekey = riak_object:key(Object),
>
> Thanks !
>
> On 18 November 2016 at 12:14, Luke Bakken <[hidden email]> wrote:
>>
>> Mav -
>>
>> Can you go into more detail? The subject of your message is
>> "initializing a commit hook".
>>
>> --
>> Luke Bakken
>> Engineer
>> [hidden email]
>>
>> On Thu, Nov 17, 2016 at 9:09 AM, Mav erick <[hidden email]> wrote:
>> > Folks
>> >
>> > Is there way RIAK can call an erlang function in a module when RIAK
>> > starts
>> > up ?
>> >
>> > Thanks
>> > Mav
>
>

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Initializing a commit hook

Mav erick
Hi Luke

I tried that and didn't work for a bucket with bucket type = maps. My erlang code below does work for buckets without types. 

But I think its because I didn't set the hook for the typed bucket correctly.Could you check my curl below, please ?

I did this to set the hook
curl -X PUT localhost:8098/riak/types/maps -H 'Content-Type: application/json' -d '{"props":{"precommit":[{"mod":"myhooks","fun":"precommit_hook"}]}}'

That returns 204, but when I get the props ...
{
  "props": {
    "active": true,
    "allow_mult": true,
    "basic_quorum": false,
    "big_vclock": 50,
    "chash_keyfun": {
      "fun": "chash_std_keyfun",
      "mod": "riak_core_util"
    },
    "claimant": "[hidden email]",
    "datatype": "map",
    "dvv_enabled": true,
    "dw": "quorum",
    "last_write_wins": false,
    "linkfun": {
      "fun": "mapreduce_linkfun",
      "mod": "riak_kv_wm_link_walker"
    },
    "n_val": 3,
    "notfound_ok": true,
    "old_vclock": 86400,
    "postcommit": [],
    "pr": 0,
    "precommit": [],
    "pw": 0,
    "r": "quorum",
    "rw": "quorum",
    "small_vclock": 50,
    "w": "quorum",
    "young_vclock": 20
  }
}

The hook code is ...

precommit_hook(Object) ->
   case riak_object:bucket(Object) of
      {BucketType, Bucket} -> Bstr = binary_to_list(Bucket), Btstr = binary_to_list(BucketType);
      Bucket -> Bstr = binary_to_list(Bucket), Btstr = <<"">>
   end,
   K = riak_object:key(Object),
   Kstr = binary_to_list(K),
   lager:info("MyHook Bucket type ~s, bucket ~s, key ~s [Btstr, Bstr, Kstr]),
   Object.


On 18 November 2016 at 14:15, Luke Bakken <[hidden email]> wrote:
Mav -

Please remember to use "Reply All" so that the riak-users list can
learn from what you find out. Thanks.

Thebucket = riak_object:bucket(Object),

Can you check to see if "Thebucket" is really a two-tuple of
"{BucketType, Bucket}"? I believe that is what is returned.

--
Luke Bakken
Engineer
[hidden email]

On Fri, Nov 18, 2016 at 10:54 AM, Mav erick <[hidden email]> wrote:
> I have some initializing to do - like connecting to a notification server,
> before I can use the commit hook. But I think I have figured that out now
> that I learnt about supervisors and OTP
>
> I have one other question though ...
> How do I get the bucket type of the bucket of the key that was committed ?
>
> I am using these to get the key and bucket names. But I cant seem to find a
> call to get the bucket's bucket type
>
>   Thebucket = riak_object:bucket(Object),
>   Thekey = riak_object:key(Object),
>
> Thanks !
>
> On 18 November 2016 at 12:14, Luke Bakken <[hidden email]> wrote:
>>
>> Mav -
>>
>> Can you go into more detail? The subject of your message is
>> "initializing a commit hook".
>>
>> --
>> Luke Bakken
>> Engineer
>> [hidden email]
>>
>> On Thu, Nov 17, 2016 at 9:09 AM, Mav erick <[hidden email]> wrote:
>> > Folks
>> >
>> > Is there way RIAK can call an erlang function in a module when RIAK
>> > starts
>> > up ?
>> >
>> > Thanks
>> > Mav
>
>


_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Initializing a commit hook

Luke Bakken
Mav -

You're not using the correct HTTP URL. You can use this command:

http://docs.basho.com/riak/kv/2.1.4/using/reference/bucket-types/#updating-a-bucket-type

Or this URL:

curl -XPUT localhost:8098/types/maps/props -H 'Content-Type:
application/json' -d
'{"props":{"precommit":[{"mod":"myhooks","fun":"precommit_hook"}]}}'

Please ensure that the "myhooks" beam file is on all Riak servers in a
directory that will be picked up by Riak when it starts:

http://docs.basho.com/riak/kv/2.1.4/using/reference/custom-code/

--
Luke Bakken
Engineer
[hidden email]

On Fri, Nov 18, 2016 at 1:36 PM, Mav erick <[hidden email]> wrote:

> Hi Luke
>
> I tried that and didn't work for a bucket with bucket type = maps. My erlang
> code below does work for buckets without types.
>
> But I think its because I didn't set the hook for the typed bucket
> correctly.Could you check my curl below, please ?
>
> I did this to set the hook
> curl -X PUT localhost:8098/riak/types/maps -H 'Content-Type:
> application/json' -d
> '{"props":{"precommit":[{"mod":"myhooks","fun":"precommit_hook"}]}}'
>
> That returns 204, but when I get the props ...
> curl http://localhost:8098/types/maps/props
> {
>   "props": {
>     "active": true,
>     "allow_mult": true,
>     "basic_quorum": false,
>     "big_vclock": 50,
>     "chash_keyfun": {
>       "fun": "chash_std_keyfun",
>       "mod": "riak_core_util"
>     },
>     "claimant": "riak@10.243.44.165",
>     "datatype": "map",
>     "dvv_enabled": true,
>     "dw": "quorum",
>     "last_write_wins": false,
>     "linkfun": {
>       "fun": "mapreduce_linkfun",
>       "mod": "riak_kv_wm_link_walker"
>     },
>     "n_val": 3,
>     "notfound_ok": true,
>     "old_vclock": 86400,
>     "postcommit": [],
>     "pr": 0,
>     "precommit": [],
>     "pw": 0,
>     "r": "quorum",
>     "rw": "quorum",
>     "small_vclock": 50,
>     "w": "quorum",
>     "young_vclock": 20
>   }
> }
>
> The hook code is ...
>
> precommit_hook(Object) ->
>    case riak_object:bucket(Object) of
>       {BucketType, Bucket} -> Bstr = binary_to_list(Bucket), Btstr =
> binary_to_list(BucketType);
>       Bucket -> Bstr = binary_to_list(Bucket), Btstr = <<"">>
>    end,
>    K = riak_object:key(Object),
>    Kstr = binary_to_list(K),
>    lager:info("MyHook Bucket type ~s, bucket ~s, key ~s [Btstr, Bstr,
> Kstr]),
>    Object.
>
>
> On 18 November 2016 at 14:15, Luke Bakken <[hidden email]> wrote:
>>
>> Mav -
>>
>> Please remember to use "Reply All" so that the riak-users list can
>> learn from what you find out. Thanks.
>>
>> Thebucket = riak_object:bucket(Object),
>>
>> Can you check to see if "Thebucket" is really a two-tuple of
>> "{BucketType, Bucket}"? I believe that is what is returned.
>>
>> --
>> Luke Bakken
>> Engineer
>> [hidden email]
>>
>> On Fri, Nov 18, 2016 at 10:54 AM, Mav erick <[hidden email]> wrote:
>> > I have some initializing to do - like connecting to a notification
>> > server,
>> > before I can use the commit hook. But I think I have figured that out
>> > now
>> > that I learnt about supervisors and OTP
>> >
>> > I have one other question though ...
>> > How do I get the bucket type of the bucket of the key that was committed
>> > ?
>> >
>> > I am using these to get the key and bucket names. But I cant seem to
>> > find a
>> > call to get the bucket's bucket type
>> >
>> >   Thebucket = riak_object:bucket(Object),
>> >   Thekey = riak_object:key(Object),
>> >
>> > Thanks !
>> >
>> > On 18 November 2016 at 12:14, Luke Bakken <[hidden email]> wrote:
>> >>
>> >> Mav -
>> >>
>> >> Can you go into more detail? The subject of your message is
>> >> "initializing a commit hook".
>> >>
>> >> --
>> >> Luke Bakken
>> >> Engineer
>> >> [hidden email]
>> >>
>> >> On Thu, Nov 17, 2016 at 9:09 AM, Mav erick <[hidden email]> wrote:
>> >> > Folks
>> >> >
>> >> > Is there way RIAK can call an erlang function in a module when RIAK
>> >> > starts
>> >> > up ?
>> >> >
>> >> > Thanks
>> >> > Mav
>> >
>> >
>
>

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Initializing a commit hook

Luke Bakken
What is the output of these commands?

curl -4vvv localhost:8098/types/maps/props

curl -4vvv localhost:8098/types/maps/props/buckets/test-bucket/props

On Fri, Nov 18, 2016 at 2:21 PM, Mav erick <[hidden email]> wrote:

> Luke
>
> I was able to change the properties with your URL, but still the hooks are
> not being called for typed buckets ONLY.
>
> The hook is being called for all buckets with no type. So I am sure that
> riak can find the beam file on all my nodes.
>
> I tried restarting riak on all nodes. Still same problem. The hook is called
> for buckets without a type, but wont be called for buckets with a type
>
>
> On 18 November 2016 at 16:45, Luke Bakken <[hidden email]> wrote:
>>
>> Mav -
>>
>> You're not using the correct HTTP URL. You can use this command:
>>
>>
>> http://docs.basho.com/riak/kv/2.1.4/using/reference/bucket-types/#updating-a-bucket-type
>>
>> Or this URL:
>>
>> curl -XPUT localhost:8098/types/maps/props -H 'Content-Type:
>> application/json' -d
>> '{"props":{"precommit":[{"mod":"myhooks","fun":"precommit_hook"}]}}'
>>
>> Please ensure that the "myhooks" beam file is on all Riak servers in a
>> directory that will be picked up by Riak when it starts:
>>
>> http://docs.basho.com/riak/kv/2.1.4/using/reference/custom-code/
>>
>> --
>> Luke Bakken
>> Engineer
>> [hidden email]

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Initializing a commit hook

Mav erick
Here you go ...

For the second url - I think you meant testbucket without the hyphen, Also I think you have an extra "props" in there





* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8098 (#0)
> GET /types/maps/props HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:8098
> Accept: */*
>
< HTTP/1.1 200 OK
< Vary: Accept-Encoding
* Server MochiWeb/1.1 WebMachine/1.10.6 (no drinks) is not blacklisted
< Server: MochiWeb/1.1 WebMachine/1.10.6 (no drinks)
< Date: Fri, 18 Nov 2016 22:27:56 GMT
< Content-Type: application/json
< Content-Length: 545
<
* Connection #0 to host localhost left intact
{"props":{"active":true,"allow_mult":true,"basic_quorum":false,"big_vclock":50,"chash_keyfun":{"mod"
:"riak_core_util","fun":"chash_std_keyfun"},"claimant":"[hidden email]","datatype":"map","dvv_en
abled":true,"dw":"quorum","last_write_wins":false,"linkfun":{"mod":"riak_kv_wm_link_walker","fun":"m
apreduce_linkfun"},"n_val":3,"notfound_ok":true,"old_vclock":86400,"postcommit":[],"pr":0,"precommit
":[{"mod":"commit_hooks","fun":"precommit_hook"}],"pw":0,"r":"quorum","rw":"quorum","smal
l_vclock":50,"w":"quorum","young_vclock":20}}


and ...

$ curl -4vvv localhost:8098/types/maps/props/buckets/testbucket/props
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8098 (#0)
> GET /types/maps/props/buckets/testbucket/props HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:8098
> Accept: */*
>
< HTTP/1.1 404 Object Not Found
* Server MochiWeb/1.1 WebMachine/1.10.6 (no drinks) is not blacklisted
< Server: MochiWeb/1.1 WebMachine/1.10.6 (no drinks)
< Date: Fri, 18 Nov 2016 22:57:51 GMT
< Content-Type: text/html
< Content-Length: 193
<
* Connection #0 to host localhost left intact
<HTML><HEAD><TITLE>404 Not Found</TITLE></HEAD><BODY><H1>Not Found</H1>The requested document was no
t found on this server.<P><HR><ADDRESS>mochiweb+webmachine web server</ADDRESS></BODY></HTML>$


with the corrected url
$ curl -4vvv localhost:8098/types/maps/buckets/testbucket/props
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8098 (#0)
> GET /types/maps//buckets/testbucket/props HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:8098
> Accept: */*
>
< HTTP/1.1 200 OK
< Vary: Accept-Encoding
* Server MochiWeb/1.1 WebMachine/1.10.6 (no drinks) is not blacklisted
< Server: MochiWeb/1.1 WebMachine/1.10.6 (no drinks)
< Date: Fri, 18 Nov 2016 22:59:22 GMT
< Content-Type: application/json
< Content-Length: 565
<
* Connection #0 to host localhost left intact
{"props":{"name":"testbucket","active":true,"allow_mult":true,"basic_quorum":false,"big_vclock":
chash_keyfun":{"mod":"riak_core_util","fun":"chash_std_keyfun"},"claimant":"[hidden email]",
atype":"map","dvv_enabled":true,"dw":"quorum","last_write_wins":false,"linkfun":{"mod":"riak_kv_
ink_walker","fun":"mapreduce_linkfun"},"n_val":3,"notfound_ok":true,"old_vclock":86400,"postcomm
[],"pr":0,"precommit":[{"mod":"commit_hooks","fun":"precommit_hook"}],"pw":0,"r":"quo
,"rw":"quorum","small_vclock":50,"w":"quorum","young_vclock":20}}$





On 18 November 2016 at 17:23, Luke Bakken <[hidden email]> wrote:
What is the output of these commands?

curl -4vvv localhost:8098/types/maps/props

curl -4vvv localhost:8098/types/maps/props/buckets/test-bucket/props

On Fri, Nov 18, 2016 at 2:21 PM, Mav erick <[hidden email]> wrote:
> Luke
>
> I was able to change the properties with your URL, but still the hooks are
> not being called for typed buckets ONLY.
>
> The hook is being called for all buckets with no type. So I am sure that
> riak can find the beam file on all my nodes.
>
> I tried restarting riak on all nodes. Still same problem. The hook is called
> for buckets without a type, but wont be called for buckets with a type
>
>
> On 18 November 2016 at 16:45, Luke Bakken <[hidden email]> wrote:
>>
>> Mav -
>>
>> You're not using the correct HTTP URL. You can use this command:
>>
>>
>> http://docs.basho.com/riak/kv/2.1.4/using/reference/bucket-types/#updating-a-bucket-type
>>
>> Or this URL:
>>
>> curl -XPUT localhost:8098/types/maps/props -H 'Content-Type:
>> application/json' -d
>> '{"props":{"precommit":[{"mod":"myhooks","fun":"precommit_hook"}]}}'
>>
>> Please ensure that the "myhooks" beam file is on all Riak servers in a
>> directory that will be picked up by Riak when it starts:
>>
>> http://docs.basho.com/riak/kv/2.1.4/using/reference/custom-code/
>>
>> --
>> Luke Bakken
>> Engineer
>> [hidden email]


_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Initializing a commit hook

Luke Bakken
Thanks for correcting that. Everything looks set up correctly.

How are you saving objects? If you're using HTTP, what is the URL?

Can you associate your precommit hook with a bucket type
("test-bucket-type" below) that is *not* set up for the "map" data
type and see if your hook is called correctly?

This command should save an object and trigger the precommit hook
*with* a bucket and bucket type:

curl -4vvv -H 'Content-Type: text/plain'
localhost:8098/types/test-bucket-type/buckets/test-bucket/keys/test-key
-d "THIS IS THE DATA FOR TEST-KEY"

Luke

On Fri, Nov 18, 2016 at 3:03 PM, Mav erick <[hidden email]> wrote:

>
> * Hostname was NOT found in DNS cache
> *   Trying 127.0.0.1...
> * Connected to localhost (127.0.0.1) port 8098 (#0)
>> GET /types/maps/props HTTP/1.1
>> User-Agent: curl/7.35.0
>> Host: localhost:8098
>> Accept: */*
>>
> < HTTP/1.1 200 OK
> < Vary: Accept-Encoding
> * Server MochiWeb/1.1 WebMachine/1.10.6 (no drinks) is not blacklisted
> < Server: MochiWeb/1.1 WebMachine/1.10.6 (no drinks)
> < Date: Fri, 18 Nov 2016 22:27:56 GMT
> < Content-Type: application/json
> < Content-Length: 545
> <
> * Connection #0 to host localhost left intact
> {"props":{"active":true,"allow_mult":true,"basic_quorum":false,"big_vclock":50,"chash_keyfun":{"mod"
> :"riak_core_util","fun":"chash_std_keyfun"},"claimant":"riak@10.243.44.165","datatype":"map","dvv_en
> abled":true,"dw":"quorum","last_write_wins":false,"linkfun":{"mod":"riak_kv_wm_link_walker","fun":"m
> apreduce_linkfun"},"n_val":3,"notfound_ok":true,"old_vclock":86400,"postcommit":[],"pr":0,"precommit
> ":[{"mod":"commit_hooks","fun":"precommit_hook"}],"pw":0,"r":"quorum","rw":"quorum","smal
> l_vclock":50,"w":"quorum","young_vclock":20}}
>
> $ curl -4vvv localhost:8098/types/maps/buckets/testbucket/props
> * Hostname was NOT found in DNS cache
> *   Trying 127.0.0.1...
> * Connected to localhost (127.0.0.1) port 8098 (#0)
>> GET /types/maps//buckets/testbucket/props HTTP/1.1
>> User-Agent: curl/7.35.0
>> Host: localhost:8098
>> Accept: */*
>>
> < HTTP/1.1 200 OK
> < Vary: Accept-Encoding
> * Server MochiWeb/1.1 WebMachine/1.10.6 (no drinks) is not blacklisted
> < Server: MochiWeb/1.1 WebMachine/1.10.6 (no drinks)
> < Date: Fri, 18 Nov 2016 22:59:22 GMT
> < Content-Type: application/json
> < Content-Length: 565
> <
> * Connection #0 to host localhost left intact
> {"props":{"name":"testbucket","active":true,"allow_mult":true,"basic_quorum":false,"big_vclock":
> chash_keyfun":{"mod":"riak_core_util","fun":"chash_std_keyfun"},"claimant":"riak@10.243.44.165",
> atype":"map","dvv_enabled":true,"dw":"quorum","last_write_wins":false,"linkfun":{"mod":"riak_kv_
> ink_walker","fun":"mapreduce_linkfun"},"n_val":3,"notfound_ok":true,"old_vclock":86400,"postcomm
> [],"pr":0,"precommit":[{"mod":"commit_hooks","fun":"precommit_hook"}],"pw":0,"r":"quo
> ,"rw":"quorum","small_vclock":50,"w":"quorum","young_vclock":20}}$

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Initializing a commit hook

Mav erick
No luck :(

I set up a bucket type called test-bucket-type. I did NOT set data type. 
I set the hooks
Ran your curl -X PUT. The Hook was not called. Tried several times, no luck
I changed the curl to hit my non-typed bucket, and the commit hook hit

$ riak-admin bucket-type list
default (active)
test-bucket-type (active)
sets (active)
maps (active)
counters (active)

I made sure the hooks are applied
Also note there is **no** data type associated
{
  "props": {
    "active": true,
    "allow_mult": true,
    "basic_quorum": false,
    "big_vclock": 50,
    "chash_keyfun": {
      "fun": "chash_std_keyfun",
      "mod": "riak_core_util"
    },
    "claimant": "[hidden email]",
    "dvv_enabled": true,
    "dw": "quorum",
    "last_write_wins": false,
    "linkfun": {
      "fun": "mapreduce_linkfun",
      "mod": "riak_kv_wm_link_walker"
    },
    "n_val": 3,
    "notfound_ok": true,
    "old_vclock": 86400,
    "postcommit": [],
    "pr": 0,
    "precommit": [
      {
        "fun": "precommit_hook",
        "mod": "commit_hooks"
      }
    ],
    "pw": 0,
    "r": "quorum",
    "rw": "quorum",
    "small_vclock": 50,
    "w": "quorum",
    "young_vclock": 20
  }
}

curl -4vvv -H 'Content-Type: text/plain' localhost:8098/types/test-bucket-type/buckets/test-bucket/keys/test-key -d "THIS IS THE DATA FOR TEST-KEY"


On 18 November 2016 at 18:24, Luke Bakken <[hidden email]> wrote:
Thanks for correcting that. Everything looks set up correctly.

How are you saving objects? If you're using HTTP, what is the URL?

Can you associate your precommit hook with a bucket type
("test-bucket-type" below) that is *not* set up for the "map" data
type and see if your hook is called correctly?

This command should save an object and trigger the precommit hook
*with* a bucket and bucket type:

curl -4vvv -H 'Content-Type: text/plain'
localhost:8098/types/test-bucket-type/buckets/test-bucket/keys/test-key
-d "THIS IS THE DATA FOR TEST-KEY"

Luke

On Fri, Nov 18, 2016 at 3:03 PM, Mav erick <[hidden email]> wrote:
>
> * Hostname was NOT found in DNS cache
> *   Trying 127.0.0.1...
> * Connected to localhost (127.0.0.1) port 8098 (#0)
>> GET /types/maps/props HTTP/1.1
>> User-Agent: curl/7.35.0
>> Host: localhost:8098
>> Accept: */*
>>
> < HTTP/1.1 200 OK
> < Vary: Accept-Encoding
> * Server MochiWeb/1.1 WebMachine/1.10.6 (no drinks) is not blacklisted
> < Server: MochiWeb/1.1 WebMachine/1.10.6 (no drinks)
> < Date: Fri, 18 Nov 2016 22:27:56 GMT
> < Content-Type: application/json
> < Content-Length: 545
> <
> * Connection #0 to host localhost left intact
> {"props":{"active":true,"allow_mult":true,"basic_quorum":false,"big_vclock":50,"chash_keyfun":{"mod"
> :"riak_core_util","fun":"chash_std_keyfun"},"claimant":"[hidden email]","datatype":"map","dvv_en
> abled":true,"dw":"quorum","last_write_wins":false,"linkfun":{"mod":"riak_kv_wm_link_walker","fun":"m
> apreduce_linkfun"},"n_val":3,"notfound_ok":true,"old_vclock":86400,"postcommit":[],"pr":0,"precommit
> ":[{"mod":"commit_hooks","fun":"precommit_hook"}],"pw":0,"r":"quorum","rw":"quorum","smal
> l_vclock":50,"w":"quorum","young_vclock":20}}
>
> $ curl -4vvv localhost:8098/types/maps/buckets/testbucket/props
> * Hostname was NOT found in DNS cache
> *   Trying 127.0.0.1...
> * Connected to localhost (127.0.0.1) port 8098 (#0)
>> GET /types/maps//buckets/testbucket/props HTTP/1.1
>> User-Agent: curl/7.35.0
>> Host: localhost:8098
>> Accept: */*
>>
> < HTTP/1.1 200 OK
> < Vary: Accept-Encoding
> * Server MochiWeb/1.1 WebMachine/1.10.6 (no drinks) is not blacklisted
> < Server: MochiWeb/1.1 WebMachine/1.10.6 (no drinks)
> < Date: Fri, 18 Nov 2016 22:59:22 GMT
> < Content-Type: application/json
> < Content-Length: 565
> <
> * Connection #0 to host localhost left intact
> {"props":{"name":"testbucket","active":true,"allow_mult":true,"basic_quorum":false,"big_vclock":
> chash_keyfun":{"mod":"riak_core_util","fun":"chash_std_keyfun"},"claimant":"[hidden email]",
> atype":"map","dvv_enabled":true,"dw":"quorum","last_write_wins":false,"linkfun":{"mod":"riak_kv_
> ink_walker","fun":"mapreduce_linkfun"},"n_val":3,"notfound_ok":true,"old_vclock":86400,"postcomm
> [],"pr":0,"precommit":[{"mod":"commit_hooks","fun":"precommit_hook"}],"pw":0,"r":"quo
> ,"rw":"quorum","small_vclock":50,"w":"quorum","young_vclock":20}}$


_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Initializing a commit hook

Luke Bakken
Hi Mav,

I opened the following issue to continue investigation:

https://github.com/basho/riak_kv/issues/1541

That would be the best place to continue discussion. I'll find time to
reproduce what you have reported.

Thanks -

--
Luke Bakken
Engineer
[hidden email]

On Fri, Nov 18, 2016 at 4:57 PM, Mav erick <[hidden email]> wrote:

> No luck :(
>
> I set up a bucket type called test-bucket-type. I did NOT set data type.
> I set the hooks
> Ran your curl -X PUT. The Hook was not called. Tried several times, no luck
> I changed the curl to hit my non-typed bucket, and the commit hook hit
>
> $ riak-admin bucket-type list
> default (active)
> test-bucket-type (active)
> sets (active)
> maps (active)
> counters (active)
>
> I made sure the hooks are applied
> Also note there is **no** data type associated
> {
>   "props": {
>     "active": true,
>     "allow_mult": true,
>     "basic_quorum": false,
>     "big_vclock": 50,
>     "chash_keyfun": {
>       "fun": "chash_std_keyfun",
>       "mod": "riak_core_util"
>     },
>     "claimant": "riak@10.243.44.165",
>     "dvv_enabled": true,
>     "dw": "quorum",
>     "last_write_wins": false,
>     "linkfun": {
>       "fun": "mapreduce_linkfun",
>       "mod": "riak_kv_wm_link_walker"
>     },
>     "n_val": 3,
>     "notfound_ok": true,
>     "old_vclock": 86400,
>     "postcommit": [],
>     "pr": 0,
>     "precommit": [
>       {
>         "fun": "precommit_hook",
>         "mod": "commit_hooks"
>       }
>     ],
>     "pw": 0,
>     "r": "quorum",
>     "rw": "quorum",
>     "small_vclock": 50,
>     "w": "quorum",
>     "young_vclock": 20
>   }
> }
>
> curl -4vvv -H 'Content-Type: text/plain'
> localhost:8098/types/test-bucket-type/buckets/test-bucket/keys/test-key -d
> "THIS IS THE DATA FOR TEST-KEY"

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com