# Module dht_node

- Description
- Data Types
- Function Index
- Function Details

dht_node main file.

Copyright © 2007-2015 Zuse Institute Berlin

Version: $Id$

Behaviours: `gen_component`.

Authors: Thorsten Schuett (`schuett@zib.de`).

## Description

dht_node main file

## Data Types

### client_version()

    client_version() = non_neg_integer()

### database_message()

    database_message() =
        {22,
         Source_PID :: comm:mypid(),
         SourceId :: any(),
         HashedKey :: rt_chord:key()} |
        {get_entries,
         Source_PID :: comm:mypid(),
         Interval :: intervals:interval()} |
        {get_entries,
         Source_PID :: comm:mypid(),
         FilterFun :: fun((db_entry:entry()) -> boolean()),
         ValFun :: fun((db_entry:entry()) -> any())} |
        {get_chunk,
         Source_PID :: comm:mypid(),
         Interval :: intervals:interval(),
         MaxChunkSize :: pos_integer() | all} |
        {get_chunk,
         Source_PID :: comm:mypid(),
         Interval :: intervals:interval(),
         FilterFun :: fun((db_entry:entry()) -> boolean()),
         ValFun :: fun((db_entry:entry()) -> any()),
         MaxChunkSize :: pos_integer() | all} |
        {update_key_entries,
         Source_PID :: comm:mypid(),
         [{HashedKey :: rt_chord:key(),
           NewValue :: db_dht:value(),
           NewVersion :: client_version()}]} |
        {get_key_entry,
         Source_PID :: comm:mypid(),
         HashedKey :: rt_chord:key()} |
        {set_key_entry,
         Source_PID :: comm:mypid(),
         Entry :: db_entry:entry()} |
        {delete_key,
         Source_PID :: comm:mypid(),
         ClientsId :: {delete_client_id, uid:global_uid()},
         HashedKey :: rt_chord:key()} |
        {add_data, Source_PID :: comm:mypid(), db_dht:db_as_list()} |
        {drop_data,
         Data :: db_dht:db_as_list(),
         Sender :: comm:mypid()}

### lookup_message()

    lookup_message() =
        {1,
         Key :: rt_chord:key(),
         Hops :: pos_integer(),
         Msg :: comm:message()} |
        {2,
         Key :: rt_chord:key(),
         Data :: dht_node_lookup:data(),
         Msg :: comm:message()}

### message()

    message() =
        bulkowner:bulkowner_msg() |
        database_message() |
        lookup_message() |
        dht_node_join:join_message() |
        rt_message() |
        dht_node_move:move_message() |
        misc_message() |
        snapshot_message() |
        {zombie, Node :: node:node_type()} |
        {fd_notify,
         fd:event(),
         DeadPid :: comm:mypid(),
         Reason :: fd:reason()} |
        {leave, SourcePid :: comm:erl_local_pid() | null} |
        {rejoin,
         IdVersion :: non_neg_integer(),
         JoinOptions :: [tuple()],
         {get_move_state_response, MoveState :: [tuple()]}}

### misc_message()

    misc_message() =
        {get_yaws_info, Pid :: comm:mypid()} |
        {get_state,
         Pid :: comm:mypid(),
         Which :: dht_node_state:name()} |
        {get_node_details, Pid :: comm:mypid()} |
        {get_node_details,
         Pid :: comm:mypid(),
         Which :: [node_details:node_details_name()]} |
        {get_pid_group, Pid :: comm:mypid()} |
        {dump} |
        {web_debug_info, Requestor :: comm:erl_local_pid()} |
        {get_dht_nodes_response, KnownHosts :: [comm:mypid()]} |
        {unittest_get_bounds_and_data,
         SourcePid :: comm:mypid(),
         full | kv}

### rt_message()

    rt_message() =
        {rt_update, RoutingTable :: rt_chord:external_rt()}

### snapshot_message()

    snapshot_message() =
        {do_snapshot,
         SnapNumber :: non_neg_integer(),
         Leader :: comm:mypid()} |
        {local_snapshot_is_done}

## Function Index

init/1 | joins this node in the ring and calls the main loop.
is_alive/1 |
is_alive_fully_joined/1 |
is_alive_no_slide/1 |
is_first/1 | Checks whether this VM is marked as first, e.g.
on/2 | message handler.
start_gen_component/5 |
start_link/2 | spawns a scalaris node, called by the scalaris supervisor process.

## 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

### on/2

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

message handler

### init/1

    init(Options :: [tuple()]) ->
            dht_node_state:state() |
            {'$gen_component',
             [{on_handler, Handler :: gen_component:handler()}],
             State :: dht_node_join:join_state()}

joins this node in the ring and calls the main loop

### start_link/2

    start_link(DHTNodeGroup :: pid_groups:groupname(),
               Options :: [tuple()]) ->
                  {ok, pid()}

spawns a scalaris node, called by the scalaris supervisor process

### is_first/1

    is_first(Options :: [tuple()]) -> boolean()

Checks whether this VM is marked as first, e.g. in a unit test, and this is the first node in this VM.

### is_alive/1

    is_alive(State ::
                 dht_node_join:join_state() |
                 dht_node_state:state() |
                 term()) ->
                boolean()

### is_alive_no_slide/1

    is_alive_no_slide(State ::
                          dht_node_join:join_state() |
                          dht_node_state:state() |
                          term()) ->
                         boolean()

### is_alive_fully_joined/1

    is_alive_fully_joined(State ::
                              dht_node_join:join_state() |
                              dht_node_state:state() |
                              term()) ->
                             boolean()

Generated by EDoc, Apr 22 2017, 15:58:26.