From b33c63a9dbbcff81d055ee8b036b96279a4d2d6f Mon Sep 17 00:00:00 2001 From: "John R. Daily" Date: Tue, 19 Jul 2016 17:06:36 -0400 Subject: [PATCH] Add support for setting/querying a cluster-wide time zone --- rebar.config | 1 + src/riak_core_console.erl | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/rebar.config b/rebar.config index 286c57517..1e6a76ef6 100644 --- a/rebar.config +++ b/rebar.config @@ -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"}}} ]}. diff --git a/src/riak_core_console.erl b/src/riak_core_console.erl index 71d11ef29..3e4ee753d 100644 --- a/src/riak_core_console.erl +++ b/src/riak_core_console.erl @@ -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]). @@ -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,