Skip to content
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

Split netty client into two files #40

Closed

Conversation

Yury-Fridlyand
Copy link

@Yury-Fridlyand Yury-Fridlyand commented Nov 24, 2023

Please ignore big commit history - it is caused by fact that dev branch was diverged.

This PR contains split JNI/Netty client into two files:

  • NettyWrapper
  • Client itself

Client works as a wrapper for NettyWrapper (probably I should rename it).

NettyWrapper creates a singleton channel, which can be used by unlimited number of clients concurrently.

jonathanl-bq and others added 30 commits October 3, 2023 13:33
Signed-off-by: acarbonetto <[email protected]>
* Add a java app to run benchmarks

---------

Signed-off-by: acarbonetto <[email protected]>
* Merge Pull Request #5 - Add java pipeline.

Also changed:
* Merged two projects.
* Updated CI.
* Fixed tests and updated `junit` version.
* Spotless.
* Add new gradle tasks.

Signed-off-by: Yury-Fridlyand <[email protected]>
* Add sync and async clients both to tests.

Signed-off-by: Yury-Fridlyand <[email protected]>

* Minor fixes.

Signed-off-by: Yury-Fridlyand <[email protected]>

---------

Signed-off-by: Yury-Fridlyand <[email protected]>
…onvert to TypeScript. (valkey-io#456)

removed duplicated logic and refactored to typescript

Signed-off-by: acarbonetto <[email protected]>
* Add Jedis and Lettuce benchmarks

* Start ignoring .gradle files

* Update gitignore and remove generated files from git

Signed-off-by: acarbonetto <[email protected]>

* Update gitignore and remove generated files from git

Signed-off-by: acarbonetto <[email protected]>

* Update gitignore and remove generated files from git

Signed-off-by: acarbonetto <[email protected]>

* Add benchmarks for GET non-existing

* Revert "Update gitignore and remove generated files from git"

This reverts commit d9b26a6.

* fix redis-rs submodules

Signed-off-by: acarbonetto <[email protected]>

* Randomize commands in Java benchmarks

* rename chooseAction to randomAction

* Add a Java benchmarking app (#7)

* Add a java app to run benchmarks

---------

Signed-off-by: acarbonetto <[email protected]>

* Add Readme and update install_and_test script to runJava

Signed-off-by: acarbonetto <[email protected]>

* Add Readme and update install_and_test script to runJava

Signed-off-by: acarbonetto <[email protected]>

* Combine java pipeline and java benchmarks (#8)

* Merge Pull Request #5 - Add java pipeline.

Also changed:
* Merged two projects.
* Updated CI.
* Fixed tests and updated `junit` version.
* Spotless.
* Add new gradle tasks.

Signed-off-by: Yury-Fridlyand <[email protected]>

* Add sync and async clients both to tests. (#12)

* Add sync and async clients both to tests.

Signed-off-by: Yury-Fridlyand <[email protected]>

* Minor fixes.

Signed-off-by: Yury-Fridlyand <[email protected]>

---------

Signed-off-by: Yury-Fridlyand <[email protected]>

* Add dataSize option to java benchmark.

Signed-off-by: Yury-Fridlyand <[email protected]>

---------

Signed-off-by: acarbonetto <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Co-authored-by: Jonathan Louie <[email protected]>
Co-authored-by: acarbonetto <[email protected]>
Co-authored-by: jonathanl-bq <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
* Add option to run tests on multiple clients in concurrency

* Common pool of iterations.
* Awaiting result from async methods.

Signed-off-by: Yury-Fridlyand <[email protected]>

* minor fix

Signed-off-by: Yury-Fridlyand <[email protected]>

* Change while-loop; Spotless Apply

Signed-off-by: acarbonetto <[email protected]>

---------

Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: acarbonetto <[email protected]>
Co-authored-by: acarbonetto <[email protected]>
Signed-off-by: acarbonetto <[email protected]>
Signed-off-by: acarbonetto <[email protected]>
Signed-off-by: acarbonetto <[email protected]>
Signed-off-by: acarbonetto <[email protected]>
@@ -24,6 +24,7 @@ use std::cell::Cell;
use std::rc::Rc;
use std::{env, str};
use std::{io, thread};
use std::fmt::format;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to import this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, removed in d58bff9.

}

public void close() {
// channel.closeFuture().sync()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to check in this comment here, do we?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in d58bff9.

@@ -23,11 +23,6 @@ public String getName() {
return name;
}

@Override
public void closeConnection() {
testClient.closeConnection();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need to close the connection anymore? I'm not sure why this is removed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another client instance may still use the connection - it is common for all.

@@ -210,7 +210,7 @@ async fn write_result(
error_message.into(),
))
} else {
log_warn("received error", error_message.as_str());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mean to check this in?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is more verbose

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While true, this change is irrelevant to the PR. We should put this in a separate PR.

@@ -0,0 +1,18 @@
plugins {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this probably belongs in a separate PR?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, reverting

Signed-off-by: Yury-Fridlyand <[email protected]>
@@ -210,7 +210,7 @@ async fn write_result(
error_message.into(),
))
} else {
log_warn("received error", error_message.as_str());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While true, this change is irrelevant to the PR. We should put this in a separate PR.

java/client/src/main/java/javababushka/NettyWrapper.java Outdated Show resolved Hide resolved
java/client/src/main/java/javababushka/NettyWrapper.java Outdated Show resolved Hide resolved
java/client/src/main/java/javababushka/NettyWrapper.java Outdated Show resolved Hide resolved
java/client/src/main/java/javababushka/NettyWrapper.java Outdated Show resolved Hide resolved
java/client/src/main/java/javababushka/NettyWrapper.java Outdated Show resolved Hide resolved
java/client/src/main/java/javababushka/NettyWrapper.java Outdated Show resolved Hide resolved
java/client/src/main/java/javababushka/NettyWrapper.java Outdated Show resolved Hide resolved
// Futures to handle responses. Index is callback id, starting from 1 (0 index is for connection
// request always).
// Is it not a concurrent nor sync collection, but it is synced on adding. No removes.
private final Map<Integer, CompletableFuture<Response>> responses = new ConcurrentHashMap<>();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a builder factor to define all of this together, and then we can share the responses map between files.
This would also mean we don't define the instance object statically (better to define it explicitly or at first use).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, re-review it is moved to another class

acarbonetto and others added 8 commits November 29, 2023 14:21
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Copy link

@acarbonetto acarbonetto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yury-Fridlyand We should go full MVC on this refactor/redesign. This will make it much easier to test. As is, we kind of have a MV* but we haven't all decided what our Model is (protobuf?) and both our client and wrappers/SocketManager has multiple responsibilities. Now would be a good time to split up these responsibilities... I'm thinking we should also split connection requests from command requests since those requests types have completely divergent calls.

@@ -36,7 +34,7 @@ java {

application {
// Define the main class for the application.
mainClass = 'javababushka.benchmarks.BenchmarkingApp'
mainClass = 'babushka.benchmarks.BenchmarkingApp'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been meaning to make this change, but a new name here is imminent. I was going to wait until we needed to change to 'Glide' or whatever...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was requested to do this upstream. So I made the same change here to have less conflicts later.

Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
@Yury-Fridlyand Yury-Fridlyand deleted the branch integ-java-client-milestone-1 December 15, 2023 18:32
@Yury-Fridlyand Yury-Fridlyand deleted the dev-split-netty-client branch December 15, 2023 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants