Metadata-Version: 2.1
Name: pyraftlog
Version: 2.0.1
Summary: Pure Python implementation of the RAFT concencous algorithm
Home-page: UNKNOWN
Author: Peter Scopes
Author-email: peter.scopes@nccgroup.trust
License: Copyright 2018 NCC
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 2.7
Classifier: Operating System :: OS Independent
Requires-Dist: msgpack (>=0.6.1)
Requires-Dist: redis (>=2.10.6)

PyRaftLog
=========
``pyraftlog`` is a RAFT consensus algorithm implementation that provides direct access to the consensus log.

Consensus Nodes can be instantiated into defined mode, but can also have its mode changed via an RPC.
There are three modes a node can be in:

Active
  A fully-fledged consensus node which will attempt to take leadership of the cluster if a leadership
  timeout is reached.

Reluctant
  A consensus node which will reluctantly take leadership of the cluster while there is no eligible
  candidate. As soon as there is an eligible active node a reluctant node will rescind its leadership.

Passive
  A consensus node which that will respond to all vote requests but will never convert itself to a
  candidate. This mode can be useful in testing or development environments but shouldn't be used
  in production.

Consensus Nodes can enable log reduction, this can be useful in certain situations where a complete history
of actions is not required or would take considerable storage to retain. If ``log_reduction`` is set to
``True`` in the ``state`` then the cluster will automatically reduce the log to the most recent
``last_applied`` index that is shared across the cluster. Have log reduction set to ``True`` would make
it difficult to add additional nodes to the cluster.

Mock Server
-----------
There is a mock server that can be run by calling ``pyraftlog-mock``::

    usage: pyraftlog-mock [-h] [-t {active,reluctant,passive}] -n NODE -b
                          NEIGHBOURS [NEIGHBOURS ...] [-p PORT] [-r]
                          [-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-f FILE]

    Run a mock localhost pyraftlog server

    optional arguments:
      -h, --help            show this help message and exit
      -t {active,reluctant,passive}, --type {active,reluctant,passive}
                            Type of the node
      -n NODE, --node NODE  (host:)?port of this node. e.g. 7001 or node:7001
      -b NEIGHBOURS [NEIGHBOURS ...], --neighbours NEIGHBOURS [NEIGHBOURS ...]
                            Port(s) of neighbour
      -p PORT, --port PORT  Port for receiving commands
      -r, --log-reduction   Set log reduction to True
      -l {DEBUG,INFO,WARNING,ERROR,CRITICAL}, --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
                            Logging level
      -f FILE, --file FILE  Storage filename

Create SSL certs (for mock)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
The following set of commands (performed in ``./certs/``) will create a set a CA and device certificate for running the mock cluster on localhost::

    # Only do once: generate the root CA key:
    > openssl genrsa -out transport-ca.key 4096

    # Generate the root CA certificate:
    ## Country Name (2 letter code) []:GB
    ## State or Province Name (full name) []:.
    ## Locality Name (eg, city) []:.
    ## Organization Name (eg, company) []:.
    ## Organizational Unit Name (eg, section) []:.
    ## Common Name (eg, fully qualified host name) []:PyRaftLog
    ## Email Address []:.
    > openssl req -x509 -new -nodes -key transport-ca.key -sha256 -days 1024 -out transport-ca.pem

    # Generate device certificates
    # Only do once: generate device key:
    > openssl genrsa -out transport-consensus.key 4096

    # Generate device certificate signing request:
    ## Country Name (2 letter code) []:GB
    ## State or Province Name (full name) []:.
    ## Locality Name (eg, city) []:.
    ## Organization Name (eg, company) []:.
    ## Organizational Unit Name (eg, section) []:.
    ## Common Name (eg, fully qualified host name) []:localhost
    ## Email Address []:.
    > openssl req -new -key transport-consensus.key -out transport-consensus.csr

    # Generate a signed device certificate:
    > openssl x509 -req -in transport-consensus.csr -CA transport-ca.pem -CAkey transport-ca.key -CAcreateserial -out transport-consensus.crt -days 500 -sha256



Also See
--------
- `Raft Github`_
- `Raft Paper`_
- `Raft Thesis`_
- `Raft lecture`_  (Raft user study)
- `Raft Optimisations`_

.. _Raft Github: https://raft.github.io/
.. _Raft Paper: https://raft.github.io/raft.pdf
.. _Raft Thesis: https://ramcloud.stanford.edu/~ongaro/thesis.pdf
.. _Raft lecture: https://www.youtube.com/watch?v=YbZ3zDzDnrw
.. _Raft Optimisations: https://www.cl.cam.ac.uk/~ms705/pub/papers/2015-osr-raft.pdf


