Home

Awesome

Cassandra and Scylla are completely interchangeable names for the following document. Both the databases can be used with the same driver.

Installation

Working with Irmin-scylla requires two installations:

Installing Scylla driver

Scylla DB is just a C++ implementation of Cassandra DB. So the drivers used for C* works for Scylla too, without any changes. We have used the C++ implementation of Datastax Cassandra driver which can be downloaded from: https://github.com/datastax/cpp-driver Instructions to build it can be found at: https://datastax.github.io/cpp-driver/topics/building/ Please note the following when building the libraries:

To use the C* driver with OCaml, we can add it to opam libraries as an external stub. Dune and other files for the same can be found at: https://github.com/prismlab/irmin-scylla/tree/master/irmin-master/src/libcassandra The folder structure in the git repo is designed to accomodate the correct placing of the libraries. In my setup, I have named the directory containing the driver and other related files as libcassandra . It can be added to opam using: opam pin add libcassandra -k path < path to root folder> (irmin-master is the root folder).

The installation may ask to first install ctypes, ctypes-foreign, and posix-types, if not already installed in the current switch. It can be installed directly from opam.

Installing the Scylla backend

Installing the Scylla backend is quite straight forward, just like any other backend. Since the backend is supposed to interact with the external driver which is written in C++, we have a C stub to convert some of the basic types between OCaml and C/C++. Dune is modified to install this file along with few library dependencies which are required to connect with the driver. These are system based libraries. Irmin-scylla can be installed using: opam pin add irmin-scylla -k path < path to root folder>

Setting up the Cassandra database

Cassandra can be installed using the standard installation steps from the website. Once up and running, it can be checked using nodetool status.

Setting up the scylla database

Currently I am using the containerized version of the scylla database, for which instructions can be found at: https://docs.scylladb.com/operating-scylla/procedures/tips/best_practices_scylla_on_docker/ Alternatively, it can be installed by compiling the source present at its github repo. Scylla DB does not provide Light weight transactions in the main source currently. Hence to use it in the docker, use --experimental 1 flag when creating the container. To create the cluster instructions are given in the above link. TLDR; If the first container is named as lwt-scylla1 and uses LWT then using it as seed node, cluster can be started with docker run --name lwt-scylla2 --hostname lwt-scylla2 -d scylladb/scylla --seeds="$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' lwt-scylla1)" --experimental 1. Further nodes can be added in the similar fashion. This has been tried when all the containers are on the same machine.

Examples

This repository also contains a simple example for setting a key-value pair to database in one node and fetching it back from another. I have also checked-in one piece of code which I run on utop for testing purpose, just in case it comes handy.

Note

CREATE KEYSPACE irmin_scylla WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'};

CREATE TABLE irmin_scylla.atomic_write (
    key text PRIMARY KEY,
    value text);

CREATE TABLE irmin_scylla.append_only (
    key text PRIMARY KEY,
    value blob);