# Module rrepair

- Description
- Data Types
- Function Index
- Function Details

replica repair module Replica sets will be synchronized in two steps.

Copyright © 2011-2015 Zuse Institute Berlin

Version: $Id$

Behaviours: `gen_component`.

Authors: Maik Lange (`malange@informatik.hu-berlin.de`).

## Description

replica repair module Replica sets will be synchronized in two steps. I) reconciliation - find set differences (rr_recon.erl) II) resolution - resolve found differences (rr_resolve.erl)

Examples: 1) remote node should get a single kvv-pair (Key, Value, Version) with Key mapped into first quadrant >>comm:send(RemoteRRepairPid, {request_resolve, {?key_upd, [{Key, Value, Version}], []}, []}).

## Data Types

### message()

    message() =
        {request_sync, DestKey :: random | rt_chord:key()} |
        {request_sync,
         Method :: rr_recon:method(),
         DestKey :: random | rt_chord:key()} |
        {request_sync,
         Method :: rr_recon:method(),
         DestKey :: random | rt_chord:key(),
         Principal :: principal_id()} |
        {request_resolve,
         rr_resolve:operation(),
         rr_resolve:options()} |
        {get_state,
         Sender :: comm:mypid(),
         Keys :: state_field() | [state_field(), ...]} |
        {rr_trigger} |
        {rr_gc_trigger} |
        {start_sync,
         get_range,
         session_id(),
         rr_recon:method(),
         DestKey :: random | rt_chord:key(),
         {get_state_response,
          [{my_range, intervals:interval()} |
           {load, non_neg_integer()},
           ...]}} |
        {start_recon | continue_recon,
         SenderRRPid :: comm:mypid(),
         session_id(),
         ReqMsg :: rr_recon:request()} |
        {request_resolve | continue_resolve,
         session_id() | null,
         rr_resolve:operation(),
         rr_resolve:options()} |
        {web_debug_info, Requestor :: comm:erl_local_pid()} |
        {recon_progress_report,
         Sender :: comm:mypid(),
         Initiator :: boolean(),
         DestRR :: comm:mypid(),
         DestRC :: comm:mypid() | undefined,
         Stats :: rr_recon_stats:stats()} |
        {resolve_progress_report,
         Sender :: comm:erl_local_pid(),
         Stats :: rr_resolve:stats()}

### principal_id()

    principal_id() = comm:mypid() | none

### round()

    round() = non_neg_integer()

### session()

    session() =
        #session{id = session_id(),
                 principal = principal_id(),
                 rc_method = rr_recon:method(),
                 rc_stats = rr_recon_stats:stats() | none,
                 rs_stats = rr_resolve:stats() | none,
                 rs_expected = non_neg_integer(),
                 rs_finish = non_neg_integer(),
                 ttl = pos_integer()}

### session_id()

    session_id() = {round(), comm:mypid()}

### state()

    state() =
        #rrepair_state{round = round(),
                       open_recon = non_neg_integer(),
                       open_resolve = non_neg_integer(),
                       open_sessions = [session()]}

### state_field()

    state_field() =
        round | open_recon | open_resolve | open_sessions

## Function Index

check_config/0 | Checks whether config parameters exist and are valid.
init/1 | Initialises the module and starts the trigger.
on/2 |
select_sync_node/2 | Selects a random key in the given (continuous) interval and returns one of its replicas which is not in the interval (if ExcludeInterval is true).
session_get/2 |
start_gen_component/5 | session contains only data of the sync request initiator thus rs_stats:regen_count represents only number of regenerated db items on the initator.
start_link/1 | Starts the replica update process, registers it with the process dictionary and returns its pid for use by a supervisor.

## Function Details

### start_gen_component/5

    start_gen_component(Module :: module(),
                        Handler :: gen_component:handler(),
                        Args :: term(),
                        Options :: [gen_component:option()],
                        Self :: pid()) ->
                           no_return() | ok

session contains only data of the sync request initiator thus rs_stats:regen_count represents only number of regenerated db items on the initator

### on/2

    on(Msg :: message(), State :: state()) -> state()

### select_sync_node/2

    select_sync_node(Interval :: intervals:continuous_interval(),
                     ExcludeInterval :: false) ->
                        rt_chord:key()

Selects a random key in the given (continuous) interval and returns one of its replicas which is not in the interval (if ExcludeInterval is true). If ExcludeInterval is false, any of its replica keys is returned.

### start_link/1

    start_link(DHTNodeGroup :: pid_groups:groupname()) -> {ok, pid()}

Starts the replica update process, registers it with the process dictionary and returns its pid for use by a supervisor.

### init/1

    init(X1 :: []) -> state()

Initialises the module and starts the trigger

### session_get/2

    session_get(X1 :: id, Session :: session()) -> session_id()

### check_config/0

    check_config() -> boolean()

Checks whether config parameters exist and are valid.

Generated by EDoc, Feb 29 2016, 16:12:15.