The following repository contains a simple distributed key-value database
- Load Balancing - Utilizes Consistent Hashing
- Data Replication Mechanism - Data is lazily replicated on two other servers for every write request (Given 3 servers running)
- Graceful Server Failure Recovery - Data is automatically recovered in the case of server crashes
- HTTP Server - Running regex query operations for fetching/inserting/modifying key-value pairs
Refer to the linked design documents in the releases for an in-depth look into the performance and functionality of the database.
connect <address> <port>
- Eastablish a TCP connection to the storage server
disconnect
- Disconnect from the connected server
put <key> <value>
:
- Insert key-value pair into the storage system
- Update (overwrite) key-value pair into the storage system if the given key already exists
- Delete key-value pair if the
<value>
is null
get <key>
- Retrieves given key from storage system
logLevel <level>
- Sets log level for insepcting commands
help
- Displays all commands available
quit
- Tear down active connection and exit client program
Request | Result | Response |
---|---|---|
put <key> <value> |
Tuple Inserted |
PUT_SUCCESS<key,value> |
put <key> <value> |
Tuple Updated |
PUT_UPDATE<key,value> |
put <key> <value> |
Unable to Insert Tuple |
PUT_ERROR<key,value> |
put <key> <null> |
Deleted Tuple |
DELETE_SUCCESS<key,value> |
put <key> <null> |
Unable to Delete Tuple |
DELETE_ERROR<key,value> |
get <key> |
Tuple Found |
GET_SUCCESS<key,value> |
get <key> |
Tuple not Found |
GET_ERROR<key,value> |
Responsible for adding/removing/stopping/starting servers in your distributed database
addNodes <numberOfNodes>
- Initializes the specified number of servers inserting them into a queue to be startedstart
- Starts all initialized servers within the queuestop
- Stops all servers currently runningshutdown
- Shutdown all servers currently runningremoveNode
- removes a random server that is currently running
Find details on the the Regex API specifications here
- Java
- Ant
- Apache Zookeeper
ant
- Builds the project generating 4 jar files
m4-client.jar
m4-ecs.jar
m4-http.jar
m4-server.jar
java -jar m4-client.jar
- Starts the terminal client interface
- Before starting ECS, you must ensure an instance of apache zookeeper is running. This can be done by navigating to the apache-zookeeper folder and running
bin/zkServer.sh start
- You can stop apache-zookeeper by running the corresponding command:
bin/zkServer.sh stop
- Create a file called
ecs.config
which contains a list of:<server_name> <host> <port>
java -jar m4-ecs.jar ecs.config <apache-zookeeper port>
- Note there is a default value provided for<apache-zookeeper port>
and does not need to be provided
java -jar m4-server.jar <host> <port>
- Starts the HTTP Server at the specified <host> <port>