Anonymous avatar Anonymous committed 0e71331

convert bucket data in ringstate from atom to binary names
(so that you can keep your bucket metadata across the pre-0.5->post-0.5 transition boundary)

Comments (0)

Files changed (3)


 {riak_web_port, 8098}.
 {riak_web_logdir, "priv/weblogs"}.
 {jiak_buckets, [notes, groups]}. %% just to get atoms loaded in node
+{riak_local_logfile, "restart.log"}.


          transfer_node/3,reconcile/2, my_indices/1,
 	 index_owner/2,diff_nodes/2,random_node/1, random_other_index/1,
-         get_meta/2, update_meta/3]).	 
+         get_meta/2, update_meta/3]).
 % @type riak_ring(). The opaque data type used for partition ownership.
 -record(chstate, {
     VClock = vclock:increment(State#chstate.nodename, State#chstate.vclock),
     State#chstate{vclock=VClock, meta=dict:store(Key, M, State#chstate.meta)}.
+%% @doc utility for converting from pre riak-0.5 bucket names,
+%%      which were atoms to riak-0.5 bucket names, which
+%%      are binaries
+atom_to_binary_bucket_names(Ring=#chstate{meta=Meta0}) ->
+    AtomBuckets = [ B || {bucket, B} <- dict:fetch_keys(Meta0),
+                         is_atom(B) ],
+    Meta = lists:foldl(
+             fun(B, Acc) ->
+                     BN = list_to_binary(atom_to_list(B)),
+                     BM = dict:fetch({bucket, B}, Meta0),
+                     BP = [{name, BN}|
+                           proplists:delete(name, BM#meta_entry.value)],
+                     dict:store({bucket, BN}, BM#meta_entry{value=BP},
+                                dict:erase({bucket, B}, Acc))
+             end,
+             Meta0,
+             AtomBuckets),
+    Ring#chstate{meta=Meta}.
 sequence_test() ->
     I1 = 365375409332725729550921208179070754913983135744,
     I2 = 730750818665451459101842416358141509827966271488,
     Ring = transfer_node(I,b,Ring0),


 read_ringfile(RingFile) ->
     {ok, Binary} = file:read_file(RingFile),
     riak_eventer:notify(riak_ring_manager, read_ringfile, RingFile),
-    binary_to_term(Binary).
+    riak_ring:atom_to_binary_bucket_names(binary_to_term(Binary)).
 %% @spec prune_ringfiles() -> ok
 prune_ringfiles() ->
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
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.