-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java: README.md #388
Java: README.md #388
Changes from all commits
7e32e1b
2438d8b
c921f13
2390e71
93b0f02
8f03ac9
62da7f8
6242abb
a41887a
d6595bf
66d97e5
a8e7f77
b2ece6c
7ffa464
855999e
268cda4
a35414e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,18 +1,41 @@ | ||||||
# GLIDE for Valkey | ||||||
|
||||||
General Language Independent Driver for the Enterprise (GLIDE) for Valkey, is an AWS-sponsored, open-source Valkey client. GLIDE for Valkey works with any Valkey distribution that adheres to the Valkey Serialization | ||||||
Protocol (RESP) specification, including open-source Valkey, Amazon ElastiCache for Valkey, and Amazon MemoryDB for Valkey. | ||||||
Strategic, mission-critical Valkey-based applications have requirements for security, optimized performance, minimal downtime, and observability. GLIDE for Valkey is designed to provide a client experience that helps meet these objectives. | ||||||
It is sponsored and supported by AWS, and comes pre-configured with best practices learned from over a decade of operating Valkey-compatible services used by hundreds of thousands of customers. | ||||||
To help ensure consistency in development and operations, GLIDE for Valkey is implemented using a core driver framework, written in Rust, with extensions made available for each supported programming language. This design ensures that updates easily propagate to each language and reduces overall complexity. | ||||||
In this release, GLIDE for Valkey is available for Python, Javascript (Node.js), and Java. | ||||||
|
||||||
## Supported Valkey Versions | ||||||
|
||||||
GLIDE for Valkey is API-compatible with open source Valkey version 6 and 7. | ||||||
|
||||||
## Current Status | ||||||
|
||||||
We've made GLIDE for Valkey an open-source project, and are releasing it in Preview to the community to gather feedback, and actively collaborate on the project roadmap. We welcome questions and contributions from all Valkey stakeholders. | ||||||
This preview release is recommended for testing purposes only. | ||||||
|
||||||
# Getting Started - Java Wrapper | ||||||
|
||||||
## Notice: Java Wrapper - Work in Progress | ||||||
## System Requirements | ||||||
|
||||||
The beta release of GLIDE for Valkey was tested on Intel x86_64 using Ubuntu 22.04.1, Amazon Linux 2023 (AL2023), and macOS 12.7. | ||||||
|
||||||
## Supported Operating Systems | ||||||
|
||||||
We're excited to share that the Java client is currently in development! However, it's important to note that this client | ||||||
is a work in progress and is not yet complete or fully tested. Your contributions and feedback are highly encouraged as | ||||||
we work towards refining and improving this implementation. Thank you for your interest and understanding as we continue | ||||||
to develop this Java wrapper. | ||||||
GLIDE for Valkey is supported in Ubuntu, CentOS, and MacOS. | ||||||
|
||||||
cyip10 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
## Java supported version | ||||||
JDK 11+. | ||||||
|
||||||
The Java client contains the following parts: | ||||||
|
||||||
1. `client`: A Java-wrapper around the rust-core client. | ||||||
2. `examples`: An examples app to test the client against a Redis localhost | ||||||
3. `benchmark`: A dedicated benchmarking tool designed to evaluate and compare the performance of GLIDE for Redis and other Java clients. | ||||||
4. `integTest`: An integration test sub-project for API and E2E testing | ||||||
1. `src`: Rust dynamic library FFI to integrate with [GLIDE core library](https://github.com/aws/glide-for-redis/blob/main/glide-core/README.md). | ||||||
Yury-Fridlyand marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
2. `client`: A Java-wrapper around the [GLIDE core rust library](../glide-core/README.md) and unit tests for it. | ||||||
3. `examples`: An examples app to test the client against a Valkey localhost. | ||||||
4. `benchmark`: A dedicated benchmarking tool designed to evaluate and compare the performance of GLIDE for Valkey and other Java clients. | ||||||
5. `integTest`: An integration test sub-project for API and E2E testing. | ||||||
|
||||||
## Installation and Setup | ||||||
|
||||||
|
@@ -25,61 +48,48 @@ At the moment, the Java client must be built from source. | |||||
Software Dependencies: | ||||||
|
||||||
- JDK 11+ | ||||||
- git | ||||||
- protoc (protobuf compiler) | ||||||
- Rust | ||||||
|
||||||
Please also consider installing the following packages to build [GLIDE core rust library](../glide-core/README.md): | ||||||
|
||||||
- openssl | ||||||
- openssl-dev | ||||||
|
||||||
#### Prerequisites | ||||||
|
||||||
**Protoc installation** | ||||||
|
||||||
Download a binary matching your system from the [official release page](https://github.com/protocolbuffers/protobuf/releases) and make it accessible in your $PATH by moving it or creating a symlink. | ||||||
For example, on Linux you can copy it to `/usr/bin`: | ||||||
|
||||||
```bash | ||||||
sudo cp protoc /usr/bin/ | ||||||
``` | ||||||
|
||||||
**Dependencies installation for Ubuntu** | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A user of java wrapper don't need rust, gcc, git and other things. Only java and maybe openssl. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly. Java users should only need to import the JAR library as a dependency from Maven or Gradle - or download. Building from source should be part of the DEVELOPER.md. You could reference the DEVELOPER.md if you want to point them to how to build from source. |
||||||
```bash | ||||||
sudo apt update -y | ||||||
sudo apt install -y protobuf-compiler openjdk-11-jdk openssl gcc | ||||||
sudo apt install -y openjdk-11-jdk openssl gcc | ||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh | ||||||
source "$HOME/.cargo/env" | ||||||
``` | ||||||
|
||||||
**Dependencies for MacOS** | ||||||
**Dependencies installation for MacOS** | ||||||
|
||||||
Ensure that you have a minimum Java version of JDK 11 installed on your system: | ||||||
```bash | ||||||
$ echo $JAVA_HOME | ||||||
/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home | ||||||
|
||||||
$ java -version | ||||||
openjdk version "11.0.1" 2018-10-16 | ||||||
OpenJDK Runtime Environment 18.9 (build 11.0.1+13) | ||||||
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode) | ||||||
brew update | ||||||
brew install git gcc pkgconfig openssl openjdk@11 | ||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh | ||||||
source "$HOME/.cargo/env" | ||||||
``` | ||||||
|
||||||
#### Building and installation steps | ||||||
The Java client is currently a work in progress and offers no guarantees. Users should build at their own risk. | ||||||
**Java version check** | ||||||
|
||||||
Ensure that you have a minimum Java version of JDK 11 installed on your system: | ||||||
|
||||||
Before starting this step, make sure you've installed all software requirements. | ||||||
1. Clone the repository: | ||||||
```bash | ||||||
VERSION=0.1.0 # You can modify this to other released version or set it to "main" to get the unstable branch | ||||||
git clone --branch ${VERSION} https://github.com/aws/glide-for-redis.git | ||||||
cd glide-for-redis | ||||||
``` | ||||||
2. Initialize git submodule: | ||||||
```bash | ||||||
git submodule update --init --recursive | ||||||
``` | ||||||
3. Generate protobuf files: | ||||||
```bash | ||||||
cd java/ | ||||||
./gradlew :client:protobuf | ||||||
``` | ||||||
4. Build the client library: | ||||||
```bash | ||||||
cd java/ | ||||||
./gradlew :client:build | ||||||
``` | ||||||
5. Run tests: | ||||||
```bash | ||||||
cd java/ | ||||||
$ ./gradlew :client:test | ||||||
echo $JAVA_HOME | ||||||
java -version | ||||||
``` | ||||||
|
||||||
Other useful gradle developer commands: | ||||||
|
@@ -90,20 +100,105 @@ Other useful gradle developer commands: | |||||
* `./gradlew :examples:run` to run client examples (make sure you have a running redis on port `6379`) | ||||||
* `./gradlew :benchmarks:run` to run performance benchmarks | ||||||
|
||||||
|
||||||
### Setting up the Driver | ||||||
|
||||||
Refer to https://central.sonatype.com/search?q=glide&namespace=software.amazon.glide for your specific system. | ||||||
Once set up, you can run the basic examples. | ||||||
|
||||||
Gradle: | ||||||
- Copy the snippet and paste it in the `build.gradle` dependencies section. | ||||||
Example shown below is for `glide-osx-aarch_64`. | ||||||
```bash | ||||||
dependencies { | ||||||
testImplementation platform('org.junit:junit-bom:5.10.0') | ||||||
testImplementation 'org.junit.jupiter:junit-jupiter' | ||||||
implementation group: 'software.amazon.glide', name: 'glide-osx-aarch_64', version: '0.4.2' | ||||||
} | ||||||
``` | ||||||
|
||||||
Maven (AARCH_64) specific. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also add example in gradle syntax. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. something to copy-paste ;) |
||||||
- **IMPORTANT** must include a `classifier` block. Please use this dependency block instead and add it to the pom.xml file. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we include classifier for mac x64 or linux x64? |
||||||
```bash | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<dependency> | ||||||
<groupId>software.amazon.glide</groupId> | ||||||
<artifactId>glide-osx-aarch_64</artifactId> | ||||||
<classifier>osx-aarch_64</classifier> | ||||||
<version>0.4.2</version> | ||||||
</dependency> | ||||||
``` | ||||||
|
||||||
## Basic Examples | ||||||
|
||||||
### Standalone Redis: | ||||||
### Standalone Valkey: | ||||||
|
||||||
```java | ||||||
import glide.api.RedisClient; | ||||||
import glide.api.models.configuration.NodeAddress; | ||||||
import glide.api.models.configuration.RedisClientConfiguration; | ||||||
|
||||||
import java.util.concurrent.ExecutionException; | ||||||
import static glide.api.models.GlideString.gs; | ||||||
|
||||||
# Run this code in the Main file. Include InterruptedException and ExecutionException handling. | ||||||
|
||||||
public static void main(String[] args) throws InterruptedException, ExecutionException { | ||||||
|
||||||
String host = "localhost"; | ||||||
Integer port = 6379; | ||||||
boolean useSsl = false; | ||||||
|
||||||
RedisClientConfiguration config = | ||||||
RedisClientConfiguration.builder() | ||||||
.address(NodeAddress.builder().host(host).port(port).build()) | ||||||
.useTLS(useSsl) | ||||||
.build(); | ||||||
|
||||||
RedisClient client = RedisClient.CreateClient(config).get(); | ||||||
|
||||||
System.out.println("PING: " + client.ping().get()); | ||||||
System.out.println("PING(found you): " + client.ping("found you").get()); | ||||||
|
||||||
System.out.println("SET(apples, oranges): " + client.set("apples", "oranges").get()); | ||||||
System.out.println("GET(apples): " + client.get("apples").get()); | ||||||
|
||||||
System.out.println("GLIDESTRINGSET(cats, meow): " + client.set(gs("cats"), gs("meow")).get()); | ||||||
System.out.println("GET(cats): " + client.get("cats").get()); | ||||||
} | ||||||
``` | ||||||
|
||||||
### Cluster Valkey: | ||||||
```java | ||||||
|
||||||
import glide.api.RedisClusterClient; | ||||||
import glide.api.models.configuration.NodeAddress; | ||||||
import glide.api.models.configuration.RedisClusterClientConfiguration; | ||||||
|
||||||
import java.util.concurrent.ExecutionException; | ||||||
import static glide.api.models.GlideString.gs; | ||||||
|
||||||
# Run this code in the Main file. Include InterruptedException and ExecutionException handling. | ||||||
|
||||||
String host = "localhost"; | ||||||
Integer port = 6379; | ||||||
boolean useSsl = false; | ||||||
|
||||||
RedisClusterClientConfiguration config = | ||||||
RedisClusterClientConfiguration.builder() | ||||||
.address(NodeAddress.builder().host(host).port(port).build()) | ||||||
.useTLS(useSsl) | ||||||
.build(); | ||||||
|
||||||
RedisClusterClient client = RedisClusterClient.CreateClient(config).get(); | ||||||
|
||||||
RedisClient client = RedisClient.CreateClient().get(); | ||||||
System.out.println("PING: " + client.ping().get()); | ||||||
System.out.println("PING(found you): " + client.ping("found you").get()); | ||||||
|
||||||
CompletableFuture<String> setResponse = client.set("key", "foobar"); | ||||||
assert setResponse.get() == "OK" : "Failed on client.set("key", "foobar") request"; | ||||||
System.out.println("SET(apples, oranges): " + client.set("apples", "oranges").get()); | ||||||
System.out.println("GET(apples): " + client.get("apples").get()); | ||||||
|
||||||
CompletableFuture<String> getResponse = client.get("key"); | ||||||
assert getResponse.get() == "foobar" : "Failed on client.get("key") request"; | ||||||
System.out.println("GLIDESTRINGSET(cats, meow): " + client.set(gs("cats"), gs("meow")).get()); | ||||||
System.out.println("GET(cats): " + client.get("cats").get()); | ||||||
``` | ||||||
|
||||||
### Benchmarks | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rebase please...