Andrew Bickerton
Andrew Bickerton

Reputation: 478

How to add a replication hook to Riak v2.0+

Background

Riak v2.0 changed the configuration system from:

to:

Question

In Multi-Data-Center-Replication-Hooks the Riak v2.0+ documentation still refers to:

Add a -pa argument to your vm.args file to specify the path where your compiled .beam file lives:

Shell -pa /path/to/replication/hook Finally, add a -run argument to your vm.args file to register the hook:

Shell -run riak_repl_hook_sample register

What are the riak.conf or advanced.config versions of the -pa & -run parameters?


Note: I know that in the doc:Upgrading Your Configuration System we can:

Keep your configuration files from the older system, which are still recognized in Riak 2.0.

but we would like to move to the new configuration system as it gives us more visibility.

Upvotes: 0

Views: 169

Answers (2)

Andrew Bickerton
Andrew Bickerton

Reputation: 478

Possible solution

Note: If you want to understand how riak.conf settings are mapped to vm.args the below file is very useful, however be warned that if you do not use the below settings you will end up with blank entries in the generated vm.args file:

/var/lib/riak/generated.configs/vm..args

-pa
-run

Riak v2.0+ schema file for config

Turns out that there is a nice schema file in the riak lib directory that can be expanded to add on any missing erlang flags, for me this was:

/usr/lib64/riak/lib/10-riak.schema

To this I added:

%% Add the replication hook directory to the code path 
{mapping, "repl.hook.path", "vm_args.-pa", [   
  {default, ""} 
]}.

%% Call Module:start/0 
{mapping, "repl.hook.run", "vm_args.-run", [
  {default, ""} 
]}.

Then I added to the riak.conf file:

# add the repl hook path and register it
repl.hook.path = /path/to/replication/hook
repl.hook.run = riak_repl_hook_sample register

after this I needed to restart the node.

Upvotes: 1

dams
dams

Reputation: 399

in your advanced.config file, try someting like that:

[
 {riak_kv, [
            {add_paths, ["/path/to/replication/hook"]}
           ]},
 {vm_args, [
            {'-run riak_repl_hook_sample register', ""}
           ]}
].

I know that starting an app works, I'm using this:

[
 {riak_kv, [
            {add_paths, ["/path/to/my/beams/"]}
           ]},
 {vm_args, [
            {'-s my_app', ""}
           ]}
].

So with a little fiddling you should be able to make it work :)

Upvotes: 4

Related Questions