Skip to content

Commit

Permalink
Merge pull request #6 from aerospike/develop
Browse files Browse the repository at this point in the history
v0.8.0
  • Loading branch information
reugn authored May 5, 2021
2 parents 3f3aa7d + 6d566f7 commit 0f7f012
Show file tree
Hide file tree
Showing 72 changed files with 1,193 additions and 964 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ echo "GET key1\r\n" | nc localhost 6379
Operation | Description
----------|------------
[APPEND](https://redis.io/commands/append) *key value* | If key already exists and is a string, this command appends the value at the end of the string. If key does not exist it is created and set as an empty string.
[AUTH](https://redis.io/commands/auth) *[username] password* | The AUTH command authenticates the current connection.
[BGSAVE](https://redis.io/commands/bgsave) | Returns OK.
[COMMAND](https://redis.io/commands/command) | Returns Array reply of details about all Redis commands.
[COMMAND COUNT](https://redis.io/commands/command-count) | Returns Integer reply of number of total commands in this Redis server.
Expand All @@ -50,7 +51,9 @@ Operation | Description
[DECR](https://redis.io/commands/decr) *key* | Decrements the number stored at key by one.
[DECRBY](https://redis.io/commands/decrby) *key decrement* | Decrements the number stored at key by decrement.
[DEL](https://redis.io/commands/del) *key* | Removes the specified key.
[DISCARD](https://redis.io/commands/discard) | Flushes all previously queued commands in a [transaction](https://redis.io/topics/transactions) and restores the connection state to normal.
[ECHO](https://redis.io/commands/echo) *message* | Returns message.
[EXEC](https://redis.io/commands/exec) | Executes all previously queued commands in a [transaction](https://redis.io/topics/transactions) and restores the connection state to normal.
[EXISTS](https://redis.io/commands/exists) *key [key ...]* | Returns if key exists.
[EXPIRE](https://redis.io/commands/expire) *key seconds* | Set a timeout on key. After the timeout has expired, the key will automatically be deleted.
[EXPIREAT](https://redis.io/commands/expireat) *key timestamp* | EXPIREAT has the same effect and semantic as EXPIRE, but instead of specifying the number of seconds representing the TTL (time to live), it takes an absolute Unix timestamp (seconds since January 1, 1970).
Expand Down Expand Up @@ -86,6 +89,7 @@ Operation | Description
[MGET](https://redis.io/commands/mget) *key [key ...]* | Returns the values of all specified keys.
[MSET](https://redis.io/commands/mset) *key value [key value ...]* | Sets the given keys to their respective values.
[MSETNX](https://redis.io/commands/msetnx) *key value [key value ...]* | Sets the given keys to their respective values. MSETNX will not perform any operation at all even if just a single key already exists.
[MULTI](https://redis.io/commands/multi) | Marks the start of a [transaction](https://redis.io/topics/transactions) block. Subsequent commands will be queued for execution using EXEC.
[PERSIST](https://redis.io/commands/persist) *key* | Remove the existing timeout on key, turning the key from volatile (a key with an expire set) to persistent.
[PEXPIRE](https://redis.io/commands/pexpire) *key milliseconds* | This command works exactly like EXPIRE but the time to live of the key is specified in milliseconds instead of seconds.
[PEXPIREAT](https://redis.io/commands/pexpireat) *key milliseconds-timestamp* | PEXPIREAT has the same effect and semantic as EXPIREAT, but the Unix time at which the key will expire is specified in milliseconds instead of seconds.
Expand Down Expand Up @@ -146,8 +150,9 @@ Operation | Description

## Known Limitations
* A partial but growing list of Redis commands. See [Redis Command Coverage](#redis-command-coverage).
* By default, an Aerospike namespace does not allow for TTLs. Read [more](https://discuss.aerospike.com/t/faq-what-are-expiration-eviction-and-stop-writes/2311) on how to set up expiration and eviction support.
* Like Redis Cluster, Skyhook supports a single Redis 'database 0', which maps to a single namespace and set in the Aerospike Database.
* Will not try try to implement the cluster operations sub-commands of `CLUSTER`, `CLIENT`, `CONFIG`, `MEMORY`, `MONITOR`, `LATENCY`.
* Will not try to implement the cluster operations sub-commands of `CLUSTER`, `CLIENT`, `CONFIG`, `MEMORY`, `MONITOR`, `LATENCY`.
* No support for Pub/Sub commands.
* No support for Lua scripts.

Expand Down Expand Up @@ -200,7 +205,9 @@ Now the server is listening to the `config.redisPort` (default: 6379) and is rea
| hostList | The host list to seed the Aerospike cluster. | localhost:3000 |
| namespase | The Aerospike namespace. | test |
| set | The Aerospike set name. | redis |
| bin | The Aerospike bin name to set values. | b |
| clientPolicy | The Aerospike Java client [ClientPolicy](https://docs.aerospike.com/apidocs/java/com/aerospike/client/policy/ClientPolicy.html) configuration properties. | ClientPolicyConfig |
| bin | The Aerospike value bin name. | b |
| typeBin | The Aerospike value [type](https://redis.io/topics/data-types) bin name. | t |
| redisPort | The server port to bind to. | 6379 |
| workerThreads<sup>[1](#worker-threads)</sup> | The Netty worker group size. | number of available cores |
| bossThreads | The Netty acceptor group size. | 2 |
Expand All @@ -213,4 +220,3 @@ Licensed under an Apache 2.0 License.
This is an active open source project. You can contribute to it by trying
Skyhook, providing feedback, reporting bugs, and implementing more Redis
commands.

5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "com.aerospike"
version = "0.7.0"
version = "0.8.0"

repositories {
mavenCentral()
Expand All @@ -35,7 +35,7 @@ extra["logbackVersion"] = "1.2.3"
extra["jacksonVersion"] = "2.12.2"

dependencies {
implementation("com.aerospike:aerospike-client:5.0.5")
implementation("com.aerospike:aerospike-client:5.1.0")
implementation("io.netty:netty-all:${project.extra["nettyVersion"]}")
implementation("io.netty:netty-codec-redis:${project.extra["nettyVersion"]}")
implementation("com.google.inject:guice:5.0.1")
Expand All @@ -49,6 +49,7 @@ dependencies {
implementation("com.fasterxml.jackson.core:jackson-databind:${project.extra["jacksonVersion"]}")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:${project.extra["jacksonVersion"]}")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${project.extra["jacksonVersion"]}")
implementation("com.google.guava:guava:30.1.1-jre")

testImplementation(kotlin("test-junit5"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.0")
Expand Down
39 changes: 28 additions & 11 deletions src/main/kotlin/com/aerospike/skyhook/SkyhookModule.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.aerospike.skyhook

import com.aerospike.client.AerospikeClient
import com.aerospike.client.Host
import com.aerospike.client.IAerospikeClient
import com.aerospike.client.async.EventLoops
import com.aerospike.client.async.NettyEventLoops
import com.aerospike.client.async.NioEventLoops
import com.aerospike.client.policy.ClientPolicy
import com.aerospike.skyhook.config.ServerConfiguration
import com.aerospike.skyhook.util.SystemUtils
import com.aerospike.skyhook.util.client.AerospikeClientPool
import com.aerospike.skyhook.util.client.AerospikeClientPoolImpl
import com.google.inject.AbstractModule
import com.google.inject.Provides
import com.google.inject.name.Names
Expand All @@ -19,6 +20,8 @@ import io.netty.channel.nio.NioEventLoopGroup
import io.netty.channel.socket.ServerSocketChannel
import io.netty.channel.socket.nio.NioServerSocketChannel
import mu.KotlinLogging
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import javax.inject.Inject
import javax.inject.Singleton

Expand All @@ -31,6 +34,7 @@ class SkyhookModule(
}

override fun configure() {
bind(AerospikeClientPool::class.java).to(AerospikeClientPoolImpl::class.java)
bindEventLoops()
}

Expand Down Expand Up @@ -97,15 +101,28 @@ class SkyhookModule(
@Provides
@Singleton
@Inject
fun aerospikeClient(): IAerospikeClient {
fun clientPolicy(): ClientPolicy {
val clientPolicy = ClientPolicy()
clientPolicy.eventLoops = NioEventLoops(config.workerThreads)
clientPolicy.eventLoops = getClientEventLoops()
config.clientPolicy.user?.let { clientPolicy.user = it }
config.clientPolicy.password?.let { clientPolicy.password = it }
config.clientPolicy.authMode?.let { clientPolicy.authMode = it }
config.clientPolicy.timeout?.let { clientPolicy.timeout = it }
return clientPolicy
}

return AerospikeClient(
clientPolicy, *Host.parseHosts(
config.hostList,
3000
)
)
private fun getClientEventLoops(): EventLoops {
return when (SystemUtils.os) {
SystemUtils.OS.LINUX -> NettyEventLoops(EpollEventLoopGroup(config.workerThreads))
SystemUtils.OS.MAC -> NettyEventLoops(KQueueEventLoopGroup(config.workerThreads))
else -> NioEventLoops(config.workerThreads)
}
}

@Provides
@Singleton
@Inject
fun executorService(): ExecutorService {
return Executors.newFixedThreadPool(config.workerThreads)
}
}
Loading

0 comments on commit 0f7f012

Please sign in to comment.