diff --git a/rebar.config.script b/rebar.config.script index 4645fdd10..74706a568 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -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\"}. diff --git a/rel/files/riak-cs-multibag b/rel/files/riak-cs-multibag index baa2d0666..7d795904b 100755 --- a/rel/files/riak-cs-multibag +++ b/rel/files/riak-cs-multibag @@ -1,5 +1,12 @@ #!/bin/sh +cat<" instead of this. +############################################################################ +EOS + # Pull environment for this install . "{{runner_base_dir}}/lib/env.sh" @@ -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 diff --git a/rel/files/riak-cs-supercluster b/rel/files/riak-cs-supercluster new file mode 100755 index 000000000..e9f4c5cf4 --- /dev/null +++ b/rel/files/riak-cs-supercluster @@ -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 diff --git a/rel/files/riak_cs.schema b/rel/files/riak_cs.schema index 73de2519c..c6f16760e 100644 --- a/rel/files/riak_cs.schema +++ b/rel/files/riak_cs.schema @@ -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"}, + {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. diff --git a/rel/reltool.config b/rel/reltool.config index 83bb77e78..add2b1520 100644 --- a/rel/reltool.config +++ b/rel/reltool.config @@ -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"} ]}. diff --git a/test/riak_cs_config_test.erl b/test/riak_cs_config_test.erl index 8f479bcd6..3b6b67ead 100644 --- a/test/riak_cs_config_test.erl +++ b/test/riak_cs_config_test.erl @@ -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. @@ -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"].