Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supercluster by cuttlefish schema (aka multibag name chage) #1257

Merged
merged 2 commits into from
Oct 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rebar.config.script
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ case IsEE of
{package_install_user, \"riakcs\"}.
{package_install_group, \"riak\"}.
{package_install_user_desc, \"Riak CS user\"}.
{package_commands, {list, [[{name, \"riak-cs\"}], [{name, \"riak-cs-access\"}], [{name, \"riak-cs-gc\"}], [{name, \"riak-cs-storage\"}], [{name, \"riak-cs-stanchion\"}], [{name, \"riak-cs-debug\"}], [{name, \"riak-cs-admin\"}], [{name, \"riak-cs-multibag\"}]]}}.
{package_commands, {list, [[{name, \"riak-cs\"}], [{name, \"riak-cs-access\"}], [{name, \"riak-cs-gc\"}], [{name, \"riak-cs-storage\"}], [{name, \"riak-cs-stanchion\"}], [{name, \"riak-cs-debug\"}], [{name, \"riak-cs-admin\"}], [{name, \"riak-cs-supercluster\"}], [{name, \"riak-cs-multibag\"}]]}}.
{package_shortdesc, \"Riak CS\"}.
{package_patch_dir, \"basho-patches\"}.
{package_desc, \"Riak CS\"}.
Expand Down
15 changes: 13 additions & 2 deletions rel/files/riak-cs-multibag
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/sh

cat<<EOS
### WARNING ################################################################
# This command has been deprecated and will be removed in a future release.
# Use "riak-cs-supercluster <subcommand>" instead of this.
############################################################################
EOS

# Pull environment for this install
. "{{runner_base_dir}}/lib/env.sh"

Expand All @@ -14,14 +21,18 @@ SCRIPT=`basename $0`

# Check the first argument for instructions
case "$1" in
list-bags|weight|weight-manifest|weight-block|refresh)
list-members|weight|weight-manifest|weight-block|refresh)
# Make sure the local node IS running
node_up_check

$NODETOOL rpc riak_cs_multibag_console "$@"
;;
list-bags)
node_up_check
$NODETOOL rpc riak_cs_multibag_console list-members
;;
*)
echo "Usage: $SCRIPT { list-bags | weight | weight-manifest | weight-block | refresh }"
echo "Usage: $SCRIPT { list-members | weight | weight-manifest | weight-block | refresh | list-bags }"
exit 1
;;
esac
27 changes: 27 additions & 0 deletions rel/files/riak-cs-supercluster
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

# Pull environment for this install
. "{{runner_base_dir}}/lib/env.sh"

# Make sure the user running this script is the owner and/or su to that user
check_user $@

# Make sure CWD is set to runner run dir
cd $RUNNER_BASE_DIR

# Identify the script name
SCRIPT=`basename $0`

# Check the first argument for instructions
case "$1" in
list-members|weight|weight-manifest|weight-block|refresh)
# Make sure the local node IS running
node_up_check

$NODETOOL rpc riak_cs_multibag_console "$@"
;;
*)
echo "Usage: $SCRIPT { list-members | weight | weight-manifest | weight-block | refresh }"
exit 1
;;
esac
35 changes: 35 additions & 0 deletions rel/files/riak_cs.schema
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,41 @@
{default, "{{platform_log_dir}}"}
]}.

%% == Supercluster aka Multi-bug Support ==

%% @doc IP and port for supercluster members. Specify one member for
%% each line, in which the last token of key is member identifier and
%% value is a PB address of Riak node to connect.
{mapping, "supercluster.member.$member_id", "riak_cs_multibag.bags", [
{datatype, ip},
{include_default, "bag-A"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best way is to match the string here with one in the doc (in the future.) This is not user-facing because of hidden, how about leaving as it is and defer change ?

{commented, {"192.168.0.101", 8087}},
hidden
]}.

{translation,
"riak_cs_multibag.bags",
fun(Conf) ->
Keys = cuttlefish_variable:fuzzy_matches(["supercluster", "member", "$member_id"], Conf),
case Keys of
[] -> undefined;
[_|_] -> [begin
{Host, Port} = cuttlefish:conf_get(
"supercluster.member." ++ MemberId, Conf),
{MemberId, Host, Port}
end || {Key, MemberId} <- Keys]
end
end
}.

%% @doc Interval to refresh weight information for every supercluster member.
{mapping, "supercluster.weight_refresh_interval",
"riak_cs_multibag.weight_refresh_interval", [
{default, "15m"},
{datatype, [{duration, s}]},
hidden
]}.

%% @doc Cookie for distributed node communication. All nodes in the
%% same cluster should use the same cookie or they will not be able to
%% communicate.
Expand Down
1 change: 1 addition & 0 deletions rel/reltool.config
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
{template, "files/riak-cs-stanchion", "bin/riak-cs-stanchion"},
{template, "files/riak-cs-debug", "bin/riak-cs-debug"},
{template, "files/riak-cs-admin", "bin/riak-cs-admin"},
{template, "files/riak-cs-supercluster", "bin/riak-cs-supercluster"},
{template, "files/riak-cs-multibag", "bin/riak-cs-multibag"},
{mkdir, "lib/basho-patches"}
]}.
46 changes: 46 additions & 0 deletions test/riak_cs_config_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ default_config_test() ->
{size, 10485760},
{date, "$D0"},
{count, 5}]),
cuttlefish_unit:assert_not_configured(Config, "riak_cs_multibag.bags"),
cuttlefish_unit:assert_config(Config, "riak_cs_multibag.weight_refresh_interval", 900),
%% cuttlefish_unit:assert_config(Config, "vm_args.+scl", false),
ok.

Expand Down Expand Up @@ -218,6 +220,50 @@ wm_log_config_test_() ->
]
end}.

supercluster_members_test_() ->
[{"One bag",
fun() ->
Conf = [{["supercluster", "member", "bag-A"], "192.168.0.101:8087"}],
Config = cuttlefish_unit:generate_templated_config(
schema_files(), Conf, context()),
cuttlefish_unit:assert_config(Config, "riak_cs_multibag.bags",
[{"bag-A", "192.168.0.101", 8087}])
end},
{"Two bags",
fun() ->
Conf = [{["supercluster", "member", "bag-A"], "192.168.0.101:18087"},
{["supercluster", "member", "bag-B"], "192.168.0.102:28087"}],
Config = cuttlefish_unit:generate_templated_config(
schema_files(), Conf, context()),
cuttlefish_unit:assert_config(Config, "riak_cs_multibag.bags",
[{"bag-A", "192.168.0.101", 18087},
{"bag-B", "192.168.0.102", 28087}])
end},
{"FQDN for host part",
fun() ->
Conf = [{["supercluster", "member", "bag-A"], "riak-A1.example.com:8087"}],
Config = cuttlefish_unit:generate_templated_config(
schema_files(), Conf, context()),
cuttlefish_unit:assert_config(Config, "riak_cs_multibag.bags",
[{"bag-A", "riak-A1.example.com", 8087}])
end}
].

supercluster_refresh_interval_test_() ->
[fun() ->
Conf = [{["supercluster", "weight_refresh_interval"], "5s"}],
Config = cuttlefish_unit:generate_templated_config(
schema_files(), Conf, context()),
cuttlefish_unit:assert_config(
Config, "riak_cs_multibag.weight_refresh_interval", 5) end,
fun() ->
Conf = [{["supercluster", "weight_refresh_interval"], "1h"}],
Config = cuttlefish_unit:generate_templated_config(
schema_files(), Conf, context()),
cuttlefish_unit:assert_config(
Config, "riak_cs_multibag.weight_refresh_interval", 3600) end
].

schema_files() ->
["../rel/files/riak_cs.schema"].

Expand Down