# Module lb_active

- Description
- Data Types
- Function Index
- Function Details

Active load balancing core module.

Copyright © 2014-2015 Zuse Institute Berlin Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Version: $Id$

Behaviours: `gen_component`.

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

## Description

Active load balancing core module

## Data Types

### dht_message()

    dht_message() =
        {lb_active, reset_db_monitors} |
        {lb_active,
         balance,
         HeavyNode :: lb_info:lb_info(),
         LightNode :: lb_info:lb_info(),
         LightNodeSucc :: lb_info:lb_info(),
         Options :: options()}

### erlang_timestamp()

    erlang_timestamp() =
        {MegaSecs :: non_neg_integer(),
         Secs :: 0..999999,
         MicroSecs :: 0..999999}

### lb_op()

    lb_op() =
        #lb_op{id = uid:global_uid(),
               type = slide_pred | slide_succ | jump,
               heavy_node = node:node_type(),
               light_node = node:node_type(),
               light_node_succ = node:node_type(),
               target = rt_chord:key(),
               data_time = erlang_timestamp(),
               time = erlang_timestamp()}

### message()

    message() =
        {lb_stats_trigger} |
        {reset_monitors} |
        {gossip_reply,
         LightNode :: lb_info:lb_info(),
         HeavyNode :: lb_info:lb_info(),
         LightNodeSucc :: lb_info:lb_info(),
         Options :: options(),
         {gossip_get_values_best_response,
          LoadInfo :: gossip_load:load_info()}} |
        {balance_phase1, Op :: lb_op()} |
        {balance_phase2a, Op :: lb_op()} |
        {balance_phase2b, Op :: lb_op()} |
        {balance_failed, OpId :: uid:global_uid()} |
        {balance_success, OpId :: uid:global_uid()} |
        {move,
         result,
         Tag ::
             {jump | slide_pred | slide_succ,
              OpId :: uid:global_uid()},
         Result :: ok | dht_node_move:abort_reason()} |
        {web_debug_info, Requestor :: pid()}

### my_state()

    my_state() =
        #my_state{last_balance = erlang_timestamp(),
                  last_db_monitor_reset = erlang_timestamp(),
                  pending_op = lb_op() | nil}

### options()

    options() = [tuple()]

### state()

abstract datatype: `state()`

## Function Index

balance_nodes/3 |
balance_nodes/4 |
balance_noop/1 |
check_config/0 | config check registered in config.erl.
check_gossip_modules/2 |
get_last_db_monitor_init/1 |
handle_dht_msg/2 | Process load balancing messages sent to the dht node.
init/1 | Initialization of core module and lb_stats.
is_enabled/0 |
on/2 | On handler after initialization.
requests_balance/0 |
start_gen_component/5 |
start_link/1 | Start this process as a gen component and register it in the dht node group.

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

### start_link/1

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

Start this process as a gen component and register it in the dht node group

### init/1

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

Initialization of core module and lb_stats

### on/2

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

On handler after initialization

### balance_nodes/3

    balance_nodes(HeavyNode :: lb_info:lb_info(),
                  LightNode :: lb_info:lb_info(),
                  Options :: options()) ->
                     ok

### balance_nodes/4

    balance_nodes(HeavyNode :: lb_info:lb_info(),
                  LightNode :: lb_info:lb_info(),
                  LightNodeSucc :: lb_info:lb_info() | nil,
                  Options :: options()) ->
                     ok

### balance_noop/1

    balance_noop(Options :: options()) -> ok

### handle_dht_msg/2

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

Process load balancing messages sent to the dht node

### is_enabled/0

    is_enabled() -> boolean()

### requests_balance/0

    requests_balance() -> boolean()

### get_last_db_monitor_init/1

    get_last_db_monitor_init(MyState :: my_state()) ->
                                erlang_timestamp()

### check_gossip_modules/2

    check_gossip_modules(RequiredModule :: atom(),
                         DependencyKey :: atom()) ->
                            boolean()

### check_config/0

    check_config() -> boolean()

config check registered in config.erl

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