Skip to content

QuickStart

João Neto edited this page Mar 2, 2018 · 10 revisions

A Simple Quick Start Guide

This tutorial will help you start from scratch to interact with a containerized Docker image of Antidote DB.

Prerequisites

This section summarizes the required software/versions to complete the tutorial successfully.

Operating System and OS packages

I'll just deal with Linux (Debian) and macOS here. Feel free to extend the document to Windows platforms or other distros.

In Linux distros, it's strongly recommended to install the build-essential package.

We will also need git and curl. On Linux, just install directly from repos (apt-get install git curl). On macOS just install XCode and its command line tools, or from Homebrew.

Docker

We will use Docker to simplify the deployment of an AntidoteDB instance.

To download Docker, go to the Docker website. I did this tutorial using the Community Edition, version 17.06.

We will also need to install Docker Compose. I used version 1.14.0.

NodeJS / NPM

The REST Server is a NodeJS server application. To get NodeJS, go to the NodeJS Website.

It should work with NodeJS version 5 or later, and NPM versions 3 or later. I did this tutorial using NodeJS version 8.4.0, and NPM version 5.3.0.

Getting a AntidoteDB Docker Image

We will just steal the stuff from Deepthi's Antidote Java Tutorial:

$ git clone https://github.com/SyncFree/antidote-java-tutorial.git
$ cd antidote-java-tutorial/setup
$ ./start_antidote.sh
$ cd ../..

This should download a Docker image with AntidoteDB, start two instances and automatically configure them as a tiny cluster. The AntidoteDB instances antidote1 and antidote2 will run on ports 8087 and 8088, respectively.

Installing and Running the Antidote REST Server

You can install the server directly from NPM.

$ npm install -g antidote-rest-server

To run the Antidote REST Server, just enter:

$ antidote-rest-server

Interacting with Antidote via REST

Counters

Let's say we want to increment the counter mycounter in the bucket testbucket:

$ curl localhost:3000/counter/increment/testbucket/mycounter
ok

To see what is its current value

$ curl localhost:3000/counter/read/testbucket/mycounter
1

We can increment by a different amount. Let's say, 10:

$ curl localhost:3000/counter/increment/testbucket/mycounter/10
ok
$ curl localhost:3000/counter/read/testbucket/mycounter
11

We can decrement by specifying a negative amount:

$ curl localhost:3000/counter/increment/testbucket/mycounter/-20
ok
$ curl localhost:3000/counter/read/testbucket/mycounter
-9

Sets

We also have sets! Imagine that! Let's work with the set beatles in the bucket bands. We need to add the band members!

$ curl localhost:3000/set/add/bands/beatles/john
ok
$ curl localhost:3000/set/add/bands/beatles/paul
ok
$ curl localhost:3000/set/add/bands/beatles/george
ok
$ curl localhost:3000/set/add/bands/beatles/ringo
ok
$ curl localhost:3000/set/read/bands/beatles
["john","paul","ringo","george"]

Sadly, John Lennon was shot and killed in 1980, and George Harrison died of lung cancer in 2001. We need to update our records!

$ curl localhost:3000/set/remove/bands/beatles/john
ok
$ curl localhost:3000/set/remove/bands/beatles/george
ok
$ curl localhost:3000/set/read/bands/beatles
["paul","ringo"]

Cleaning Up

Now your computer is messy because of all the things we did. I'll help you clean things up.

REST Server and Node.JS

To stop the REST Server, just Ctrl-C in the console.

To uninstall the REST Server and its dependencies, issue $ sudo npm uninstall -g antidote-rest-server

To uninstall all the dependencies we installed, $ sudo npm uninstall -g iced-coffee-script

To uninstall NodeJS, please use Google :( there are millions of ways to install it in all the OS flavors. I refuse to cover them here.

Docker Containers

If you want to just stop the containers (but keep them around):

$ docker container stop setup_antidote1_1 setup_antidote2_1

If you want to remove the containers completely (and remove the antidote-java-tutorial folder we used to set them up):

$ docker container rm setup_antidote1_1 setup_antidote2_1 setup_link_run_1; rm -rf antidote-java-tutorial

If you want to completely uninstall Docker: