Skip to content

Commit

Permalink
Introduce API v2
Browse files Browse the repository at this point in the history
  • Loading branch information
iamyulong committed Mar 7, 2020
1 parent 9ef3b1e commit 2909d23
Show file tree
Hide file tree
Showing 13 changed files with 649 additions and 749 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# Maven build target folder
target/
dist/
log/
data/

# IntelliJ
.idea/
Expand All @@ -12,4 +14,4 @@ dist/
# Eclipse
.classpath
.project
.settings/
.settings/
122 changes: 65 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,78 @@
# rocksdb-server
A tiny HTTP-based server for RocksDB
# RocksDB Server

This is a lightweight RocksDB Server based on jetty.

## Features

* Use RocksDB as key-value storage engine
* HTTP-base API interface
* Authorization
* Support basic operations: get, put, remove, drop_database
* Batch get/put/remove (not atomic)
* Multiple concurrent databases;
* Simple API interface and client libraries;
* Basic Authentication;
* Batch `put`, `get` and `remove` operations.

## Prerequisites
You need to have Java 8+ installed. Currently supported platform includes Mac OS X and Linux.

## How to use
You need to have a Java 8 or above runtime installed.

## Get started

1. Download and unzip the latest binary release from [here](https://github.com/iamyulong/rocksdb-server/releases);
2. Update the configuration file at `./conf/server.json`;
3. Start up the server: `./bin/startup.sh`.

Once boot up, you can check if it's working via http://localhost:8516.

## Install as system service (Ubuntu)

1. Copy the following config to `/etc/init.d/rocksdb-server`, after replacing `SERVER_ROOT` with a real path:

```bash
#!/bin/bash

### BEGIN INIT INFO
# Provides: rocksdb-server
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start/stop rocksdb-server
### END INIT INFO

SERVER_ROOT=/path/to/rocksdb/server

case $1 in
start)
/bin/bash $SERVER_ROOT/bin/startup.sh
;;
stop)
/bin/bash $SERVER_ROOT/bin/shutdown.sh
;;
restart)
/bin/bash $SERVER_ROOT/bin/restart.sh
;;
esac
exit 0
```

2. Update the permissions and enable service:

```bash
chmod 755 /etc/init.d/rocksdb-server
update-rc.d rocksdb-server defaults
```

3. Now, you can start/stop/restart your server via the following commands:

```bash
service rocksdb-server start
service rocksdb-server stop
service rocksdb-server restart
```

1. Download the latest release from <https://github.com/iamyulong/rocksdb-server/releases>.
2. Unarchive and modify the configuration file at `conf/server.json`.
3. Start the server via terminal: `./bin/startup.sh`.
4. You can verify if it is working by visiting: <http://localhost:8516>

## Build from source

```bash
git clone https://github.com/iamyulong/rocksdb-server
cd rocksdb-server
mvn package
```

## Install as system service (Linux)

Edit SERVER_ROOT in the following script and copy to `/etc/init.d/rocksdb-server`.
```bash
#!/bin/bash

### BEGIN INIT INFO
# Provides: rocksdb-server
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start/stop rocksdb-server
### END INIT INFO

SERVER_ROOT=/path/to/rocksdb/server

case $1 in
start)
/bin/bash $SERVER_ROOT/bin/startup.sh
;;
stop)
/bin/bash $SERVER_ROOT/bin/shutdown.sh
;;
restart)
/bin/bash $SERVER_ROOT/bin/restart.sh
;;
esac
exit 0
```
Change its permissions and add the correct symlinks automatically.
```bash
chmod 755 /etc/init.d/rocksdb-server
update-rc.d rocksdb-server defaults
```
From now on, you can start/stop/restart your server via the following commands:
```bash
service rocksdb-server start
service rocksdb-server stop
service rocksdb-server restart
```
mvn clean install
```
26 changes: 16 additions & 10 deletions conf/server.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{
"listen": "127.0.0.1",
"port": 8516,

"auth": {
"enabled": true,
"username": "username",
"password": "password"
},

"data_dir": "data"
"node": {
"host": "127.0.0.1",
"port": 8516
},
"auth": {
"enabled": false,
"username": "admin",
"password": "admin"
},
"db": {
"maxOpenFiles": 256,
"blockSize": 4096,
"rowCache": 33554432,
"writeBufferSize": 4194304
},
"dataDir": "data"
}
Loading

0 comments on commit 2909d23

Please sign in to comment.