Hello.
I have a little problem with Riak. I have wrote Riak-client script via Erlang.
My code here:
---------------------- Code ----------------------
%% @doc Method to get object by bucket and key
get_object(Bucket, Key)->
do_get_request(lists:concat(["/buckets/",binary_to_list(Bucket),"/keys/",binary_to_list(Key)])).
%% @doc Make GET request by request url. Response returns.
do_get_request(RequestString)->
do_request(get, RequestString).
%% @doc Make request by method and request url without body value
do_request(Method, RequestString)->
inets:start(temporary),
URL = lists:concat([shared_config:get_riak_destination(),
RequestString]),
% shared_config:get_riak_destination() returns http-path to Riak.
Resp = httpc:request(Method, {URL, []}, [], []),
process_response(Resp).
%% @doc Method that processes response
process_response(Resp)->
case Resp of
{ok, {{Version, ResponseCode, ReasonPhrase}, Headers, Body}}->
case ResponseCode of
200->%ok
{ok, Body};
201->%created response (when riak generates key)
{ok, Body};
204->%if key has no content
{ok, nocontent};
300->%multiple content
{error, Body};
400->%when request parameters are invalid
{error, badrequest};
404->
{error, notfound};
412->%if one of the conditional request headers
failed to match
{error, precondition_failed};
_->
{error, "Unknown error: "++ResponseCode}
end;
{error, ErrorMsg} ->
{error, ErrorMsg}
end.
----------------- End of code -----------------
This code properly worked till today. But today function get_object(Bucket,
Key) returns {ok, nocontent}. Response code was 204, I saw it in logs. Can
anyone tell me about this behavior of Riak? This problem fixed by restarting
Riak.
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com