2

我正在关注本指南 http://docs.basho.com/riak/latest/dev/advanced/mapreduce/

按照本指南设置 5 个节点 http://docs.basho.com/riak/latest/quickstart/

start() ->
  {ok, Client} = riakc_pb_socket:start("127.0.0.1", 10018),
  Mine = riakc_obj:new(<<"groceries">>, <<"mine">>,
                     term_to_binary(["eggs", "bacon"])),
  Yours = riakc_obj:new(<<"groceries">>, <<"yours">>,
                      term_to_binary(["bread", "bacon"])),
  riakc_pb_socket:put(Client, Yours, [{w, 1}]),
  riakc_pb_socket:put(Client, Mine, [{w, 1}]).

我运行这个查询,它给出了这个错误

** Reason for termination == 
** {{badrecord,rpbputreq},
[{riak_kv_pb,iolist,2,[{file,"src/riak_kv_pb.erl"},{line,48}]},
 {riak_kv_pb,encode,2,[{file,"src/riak_kv_pb.erl"},{line,40}]},
 {riak_pb_codec,encode,1,[{file,"src/riak_pb_codec.erl"},{line,77}]},
 {riakc_pb_socket,send_request,2,
                  [{file,"src/riakc_pb_socket.erl"},{line,2066}]},
 {riakc_pb_socket,handle_call,3,
                  [{file,"src/riakc_pb_socket.erl"},{line,1252}]},
 {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,588}]},
 {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,227}]}]}
** Last message in was {req,
                       {rpbputreq,<<"groceries">>,<<"yours">>,undefined,
                           {rpbcontent,
                               <<131,108,0,0,0,2,107,0,5,98,114,101,97,100,
                                 107,0,5,98,97,99,111,110,106>>,
                               undefined,undefined,undefined,undefined,[],
                               undefined,undefined,[],[],undefined},
                           1,undefined,undefined,undefined,undefined,
                           undefined,undefined,undefined,undefined,
                           undefined,undefined,undefined},
                       60000}
 ** When Server state == {state,"127.0.0.1",10018,false,false,#Port<0.3496>,
                           gen_tcp,undefined,
                           {[],[]},
                           1,[],infinity,undefined,undefined,undefined,
                           undefined,100}

提交导致它

riakc_pb_socket:put(Client, Yours, [{w, 1}]),

我没有连接到正在运行的节点的控制台。我运行 erlang 这个命令

erl -sname foo -pa ~/e/riak-erlang-client/ebin -pa /usr/lib/riak/lib/riak_kv-1.4.2-0-g61ac9d8/ebin -pa /usr/lib/riak/lib/riak_core-1.4.2/ebin -pa /usr/lib/riak/lib/riak_pb-1.4.1.1/ebin/

不良记录定义在

/usr/lib/riak/lib/riak_pb-1.4.1.1/include/riak_kv_pb.hrl
-record(rpbputreq, {
bucket = erlang:error({required, bucket}),
key,
vclock,
content = erlang:error({required, content}),
w,
dw,
return_body,
pw,
if_not_modified,
if_none_match,
return_head,
timeout,
asis,
sloppy_quorum,
n_val
}).
4

1 回答 1

2

riak-erlang-client deps 中最新版本的 riak_pb 在末尾有一个额外的 'type' 字段

  -record(rpbputreq, {
      bucket = erlang:error({required, bucket}),
      key,
      vclock,
      content = erlang:error({required, content}),
      w,
      dw,
      return_body,
      pw,
      if_not_modified,
      if_none_match,
      return_head,
      timeout,
      asis,
      sloppy_quorum,
      n_val,
      type
     }).
于 2013-10-02T19:44:50.703 回答