# Module lb_active_karger

- Description
- Data Types
- Function Index
- Function Details

Implementation of Karger and Ruhl's item balancing load balancing algorithm.

Copyright © 2013-2015 Zuse Institute Berlin

Version: $Id$

Behaviours: `lb_active_beh`.

Authors: Maximilian Michels (`michels@zib.de`).

References

- D. R. Karger and M. Ruhl, "Simple efficient load balancing algorithms for peer-to-peer systems," in Proceedings of the sixteenth annual ACM symposium on Parallelism in algorithms and architectures, 2004, pp. 36-43.

## Description

Implementation of Karger and Ruhl's item balancing load balancing algorithm. Modified to sample N nodes and use gossip information.

## Data Types

### dht_message()

    dht_message() =
        {lb_active, phase1, NodeX :: lb_info:lb_info(), options()} |
        {lb_active,
         phase2,
         HeavyNode :: lb_info:lb_info(),
         LightNode :: lb_info:lb_info()}

### my_message()

    my_message() =
        {lb_active_karger_trigger} |
        {cy_cache, [node:node_type()]} |
        {my_dht_response,
         DhtNode :: comm:mypid(),
         {get_state_response, Load :: number()}} |
        dht_node_move:result_message() |
        {simulation_result,
         Id :: integer(),
         ReqId :: integer(),
         {items | requests, LoadChange :: non_neg_integer()}} |
        {pick_best_candidate, Id :: integer()}

### options()

    options() =
        [{epsilon, float()} |
         {id, integer()} |
         {simulate} |
         {reply_to, comm:mypid()}]

### state()

    state() =
        #state{epsilon = float(),
               rnd_node = [node:node_type()],
               best_candidate =
                   [{items | requests,
                     {LoadChange :: non_neg_integer(),
                      node:node_type()}}],
               round_id = non_neg_integer() | nil,
               my_lb_info = lb_info:lb_info() | nil,
               req_ids = [{integer(), node:node_type()}]}

## Function Index

check_config/0 |
get_web_debug_kv/1 | Key/Value List for web debug.
handle_dht_msg/2 |
handle_msg/2 |
init/0 | Initialization of module called by lb_active.

## Function Details

### init/0

    init() -> state()

Initialization of module called by lb_active

### handle_msg/2

    handle_msg(X1 :: my_message(), State :: state()) -> state()

### handle_dht_msg/2

    handle_dht_msg(X1 :: dht_message(),
                   DhtState :: dht_node_state:state()) ->
                      dht_node_state:state()

### get_web_debug_kv/1

    get_web_debug_kv(State :: state()) -> [{string(), string()}]

Key/Value List for web debug

### check_config/0

    check_config() -> boolean()

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