Anonymous avatar Anonymous committed c51d799 Merge

merge

Comments (0)

Files changed (7)

 # debug-fresh <configfile>
 # create a brand new riak ring, using configfile as app config params
 # run interactively, w/o heartbeat
+if [ $# -lt 1 ]; then
+    echo Usage: 1>&2
+    echo "    `basename $0` <configfile>" 1>&2
+    exit 1
+fi
 . riak-env.sh
 NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_nodename)])" -run init stop)
 HOSTNAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_hostname)])" -run init stop)
 # debug-join <configfile> <node>
 # join an existing riak ring via a node known to be listening on ip:port
 # run in interactive debug shell mode
+if [ $# -lt 2 ]; then
+    echo Usage: 1>&2
+    echo "    `basename $0` <configfile> Node" 1>&2
+    exit 1
+fi
 . riak-env.sh
 NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_nodename)])" -run init stop)
 HOSTNAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_hostname)])" -run init stop)
 #!/usr/bin/env bash
 # debug-restart <configfile>
 # assuming we've run a node from here before, start back up in debug mode
+if [ $# -lt 1 ]; then
+    echo Usage: 1>&2
+    echo "    `basename $0` <configfile>" 1>&2
+    exit 1
+fi
 . riak-env.sh
 NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_nodename)])" -run init stop)
 HOSTNAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_hostname)])" -run init stop)

src/jiak_object.erl

 %%      by mochijson2.  Thus, a simple object looks something like:
 %%```
 %%      {struct,
-%%       [{<<"bucket">>, foo},
+%%       [{<<"bucket">>, <<"foo">>},
 %%        {<<"key">>, <<"123">>},
 %%        {<<"object">>,
 %%         {struct,
 %%           {<<"bazField">>, 42},
 %%          ]}},
 %%        {<<"links">>,
-%%         [[quuxLink, <<"quuxKey">>, <<"quuxTag">>],
-%%          [abcLink, <<"abcKey">>, <<"abcTag">>]
+%%         [[<<"quuxLink">>, <<"quuxKey">>, <<"quuxTag">>],
+%%          [<<"abcLink">>, <<"abcKey">>, <<"abcTag">>]
 %%         ]},
 %%        {<<"vclock">>, <<"opaque-riak-vclock">>},
 %%        {<<"lastmod">>, <<"Mon, 03 Aug 2009 18:49:42 GMT">>}
 %%       <<"barValue">> = jiak_object:getp(O, <<"barField">>).
 %%       3 = jiak_object:getp(
 %%             jiak_object:setp(O, <<"bazField">>, 3)).
-%%       [[linkBucket, <<"linkKey">>, <<"linkTag">>]] =
-%%         jiak_object:links(O, linkBucket).
+%%       [[<<"linkBucket">>, <<"linkKey">>, <<"linkTag">>]] =
+%%         jiak_object:links(O, <<"linkBucket">>).
 %%'''
 %%       are all true.
 -module(jiak_object).
 %%            -> [{{atom(), binary()}, binary()}]
 %% @type link_tag() = term()|'_'
 %% @type link_bucket() = riak_object:bucket()|'_'
-%% @doc This function implements the map phase to which link map/reduce
-%%      specs are mapped.  The atom '_' means "match all", so for example,
-%%      {foo, '_'} would match all links to bucket 'foo' with any tag, while
-%%      {foo, bar} would match only links to bucket 'foo' with tag 'bar'.
-%%      The tags of the links will be included as the "KeyData" for the
-%%      bucket-key pair returned.
-%%      Keys that were inputs to this phase that reference non-existent
-%%      objects are ignored (i.e. {error,notfound} => []).
+%% @doc This function implements the map phase to which link
+%%      map/reduce specs are mapped.  The atom '_' means "match all",
+%%      so for example, {<<"foo">>, '_'} would match all links to
+%%      bucket 'foo' with any tag, while {<<"foo">>, <<"bar">>} would
+%%      match only links to bucket 'foo' with tag 'bar'.  The tags of
+%%      the links will be included as the "KeyData" for the bucket-key
+%%      pair returned.  Keys that were inputs to this phase that
+%%      reference non-existent objects are ignored
+%%      (i.e. {error,notfound} => []).
 mapreduce_linkfun({error, notfound}, _, _) -> [];
 mapreduce_linkfun(RiakObject, _, {Bucket, Tag}) ->
     %% TODO: could just pull links out of riak object directly, if that

src/jiak_resource.erl

         {ok, _SchemaObj={struct, SchemaPL0}} ->
             ReqProps = [list_to_binary(atom_to_list(P)) || 
                            P <- jiak_util:jiak_required_props()],
-            {struct, SchemaPL} = proplists:get_value(<<"schema">>,SchemaPL0),
-            case lists:filter(
-                   fun(I) -> 
-                           proplists:get_value(I, SchemaPL) =:= undefined
-                   end, 
-                   ReqProps) of
-                [] ->
-                    {false, ReqData, Context#ctx{incoming=SchemaPL}};
-                L ->
-                    {true, 
-                     wrq:append_to_response_body(
-                     io_lib:format("missing required schema fields: ~p~n",[L]),
-                       ReqData),
-                     Context}
+            case proplists:get_value(<<"schema">>,SchemaPL0) of
+                {struct, SchemaPL} ->
+                    case lists:filter(
+                           fun(I) -> 
+                                   proplists:get_value(I, SchemaPL) =:= undefined
+                           end, 
+                           ReqProps) of
+                        [] ->
+                            {false, ReqData, Context#ctx{incoming=SchemaPL}};
+                        L ->
+                            {true, 
+                             wrq:append_to_response_body(
+                               io_lib:format("missing required schema fields: ~p~n",[L]),
+                               ReqData),
+                             Context}
+                    end;
+                undefined ->
+                    case proplists:get_value(<<"bucket_mod">>, SchemaPL0) of
+                        BMStr when is_binary(BMStr) ->
+                            case catch list_to_existing_atom(binary_to_list(BMStr)) of
+                                BM when is_atom(BM) ->
+                                    {false, ReqData,
+                                     Context#ctx{incoming=[{<<"bucket_mod">>, BM}]}};
+                                _ ->
+                                    {true,
+                                     wrq:append_to_response_body(
+                                       io_lib:format("no module '~s' found", [BMStr]),
+                                       ReqData),
+                                     Context}
+                            end;
+                        undefined ->
+                            {true, 
+                             wrq:append_to_response_body(
+                               io_lib:format("missing required schema fields: ~p~n",
+                                             [ReqProps]),
+                               ReqData),
+                             Context}
+                    end
             end;
         Err ->
             {true,
 #!/usr/bin/env bash
 # start-fresh <configfile>
 # create a brand new riak ring, using configfile as app config params
+if [ $# -lt 1 ]; then
+    echo Usage: 1>&2
+    echo "    `basename $0` <configfile>" 1>&2
+    exit 1
+fi
 . riak-env.sh
 NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_nodename)])" -run init stop)
 HOSTNAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_hostname)])" -run init stop)
 #!/usr/bin/env bash
 # start-restart <configfile>
 # assuming we've run a node from here before, start back up
+if [ $# -lt 1 ]; then
+    echo Usage: 1>&2
+    echo "    `basename $0` <configfile>" 1>&2
+    exit 1
+fi
 . riak-env.sh
 echo $ERL_MAX_ETS_TABLES
 NODENAME=$(erl -noshell -pa ebin -eval "error_logger:tty(false), riak_app:read_config(\"$1\"), io:format(\"~s~n\",[riak:get_app_env(riak_nodename)])" -run init stop)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.