I am setting up an ejabbered + riak cluster, where i have to use basic riak (get,put,delete..)functions in the file ejabberd/src/ejabberd_riak.erl
The functions put, get, get_by_index etc. work great and using the usage of the module in the file I could figure out what is what.
I'm facing an issue with the function delete_by_index and also get_keys_by_index, which is called by delete_by_index, anyhow.
The error thrown when I do this ->
ejabberd_riak:get_keys_by_index(game <<"language">>,
term_to_binary("English")).
{error,<<"Phase 0: invalid module named in PhaseSpec function:\n must be a valid module name (failed to load ejabberd_r"...>>}
([email protected])57> 12:28:55.177 [error] database error:
** Function: get_keys_by_index
** Table: game
** Index = <<"language">>
** Key: <<131,107,0,7,69,110,103,108,105,115,104>>
** Error: Phase 0: invalid module named in PhaseSpec function:
must be a valid module name (failed to load ejabberd_riak: nofile)
You should probably load
ejabberd_riakon the riak sideYou are currently using riak as separate erlang application, communicating with the database by protobuf. In this configuration you have independent (from each other) module sets loaded in ejabbered and riak applications.
ejabberd_riakmodule loaded in ejabberd application, but not in riak application.However
get_by_indexuses mapred that demands ejabberd_riak loaded on the riak sideYou can customize your riak and add
ejabberd_riakto the riak application (you don't need to start the whole ejabberd application on the riak side, however)With monckeypatching approach, you should copy ejabberd_riak.erl, ejabberd.hrl, logger.hrl to the
riak/deps/riak_kv/src. Then rebuild riak. You should distribute your files over the whole cluster, asmapphase is executed on each cluster node.