The server
The server is the database engine. After the server starts it connects to other nodes, loads data from disk and opens some TCP sockets. The server logs every significant operation on the console.
The structure
The server is based on the actor model. Actors can interact each other only with messages. An actor can have children and it can react to their death.
The main structure
This is the server main structure. The Doorkeeper actor opens a sockets and when a new connection is established it creates a new Usermanager actor. Doorkeeper actors and Usermanager actors receive data from the Akka's TCP actor. Every client has its own Usermanager actor which for every request creates a message and sends it to its Main actor. The Main actor has the responsibility to understand the message, executing it or forwarding it. It executes database-level requests and administrative ones. Every other request is sent to the right MapManager actor.
The database structure
A database is represented by a MapManager actor. Every map is represented by a IndexManager actor. Every IndexManager actor has its Storemanager actor which manages the map rows. Every IndexManager actor has also some Warehouseman actors that read and write on disk.
The map structure
Every map is a binary tree of Storemanager actors. Blue ones are called Storekeepers, red ones are called Storefinders. Storekeeper actors contain the data while Storefinder actors route messages.
Backup and performance increment
Every Storefinder and Storekeeper actor has some Storemanager actors called Ninjas. Ninja actors became Storefinder or Storekeeper actors when their Storemanager actor dies abruptly. Ninja actors are also used to increase read performance, they can reply to message instead of their Storemanager actor.
Distribution
Every actor belongs to an ActorSystem, also called node. A cluster is composed by a group of nodes. A node can have roles, every role changes how the node behaves. A seed node is an access point to the cluster, every new node contacts all the seed nodes it knows.
Configuration
You need to edit some configuration files to get the best performance from the database. The server reads the files in the starting phase, then they can be modified later. Every node reads all these following when it starts up. These files are in the installation folder into conf.
distribution.conf
In this file you can set some distribution settings. The file has this structure:
{
remote {
netty.tcp{
hostname="192.168.1.100"
port=2500
}
}
cluster{
roles = [
Doorkeeper
]
seed-nodes = [
"akka.tcp://[email protected]:2500"
]
}
}
The netty.tcp property set the address and the port of the current node. A seed node must have a valid port number while others can have 0, which is random.
The roles array is optional and specifies the current actor roles. The only role available is Doorkeeper
The seed-nodes array contains the list of the cluster's seed nodes. A seed node must have also its own address and port.
If the file is missing or it's not in the correct form, the server wont start.
ports.json
In this file you can set the sockets to open specifying their ports. This file is red if the node's role is Doorkeeper.
The file has this structure:
{
"ports": [ "8181", "8282" ]
}
It's possible to add an arbitrary number of TCP sockets. If the file is missing or it's not in the correct form, the server wont start.
actor_properties.json
In this file you can set some actors properties useful to get the best performance out of your system. The file has this structure:
{
"properties": [
{
"name" : "maxRowNumber",
"value" : 20
},
{
"name" : "ninjaNumber",
"value" : 8
},
{
"name" : "warehousemanNumber",
"value" : 10
},
{
"name" : "datapath",
"value" : "C:\\data"
}
]
}
If the file is missing or it's not in the correct form, the server wont start.
Run the server
To run the server open the terminal, go to the installation folder and run the actorbased executable.