Skip to content

Commit

Permalink
Create working Gradle project that uses protobuf library for JNI sock…
Browse files Browse the repository at this point in the history
…et client
  • Loading branch information
jonathanl-bq committed Oct 5, 2023
1 parent 5cac01a commit f5c74d2
Show file tree
Hide file tree
Showing 8 changed files with 8,471 additions and 49 deletions.
48 changes: 0 additions & 48 deletions java/RedisClient.java

This file was deleted.

3 changes: 3 additions & 0 deletions java/benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ dependencies {
implementation 'io.lettuce:lettuce-core:6.2.6.RELEASE'
implementation 'commons-cli:commons-cli:1.5.0'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.13.0'
// https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.24.3'
}

// Apply a specific Java toolchain to ease working on different environments.
Expand All @@ -30,6 +32,7 @@ java {
application {
// Define the main class for the application.
mainClass = 'javababushka.benchmarks.BenchmarkingApp'
applicationDefaultJvmArgs += "-Djava.library.path=${projectDir}/../target/debug"
}

tasks.withType(Test) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package javababushka.benchmarks;

import connection_request.ConnectionRequestOuterClass.ConnectionRequest;
import java.io.IOException;
import java.net.StandardProtocolFamily;
import java.net.UnixDomainSocketAddress;
import java.nio.channels.SocketChannel;
import javababushka.client.RedisClient;

public class BenchmarkingApp {

// main application entrypoint
public static void main(String[] args) throws InterruptedException {
RedisClient client = new RedisClient();
RedisClient.startSocketListenerExternal(client);
System.out.println("After starting socket listener");

int timeout = 0;
int maxTimeout = 1000;
while (client.socketPath == null && timeout < maxTimeout) {
timeout++;
Thread.sleep(250);
}

UnixDomainSocketAddress socketAddress = UnixDomainSocketAddress.of(client.socketPath);
try {
SocketChannel channel = SocketChannel.open(StandardProtocolFamily.UNIX);
channel.connect(socketAddress);
ConnectionRequest request = ConnectionRequest.newBuilder().build();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Loading

0 comments on commit f5c74d2

Please sign in to comment.