Erlang Mesh Developer’s Manual

Introduction

Please read about mesh topology and work principals on site, in User Guide and Mesh topology and implementation details presentation. Also you should be familiar with Erlang/OTP architecture principals: applications, gen_servers, supervisor trees.

 

Mesh modules

mesh.erl

Internal mesh functionality:

·         Node Join Protocol

o   [join, get_role, get_roots, get_hungry_roots, update_groups_with_root]

·         Job Processing

o   [ build_job,  rebuild_job, job_done]

 

And external interface for:

·         Monitor

o   [get_root_state, get_mesh_state ]

·         Job Processing

o   [route_job_async, route_job_sync ]

node_manager.erl

Implements gen_server behavior.

Implements behavior of Leaf Node Manager and Root Router.

 

Leaf Node Manager:

·         Job routing to workers

o   [do_job, job_done]

·         Workers Managment

o   [register_worker]

 

Root Router:

·         Job routing to leaves

o   [route_job, forward_job, job_done]

·         Node Join Protocol

o    [get_role ]

·         Leaves Monitoring

o   [handle_info]]

This module implements mesh node main logic.

 

node_supervisor.erl

Implements supervisor behavior.

init:

Connects node to the mesh network.

Initiate supervisor for workers and node manager,

Using provided parameters.

worker.erl

Implements gen_server behavior.

[do_job, do_work]:

The only function.

Process sleeps for time provide in Job argument,

Sends to Client response with doubled value of time.

Sends message to node manager that job is done.

 

mesh_app.erl

Implements application behavior.

global_lock.erl

Used for Node Join Protocol

mesh_mon.erl

Provides ehtml (format for html in yaws) formatted output for monitor ajax implementation on front end.

mesh_state_to_ehtml

loader.erl

Used to demonstrate load on mesh.

 

Web Modules

index.html

GUI for all web elements.

 

Actions panel: provides mesh functionality using AJAX

Send one job

Send number of jobs

Send number of jobs constantly

Create new node

Stop node

 

Monitor panel:

provides mesh graphic representation, each 0.5 sec loads monitor_data.yaws using AJAX.

 

Log panel:

History of commands and responses.

loader_ws.yaws

 

Loads servers with provided number of jobs, informs the index.html page by web socket.

 

monitor_data.yaws

Graphic representation of mesh state

Uses mesh_mon: mesh_state_to_ehtml to get representation

 

 

start_node.yaws

Starts new node using

[slave] – erlang BIF.

stop_node.yaws

Stops node

worker.yaws

Sends job to the mesh and wait till it’s done.

loader.erl

Used to demonstrate load on mesh.