Module rr_recon

replica reconcilication module.

Copyright © 2011-2014 Zuse Institute Berlin

Version: $Id$

Behaviours: gen_component.

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

Description

replica reconcilication module

Data Types

client_version()

client_version() = non_neg_integer()

export for testing

db_chunk_kv()

db_chunk_kv() = [{rt_chord:key(), client_version()}]

db_chunk_kvv()

db_chunk_kvv() = 
    [{rt_chord:key(), client_version(), db_dht:value()}]

exit_reason()

exit_reason() = empty_interval
              | recon_node_crash
              | sync_finished
              | sync_finished_remote

merkle_cmp_request()

merkle_cmp_request() = 
    {Hash :: merkle_tree:mt_node_key() | none,
     IsLeaf :: boolean()}

merkle_sync()

merkle_sync() = {My :: inner,
                 Other :: leaf,
                 MyMaxItemsCount :: non_neg_integer(),
                 MyKVItems :: merkle_tree:mt_bucket(),
                 LeafCount :: pos_integer()}
              | {My :: leaf,
                 Other :: leaf,
                 LeafNode :: merkle_tree:mt_node()}
              | {My :: leaf,
                 Other :: inner,
                 OtherMaxItemsCount :: non_neg_integer(),
                 LeafNode :: merkle_tree:mt_node()}

message()

message() = request()
          | {resolve_req, BinReqIdxPos :: bitstring()}
          | {resolve_req,
             DBChunk :: bitstring(),
             SigSize :: signature_size(),
             VSize :: signature_size(),
             SenderPid :: comm:mypid()}
          | {101,
             SenderPid :: comm:mypid(),
             ToCheck :: bitstring(),
             MaxItemsCount :: non_neg_integer()}
          | {101,
             ToCheck :: bitstring(),
             MaxItemsCount :: non_neg_integer()}
          | {102,
             FlagsBin :: bitstring(),
             MaxItemsCount :: non_neg_integer()}
          | {resolve_req, Hashes :: bitstring()}
          | {resolve_req,
             Hashes :: bitstring(),
             BinKeyList :: [bitstring()]}
          | {resolve_req, BinKeyList :: [bitstring()]}
          | {create_struct2,
             {get_state_response, MyI :: intervals:interval()}}
          | {create_struct2,
             DestI :: intervals:interval(),
             {get_chunk_response,
              {intervals:interval(), db_chunk_kv()}}}
          | {reconcile,
             {get_chunk_response,
              {intervals:interval(), db_chunk_kv()}}}
          | {resolve,
             {get_chunk_response,
              {intervals:interval(), db_chunk_kvv()}}}
          | {shutdown, exit_reason()}
          | {fd_notify,
             fd:event(),
             DeadPid :: comm:mypid(),
             Reason :: fd:reason()}
          | {'DOWN',
             MonitorRef :: reference(),
             process,
             Owner :: pid(),
             Info :: any()}

method()

method() = trivial | shash | bloom | merkle_tree | art

| iblt.

parameters()

parameters() = #trivial_recon_struct{interval =
                                         intervals:interval(),
                                     reconPid = comm:mypid()
                                               | undefined,
                                     db_chunk = bitstring(),
                                     sig_size =
                                         signature_size(),
                                     ver_size =
                                         signature_size()}
             | #shash_recon_struct{interval =
                                       intervals:interval(),
                                   reconPid = comm:mypid()
                                             | undefined,
                                   db_chunk = bitstring(),
                                   sig_size = signature_size(),
                                   p1e = float()}
             | #bloom_recon_struct{interval =
                                       intervals:interval(),
                                   reconPid = comm:mypid()
                                             | undefined,
                                   bf_bin = binary(),
                                   item_count =
                                       non_neg_integer(),
                                   p1e = float()}
             | #merkle_params{interval = intervals:interval(),
                              reconPid = comm:mypid()
                                        | undefined,
                              branch_factor = pos_integer(),
                              bucket_size = pos_integer(),
                              p1e = float(),
                              ni_item_count =
                                  non_neg_integer()}
             | #art_recon_struct{art = art:art(),
                                 branch_factor = pos_integer(),
                                 bucket_size = pos_integer()}

quadrant()

quadrant() = 1..4

1..rep_factor()

recon_dest()

recon_dest() = rt_chord:key() | random

request()

request() = {start, method(), DestKey :: recon_dest()}
          | {create_struct,
             method(),
             SenderI :: intervals:interval()}
          | {start_recon,
             bloom,
             #bloom_recon_struct{interval =
                                     intervals:interval(),
                                 reconPid = comm:mypid()
                                           | undefined,
                                 bf_bin = binary(),
                                 item_count =
                                     non_neg_integer(),
                                 p1e = float()}}
          | {start_recon,
             merkle_tree,
             #merkle_params{interval = intervals:interval(),
                            reconPid = comm:mypid()
                                      | undefined,
                            branch_factor = pos_integer(),
                            bucket_size = pos_integer(),
                            p1e = float(),
                            ni_item_count = non_neg_integer()}}
          | {start_recon,
             art,
             #art_recon_struct{art = art:art(),
                               branch_factor = pos_integer(),
                               bucket_size = pos_integer()}}

signature_size()

signature_size() = 0..160

use an upper bound of 160 (SHA-1) to limit automatic testing

stage()

stage() = req_shared_interval
        | build_struct
        | reconciliation
        | resolve

state()

state() = 
    #rr_recon_state{ownerPid = pid(),
                    dhtNodePid = pid(),
                    dest_rr_pid = comm:mypid(),
                    dest_recon_pid = comm:mypid() | undefined,
                    method = method() | undefined,
                    dest_interval = intervals:interval(),
                    my_sync_interval = intervals:interval(),
                    params = parameters() | {},
                    struct = sync_struct() | {},
                    stage = stage(),
                    initiator = boolean(),
                    merkle_sync = [merkle_sync()],
                    misc = [{atom(), term()}],
                    kv_list = db_chunk_kv(),
                    k_list = [rt_chord:key()],
                    stats = rr_recon_stats:stats(),
                    to_resolve =
                        {ToSend :: rr_resolve:kvv_list(),
                         ToReqIdx :: [non_neg_integer()]}}

sync_struct()

sync_struct() = #trivial_recon_struct{interval =
                                          intervals:interval(),
                                      reconPid = comm:mypid()
                                                | undefined,
                                      db_chunk = bitstring(),
                                      sig_size =
                                          signature_size(),
                                      ver_size =
                                          signature_size()}
              | #shash_recon_struct{interval =
                                        intervals:interval(),
                                    reconPid = comm:mypid()
                                              | undefined,
                                    db_chunk = bitstring(),
                                    sig_size =
                                        signature_size(),
                                    p1e = float()}
              | #bloom_recon_struct{interval =
                                        intervals:interval(),
                                    reconPid = comm:mypid()
                                              | undefined,
                                    bf_bin = binary(),
                                    item_count =
                                        non_neg_integer(),
                                    p1e = float()}
              | merkle_tree:merkle_tree()
              | [merkle_tree:mt_node()]
              | #art_recon_struct{art = art:art(),
                                  branch_factor =
                                      pos_integer(),
                                  bucket_size = pos_integer()}

Function Index

check_config/0Checks whether config parameters exist and are valid.
find_sync_interval/2Gets a randomly selected sync interval as an intersection of the two given intervals as a sub interval of A inside a single quadrant.
get_chunk_filter/1
get_chunk_kv/1
get_chunk_kvv/1
init/1init module.
key_dist/2
map_interval/2Maps interval B into interval A.
map_key_to_interval/2Maps any key (K) into a given interval (I).
map_key_to_quadrant/2Maps an abitrary key to its associated key in replication quadrant N.
merkle_compress_hashlist/4Transforms a list of merkle keys, i.e.
merkle_decompress_hashlist/3Transforms the compact binary representation of merkle hash lists from merkle_compress_hashlist/2 back into the original form.
on/2
quadrant_intervals/0Gets the quadrant intervals.
quadrant_subints_/3Gets all sub intervals of the given interval which lay only in a single quadrant.
start/2

Function Details

on/2

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

merkle_compress_hashlist/4

merkle_compress_hashlist(Nodes :: [merkle_tree:mt_node()],
                         Bin,
                         SigSizeI :: signature_size(),
                         SigSizeL :: signature_size()) ->
                            Bin

Transforms a list of merkle keys, i.e. hashes, into a compact binary representation for transfer.

merkle_decompress_hashlist/3

merkle_decompress_hashlist(Bin :: bitstring(),
                           SigSizeI :: signature_size(),
                           SigSizeL :: signature_size()) ->
                              Hashes :: [merkle_cmp_request()]

Transforms the compact binary representation of merkle hash lists from merkle_compress_hashlist/2 back into the original form.

get_chunk_filter/1

get_chunk_filter(DBEntry :: db_entry:entry()) -> boolean()

get_chunk_kv/1

get_chunk_kv(DBEntry :: db_entry:entry()) ->
                {rt_chord:key(), client_version() | -1}

get_chunk_kvv/1

get_chunk_kvv(DBEntry :: db_entry:entry()) ->
                 {rt_chord:key(),
                  client_version() | -1,
                  db_dht:value()}

map_key_to_interval/2

map_key_to_interval(Key :: rt_chord:key(),
                    I :: intervals:interval()) ->
                       rt_chord:key() | none

Maps any key (K) into a given interval (I). If K is already in I, K is returned. If K has more than one associated key in I, the closest one is returned. If all associated keys of K are not in I, none is returned.

key_dist/2

key_dist(Key1 :: rt_chord:key(), Key2 :: rt_chord:key()) ->
            number()

map_key_to_quadrant/2

map_key_to_quadrant(Key :: rt_chord:key(), Q :: quadrant()) ->
                       rt_chord:key()

Maps an abitrary key to its associated key in replication quadrant N.

quadrant_intervals/0

quadrant_intervals() -> [intervals:non_empty_interval(), ...]

Gets the quadrant intervals.

quadrant_subints_/3

quadrant_subints_(A :: intervals:interval(),
                  Quadrants :: [intervals:interval()],
                  AccIn :: [intervals:interval()]) ->
                     AccOut :: [intervals:interval()]

Gets all sub intervals of the given interval which lay only in a single quadrant.

find_sync_interval/2

find_sync_interval(A :: intervals:continuous_interval(),
                   B :: intervals:continuous_interval()) ->
                      intervals:interval()

Gets a randomly selected sync interval as an intersection of the two given intervals as a sub interval of A inside a single quadrant. Result may be empty, otherwise it is also continuous!

map_interval/2

map_interval(A :: intervals:continuous_interval(),
             B :: intervals:continuous_interval()) ->
                intervals:interval()

Maps interval B into interval A. PreCond: the second (continuous) interval must be in a single quadrant! The result is thus also only in a single quadrant. Result may be empty, otherwise it is also continuous!

init/1

init(State :: state()) -> state()

init module

start/2

start(SessionId :: rrepair:session_id() | null,
      SenderRRPid :: comm:mypid()) ->
         {ok, pid()}

check_config/0

check_config() -> boolean()

Checks whether config parameters exist and are valid.


Generated by EDoc, Jul 23 2015, 22:20:30.