fully distributed mutex server in erlang based on the sigma algorithm
Erlang
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
conf
deps
doc
ebin
include
priv/tasks
scripts
src
test
.gitignore
.gitmodules
Emakefile
INSTALL
LICENSE
README.mkd
Rakefile
VERSION

README.mkd

Stoplight

Introduction

Stoplight is a distributed mutex server, based on the Sigma algorithm.

Mutual exclusion: No two different clients are in their critical sections at the same time.

Features:

  • progress guaranteed in the face of process crashes (i.e. lockout-freedom, will not deadlock)
  • assumes asynchronous and unreliable communication
  • survives server and client memory loss
  • endures messages being lost, duplicated or delivered out of order (non-FIFO)
  • mutual exclusion guaranteed if f<n/3 where f is the number of failed servers and n is the total number of servers.

Install

Prerequisites

  • ruby / rubygems / rake
  • gem sources --add http://gems.github.com
  • gem install auser-skelerl auser-dslify

Build

cd stoplight
rake

Layout

    .
    |-- EMakefile
    |-- INSTALL
    |-- README.mkd
    |-- deps                 # dependencies
    |-- doc                  # documentation
    |-- ebin                 # app, bootscripts, ebin files
    |-- include              # headers 
    |-- priv
    |   `-- tasks            # rake tasks
    |-- scripts              # scripts to start/stop stoplight
    |-- src                  # main source
    `-- test                 # tests

Testing Locally

Open three windows:

window 1.

STOPLIGHT_NODENAME="stoplight@your-ip" ./scripts/stoplight-server

window 2.

STOPLIGHT_SERVER="stoplight@your-ip" ./scripts/stoplight-client
1> {Resp, Pid} = stoplight_client:lock(green, 1000).
{crit,<6078.82.0>}

window 3.

STOPLIGHT_SERVER="stoplight@your-ip" ./scripts/stoplight-client
1> {Resp, Lob} = stoplight_client:lock(green).        
{no,<6078.91.0>}

back to 2.

2> stoplight_client:release(Pid).
ok

back to 3.

2> {Resp2, Lob2} = stoplight_client:lock(green).
{crit,<6078.91.0>}

Clustering

On Server Machine 1

STOPLIGHT_NODENAME="stoplight@192.168.133.128" ./scripts/stoplight-server

On Server Machine 2

STOPLIGHT_NODENAME="stoplight@192.168.1.66" STOPLIGHT_SERVER="toplight@192.168.133.128" ./scripts/stoplight-server
1> nodes().
['stoplight@192.168.133.128']

On Client Machine

STOPLIGHT_SERVER="stoplight@192.168.133.128" ./scripts/stoplight-client

Configuration

stoplight servers is a valid application configuration option. This means when starting the server you can specify a list of addresses to other servers like so:

STOPLIGHT_NODENAME='stoplight@192.168.1.66' STOPLIGHT_SERVER_START_ARGS="-stoplight servers ['stoplight@192.168.133.128']" ./scripts/stoplight-server 

Acknowledgements

Similar Projects