Anonymous avatar Anonymous committed c2943c6

make default bucket properties configurable at application scope

specify with a 'default_bucket_props' entry in your configuration file

Ex:
{default_bucket_props, [{n_val, 5},{allow_mult,true}]}.

Comments (0)

Files changed (3)

  - better cleanup of node storage after handoff
  - move bucket properties out of gossiped ring state
     (allowing unlimited buckets)
- - make default bucket properties configurable at application scope
  - improved efficiency of vnode handoff and bootstrapping
  - more explicit UTF-8 support and testing
  - making nodes that have finished exiting a cluster more obvious
     [ClusterName,RingStateDir,RingCreationSize,
      WantsClaimFun,ChooseClaimFun,GossipInterval,
      DoorbellPort,StorageBackend,RiakCookie,RiakAddPaths,
-     RiakNodeName,RiakHostName,RiakHeartCommand] =
+     RiakNodeName,RiakHostName,RiakHeartCommand,
+     DefaultBucketProps] =
         [riak:get_app_env(X) || X <- 
            [cluster_name,ring_state_dir,ring_creation_size,
             wants_claim_fun,choose_claim_fun,gossip_interval,
             doorbell_port,storage_backend,riak_cookie,add_paths,
-            riak_nodename,riak_hostname,riak_heart_command]],
+            riak_nodename,riak_hostname,riak_heart_command,
+            default_bucket_props]],
     if
         ClusterName =:= undefined ->
             riak:stop(io_lib:format(
                  "riak_heart_command in ~p non-list, failing.",[ConfigPath]));
         true -> ok
     end,
+    if
+        DefaultBucketProps =:= undefined ->
+            set_bucket_params([]);
+        is_list(DefaultBucketProps) ->
+            set_bucket_params(DefaultBucketProps);
+        true ->
+            riak:stop(io_lib:format(
+                        "default_bucket_props in ~p non-list, failing.",
+                        [ConfigPath]))
+    end,
     ok.
+
+set_bucket_params(In) ->
+    application:set_env(
+      riak, default_bucket_props,
+      lists:ukeymerge(1,
+                      lists:keysort(1, lists:keydelete(name, 1, In)),
+                      lists:keysort(1, riak_bucket:defaults()))).

src/riak_bucket.erl

 
 -module(riak_bucket).
 -export([set_bucket/2, get_bucket/1, get_bucket/2]).
+-export([defaults/0]).
 
 %% @spec set_bucket(riak_object:bucket(), BucketProps::riak_bucketprops()) -> ok
 %% @doc Set the given BucketProps in Bucket.
 %% @private
 get_bucket(Name, Ring) ->
     case riak_ring:get_meta({bucket, Name}, Ring) of
-        undefined -> [{name,Name},{n_val,3},{allow_mult,false},
-                      {linkfun,{modfun, jiak_object, mapreduce_linkfun}},
-                      {old_vclock, 86400},{young_vclock, 21600},
-                      {big_vclock, 50}, {small_vclock, 10}];
+        undefined ->
+            [{name, Name}
+             |riak:get_app_env(default_bucket_props, defaults())];
         {ok, Bucket} -> Bucket
     end.
+
+defaults() ->
+    [{n_val,3},
+     {allow_mult,false},
+     {linkfun,{modfun, jiak_object, mapreduce_linkfun}},
+     {old_vclock, 86400},
+     {young_vclock, 21600},
+     {big_vclock, 50},
+     {small_vclock, 10}].
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.