5656 socket ,
5757 transport ,
5858 largest_n ,
59- owners = [],
6059 connection_ref ,
6160 partition_queue = queue :new (),
6261 retries = dict :new (),
@@ -361,7 +360,6 @@ handle_cast(start_fullsync, State) ->
361360 Partitions = sort_partitions (Ring ),
362361 State2 = State # state {
363362 largest_n = N ,
364- owners = riak_core_ring :all_owners (Ring ),
365363 partition_queue = queue :from_list (Partitions ),
366364 retries = dict :new (),
367365 reserve_retries = dict :new (),
@@ -389,7 +387,6 @@ handle_cast(stop_fullsync, State) ->
389387 <- State # state .running_sources ],
390388 State2 = State # state {
391389 largest_n = undefined ,
392- owners = [],
393390 partition_queue = queue :new (),
394391 retries = dict :new (),
395392 reserve_retries = dict :new (),
@@ -770,26 +767,26 @@ send_next_whereis_req(State) ->
770767% two specs: is the local node available, and does our cache of remote nodes
771768% say the remote node is available.
772769determine_best_partition (State ) ->
773- # state {partition_queue = Queue , busy_nodes = Busies , owners = Owners , whereis_waiting = Waiting } = State ,
770+ # state {partition_queue = Queue , busy_nodes = Busies , whereis_waiting = Waiting } = State ,
774771 SeedPart = queue :out (Queue ),
775772 lager :debug (" Starting partition search" ),
776- determine_best_partition (SeedPart , Busies , Owners , Waiting , queue :new ()).
773+ determine_best_partition (SeedPart , Busies , Waiting , queue :new ()).
777774
778- determine_best_partition ({empty , _Q }, _Business , _Owners , _Waiting , AccQ ) ->
775+ determine_best_partition ({empty , _Q }, _Business , _Waiting , AccQ ) ->
779776 lager :debug (" No partition in the queue that will not exceed a limit; will try again later." ),
780777 % there is no best partition, try again later
781778 {undefined , AccQ };
782779
783- determine_best_partition ({{value , Part }, Queue }, Busies , Owners , Waiting , AccQ ) ->
784- case node_available (Part , Owners , Waiting ) of
780+ determine_best_partition ({{value , Part }, Queue }, Busies , Waiting , AccQ ) ->
781+ case node_available (Part , Waiting ) of
785782 false ->
786- determine_best_partition (queue :out (Queue ), Busies , Owners , Waiting , queue :in (Part , AccQ ));
783+ determine_best_partition (queue :out (Queue ), Busies , Waiting , queue :in (Part , AccQ ));
787784 skip ->
788- determine_best_partition (queue :out (Queue ), Busies , Owners , Waiting , AccQ );
785+ determine_best_partition (queue :out (Queue ), Busies , Waiting , AccQ );
789786 true ->
790787 case remote_node_available (Part , Busies ) of
791788 false ->
792- determine_best_partition (queue :out (Queue ), Busies , Owners , Waiting , queue :in (Part , AccQ ));
789+ determine_best_partition (queue :out (Queue ), Busies , Waiting , queue :in (Part , AccQ ));
793790 true ->
794791 {Part , queue :join (Queue , AccQ )}
795792 end
@@ -801,8 +798,10 @@ below_max_sources(State) ->
801798 Max = app_helper :get_env (riak_repl , max_fssource_cluster , ? DEFAULT_SOURCE_PER_CLUSTER ),
802799 ( length (State # state .running_sources ) + length (State # state .whereis_waiting ) ) < Max .
803800
804- node_available (PartitionInfo , Owners , Waiting ) ->
801+ node_available (PartitionInfo , Waiting ) ->
805802 Partition = PartitionInfo # partition_info .index ,
803+ {ok , Ring } = riak_core_ring_manager :get_my_ring (),
804+ Owners = riak_core_ring :all_owners (Ring ),
806805 LocalNode = proplists :get_value (Partition , Owners ),
807806 Max = app_helper :get_env (riak_repl , max_fssource_node , ? DEFAULT_SOURCE_PER_NODE ),
808807 try riak_repl2_fssource_sup :enabled (LocalNode ) of
@@ -834,8 +833,8 @@ remote_node_available(Partition, Busies) ->
834833
835834start_fssource (PartitionVal , Ip , Port , State ) ->
836835 Partition = PartitionVal # partition_info .index ,
837- # state { owners = Owners } = State ,
838- LocalNode = proplists : get_value ( Partition , Owners ),
836+ { ok , Ring } = riak_core_ring_manager : get_my_ring () ,
837+ LocalNode = riak_core_ring : index_owner ( Ring , Partition ),
839838 case riak_repl2_fssource_sup :enable (LocalNode , Partition , {Ip , Port }) of
840839 {ok , Pid } ->
841840 link (Pid ),
0 commit comments