Skip to content

Commit

Permalink
Merge pull request #847 from basho/feature_jrd_cmd-tz
Browse files Browse the repository at this point in the history
Add support for setting/querying a cluster-wide time zone

Reviewed-by: javajolt
  • Loading branch information
borshop committed Jul 22, 2016
2 parents 1bd052f + b33c63a commit 03fb938
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions rebar.config
Expand Up @@ -18,5 +18,6 @@
{pbkdf2, ".*", {git, "git://github.com/basho/erlang-pbkdf2.git", {tag, "2.0.0"}}},
{eleveldb, ".*", {git, "git://github.com/basho/eleveldb.git", {tag, "ts-1.0.4"}}},
{exometer_core, ".*", {git, "git://github.com/basho/exometer_core.git", {tag, "1.0.0-basho6"}}},
{jam, ".*", {git, "git://github.com/macintux/jam.git", {branch, "master"}}},
{clique, "0.3.5", {git, "git://github.com/basho/clique.git", {tag, "0.3.5"}}}
]}.
24 changes: 23 additions & 1 deletion src/riak_core_console.erl
Expand Up @@ -31,7 +31,8 @@
print_users/1, print_user/1, print_sources/1,
print_groups/1, print_group/1, print_grants/1,
security_enable/1, security_disable/1, security_status/1, ciphers/1,
stat_show/1, stat_info/1, stat_enable/1, stat_disable/1, stat_reset/1]).
timezone/1,
stat_show/1, stat_info/1, stat_enable/1, stat_disable/1, stat_reset/1]).

%% New CLI API
-export([command/1]).
Expand Down Expand Up @@ -752,6 +753,27 @@ commit_staged([]) ->
"plan and try to commit again~n")
end.

timezone([]) ->
TZ = riak_core_metadata:get({riak_core, timezone}, string,
[{default, "not configured"}]),
io:format("~s~n", [TZ]);
timezone([TZString]) ->
TZ = jam:process(jam_iso8601:parse_tz(TZString)),
attempt_set_timezone(jam:is_valid(TZ), TZ, TZString).

attempt_set_timezone(false, _TZ, String) ->
io:format("Failed, unrecognized timezone string '~s'~n",
[String]);
attempt_set_timezone(true, TZ, _String) ->
NewString = jam_iso8601:to_string(TZ, [{z, false}]),
riak_core_metadata:put({riak_core, timezone}, string,
NewString),
riak_core_metadata:put({riak_core, timezone}, seconds,
jam:tz_offset(TZ)),
io:format("Success, timezone is now configured to '~s'~n",
[NewString]).


transfer_limit([]) ->
{Limits, Down} =
riak_core_util:rpc_every_member_ann(riak_core_handoff_manager,
Expand Down

0 comments on commit 03fb938

Please sign in to comment.