nickva commented on a change in pull request #1658: Enable cluster auto-assembly through a seedlist URL: https://github.com/apache/couchdb/pull/1658#discussion_r228279345
########## File path: src/mem3/src/mem3_seeds.erl ########## @@ -0,0 +1,163 @@ +% Licensed under the Apache License, Version 2.0 (the "License"); you may not +% use this file except in compliance with the License. You may obtain a copy of +% the License at +% +% http://www.apache.org/licenses/LICENSE-2.0 +% +% Unless required by applicable law or agreed to in writing, software +% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +% License for the specific language governing permissions and limitations under +% the License. + +-module(mem3_seeds). +-behaviour(gen_server). + +-export([ + init/1, + handle_call/3, + handle_cast/2, + handle_info/2, + code_change/3, + terminate/2 +]). + +-export([ + start_link/0, + get_seeds/0, + get_status/0 +]). + +-record(st, { + ready = false, + seeds = [], + jobref = nil, + status = [] % nested proplist keyed on node name +}). + +-define(REPLICATION_INTERVAL, 60000). + +start_link() -> + gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). + +get_seeds() -> + case config:get("cluster", "seedlist") of + undefined -> + []; + List -> + Nodes = string:tokens(List, ","), + Seeds = [list_to_atom(Node) || Node <- Nodes] -- [node()], + mem3_util:rotate_list(node(), Seeds) + end. + +get_status() -> + gen_server:call(?MODULE, get_status). + +init([]) -> + Seeds = get_seeds(), + timer:send_interval(?REPLICATION_INTERVAL, start_replication), Review comment: This will send `start_replication` forever every minute. What is the idea behind it? Something like, "once we have a seed list, we'll try to continuously replicate dbs from the seed list to our this node". Once we do it one time, wouldn't mem3_sync take care of this afterwards. Or this is just to handle retries if there are failures? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
